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.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. ButtonManager.setupOpGraphComboBox();
  39. }
  40. }
  41. /**
  42. * Handler for the "add" MenuItem.
  43. */
  44. public static final void addAction(ActionEvent event) {
  45. GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), false);
  46. ButtonManager.setupOpGraphComboBox();
  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. Main.getInstance().closeProgram();
  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. }