Removed some more warnings and cleaned more SWT listeners
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 18 Sep 2019 09:50:18 +0000 (11:50 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 18 Sep 2019 09:52:20 +0000 (11:52 +0200)
15 files changed:
plugins/net.mograsim.machine/src/net/mograsim/machine/MainMemory.java
plugins/net.mograsim.machine/src/net/mograsim/machine/mi/parameters/MnemonicFamily.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/AsmOpsEdit.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/editor/AsmAutoEditStrategy.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/editor/AsmContentAssistProcessor.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/editor/AsmReconcilerStrategy.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/AddRemoveMograsimNatureHandler.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/MograsimBuilder.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/RadixSelector.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/util/DropDownMenu.java
tests/net.mograsim.logic.core.tests/src/net/mograsim/logic/core/types/BitVectorTest.java
tests/net.mograsim.logic.model.am2900.tests/META-INF/MANIFEST.MF
tests/net.mograsim.logic.model.am2900.tests/build.properties
tests/net.mograsim.machine.tests/META-INF/MANIFEST.MF
tests/net.mograsim.machine.tests/build.properties

index 94140b7..909113c 100644 (file)
@@ -9,6 +9,4 @@ public interface MainMemory extends Memory<BitVector>
        public BigInteger getCellAsBigInteger(long address);
 
        public void setCellAsBigInteger(long address, BigInteger word);
-
-       public MainMemoryDefinition getDefinition();
-}
+}
\ No newline at end of file
index d6906fb..14bffbb 100644 (file)
@@ -182,8 +182,7 @@ public class MnemonicFamily implements ParameterClassification
        {
                if (m != null)
                        return m.owner == this;
-               else
-                       return false;
+               return false;
        }
 
        public boolean contains(String value)
index cc0d0ff..67ea82e 100644 (file)
@@ -9,7 +9,6 @@ import org.eclipse.e4.ui.di.Persist;
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
 import org.eclipse.jface.action.Action;
 import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
 import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.IToolBarManager;
 import org.eclipse.jface.action.MenuManager;
@@ -19,8 +18,6 @@ import org.eclipse.jface.viewers.ITableLabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -95,30 +92,18 @@ public class AsmOpsEdit extends ViewPart
                txtInput = new Text(parent, SWT.BORDER);
                txtInput.setMessage("Enter new Asm OP");
                txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-               txtInput.addKeyListener(new KeyListener()
+               txtInput.addListener(SWT.KeyDown, e ->
                {
-
-                       @Override
-                       public void keyReleased(KeyEvent e)
-                       {
-                               // TODO Auto-generated method stub
-
-                       }
-
-                       @Override
-                       public void keyPressed(KeyEvent e)
+                       if (e.keyCode == SWT.CR || e.keyCode == SWT.LF)
                        {
-                               if (e.keyCode == SWT.CR || e.keyCode == SWT.LF)
-                               {
-                                       String in = txtInput.getText().toLowerCase();
-                                       if (in.startsWith("-"))
-                                               viewer.remove(in.substring(1).trim());
-                                       else
-                                               viewer.add(in.trim());
-                                       txtInput.setText("");
-                                       part.setDirty(true);
-                                       save();
-                               }
+                               String in = txtInput.getText().toLowerCase();
+                               if (in.startsWith("-"))
+                                       viewer.remove(in.substring(1).trim());
+                               else
+                                       viewer.add(in.trim());
+                               txtInput.setText("");
+                               part.setDirty(true);
+                               save();
                        }
                });
 
@@ -159,6 +144,7 @@ public class AsmOpsEdit extends ViewPart
        {
                saveAction = new Action()
                {
+                       @Override
                        public void run()
                        {
                                save();
@@ -198,13 +184,7 @@ public class AsmOpsEdit extends ViewPart
        {
                MenuManager menuMgr = new MenuManager("#PopupMenu");
                menuMgr.setRemoveAllWhenShown(true);
-               menuMgr.addMenuListener(new IMenuListener()
-               {
-                       public void menuAboutToShow(IMenuManager manager)
-                       {
-                               AsmOpsEdit.this.fillContextMenu(manager);
-                       }
-               });
+               menuMgr.addMenuListener(this::fillContextMenu);
                Menu menu = menuMgr.createContextMenu(viewer.getControl());
                viewer.getControl().setMenu(menu);
                getSite().registerContextMenu(menuMgr, viewer);
index 7198a27..b14ac36 100644 (file)
@@ -29,7 +29,7 @@ public class AsmAutoEditStrategy implements IAutoEditStrategy
                                command.shiftsCaret = false;
                        }
                }
-               catch (BadLocationException e)
+               catch (@SuppressWarnings("unused") BadLocationException e)
                {
                        // ignore
                }
index c2b8f3f..3a3c9a5 100644 (file)
@@ -105,7 +105,7 @@ public class AsmContentAssistProcessor implements IContentAssistProcessor
                        {
                                document.replace(offset, 0, asmOp);
                        }
-                       catch (BadLocationException e)
+                       catch (@SuppressWarnings("unused") BadLocationException e)
                        {
                                // ignore
                        }
index a3253a4..388366f 100644 (file)
@@ -153,11 +153,13 @@ public class AsmReconcilerStrategy implements IReconcilingStrategy, IReconciling
                                                searchingFor = SearchingFor.START_OF_TAG;
                                        }
                                        break;
+                               default:
+                                       throw new IllegalStateException("Unknown enum type: " + searchingFor);
                                }
                                currentCharIndex++;
                        }
                }
