Forráskód Böngészése

Stash some changes, selection box not yet finished

Jan Enders 7 éve
szülő
commit
aa58554650

+ 23 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/ButtonManager.java

@@ -3,10 +3,14 @@ package de.tu_darmstadt.informatik.tk.scopviz.ui;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.stream.Collectors;
 
+import org.graphstream.graph.Graph;
 import org.jxmapviewer.viewer.GeoPosition;
 import org.jxmapviewer.viewer.WaypointPainter;
 
+import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
+import de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
 import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.CustomMapClickListener;
@@ -14,6 +18,7 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.CustomWaypoint;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.CustomWaypointRenderer;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.MapViewFunctions;
 import de.tu_darmstadt.informatik.tk.scopviz.ui.mapView.WorldView;
+import javafx.application.Platform;
 import javafx.beans.value.ObservableValue;
 import javafx.event.ActionEvent;
 import javafx.scene.control.Alert;
@@ -483,4 +488,22 @@ public final class ButtonManager {
 		MapViewFunctions.changeMapView();
 	}
 
+	public static void setupOpGraphComboBox() {
+		controller.opGraphSelectionBox.getItems().clear();
+		GraphManager operatorManager = GraphDisplayManager.getGraphManager(Layer.OPERATOR);
+		for (MyGraph g: operatorManager.getGraph().getAllSubGraphs().stream().filter((g) -> !g.isComposite()).collect(Collectors.toList())){
+			controller.opGraphSelectionBox.getItems().add(g.getId());
+		}
+		controller.opGraphSelectionBox.getItems().add("Add...");	
+		
+		//Platform.runLater(() -> controller.opGraphSelectionBox.setValue(controller.opGraphSelectionBox.getItems().get(0)));
+	}
+
+	public static void opGraphSelectedAction(ActionEvent v) {
+		
+		if (controller.opGraphSelectionBox.getValue().equals("Add...")){
+			MenuBarManager.addAction(v);
+		}
+	}
+
 }

+ 7 - 4
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/GUIController.java

@@ -489,12 +489,15 @@ public class GUIController implements Initializable {
 	private void initializeOpGraphComboBox() {
 
 		opGraphSelectionBox.setVisible(false);
+		
+		ButtonManager.setupOpGraphComboBox();
 
 		// initialization of the values of the box
-		String firstOpGraph = GraphDisplayManager.getGraphManager(Layer.OPERATOR).getGraph().getId();
-		opGraphSelectionBox.getItems().addAll(firstOpGraph, "Add...");
-		Platform.runLater(() -> opGraphSelectionBox.setValue(firstOpGraph));
+		
+		Platform.runLater(() -> opGraphSelectionBox.setValue(opGraphSelectionBox.getItems().get(0)));
 
+		opGraphSelectionBox.setOnAction((v) -> ButtonManager.opGraphSelectedAction(v));
+		/*
 		opGraphSelectionBox.setOnAction((v) -> {
 			if (opGraphSelectionBox.getValue().equals("Add...")) {
 				// add Dialog erscheint, Operator Graph wird importiert und fügt
@@ -509,7 +512,7 @@ public class GUIController implements Initializable {
 				// wechselt auf Operatorgraph mit diesem Namen
 
 			}
-		});
+		});*/
 	}
 
 	/**

+ 1 - 0
scopviz/src/main/java/de/tu_darmstadt/informatik/tk/scopviz/ui/MenuBarManager.java

@@ -48,6 +48,7 @@ public final class MenuBarManager {
 	 */
 	public static final void addAction(ActionEvent event) {
 		GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), false);
+		ButtonManager.setupOpGraphComboBox();
 	}
 
 	/**