diff --git a/src/main/java/ui/ActionPerformer.java b/src/main/java/ui/ActionPerformer.java index a5d757268224fbd3835baffdeb24ebc8d6563bf0..0a021dac7dcbb9176bf080a19db93982e707ce5d 100755 --- a/src/main/java/ui/ActionPerformer.java +++ b/src/main/java/ui/ActionPerformer.java @@ -1031,9 +1031,9 @@ public class ActionPerformer { } else if (command.equals(mgui.actions[TGUIAction.ACT_DOWN].getActionCommand())) { tdp1.downComponent(); } else if (command.equals(mgui.actions[TGUIAction.ACT_LEFT].getActionCommand())) { - tdp1.leftComponent(); + tdp1.leftComponent(); } else if (command.equals(mgui.actions[TGUIAction.ACT_RIGHT].getActionCommand())) { - tdp1.rightComponent(); + tdp1.rightComponent(); } } } diff --git a/src/main/java/ui/ArrowListener.java b/src/main/java/ui/ArrowListener.java deleted file mode 100644 index fcc6d77c11fe802171db2663a8498ed824712f4b..0000000000000000000000000000000000000000 --- a/src/main/java/ui/ArrowListener.java +++ /dev/null @@ -1,37 +0,0 @@ -package ui; - -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; - -public class ArrowListener implements KeyListener { - - private TDiagramPanel tdp; - - public ArrowListener(TDiagramPanel t) { - tdp = t; - } - - @Override - public void keyPressed(KeyEvent arg0) { - if (arg0.getKeyCode() == KeyEvent.VK_UP) - tdp.upComponent(); - if (arg0.getKeyCode() == KeyEvent.VK_DOWN) - tdp.downComponent(); - if (arg0.getKeyCode() == KeyEvent.VK_LEFT) - tdp.leftComponent(); - if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) - tdp.rightComponent(); - } - - @Override - public void keyReleased(KeyEvent arg0) { - // TODO Auto-generated method stub - - } - - @Override - public void keyTyped(KeyEvent arg0) { - - } - -} diff --git a/src/main/java/ui/JMenuBarTurtle.java b/src/main/java/ui/JMenuBarTurtle.java index 16e8753f8109b660657c97e549b59cfefc7f14ec..8e2c0d40d910a76e5d95c8001d06ebf9753bbcc2 100755 --- a/src/main/java/ui/JMenuBarTurtle.java +++ b/src/main/java/ui/JMenuBarTurtle.java @@ -173,14 +173,6 @@ public class JMenuBarTurtle extends JMenuBar { menuItem.addMouseListener(mgui.mouseHandler); menuItem = edit.add(mgui.actions[TGUIAction.ACT_SUPPR]); menuItem.addMouseListener(mgui.mouseHandler); - menuItem = edit.add(mgui.actions[TGUIAction.ACT_UP]); - menuItem.addMouseListener(mgui.mouseHandler); - menuItem = edit.add(mgui.actions[TGUIAction.ACT_DOWN]); - menuItem.addMouseListener(mgui.mouseHandler); - menuItem = edit.add(mgui.actions[TGUIAction.ACT_RIGHT]); - menuItem.addMouseListener(mgui.mouseHandler); - menuItem = edit.add(mgui.actions[TGUIAction.ACT_LEFT]); - menuItem.addMouseListener(mgui.mouseHandler); edit.addSeparator(); diff --git a/src/main/java/ui/PanelKeyListener.java b/src/main/java/ui/PanelKeyListener.java new file mode 100644 index 0000000000000000000000000000000000000000..2bede92afa866e517e053ac90b3c1e7f15f0dd06 --- /dev/null +++ b/src/main/java/ui/PanelKeyListener.java @@ -0,0 +1,50 @@ +package ui; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +/** + * KeyListener for TDiagramPanel + * @author Fabien Tessier + */ + +public class PanelKeyListener implements KeyListener { + + private TDiagramPanel tdp; + + public PanelKeyListener(TDiagramPanel t) { + tdp = t; + } + + @Override + public void keyPressed(KeyEvent arg0) { + if (arg0.getKeyCode() == KeyEvent.VK_UP && arg0.isShiftDown()) + tdp.upComponent(); + if (arg0.getKeyCode() == KeyEvent.VK_DOWN && arg0.isShiftDown()) + tdp.downComponent(); + if (arg0.getKeyCode() == KeyEvent.VK_LEFT && arg0.isShiftDown()) + tdp.leftComponent(); + if (arg0.getKeyCode() == KeyEvent.VK_RIGHT && arg0.isShiftDown()) + tdp.rightComponent(); + if (arg0.getKeyCode() == KeyEvent.VK_ESCAPE && tdp.mode == TDiagramPanel.ADDING_CONNECTOR) { + if (tdp.mode == TDiagramPanel.ADDING_CONNECTOR) { + tdp.mode = TDiagramPanel.NORMAL; + tdp.stopAddingConnector(true); + tdp.getGUI().setEditMode(); + tdp.repaint(); + } else { + tdp.getGUI().setEditMode(); + tdp.repaint(); + } + } + } + + @Override + public void keyReleased(KeyEvent arg0) { + } + + @Override + public void keyTyped(KeyEvent arg0) { + } + +} diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index d48f476bfd5c53011bdf378de10b67a6f360f8a7..b872772f953443904e1244a40d232e3e8ccd1714 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -87,7 +87,7 @@ import java.util.List; public abstract class TDiagramPanel extends JPanel implements GenericTree { protected TDiagramMouseManager tdmm; - protected ArrowListener al; + protected PanelKeyListener pkl; // for tracking changes public static final int NEW_COMPONENT = 0; @@ -235,14 +235,12 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { public boolean drawable = true; - public static final int MOVE_SPEED = 3; + public static final int MOVE_SPEED = 1; //Speed of component moving with arrow keys // Constructor public TDiagramPanel(MainGUI _mgui, TToolBar _ttb) { - UIManager.getDefaults().put("ScrollPane.ancestorInputMap", - new UIDefaults.LazyInputMap(new Object[] {})); setBackground(ColorManager.DIAGRAM_BACKGROUND); //setBackground(Color.red); //setMinimumSize(new Dimension(1000, 1000)); @@ -257,8 +255,8 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { addMouseListener(tdmm); addMouseMotionListener(tdmm); - al = new ArrowListener(this); - addKeyListener(al); + pkl = new PanelKeyListener(this); + addKeyListener(pkl); setFocusable(true); diff --git a/src/main/java/ui/TGUIAction.java b/src/main/java/ui/TGUIAction.java index 000a9814ab18250bc9f88cfd9b38cfad8be92154..a204941ad79128ed8bc1fd584e1691f314036ab6 100755 --- a/src/main/java/ui/TGUIAction.java +++ b/src/main/java/ui/TGUIAction.java @@ -657,8 +657,8 @@ public class TGUIAction extends AbstractAction { if (actions[id].hasControl) { putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].KEY, java.awt.event.InputEvent.CTRL_MASK)); } else { - if (actions[id].MNEMONIC_KEY >= 500 && actions[id].MNEMONIC_KEY <= 503) - putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].ACTION_COMMAND_KEY)); + if (actions[id].MNEMONIC_KEY >= 37 && actions[id].MNEMONIC_KEY <= 40) //handling for arrow keys + putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].MNEMONIC_KEY, 0)); else putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(actions[id].KEY)); } @@ -1232,10 +1232,10 @@ public class TGUIAction extends AbstractAction { actions[ACT_GENERATE_ONTOLOGIES_CURRENT_SET_OF_DIAGRAMS] = new TAction("generate-ontology-current-set-of-diagrams", "Generate ontology (current set of diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (current set of diagrams)", "Generate the ontology for the current set of diagrams under edition", 0); actions[ACT_GENERATE_ONTOLOGIES_ALL_DIAGRAMS] = new TAction("generate-ontology-all-diagrams", "Generate ontology (all diagrams)", IconManager.imgic338, IconManager.imgic339, "Generate ontology (all diagrams)", "Generate the ontology for the diagrams under edition", 0); - actions[ACT_UP] = new TAction("UP", "Up", IconManager.imgic78, IconManager.imgic78, "Up", "Up", 500); - actions[ACT_DOWN] = new TAction("DOWN", "Down", IconManager.imgic79, IconManager.imgic79, "Down", "Down", 501); - actions[ACT_RIGHT] = new TAction("RIGHT", "Right", IconManager.imgic780, IconManager.imgic780, "Right", "Right", 502); - actions[ACT_LEFT] = new TAction("LEFT", "Left", IconManager.imgic790, IconManager.imgic790, "Left", "Left", 503); + actions[ACT_UP] = new TAction("UP", "Up", IconManager.imgic78, IconManager.imgic78, "Up (Maj-Haut)", "Up", KeyEvent.VK_UP); + actions[ACT_DOWN] = new TAction("DOWN", "Down", IconManager.imgic79, IconManager.imgic79, "Down (Maj-Bas)", "Down", KeyEvent.VK_DOWN); + actions[ACT_RIGHT] = new TAction("RIGHT", "Right", IconManager.imgic780, IconManager.imgic780, "Right (Maj-Droit)", "Right", KeyEvent.VK_RIGHT); + actions[ACT_LEFT] = new TAction("LEFT", "Left", IconManager.imgic790, IconManager.imgic790, "Left (Maj-Gauche)", "Left", KeyEvent.VK_LEFT); }