|
@@ -9,6 +9,7 @@ import java.awt.event.MouseEvent;
|
|
import java.awt.event.MouseMotionListener;
|
|
import java.awt.event.MouseMotionListener;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
|
|
|
|
|
|
+import javax.swing.JFrame;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.event.MouseInputListener;
|
|
import javax.swing.event.MouseInputListener;
|
|
@@ -59,6 +60,11 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
*/
|
|
*/
|
|
private JMenuItem itemCreate;
|
|
private JMenuItem itemCreate;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * RightClick MenuItem for Link creation
|
|
|
|
+ */
|
|
|
|
+ private JMenuItem itemCreateLink;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* RightClick MenuItem for SmartDevice deletion
|
|
* RightClick MenuItem for SmartDevice deletion
|
|
*/
|
|
*/
|
|
@@ -128,6 +134,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
* True if the ControlKey is currently pressed
|
|
* True if the ControlKey is currently pressed
|
|
*/
|
|
*/
|
|
public boolean controlDown = false;
|
|
public boolean controlDown = false;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Creates a new VisualisationInteractor
|
|
* Creates a new VisualisationInteractor
|
|
*
|
|
*
|
|
@@ -333,44 +340,6 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
if (mode == SELECTED_DRAG || mode == DRAG_CONNECTION || mode == DRAG_SELECT)
|
|
if (mode == SELECTED_DRAG || mode == DRAG_CONNECTION || mode == DRAG_SELECT)
|
|
panel.repaint();
|
|
panel.repaint();
|
|
}
|
|
}
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Shows the RightClick Menu on the Visualization Panel, with Options for
|
|
|
|
- * the given SmartDevice clickedOn, if clickedOn is null, the RightClick
|
|
|
|
- * Menu contains Options for creation of new SmartDevices. The Menu will be
|
|
|
|
- * shown at the Mouse position on the VisualisationPanel.
|
|
|
|
- *
|
|
|
|
- * @param clickedOn
|
|
|
|
- * Device which was clicked, null if no
|
|
|
|
- */
|
|
|
|
- protected void showRightClickMenu(SmartDevice clickedOn) {
|
|
|
|
- /**
|
|
|
|
- * Mouse Position on the VisualisationPanel
|
|
|
|
- */
|
|
|
|
- Point mousePos = panel.getMousePosition();
|
|
|
|
- // Just execute if Mouse Position is on the Panel
|
|
|
|
- if (mousePos != null) {
|
|
|
|
- if (clickedOn == null) {
|
|
|
|
- itemCreate.setText("Create Device");
|
|
|
|
- itemCreate.setEnabled(true);
|
|
|
|
- itemDelete.setEnabled(false);
|
|
|
|
- itemDeleteSelected.setEnabled(false);
|
|
|
|
- } else {
|
|
|
|
- itemCreate.setText("Edit Device");
|
|
|
|
- itemCreate.setEnabled(true);
|
|
|
|
- itemDelete.setEnabled(true);
|
|
|
|
- if(selectedDevices.contains(clickedOn))
|
|
|
|
- itemDeleteSelected.setEnabled(true);
|
|
|
|
- else
|
|
|
|
- itemDeleteSelected.setEnabled(false);
|
|
|
|
- }
|
|
|
|
- // Show the RightClickMenu
|
|
|
|
- rightClickMenu.show(panel, mousePos.x, mousePos.y);
|
|
|
|
- rightClickMenu.setEnabled(true);
|
|
|
|
- rightClickMenu.setVisible(true);
|
|
|
|
- mode = RIGHTCLICK_MENU;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Finishes the drag operation, if a SmartDevice was dragged, repaint the
|
|
* Finishes the drag operation, if a SmartDevice was dragged, repaint the
|
|
@@ -517,6 +486,47 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {}
|
|
public void actionPerformed(ActionEvent e) {}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Shows the RightClick Menu on the Visualization Panel, with Options for
|
|
|
|
+ * the given SmartDevice clickedOn, if clickedOn is null, the RightClick
|
|
|
|
+ * Menu contains Options for creation of new SmartDevices. The Menu will be
|
|
|
|
+ * shown at the Mouse position on the VisualisationPanel.
|
|
|
|
+ *
|
|
|
|
+ * @param clickedOn
|
|
|
|
+ * Device which was clicked, null if no
|
|
|
|
+ */
|
|
|
|
+ protected void showRightClickMenu(SmartDevice clickedOn) {
|
|
|
|
+ /**
|
|
|
|
+ * Mouse Position on the VisualisationPanel
|
|
|
|
+ */
|
|
|
|
+ Point mousePos = panel.getMousePosition();
|
|
|
|
+ // Just execute if Mouse Position is on the Panel
|
|
|
|
+ if (mousePos != null) {
|
|
|
|
+ if (clickedOn == null) {
|
|
|
|
+ itemCreate.setText("Create Device");
|
|
|
|
+ itemCreate.setEnabled(true);
|
|
|
|
+ itemDelete.setEnabled(false);
|
|
|
|
+ itemDeleteSelected.setEnabled(false);
|
|
|
|
+ } else {
|
|
|
|
+ itemCreate.setText("Edit Device");
|
|
|
|
+ itemCreate.setEnabled(true);
|
|
|
|
+ itemDelete.setEnabled(true);
|
|
|
|
+ if(selectedDevices.contains(clickedOn)){
|
|
|
|
+ itemDeleteSelected.setEnabled(true);
|
|
|
|
+ itemCreateLink.setEnabled(true);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ itemDeleteSelected.setEnabled(false);
|
|
|
|
+ itemCreateLink.setEnabled(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Show the RightClickMenu
|
|
|
|
+ rightClickMenu.show(panel, mousePos.x, mousePos.y);
|
|
|
|
+ rightClickMenu.setEnabled(true);
|
|
|
|
+ rightClickMenu.setVisible(true);
|
|
|
|
+ mode = RIGHTCLICK_MENU;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates the RightClickMenu, adds the different Labels and functionalities to the menu and adds it to the panel.
|
|
* Creates the RightClickMenu, adds the different Labels and functionalities to the menu and adds it to the panel.
|
|
@@ -545,6 +555,25 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
});
|
|
});
|
|
|
|
|
|
rightClickMenu.add(itemCreate);
|
|
rightClickMenu.add(itemCreate);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // Create Link
|
|
|
|
+ itemCreateLink = new JMenuItem("Create Link");
|
|
|
|
+
|
|
|
|
+ itemCreateLink.addActionListener(e -> {
|
|
|
|
+ JFrame frame = new JFrame("LinkCreation Panel");
|
|
|
|
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
+ //frame.set
|
|
|
|
+ LinkCreationPanel panel = new LinkCreationPanel();
|
|
|
|
+ frame.setContentPane(panel);
|
|
|
|
+ frame.setLocationRelativeTo(panel);
|
|
|
|
+ frame.pack();
|
|
|
|
+ frame.setVisible(true);
|
|
|
|
+ mode = NOTHING;
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ rightClickMenu.add(itemCreateLink);
|
|
|
|
|
|
// Delete device option
|
|
// Delete device option
|
|
itemDelete = new JMenuItem("Delete");
|
|
itemDelete = new JMenuItem("Delete");
|