MenuBarManager.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package de.tu_darmstadt.informatik.tk.scopviz.ui;
  2. import de.tu_darmstadt.informatik.tk.scopviz.graphs.GraphManager;
  3. import de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph;
  4. import de.tu_darmstadt.informatik.tk.scopviz.io.GraphMLExporter;
  5. import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
  6. import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
  7. import javafx.event.ActionEvent;
  8. import javafx.scene.control.Alert;
  9. import javafx.scene.control.Alert.AlertType;
  10. import javafx.scene.control.Label;
  11. import javafx.scene.layout.Region;
  12. /**
  13. * Manager Class for the Menu Bar.
  14. *
  15. * @author Jascha Bohne
  16. * @version 1.1
  17. *
  18. */
  19. public final class MenuBarManager {
  20. /**
  21. * Private Constructor to prevent Instantiation.
  22. */
  23. private MenuBarManager() {
  24. }
  25. /**
  26. * Handler for the "new" MenuItem.
  27. */
  28. public static final void newAction(ActionEvent event) {
  29. GraphDisplayManager.addGraph();
  30. }
  31. /**
  32. * Handler for the "open" MenuItem.
  33. */
  34. public static final void openAction(ActionEvent event) {
  35. if (GraphDisplayManager.getCurrentLayer() == Layer.MAPPING) {
  36. GraphDisplayManager.readMapping();
  37. } else {
  38. GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), true);
  39. }
  40. }
  41. /**
  42. * Handler for the "add" MenuItem.
  43. */
  44. public static final void addAction(ActionEvent event) {
  45. MyGraph newGraph = GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), false);
  46. ButtonManager.addToOpGraphComboBox(newGraph.getId());
  47. }
  48. /**
  49. * Handler for the "save" button.
  50. */
  51. public static void saveAction(ActionEvent event) {
  52. GraphManager v = Main.getInstance().getGraphManager();
  53. if(GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)){
  54. new GraphMLExporter().exportMapping(v.getGraph());
  55. return;
  56. }
  57. if (v.getCurrentPath() != null) {
  58. new GraphMLExporter().writeGraph(v.getGraph(), v.getCurrentPath(), false);
  59. } else {
  60. new GraphMLExporter().writeGraph(v.getGraph(), Main.getInstance().getPrimaryStage());
  61. }
  62. }
  63. /**
  64. * Handler for the "save as..." button.
  65. */
  66. public static void saveAsAction(ActionEvent event) {
  67. GraphManager v = Main.getInstance().getGraphManager();
  68. if(GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)){
  69. new GraphMLExporter().exportMapping(v.getGraph());
  70. return;
  71. }
  72. new GraphMLExporter().writeGraph(v.getGraph(), Main.getInstance().getPrimaryStage());
  73. }
  74. /**
  75. * Handler for the "quit" button.
  76. */
  77. public static void quitAction(ActionEvent event) {
  78. System.exit(0);
  79. }
  80. /**
  81. * Handler for the "delete" button.
  82. */
  83. public static void deleteAction(ActionEvent event) {
  84. GraphManager v = Main.getInstance().getGraphManager();
  85. if (v.getSelectedEdgeID() != null) {
  86. v.deleteEdge(v.getSelectedEdgeID());
  87. }
  88. if (v.getSelectedNodeID() != null) {
  89. v.deleteNode(v.getSelectedNodeID());
  90. }
  91. PropertiesManager.showNewDataSet(null);
  92. }
  93. /**
  94. * Handler for the "undelete" button.
  95. */
  96. public static void undeleteAction(ActionEvent event) {
  97. Main.getInstance().getGraphManager().undelete();
  98. }
  99. /**
  100. * Handler for the "preferences" MenuItem.
  101. */
  102. public static void preferencesAction(ActionEvent event) {
  103. OptionsManager.openOptionsDialog();
  104. }
  105. /**
  106. * Handler for the "about" MenuItem.
  107. */
  108. public static void aboutAction(ActionEvent event) {
  109. Alert alert = new Alert(AlertType.INFORMATION);
  110. alert.setTitle("About this programm");
  111. alert.setHeaderText(null);
  112. alert.setContentText("" + "Visualization Software of the Telecooperation group, \n"
  113. + "Department of Computer Science, \n" + "Technische Universität Darmstadt. \n" + "\n"
  114. + "Created by: \n" + "Jan Enders, Jascha Bohne, Dominik Renkel, \n"
  115. + "Julian Ohl und Matthias Wilhelm \n" + "comissioned by Julien Gedeon");
  116. alert.getDialogPane().getChildren().stream().filter(node -> node instanceof Label)
  117. .forEach(node -> ((Label) node).setMinHeight(Region.USE_PREF_SIZE));
  118. alert.showAndWait();
  119. }
  120. }