diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java index 1835abf..dfbbe9f 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationMenuBar.java @@ -1,100 +1,86 @@ package application; -import javax.swing.JMenu; -import javax.swing.JMenuBar; - -import application.actions.CircleLayoutAction; -import application.actions.DAGLayoutAction; -import application.actions.DeleteAction; -import application.actions.ExitAction; -import application.actions.JavaPrototypeGenerateAction; -import application.actions.JerseyPrototypeGenerateAction; -import application.actions.NewChannelAction; -import application.actions.NewFormulaChannelAction; -import application.actions.NewIOChannelAction; -import application.actions.NewModelAction; -import application.actions.NewResourceAction; -import application.actions.OpenAction; -import application.actions.SaveAction; -import application.actions.SaveAsAction; -import application.actions.SimulateAction; -import application.actions.TreeLayoutAction; -import application.actions.ZoomInAction; -import application.actions.ZoomOutAction; +import application.actions.*; import application.editor.Editor; +import javax.swing.*; + public class ApplicationMenuBar extends JMenuBar { - private static final long serialVersionUID = 4811536194182272888L; + private static final long serialVersionUID = 4811536194182272888L; - private ApplicationWindow applicationWindow = null; - - private NewResourceAction newResourceAction = null; - private NewChannelAction newChannelAction = null; - private NewIOChannelAction newIOChannelAction = null; - private NewFormulaChannelAction newFormulaChannelAction = null; - private DeleteAction deleteAction = null; - private JavaPrototypeGenerateAction javaPrototypeGenerateAction = null; - private JerseyPrototypeGenerateAction jerseyPrototypeGenerateAction = null; - private DAGLayoutAction dagLayoutAction = null; - private TreeLayoutAction treeLayoutAction = null; - private CircleLayoutAction circleLayoutAction = null; - //private SimulateAction simulateAction = null; - + private ApplicationWindow applicationWindow = null; - public ApplicationMenuBar(ApplicationWindow applicationWindow) { - this.applicationWindow = applicationWindow; - JMenu newMenu = new JMenu("New"); - - newMenu.add(new NewModelAction(applicationWindow)); - - newMenu.add(newResourceAction = new NewResourceAction(applicationWindow.getEditor())); - newMenu.add(newChannelAction = new NewChannelAction(applicationWindow.getEditor())); - newMenu.add(newIOChannelAction = new NewIOChannelAction(applicationWindow.getEditor())); - newMenu.add(newFormulaChannelAction = new NewFormulaChannelAction(applicationWindow.getEditor())); - - JMenu menu = null; - menu = add(new JMenu("File")); - menu.add(newMenu); - menu.add(new OpenAction(applicationWindow)); - menu.addSeparator(); - menu.add(new SaveAction(applicationWindow)); - menu.add(new SaveAsAction(applicationWindow)); - menu.addSeparator(); - menu.add(new ExitAction()); - - menu = add(new JMenu("Edit")); - menu.add(deleteAction = new DeleteAction(applicationWindow.getEditor())); + private NewResourceAction newResourceAction = null; + private NewChannelAction newChannelAction = null; + private NewIOChannelAction newIOChannelAction = null; + private NewFormulaChannelAction newFormulaChannelAction = null; + private DeleteAction deleteAction = null; + private JavaPrototypeGenerateAction javaPrototypeGenerateAction = null; + private JerseyPrototypeGenerateAction jerseyPrototypeGenerateAction = null; + private DAGLayoutAction dagLayoutAction = null; + private TreeLayoutAction treeLayoutAction = null; + private CircleLayoutAction circleLayoutAction = null; + private ShowNavigationAction showNavigationAction; + //private SimulateAction simulateAction = null; - menu = add(new JMenu("Layout")); - menu.add(dagLayoutAction = new DAGLayoutAction(applicationWindow.getEditor())); - menu.add(treeLayoutAction = new TreeLayoutAction(applicationWindow.getEditor())); - menu.add(circleLayoutAction = new CircleLayoutAction(applicationWindow.getEditor())); + public ApplicationMenuBar(ApplicationWindow applicationWindow) { + this.applicationWindow = applicationWindow; + JMenu newMenu = new JMenu("New"); - menu = add(new JMenu("View")); - menu.add(new ZoomInAction(applicationWindow.getGraphComponent())); - menu.add(new ZoomOutAction(applicationWindow.getGraphComponent())); + newMenu.add(new NewModelAction(applicationWindow)); - menu = add(new JMenu("Simulate")); - menu.add(new SimulateAction(applicationWindow)); - - menu = add(new JMenu("Generate")); - menu.add(javaPrototypeGenerateAction = new JavaPrototypeGenerateAction(applicationWindow.getEditor())); - menu.add(jerseyPrototypeGenerateAction = new JerseyPrototypeGenerateAction(applicationWindow.getEditor())); - } + newMenu.add(newResourceAction = new NewResourceAction(applicationWindow.getEditor())); + newMenu.add(newChannelAction = new NewChannelAction(applicationWindow.getEditor())); + newMenu.add(newIOChannelAction = new NewIOChannelAction(applicationWindow.getEditor())); + newMenu.add(newFormulaChannelAction = new NewFormulaChannelAction(applicationWindow.getEditor())); - public Editor getEditor() { - return applicationWindow.getEditor(); - } + JMenu menu = null; + menu = add(new JMenu("File")); + menu.add(newMenu); + menu.add(new OpenAction(applicationWindow)); + menu.addSeparator(); + menu.add(new SaveAction(applicationWindow)); + menu.add(new SaveAsAction(applicationWindow)); + menu.addSeparator(); + menu.add(new ExitAction()); - public void setEditor(Editor editor) { - newResourceAction.setEditor(editor); - newChannelAction.setEditor(editor); - newIOChannelAction.setEditor(editor); - deleteAction.setEditor(editor); - javaPrototypeGenerateAction.setEditor(editor); - jerseyPrototypeGenerateAction.setEditor(editor); - treeLayoutAction.setEditor(editor); - circleLayoutAction.setEditor(editor); - } + menu = add(new JMenu("Edit")); + menu.add(deleteAction = new DeleteAction(applicationWindow.getEditor())); + + + menu = add(new JMenu("Layout")); + menu.add(dagLayoutAction = new DAGLayoutAction(applicationWindow.getEditor())); + menu.add(treeLayoutAction = new TreeLayoutAction(applicationWindow.getEditor())); + menu.add(circleLayoutAction = new CircleLayoutAction(applicationWindow.getEditor())); + + menu = add(new JMenu("View")); + menu.add(new ZoomInAction(applicationWindow.getGraphComponent())); + menu.add(new ZoomOutAction(applicationWindow.getGraphComponent())); + + menu = add(new JMenu("Simulate")); + menu.add(new SimulateAction(applicationWindow)); + + menu = add(new JMenu("Generate")); + menu.add(javaPrototypeGenerateAction = new JavaPrototypeGenerateAction(applicationWindow.getEditor())); + menu.add(jerseyPrototypeGenerateAction = new JerseyPrototypeGenerateAction(applicationWindow.getEditor())); + + menu = add(new JMenu("Window")); + menu.add(showNavigationAction = new ShowNavigationAction(applicationWindow)); + } + + public Editor getEditor() { + return applicationWindow.getEditor(); + } + + public void setEditor(Editor editor) { + newResourceAction.setEditor(editor); + newChannelAction.setEditor(editor); + newIOChannelAction.setEditor(editor); + deleteAction.setEditor(editor); + javaPrototypeGenerateAction.setEditor(editor); + jerseyPrototypeGenerateAction.setEditor(editor); + treeLayoutAction.setEditor(editor); + circleLayoutAction.setEditor(editor); + } }