diff --git a/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java b/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java index 8d20abc..4630830 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java +++ b/AlgebraicDataflowArchitectureModel/src/application/ApplicationWindow.java @@ -19,7 +19,7 @@ import application.editor.Editor; import application.editor.stages.DataFlowCellEditor; import application.views.NavigationWindow; -import application.views.controlFlowDelegation.FlowLayerWindow; +import application.views.controlFlowDelegation.ShowFlowWindow; public class ApplicationWindow extends JFrame { private static final long serialVersionUID = -8690140317781055614L; @@ -31,7 +31,7 @@ private ApplicationMenuBar menuBar = null; private NavigationWindow navigationWindow = null; - private FlowLayerWindow switchDisplayFlowWindow = null; + private ShowFlowWindow FlowLayerWindow = null; public ApplicationWindow() { setTitle(title); @@ -65,10 +65,11 @@ navigationWindow = new NavigationWindow(this, editor); navigationWindow.setVisible(true); - switchDisplayFlowWindow = new FlowLayerWindow(this); - switchDisplayFlowWindow.setVisible(false); + FlowLayerWindow = new ShowFlowWindow(this); + FlowLayerWindow.setVisible(false); editor.addStageChangeListener(navigationWindow); + editor.addStageChangeListener(FlowLayerWindow); } public mxGraph getGraph() { @@ -92,7 +93,7 @@ } public void showSwitchLayerWindow() { - switchDisplayFlowWindow.setVisible(true); + FlowLayerWindow.setVisible(true); } } diff --git a/AlgebraicDataflowArchitectureModel/src/application/actions/ShowSwitchLayerWindowAction.java b/AlgebraicDataflowArchitectureModel/src/application/actions/ShowSwitchLayerWindowAction.java index 58019dd..b137463 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/actions/ShowSwitchLayerWindowAction.java +++ b/AlgebraicDataflowArchitectureModel/src/application/actions/ShowSwitchLayerWindowAction.java @@ -6,7 +6,7 @@ public class ShowSwitchLayerWindowAction extends AbstractSystemAction { public ShowSwitchLayerWindowAction(ApplicationWindow frame) { - super("Switch Layer", frame); + super("Show Flow", frame); } @Override diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index d0475ca..6850450 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -127,6 +127,7 @@ graph.getModel().addListener(mxEvent.CHANGE, curChangeEventListener); } curStage = nextStage; + notifyStageChangeListeners(); return true; } diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java index db7a99f..bd311ff 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java @@ -302,7 +302,7 @@ * */ private mxGraph constructGraph(mxGraph graph, ControlFlowGraph controlFlowGraph) { - showOnlyLayer(CONTROL_FLOW_LAYER); + showOnlyLayer(PUSH_FLOW_LAYER, PULL_FLOW_LAYER); graph.getModel().beginUpdate(); try { @@ -322,9 +322,6 @@ // Inserting edges of both Push and Pull transfer graph = insertControlFlowEdges(graph, CONTROL_FLOW_LAYER, controlFlowGraph.getPushCallGraph(),controlFlowNodeCells, controlFlowEntryNodeCells); graph = insertControlFlowEdges(graph, CONTROL_FLOW_LAYER, controlFlowGraph.getPullCallGraph(),controlFlowNodeCells, controlFlowEntryNodeCells); - - - } finally { graph.getModel().endUpdate(); } diff --git a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java deleted file mode 100644 index f78fa03..0000000 --- a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/FlowLayerWindow.java +++ /dev/null @@ -1,80 +0,0 @@ -package application.views.controlFlowDelegation; - -import java.awt.Container; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.swing.ButtonGroup; -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JRadioButton; - -import application.ApplicationWindow; -import application.editor.Editor; -import application.editor.IStageChangeListener; -import application.editor.Stage; -import application.editor.stages.ControlFlowDelegationStage; - -/************************************************************* - * the window has a button group for swichting layers in the control-flow-modeling. - */ -public class FlowLayerWindow extends JDialog implements ActionListener, IStageChangeListener { - private String title = "ShowFlowLayer"; - private Map checkBoxes = null; - private ControlFlowDelegationStage stage = null; - - /************************************************************* - * [ *constructor ] - /************************************************************* - * - */ - public FlowLayerWindow(final ApplicationWindow owner) { - super(owner); - - setTitle(title); - setDefaultCloseOperation(HIDE_ON_CLOSE); - - // initialize buttons - checkBoxes = new HashMap<>(); - checkBoxes.put(FlowLayerValue.DATA_FLOW, new JCheckBox("Data-Flow")); - checkBoxes.put(FlowLayerValue.PUSH_FLOW, new JCheckBox("Push-Flow")); - checkBoxes.put(FlowLayerValue.PULL_FLOW, new JCheckBox("Pull-Flow")); - - ButtonGroup buttonGroup = new ButtonGroup(); - for(JCheckBox checkBox : checkBoxes.values()) { - buttonGroup.add(checkBox); - checkBox.setEnabled(true); - } - - // initialize panel - Container panel = getContentPane(); - panel.setLayout(new GridLayout(/*low*/3, /*col*/1)); - for(JCheckBox checkBox : checkBoxes.values()) { - panel.add(checkBox); - } - pack(); - setResizable(false); - } - - /************************************************************* - * [ *public ] - /************************************************************* - * - */ - @Override - public void actionPerformed(ActionEvent e) { - stage.setEnabledForLayer(Stage.DATA_FLOW_LAYER, checkBoxes.get(FlowLayerValue.DATA_FLOW).isSelected()); - stage.setEnabledForLayer(Stage.PUSH_FLOW_LAYER, checkBoxes.get(FlowLayerValue.PUSH_FLOW).isSelected()); - stage.setEnabledForLayer(Stage.PULL_FLOW_LAYER, checkBoxes.get(FlowLayerValue.PULL_FLOW).isSelected()); - } - - @Override - public void stageChanged(Stage newStage) { - if(!(newStage instanceof ControlFlowDelegationStage))return; - - } -} diff --git a/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ShowFlowWindow.java b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ShowFlowWindow.java new file mode 100644 index 0000000..a0635f0 --- /dev/null +++ b/AlgebraicDataflowArchitectureModel/src/application/views/controlFlowDelegation/ShowFlowWindow.java @@ -0,0 +1,107 @@ +package application.views.controlFlowDelegation; + +import java.awt.Container; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JRadioButton; + +import application.ApplicationWindow; +import application.editor.Editor; +import application.editor.IStageChangeListener; +import application.editor.Stage; +import application.editor.stages.ControlFlowDelegationStage; + +/************************************************************* + * the window has a button group for swichting layers in the control-flow-modeling. + */ +public class ShowFlowWindow extends JDialog implements IStageChangeListener { + private String title = "ShowFlowWindow"; + private JCheckBox dataFlowCheckBox = null; + private JCheckBox pushFlowCheckBox = null; + private JCheckBox pullFlowCheckBox = null; + + private ControlFlowDelegationStage stage = null; + + /************************************************************* + * [ *constructor ] + /************************************************************* + * + */ + public ShowFlowWindow(final ApplicationWindow owner) { + super(owner); + + setTitle(title); + setDefaultCloseOperation(HIDE_ON_CLOSE); + + // initialize buttons + dataFlowCheckBox = new JCheckBox("Data-Flow", false); + pushFlowCheckBox = new JCheckBox("Push-Flow", true); + pullFlowCheckBox = new JCheckBox("Pull-Flow", true); + + // each add handler + dataFlowCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + stage.setEnabledForLayer(Stage.DATA_FLOW_LAYER, dataFlowCheckBox.isSelected()); + }}); + + pushFlowCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + stage.setEnabledForLayer(Stage.PUSH_FLOW_LAYER, pushFlowCheckBox.isSelected()); + }}); + + pullFlowCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + stage.setEnabledForLayer(Stage.PULL_FLOW_LAYER, pullFlowCheckBox.isSelected()); + }}); + + dataFlowCheckBox.setEnabled(false); + pushFlowCheckBox.setEnabled(false); + pullFlowCheckBox.setEnabled(false); + + // initialize panel + Container panel = getContentPane(); + panel.setLayout(new GridLayout(/*low*/3, /*col*/1)); + panel.add(dataFlowCheckBox); + panel.add(pushFlowCheckBox); + panel.add(pullFlowCheckBox); + + pack(); + setResizable(false); + } + + /************************************************************* + * [ *public ] + /************************************************************* + * + */ + @Override + public void stageChanged(Stage newStage) { + if((newStage instanceof ControlFlowDelegationStage)) { + stage = (ControlFlowDelegationStage)newStage; + + dataFlowCheckBox.setEnabled(true); + pushFlowCheckBox.setEnabled(true); + pullFlowCheckBox.setEnabled(true); + + stage.setEnabledForLayer(Stage.PUSH_FLOW_LAYER, pushFlowCheckBox.isSelected()); + stage.setEnabledForLayer(Stage.PULL_FLOW_LAYER, pullFlowCheckBox.isSelected()); + } + else { + dataFlowCheckBox.setEnabled(false); + pushFlowCheckBox.setEnabled(false); + pullFlowCheckBox.setEnabled(false); + } + } +} +