diff --git a/src/main/java/ui/PanelKeyListener.java b/src/main/java/ui/PanelKeyListener.java index 0dd929c2e05547a08bca45ffe669e0348163fb62..16f23f1f94eb8fc2f0763b0e5c0aaa15c381e340 100644 --- a/src/main/java/ui/PanelKeyListener.java +++ b/src/main/java/ui/PanelKeyListener.java @@ -1,5 +1,7 @@ package ui; +import java.awt.Cursor; +import java.awt.MouseInfo; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; @@ -18,6 +20,24 @@ public class PanelKeyListener implements KeyListener { @Override public void keyPressed(KeyEvent arg0) { + if (arg0.isShiftDown() && (tdp.mode == TDiagramPanel.SELECTED_COMPONENTS || tdp.mode == TDiagramPanel.MOVING_SELECTED_COMPONENTS)) { + tdp.showSelectionZone = true; + tdp.mode = TDiagramPanel.MOVING_SELECTED_COMPONENTS; + tdp.setMovingSelectedComponents(); + tdp.repaint(); + if (arg0.getKeyCode() == KeyEvent.VK_UP) { + tdp.upComponents(); + } + if (arg0.getKeyCode() == KeyEvent.VK_DOWN) { + tdp.downComponents(); + } + if (arg0.getKeyCode() == KeyEvent.VK_LEFT) { + tdp.leftComponents(); + } + if (arg0.getKeyCode() == KeyEvent.VK_RIGHT) { + tdp.rightComponents(); + } + } if (arg0.getKeyCode() == KeyEvent.VK_UP && arg0.isShiftDown()) tdp.upComponent(); if (arg0.getKeyCode() == KeyEvent.VK_DOWN && arg0.isShiftDown()) @@ -42,7 +62,15 @@ public class PanelKeyListener implements KeyListener { } @Override - public void keyReleased(KeyEvent arg0) { + public void keyReleased(KeyEvent arg0) { + if (!arg0.isShiftDown()) + if (tdp.mode == TDiagramPanel.MOVING_SELECTED_COMPONENTS) { + tdp.showSelectionZone(tdp.currentX, tdp.currentY); + tdp.mode = TDiagramPanel.SELECTED_COMPONENTS; + tdp.setStopMovingSelectedComponents(); + tdp.getGUI().changeMade(tdp, TDiagramPanel.MOVE_COMPONENT); + tdp.repaint(); + } } @Override diff --git a/src/main/java/ui/TDiagramMouseManager.java b/src/main/java/ui/TDiagramMouseManager.java index 6abec2258a8dda5fa75834c49d09237e456ada39..fd01d7a8069ad53754af4da66f9f45bf5d74fb6f 100755 --- a/src/main/java/ui/TDiagramMouseManager.java +++ b/src/main/java/ui/TDiagramMouseManager.java @@ -396,6 +396,7 @@ public class TDiagramMouseManager extends MouseAdapter {//implements MouseListen tdp.mode = TDiagramPanel.NORMAL; tdp.mgui.setMode(MainGUI.CUTCOPY_KO); tdp.mgui.setMode(MainGUI.EXPORT_LIB_KO); + tdp.getMainGUI().actions[TGUIAction.MOVE_ENABLED].setEnabled(false); tdp.unselectSelectedComponents(); tdp.repaint(); } diff --git a/src/main/java/ui/TDiagramPanel.java b/src/main/java/ui/TDiagramPanel.java index e906f43de7d17da5c04167ef898209d406bb9b67..42c2e36563acc30f8f92e0d4c13fee616bd2e664 100755 --- a/src/main/java/ui/TDiagramPanel.java +++ b/src/main/java/ui/TDiagramPanel.java @@ -1144,10 +1144,12 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { mode = NORMAL; mgui.setMode(MainGUI.CUTCOPY_KO); mgui.setMode(MainGUI.EXPORT_LIB_KO); + mgui.actions[TGUIAction.MOVE_ENABLED].setEnabled(false); } else { mode = SELECTED_COMPONENTS; mgui.setMode(MainGUI.CUTCOPY_OK); mgui.setMode(MainGUI.EXPORT_LIB_OK); + mgui.actions[TGUIAction.MOVE_ENABLED].setEnabled(true); showSelectionZone = true; xSel = Math.min(currentSelectX, initSelectX); ySel = Math.min(currentSelectY, initSelectY); @@ -3445,6 +3447,26 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { } } + public void upComponents() { + moveSelected(xSel, ySel - MOVE_SPEED); + repaint(); + } + + public void downComponents() { + moveSelected(xSel, ySel + MOVE_SPEED); + repaint(); + } + + public void leftComponents() { + moveSelected(xSel - MOVE_SPEED, ySel); + repaint(); + } + + public void rightComponents() { + moveSelected(xSel + MOVE_SPEED, ySel); + repaint(); + } + public void setComponentPointed(TGComponent tgc) { componentPointed = tgc; }