MenuBarManager.java 3.7 KB

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