MenuBarManager.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.getGraphManager().deselect();
  46. GraphDisplayManager.addGraph(Main.getInstance().getPrimaryStage(), false);
  47. ButtonManager.setupOpGraphComboBox();
  48. }
  49. /**
  50. * Handler for the "save" button.
  51. */
  52. public static void saveAction(ActionEvent event) {
  53. GraphManager v = Main.getInstance().getGraphManager();
  54. if (GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
  55. new GraphMLExporter().exportMapping(v.getGraph());
  56. return;
  57. }
  58. if (v.getCurrentPath() != null) {
  59. new GraphMLExporter().writeGraph(v.getGraph(), v.getCurrentPath(), false);
  60. } else {
  61. new GraphMLExporter().writeGraph(v.getGraph(), Main.getInstance().getPrimaryStage());
  62. }
  63. }
  64. /**
  65. * Handler for the "save as..." button.
  66. */
  67. public static void saveAsAction(ActionEvent event) {
  68. GraphManager v = Main.getInstance().getGraphManager();
  69. if (GraphDisplayManager.getCurrentLayer().equals(Layer.MAPPING)) {
  70. new GraphMLExporter().exportMapping(v.getGraph());
  71. return;
  72. }
  73. new GraphMLExporter().writeGraph(v.getGraph(), Main.getInstance().getPrimaryStage());
  74. }
  75. /**
  76. * Handler for the "quit" button.
  77. */
  78. public static void quitAction(ActionEvent event) {
  79. Main.getInstance().closeProgram();
  80. }
  81. /**
  82. * Handler for the "delete" button.
  83. */
  84. public static void deleteAction(ActionEvent event) {
  85. GraphManager v = Main.getInstance().getGraphManager();
  86. if (v.getSelectedEdgeID() != null) {
  87. v.deleteEdge(v.getSelectedEdgeID());
  88. }
  89. if (v.getSelectedNodeID() != null) {
  90. v.deleteNode(v.getSelectedNodeID());
  91. }
  92. PropertiesManager.showNewDataSet(null);
  93. }
  94. /**
  95. * Handler for the "undelete" button.
  96. */
  97. public static void undeleteAction(ActionEvent event) {
  98. Main.getInstance().getGraphManager().undelete();
  99. }
  100. /**
  101. * Handler for the "preferences" MenuItem.
  102. */
  103. public static void preferencesAction(ActionEvent event) {
  104. OptionsManager.openOptionsDialog();
  105. }
  106. /**
  107. * Handler for the "about" MenuItem.
  108. */
  109. public static void aboutAction(ActionEvent event) {
  110. Alert alert = new Alert(AlertType.INFORMATION);
  111. alert.setTitle("About this programm");
  112. alert.setHeaderText(null);
  113. alert.setContentText("" + "Visualization Software of the Telecooperation group, \n"
  114. + "Department of Computer Science, \n" + "Technische Universität Darmstadt. \n" + "\n"
  115. + "Created by: \n" + "Jan Enders, Jascha Bohne, Dominik Renkel, \n"
  116. + "Julian Ohl and Matthias Wilhelm \n" + "comissioned by Julien Gedeon");
  117. alert.getDialogPane().getChildren().stream().filter(node -> node instanceof Label)
  118. .forEach(node -> ((Label) node).setMinHeight(Region.USE_PREF_SIZE));
  119. alert.showAndWait();
  120. }
  121. }