From 72849cddabeb34154784228222ef2f52fdc8e5b9 Mon Sep 17 00:00:00 2001 From: hneemann Date: Sat, 27 May 2017 10:47:33 +0200 Subject: [PATCH] resolved merge conflicts --- .../gui/components/CircuitComponent.java | 49 +++++++------------ .../digital/integration/TestExamples.java | 2 +- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java b/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java index adff19cdd..357b2bca7 100644 --- a/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java +++ b/src/main/java/de/neemann/digital/gui/components/CircuitComponent.java @@ -74,9 +74,9 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe private final MouseController mouseRun; private final MouseControllerInsertCopied mouseInsertList; private final Cursor moveCursor; - private final AbstractAction copyAction; - private final AbstractAction pasteAction; - private final AbstractAction rotateAction; + private final ToolTipAction copyAction; + private final ToolTipAction pasteAction; + private final ToolTipAction rotateAction; private final ToolTipAction undoAction; private final ToolTipAction redoAction; @@ -109,13 +109,12 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe this.library = library; highLighted = new HashSet<>(); - rotateAction = new AbstractAction(Lang.get("menu_rotate")) { + rotateAction = new ToolTipAction(Lang.get("menu_rotate")) { @Override public void actionPerformed(ActionEvent e) { activeMouseController.rotate(); } - }; - rotateAction.setEnabled(false); + }.setActive(false).setAccelerator(KeyStroke.getKeyStroke("R")).enableAcceleratorIn(this); copyAction = createCopyAction(shapeFactory); @@ -142,35 +141,25 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe } }.setToolTip(Lang.get("menu_redo_tt")); - Action escapeAction = new AbstractAction() { + new ToolTipAction("Escape") { @Override public void actionPerformed(ActionEvent e) { activeMouseController.escapePressed(); } - }; + }.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)).enableAcceleratorIn(this); - AbstractAction programAction = new AbstractAction(Lang.get("menu_programDiode")) { + new ToolTipAction(Lang.get("menu_programDiode")) { @Override public void actionPerformed(ActionEvent e) { if (activeMouseController instanceof MouseControllerNormal) { programElementAt(getPosVector(lastMousePos.x, lastMousePos.y)); } } - }; + }.setAccelerator(KeyStroke.getKeyStroke("P")).enableAcceleratorIn(this); - getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ESC_ACTION); - getActionMap().put(ESC_ACTION, escapeAction); getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), DEL_ACTION); getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), DEL_ACTION); getActionMap().put(DEL_ACTION, deleteAction); - getInputMap().put(KeyStroke.getKeyStroke('C', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "myCopy"); - getActionMap().put("myCopy", copyAction); - getInputMap().put(KeyStroke.getKeyStroke('V', Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "myPaste"); - getActionMap().put("myPaste", pasteAction); - getInputMap().put(KeyStroke.getKeyStroke("R"), "myRotate"); - getActionMap().put("myRotate", rotateAction); - getInputMap().put(KeyStroke.getKeyStroke("P"), "myProgram"); - getActionMap().put("myProgram", programAction); setFocusable(true); @@ -221,8 +210,8 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe setToolTipText(""); } - private AbstractAction createPasteAction(ShapeFactory shapeFactory) { - return new AbstractAction(Lang.get("menu_paste")) { + private ToolTipAction createPasteAction(ShapeFactory shapeFactory) { + return new ToolTipAction(Lang.get("menu_paste")) { @Override public void actionPerformed(ActionEvent e) { if (!isLocked()) { @@ -243,11 +232,11 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe } } } - }; + }.setAcceleratorCTRLplus('V').enableAcceleratorIn(this); } - private AbstractAction createCopyAction(ShapeFactory shapeFactory) { - AbstractAction copyAction = new AbstractAction(Lang.get("menu_copy")) { + private ToolTipAction createCopyAction(ShapeFactory shapeFactory) { + return new ToolTipAction(Lang.get("menu_copy")) { @Override public void actionPerformed(ActionEvent e) { ArrayList elements = null; @@ -265,9 +254,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe activeMouseController.escapePressed(); } } - }; - copyAction.setEnabled(false); - return copyAction; + }.setActive(false).setAcceleratorCTRLplus('C').enableAcceleratorIn(this); } private void programElementAt(Vector pos) { @@ -405,21 +392,21 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe /** * @return the copy action */ - public AbstractAction getCopyAction() { + public ToolTipAction getCopyAction() { return copyAction; } /** * @return the paste action */ - public AbstractAction getPasteAction() { + public ToolTipAction getPasteAction() { return pasteAction; } /** * @return the rotate action */ - public AbstractAction getRotateAction() { + public ToolTipAction getRotateAction() { return rotateAction; } diff --git a/src/test/java/de/neemann/digital/integration/TestExamples.java b/src/test/java/de/neemann/digital/integration/TestExamples.java index cdff8a6eb..35735ccb4 100644 --- a/src/test/java/de/neemann/digital/integration/TestExamples.java +++ b/src/test/java/de/neemann/digital/integration/TestExamples.java @@ -28,7 +28,7 @@ public class TestExamples extends TestCase { */ public void testDistExamples() throws Exception { File examples = new File(Resources.getRoot().getParentFile().getParentFile(), "/main/dig"); - assertEquals(175, new FileScanner(this::check).scan(examples)); + assertEquals(176, new FileScanner(this::check).scan(examples)); assertEquals(78, testCasesInFiles); }