Browse Source

Adds Control+A to select all, Esc for deselect all

Andreas T. Meyer-Berg 5 years ago
parent
commit
f5fb9a2136

+ 1 - 3
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/core/configuration/SelectionModel.java

@@ -20,7 +20,5 @@ public class SelectionModel {
 	 */
 	public LinkedList<Pair<Connection,Pair<Port,Port>>> clickedConnection = new LinkedList<Pair<Connection,Pair<Port,Port>>>();
 	
-	public SelectionModel() {
-		// TODO Auto-generated constructor stub
-	}
+	public SelectionModel() {}
 }

+ 25 - 1
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/view/VisualizationInteractor.java

@@ -623,8 +623,26 @@ public class VisualizationInteractor implements MouseInputListener,
 				panel.repaint();
 			}
 		}
+		if(e.getKeyCode()==KeyEvent.VK_A && controlDown){
+			selectAllDevics();	
+		}
+		if(e.getKeyCode()==KeyEvent.VK_ESCAPE){
+			deselectAllDevics();
+		}
 	}
-
+	
+	private void selectAllDevics(){
+		deselectAllDevics();
+		config.getConfigurationManager().getSelectionModel().selectedDevices.addAll(controller.getNetworkController().getVisibleSmartDevices());
+		panel.repaint();
+	}
+	
+	private void deselectAllDevics(){
+		config.getConfigurationManager().getSelectionModel().selectedDevicesDrag.clear();
+		config.getConfigurationManager().getSelectionModel().selectedDevices.clear();
+		panel.repaint();
+	}
+	
 	@Override
 	public void keyPressed(KeyEvent e) {
 		if(e.getKeyCode()==KeyEvent.VK_CONTROL){
@@ -633,6 +651,12 @@ public class VisualizationInteractor implements MouseInputListener,
 				panel.repaint();
 			}
 		}
+		if(e.getKeyCode()==KeyEvent.VK_A && controlDown){
+			selectAllDevics();
+		}
+		if(e.getKeyCode()==KeyEvent.VK_ESCAPE){
+			deselectAllDevics();
+		}
 	}
 
 	@Override