-               catch (BadLocationException e)
+               catch (@SuppressWarnings("unused") BadLocationException e)
                {
                        // skip the remainder of file due to error
                }
index 581b4a6..e8b38e9 100644 (file)
@@ -1,7 +1,10 @@
 package net.mograsim.plugin.nature;
 
 import java.util.Iterator;
-import org.eclipse.core.commands.*;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IProjectDescription;
 import org.eclipse.core.runtime.CoreException;
@@ -12,7 +15,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 
 public class AddRemoveMograsimNatureHandler extends AbstractHandler
 {
-
+       @Override
        public Object execute(ExecutionEvent event) throws ExecutionException
        {
                ISelection selection = HandlerUtil.getCurrentSelection(event);
index 9fc0ea4..44d9b51 100644 (file)
@@ -50,6 +50,7 @@ public class MograsimBuilder extends IncrementalProjectBuilder
 
        class SampleResourceVisitor implements IResourceVisitor
        {
+               @Override
                public boolean visit(IResource resource)
                {
                        checkXML(resource);
@@ -73,16 +74,19 @@ public class MograsimBuilder extends IncrementalProjectBuilder
                        MograsimBuilder.this.addMarker(file, e.getMessage(), e.getLineNumber(), severity);
                }
 
+               @Override
                public void error(SAXParseException exception) throws SAXException
                {
                        addMarker(exception, IMarker.SEVERITY_ERROR);
                }
 
+               @Override
                public void fatalError(SAXParseException exception) throws SAXException
                {
                        addMarker(exception, IMarker.SEVERITY_ERROR);
                }
 
+               @Override
                public void warning(SAXParseException exception) throws SAXException
                {
                        addMarker(exception, IMarker.SEVERITY_WARNING);
@@ -133,6 +137,7 @@ public class MograsimBuilder extends IncrementalProjectBuilder
                return null;
        }
 
+       @Override
        protected void clean(IProgressMonitor monitor) throws CoreException
        {
                // delete markers set and files created
index b72df0e..334dd9e 100644 (file)
@@ -1,8 +1,6 @@
 package net.mograsim.plugin.tables;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
@@ -33,25 +31,13 @@ public class RadixSelector
                NumberType corTypes[] = new NumberType[] { NumberType.BINARY, NumberType.OCTAL, NumberType.DECIMAL, NumberType.HEXADECIMAL };
                combo.setItems(entries);
                combo.select(3);
-               combo.addSelectionListener(new SelectionListener()
+               combo.addListener(SWT.Selection, e ->
                {
-                       @Override
-                       public void widgetSelected(SelectionEvent e)
-                       {
-                               int index = combo.getSelectionIndex();
-                               if (index == -1)
-                                       target.setDataNumberType(NumberType.HEXADECIMAL);
-                               else
-                               {
-                                       target.setDataNumberType(corTypes[index]);
-                               }
-                       }
-
-                       @Override
-                       public void widgetDefaultSelected(SelectionEvent e)
-                       {
-                               widgetSelected(e);
-                       }
+                       int index = combo.getSelectionIndex();
+                       if (index == -1)
+                               target.setDataNumberType(NumberType.HEXADECIMAL);
+                       else
+                               target.setDataNumberType(corTypes[index]);
                });
        }
 
index ffa1857..0e6b90a 100644 (file)
@@ -1,14 +1,10 @@
 package net.mograsim.plugin.util;
 
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Point;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
 import org.eclipse.swt.widgets.Menu;
 import org.eclipse.swt.widgets.MenuItem;
 
@@ -29,34 +25,17 @@ public class DropDownMenu
                for (DropDownEntry entry : entries)
                {
                        MenuItem item = new MenuItem(menu, SWT.PUSH);
-                       item.addSelectionListener(new SelectionListener()
-                       {
-                               @Override
-                               public void widgetSelected(SelectionEvent e)
-                               {
-                                       entry.listener.widgetSelected(e);
-                               }
-
-                               @Override
-                               public void widgetDefaultSelected(SelectionEvent e)
-                               {
-                                       widgetSelected(e);
-                               }
-                       });
+                       item.addListener(SWT.Selection, e -> entry.onSelected.run());
                        item.setText(entry.title);
                }
 
-               button.addListener(SWT.Selection, new Listener()
+               button.addListener(SWT.Selection, e ->
                {
-                       @Override
-                       public void handleEvent(Event event)
-                       {
-                               Rectangle rect = button.getBounds();
-                               Point pt = new Point(rect.x, rect.y + rect.height);
-                               pt = button.getParent().toDisplay(pt);
-                               menu.setLocation(pt.x, pt.y);
-                               menu.setVisible(true);
-                       }
+                       Rectangle rect = button.getBounds();
+                       Point pt = new Point(rect.x, rect.y + rect.height);
+                       pt = button.getParent().toDisplay(pt);
+                       menu.setLocation(pt.x, pt.y);
+                       menu.setVisible(true);
                });
        }
 
@@ -68,19 +47,12 @@ public class DropDownMenu
        public static class DropDownEntry
        {
                public final String title;
-               public final EntrySelectedListener listener;
+               public final Runnable onSelected;
 
-               public DropDownEntry(String title, EntrySelectedListener listener)
+               public DropDownEntry(String title, Runnable onSelected)
                {
-                       super();
                        this.title = title;
-                       this.listener = listener;
+                       this.onSelected = onSelected;
                }
        }
-
-       @FunctionalInterface
-       public static interface EntrySelectedListener
-       {
-               public void widgetSelected(SelectionEvent e);
-       }
 }
index 48e1b9a..f553823 100644 (file)
@@ -11,3 +11,9 @@ Require-Bundle: org.junit;bundle-version="4.12.0",
  org.junit.jupiter.api;bundle-version="5.4.0";visibility:=reexport,
  org.junit.jupiter.params;bundle-version="5.4.0";visibility:=reexport,
  org.opentest4j;bundle-version="1.1.1";visibility:=reexport
+Export-Package: net.mograsim.logic.model,
+ net.mograsim.logic.model.am2900,
+ net.mograsim.logic.model.am2900.am2901,
+ net.mograsim.logic.model.am2900.am2904,
+ net.mograsim.logic.model.am2900.am2910,
+ net.mograsim.logic.model.am2900.util
index 175305b..b5d8f2d 100644 (file)
@@ -10,3 +10,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-11
 Require-Bundle: org.junit;bundle-version="4.12.0",
  org.junit.jupiter.api;bundle-version="5.4.0";visibility:=reexport,
  org.junit.jupiter.params;bundle-version="5.4.0";visibility:=reexport
+Export-Package: net.mograsim.machine.standard.memory
index 34d2e4d..b107977 100644 (file)
@@ -1,4 +1,3 @@
 source.. = src/
-output.. = bin/
 bin.includes = META-INF/,\
                .