MenuBarManager.java 3.7 KB

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