diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractSystemAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractSystemAction.java new file mode 100644 index 0000000..e3f827d --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractSystemAction.java @@ -0,0 +1,23 @@ +package graphicalrefactor.actions; + +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; + +import graphicalrefactor.editor.Editor; +import graphicalrefactor.views.GraphicalRefactor; + +public abstract class AbstractSystemAction extends AbstractAction { + + protected GraphicalRefactor frame; + + public AbstractSystemAction(String name, GraphicalRefactor frame) { + super(name); + this.frame = frame; + } + + public void setFrame(GraphicalRefactor frame) { + this.frame = frame; + } + +} diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractViewerAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractViewerAction.java index 97181bf..13c4a07 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractViewerAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/AbstractViewerAction.java @@ -6,7 +6,7 @@ import com.mxgraph.swing.mxGraphComponent; -public class AbstractViewerAction extends AbstractAction { +public abstract class AbstractViewerAction extends AbstractAction { protected mxGraphComponent graphComponent = null; @@ -14,9 +14,4 @@ super(name); this.graphComponent = graphComponent; } - - @Override - public void actionPerformed(ActionEvent e) { - } - } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewModelAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewModelAction.java index 116a186..c79d868 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewModelAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/NewModelAction.java @@ -3,20 +3,22 @@ import java.awt.event.ActionEvent; import graphicalrefactor.editor.Editor; +import graphicalrefactor.views.GraphicalRefactor; -public class NewModelAction extends AbstractEditorAction { +public class NewModelAction extends AbstractSystemAction { /** * */ private static final long serialVersionUID = 8484493203589724589L; - public NewModelAction(Editor editor) { - super("Model", editor); + public NewModelAction(GraphicalRefactor frame) { + super("Model", frame); } @Override public void actionPerformed(ActionEvent e) { - editor.clear(); + frame.getEditor().clear(); + frame.setTitle(frame.title); } } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/OpenAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/OpenAction.java index e018590..dac48f9 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/OpenAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/OpenAction.java @@ -7,8 +7,9 @@ import javax.swing.filechooser.FileFilter; import graphicalrefactor.editor.Editor; +import graphicalrefactor.views.GraphicalRefactor; -public class OpenAction extends AbstractEditorAction { +public class OpenAction extends AbstractSystemAction { /** * */ @@ -16,12 +17,13 @@ private String lastDir = null; - public OpenAction(Editor editor) { - super("Open...", editor); + public OpenAction(GraphicalRefactor frame) { + super("Open...", frame); } @Override public void actionPerformed(ActionEvent e) { + Editor editor = frame.getEditor(); if (editor != null) { String wd = (lastDir != null) ? lastDir : System.getProperty("user.dir"); @@ -45,6 +47,7 @@ if (rc == JFileChooser.APPROVE_OPTION) { lastDir = fc.getSelectedFile().getParent(); editor.open(fc.getSelectedFile()); + frame.setTitle(frame.title + " - " + fc.getSelectedFile().getAbsolutePath()); } } } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java index 0d503de..62f0609 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAction.java @@ -3,19 +3,21 @@ import java.awt.event.ActionEvent; import graphicalrefactor.editor.Editor; +import graphicalrefactor.views.GraphicalRefactor; -public class SaveAction extends AbstractEditorAction { +public class SaveAction extends AbstractSystemAction { /** * */ private static final long serialVersionUID = 5660460585305281982L; - public SaveAction(Editor editor) { - super("Save", editor); + public SaveAction(GraphicalRefactor frame) { + super("Save", frame); } @Override public void actionPerformed(ActionEvent e) { + Editor editor = frame.getEditor(); if (editor != null && editor.getCurFileName() != null) { editor.save(); } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAsAction.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAsAction.java index 20a3233..35e39bc 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAsAction.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/actions/SaveAsAction.java @@ -8,8 +8,9 @@ import javax.swing.filechooser.FileFilter; import graphicalrefactor.editor.Editor; +import graphicalrefactor.views.GraphicalRefactor; -public class SaveAsAction extends AbstractEditorAction { +public class SaveAsAction extends AbstractSystemAction { /** * */ @@ -17,12 +18,13 @@ private String lastDir = null; - public SaveAsAction(Editor editor) { - super("Save As...", editor); + public SaveAsAction(GraphicalRefactor frame) { + super("Save As...", frame); } @Override public void actionPerformed(ActionEvent e) { + Editor editor = frame.getEditor(); if (editor != null) { String wd = (lastDir != null) ? lastDir : System.getProperty("user.dir"); @@ -47,6 +49,7 @@ lastDir = fc.getSelectedFile().getParent(); editor.setCurFilePath(fc.getSelectedFile().getAbsolutePath()); editor.save(); + frame.setTitle(frame.title + " - " + fc.getSelectedFile().getAbsolutePath()); } } } diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java index c9d905d..ab035a5 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactor.java @@ -20,6 +20,7 @@ public class GraphicalRefactor extends JFrame { private static final long serialVersionUID = -8690140317781055614L; + public static final String title = "Visual Modeling Tool"; private Editor editor; private mxGraph graph; @@ -27,7 +28,7 @@ private mxGraphComponent graphComponent; public GraphicalRefactor() { - setTitle("Graphical Refactor"); + setTitle(title); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); graph = new mxGraph() { diff --git a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java index 23f06bf..ed54e48 100644 --- a/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java +++ b/AlgebraicDataflowArchitectureModel/src/graphicalrefactor/views/GraphicalRefactorMenuBar.java @@ -3,9 +3,6 @@ import javax.swing.JMenu; import javax.swing.JMenuBar; -import com.mxgraph.view.mxGraph; - -import graphicalrefactor.actions.AbstractEditorAction; import graphicalrefactor.actions.CircleLayoutAction; import graphicalrefactor.actions.DeleteAction; import graphicalrefactor.actions.ExitAction; @@ -27,11 +24,9 @@ private static final long serialVersionUID = 4811536194182272888L; private GraphicalRefactor graphicalModelRefactor = null; - private NewModelAction newModelAction = null; private NewResourceAction newResourceAction = null; private NewChannelAction newChannelAction = null; private NewIOChannelAction newIOChannelAction = null; - private OpenAction openAction = null; private DeleteAction deleteAction = null; private JavaPrototypeGenerateAction javaPrototypeGenerateAction = null; private JerseyPrototypeGenerateAction jerseyPrototypeGenerateAction = null; @@ -41,17 +36,17 @@ public GraphicalRefactorMenuBar(GraphicalRefactor graphicalModelRefactor) { this.graphicalModelRefactor = graphicalModelRefactor; JMenu newMenu = new JMenu("New"); - newMenu.add(newModelAction = new NewModelAction(graphicalModelRefactor.getEditor())); + newMenu.add(new NewModelAction(graphicalModelRefactor)); newMenu.add(newResourceAction = new NewResourceAction(graphicalModelRefactor.getEditor())); newMenu.add(newChannelAction = new NewChannelAction(graphicalModelRefactor.getEditor())); newMenu.add(newIOChannelAction = new NewIOChannelAction(graphicalModelRefactor.getEditor())); JMenu menu = null; menu = add(new JMenu("File")); menu.add(newMenu); - menu.add(openAction = new OpenAction(graphicalModelRefactor.getEditor())); + menu.add(new OpenAction(graphicalModelRefactor)); menu.addSeparator(); - menu.add(new SaveAction(graphicalModelRefactor.getEditor())); - menu.add(new SaveAsAction(graphicalModelRefactor.getEditor())); + menu.add(new SaveAction(graphicalModelRefactor)); + menu.add(new SaveAsAction(graphicalModelRefactor)); menu.addSeparator(); menu.add(new ExitAction()); @@ -77,8 +72,12 @@ } public void setEditor(Editor editor) { - openAction.setEditor(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); }