resolved merge conflicts

This commit is contained in:
hneemann 2017-05-27 10:47:33 +02:00
parent 890fde5903
commit 72849cddab
2 changed files with 19 additions and 32 deletions

View File

@ -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<Movable> 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;
}

View File

@ -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);
}