|
@@ -15,12 +15,12 @@ import javax.swing.event.MouseInputListener;
|
|
|
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.control.Controller;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.ConnectionImplementation;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Packet;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
|
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleConnection;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleLink;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.simpleImplementation.SimpleProtocol;
|
|
|
|
|
@@ -63,6 +63,11 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
* RightClick MenuItem for Link creation
|
|
|
*/
|
|
|
private JMenuItem itemCreateLink;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * RightClick MenuItem for Connection creation
|
|
|
+ */
|
|
|
+ private JMenuItem itemCreateConnection;
|
|
|
|
|
|
/**
|
|
|
* RightClick MenuItem for SmartDevice deletion
|
|
@@ -399,9 +404,9 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
l.addDevice(connectionTo);
|
|
|
Port p1 = new Port(connectionFrom, (short) 1);
|
|
|
Port p2 = new Port(connectionTo, (short) 2);
|
|
|
-
|
|
|
- Connection c = new SimpleConnection(p1, p2,
|
|
|
- l, new SimpleProtocol(p1, p2));
|
|
|
+ Connection c = new ConnectionImplementation(l, new SimpleProtocol(p1, p2));
|
|
|
+ c.addSmartDevice(p1);
|
|
|
+ c.addSmartDevice(p2);
|
|
|
p1.setConnection(c);
|
|
|
p2.setConnection(c);
|
|
|
connectionTo.addLink(l);
|
|
@@ -513,10 +518,12 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
if(selectedDevices.contains(clickedOn)){
|
|
|
itemDeleteSelected.setEnabled(true);
|
|
|
itemCreateLink.setEnabled(true);
|
|
|
+ itemCreateConnection.setEnabled(true);
|
|
|
}
|
|
|
else{
|
|
|
itemDeleteSelected.setEnabled(false);
|
|
|
itemCreateLink.setEnabled(false);
|
|
|
+ itemCreateConnection.setEnabled(false);
|
|
|
}
|
|
|
}
|
|
|
// Show the RightClickMenu
|
|
@@ -555,16 +562,32 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
|
|
|
rightClickMenu.add(itemCreate);
|
|
|
|
|
|
-
|
|
|
// Create Link
|
|
|
itemCreateLink = new JMenuItem("Create Link");
|
|
|
|
|
|
itemCreateLink.addActionListener(e -> {
|
|
|
new LinkCreationDialog(selectedDevices, controller, panel);
|
|
|
- mode = NOTHING;
|
|
|
+ if(selectedDevices.isEmpty())
|
|
|
+ mode = NOTHING;
|
|
|
+ else
|
|
|
+ mode = SELECTED;
|
|
|
+ });
|
|
|
+
|
|
|
+ // Create Connection
|
|
|
+ itemCreateConnection = new JMenuItem("Create Connection");
|
|
|
+
|
|
|
+ itemCreateConnection.addActionListener(e -> {
|
|
|
+ LinkedList<Port> ports = new LinkedList<Port>();
|
|
|
+ for(SmartDevice d: selectedDevices)
|
|
|
+ ports.add(new Port(d, (short) 12));
|
|
|
+ new ConnectionCreationDialog(ports,new SimpleLink("TestLink"), controller, panel);
|
|
|
+ if(selectedDevices.isEmpty())
|
|
|
+ mode = NOTHING;
|
|
|
+ else
|
|
|
+ mode = SELECTED;
|
|
|
});
|
|
|
|
|
|
- rightClickMenu.add(itemCreateLink);
|
|
|
+ rightClickMenu.add(itemCreateConnection);
|
|
|
|
|
|
// Delete device option
|
|
|
itemDelete = new JMenuItem("Delete");
|