|
@@ -214,7 +214,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
this.model = model;
|
|
|
this.controller = controller;
|
|
|
this.panel = panel;
|
|
|
- this.config = controller.getControllerConfiguration();
|
|
|
+ this.config = controller.getSettingsController();
|
|
|
this.network = controller.getNetworkController();
|
|
|
this.toolTip = new LinkToolTip();
|
|
|
|
|
@@ -229,9 +229,9 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
*/
|
|
|
clicked = getSmartDeviceAtPosition(e.getX(), e.getY());
|
|
|
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().clickedConnection.clear();
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().clickedConnection.clear();
|
|
|
if(clicked == null)
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().clickedConnection = getConnectionsAtPosition(e.getX(), e.getY());
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().clickedConnection = getConnectionsAtPosition(e.getX(), e.getY());
|
|
|
|
|
|
|
|
|
switch (mode) {
|
|
@@ -250,24 +250,24 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
showRightClickMenu(clicked, linkAtPosition);
|
|
|
break;
|
|
|
}
|
|
|
- if(!controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty()&&!controlDown){
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
+ if(!controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty()&&!controlDown){
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
if (clicked == null) {
|
|
|
panel.repaint();
|
|
|
}
|
|
|
}
|
|
|
if(clicked!=null){
|
|
|
if(!controlDown)
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.add(clicked);
|
|
|
- else if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.remove(clicked)&&!draggedDeviceWasSelected){
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.add(clicked);
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.add(clicked);
|
|
|
+ else if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.remove(clicked)&&!draggedDeviceWasSelected){
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.add(clicked);
|
|
|
}
|
|
|
mode = SELECTED;
|
|
|
panel.repaint();
|
|
|
}else{
|
|
|
if(!controlDown)
|
|
|
mode = NOTHING;
|
|
|
- else if(!controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ else if(!controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = SELECTED;
|
|
|
|
|
|
panel.repaint();
|
|
@@ -301,15 +301,15 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
dragged_y_start = e.getY();
|
|
|
mode = DRAG_SELECT;
|
|
|
if(!controlDown)
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
break;
|
|
|
} else if (e.getButton() == MouseEvent.BUTTON1){// && connectionFrom == null) {
|
|
|
// Recognize possible drag operation
|
|
|
- draggedDeviceWasSelected = controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.contains(pressedOn);
|
|
|
+ draggedDeviceWasSelected = controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.contains(pressedOn);
|
|
|
if(!draggedDeviceWasSelected){
|
|
|
if(!controlDown)
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.add(pressedOn);
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.add(pressedOn);
|
|
|
}
|
|
|
dragged = pressedOn;
|
|
|
dragged_x = pressedOn.getX();
|
|
@@ -378,11 +378,11 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
int max_x = Math.max(dragged_x, dragged_x_start);
|
|
|
int max_y = Math.max(dragged_y, dragged_y_start);
|
|
|
//Remove unselected
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag.removeIf(s->(s.getX()<min_x||s.getX()>max_x||s.getY()<min_y||s.getY()>max_y));
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag.removeIf(s->(s.getX()<min_x||s.getX()>max_x||s.getY()<min_y||s.getY()>max_y));
|
|
|
//Add selected devices
|
|
|
for(SmartDevice sel:model.getDevices()){
|
|
|
- if(sel.getX()>=min_x&&sel.getX()<=max_x&&sel.getY()>=min_y&&sel.getY()<=max_y&&!controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag.contains(sel)){
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag.add(sel);
|
|
|
+ if(sel.getX()>=min_x&&sel.getX()<=max_x&&sel.getY()>=min_y&&sel.getY()<=max_y&&!controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag.contains(sel)){
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag.add(sel);
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
@@ -394,7 +394,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
int x_offset = dragged_x - dragged.getX();
|
|
|
int y_offset = dragged_y - dragged.getY();
|
|
|
//Validate for all moved devices, that they are within the model, if not change offset
|
|
|
- for(SmartDevice d:controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices){
|
|
|
+ for(SmartDevice d:controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices){
|
|
|
if (d.getX() + x_offset <= config.getDeviceVisualizationRadius())
|
|
|
x_offset = config.getDeviceVisualizationRadius()-d.getX();
|
|
|
else if (d.getX() + x_offset >= model.getWidth() - config.getDeviceVisualizationRadius())
|
|
@@ -428,11 +428,11 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
&& (dragged.getX() != dragged_x || dragged.getY() != dragged_y)) {
|
|
|
int x_offset = dragged_x-dragged.getX();
|
|
|
int y_offset = dragged_y-dragged.getY();
|
|
|
- for(SmartDevice d: controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices)
|
|
|
+ for(SmartDevice d: controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices)
|
|
|
network.moveSmartDevice(d, d.getX()+x_offset, d.getY()+y_offset, d.getZ());
|
|
|
}
|
|
|
dragged = null;
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = NOTHING;
|
|
|
else
|
|
|
mode = SELECTED;
|
|
@@ -444,15 +444,15 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
private void finishDragSelect() {
|
|
|
LinkedList<SmartDevice> merged = new LinkedList<SmartDevice>();
|
|
|
//XOR of controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices and controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices Drag
|
|
|
- merged.addAll(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices);
|
|
|
- merged.removeAll(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag);
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag.removeAll(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices);
|
|
|
- merged.addAll(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag);
|
|
|
+ merged.addAll(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices);
|
|
|
+ merged.removeAll(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag);
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag.removeAll(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices);
|
|
|
+ merged.addAll(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag);
|
|
|
//clear sets
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevicesDrag.clear();
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices = merged;
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevicesDrag.clear();
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices = merged;
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = NOTHING;
|
|
|
else
|
|
|
mode = SELECTED;
|
|
@@ -492,7 +492,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
|
|
|
}
|
|
|
connectionFrom = null;
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = NOTHING;
|
|
|
else
|
|
|
mode = SELECTED;
|
|
@@ -746,7 +746,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
itemCreate.setEnabled(true);
|
|
|
itemDelete.setEnabled(false);
|
|
|
itemDeleteSelected.setEnabled(false);
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().clickedConnection.size()>0){
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().clickedConnection.size()>0){
|
|
|
/**
|
|
|
* Update Connections which can be edited
|
|
|
*/
|
|
@@ -754,7 +754,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
|
|
|
//List to prevent duplicate connection entries
|
|
|
LinkedList<Connection> editableConnections = new LinkedList<Connection>();
|
|
|
- for(Pair<Connection, Pair<Port,Port>> p:controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().clickedConnection){
|
|
|
+ for(Pair<Connection, Pair<Port,Port>> p:controller.getSettingsController().getConfigurationManager().getSelectionModel().clickedConnection){
|
|
|
//Don't add the same connection multiple times
|
|
|
if(editableConnections.contains(p.getLeft())|| p == null || p.getLeft() == null)continue;
|
|
|
editableConnections.add(p.getLeft());
|
|
@@ -786,7 +786,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
rightClickMenu.add(itemCreateConnection,editCreateConnectionIndex);
|
|
|
}
|
|
|
itemCreateLink.setText("Create Link");
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.contains(clickedOn)){
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.contains(clickedOn)){
|
|
|
itemDeleteSelected.setEnabled(true);
|
|
|
itemCreateLink.setEnabled(true);
|
|
|
itemCreateConnection.setEnabled(true);
|
|
@@ -840,9 +840,9 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
if(clickedLink!=null){
|
|
|
new LinkCreationDialog(clickedLink, controller, panel);
|
|
|
}else{
|
|
|
- new LinkCreationDialog(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices, controller, panel);
|
|
|
+ new LinkCreationDialog(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices, controller, panel);
|
|
|
}
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = NOTHING;
|
|
|
else
|
|
|
mode = SELECTED;
|
|
@@ -854,10 +854,10 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
itemCreateConnection = new JMenuItem("Create Connection");
|
|
|
itemCreateConnection.addActionListener(e->{
|
|
|
LinkedList<Port> ports = new LinkedList<Port>();
|
|
|
- for(SmartDevice d: controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices)
|
|
|
+ for(SmartDevice d: controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices)
|
|
|
ports.add(new Port(d, (short) 12));
|
|
|
new ConnectionCreationDialog(ports,new SimpleLink("TestLink"), controller, panel);
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = NOTHING;
|
|
|
else
|
|
|
mode = SELECTED;
|
|
@@ -885,9 +885,9 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
|
|
|
itemDeleteSelected.addActionListener(e -> {
|
|
|
// Delete the clicked object
|
|
|
- for(SmartDevice c: controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices)
|
|
|
+ for(SmartDevice c: controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices)
|
|
|
network.deleteSmartDevice(c);
|
|
|
- controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
+ controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.clear();
|
|
|
clicked = null;
|
|
|
controller.notifyObservers();
|
|
|
mode = NOTHING;
|
|
@@ -943,7 +943,7 @@ public class VisualisationInteractor implements MouseInputListener,
|
|
|
System.out.println(p.getTextualRepresentation());
|
|
|
});
|
|
|
model.getConnections().removeAll(terminated);
|
|
|
- if(controller.getControllerConfiguration().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
+ if(controller.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty())
|
|
|
mode = NOTHING;
|
|
|
else
|
|
|
mode = SELECTED;
|