diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java index dd4ba5e..0ea75bf 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationStage.java @@ -2,6 +2,7 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -10,9 +11,11 @@ import com.mxgraph.model.mxCell; import com.mxgraph.model.mxGeometry; +import com.mxgraph.model.mxGraphModel; import com.mxgraph.swing.mxGraphComponent; import com.mxgraph.swing.util.mxMouseAdapter; import com.mxgraph.util.mxEventSource.mxIEventListener; +import com.mxgraph.util.mxEventObject; import com.mxgraph.util.mxPoint; import com.mxgraph.view.mxGraph; @@ -133,13 +136,30 @@ public FlowCellEditor createCellEditor(mxGraphComponent graphComponent) { return new ControlFlowDelegationCellEditor(this, graphComponent); } - + /************************************************************* * */ @Override public mxIEventListener createChangeEventListener(Editor editor) { - return null; + return new mxIEventListener() { + public void invoke(Object sender, mxEventObject evt) { + List terminals = new ArrayList<>(); + mxCell cell = null; + for (Object change: ((List) evt.getProperties().get("changes"))) { + if (change instanceof mxGraphModel.mxTerminalChange) { + mxGraphModel.mxTerminalChange terminalChange = (mxGraphModel.mxTerminalChange) change; + cell = (mxCell) terminalChange.getCell(); + mxCell terminal = (mxCell) terminalChange.getTerminal(); + terminals.add(terminal); + } + } + if (terminals.size() == 2) { + graph.removeCells(new mxCell[] {cell}); + graph.clearSelection(); + } + } + }; } /************************************************************* diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java index 363796a..db1f2f7 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DataFlowModelingStage.java @@ -105,6 +105,7 @@ if (terminals.size() == 2) { if (!editor.connectEdge(cell, terminals.get(0), terminals.get(1))) { graph.removeCells(new mxCell[] {cell}); + graph.clearSelection(); } } } @@ -359,7 +360,10 @@ public boolean connectEdge(mxCell edge, mxCell src, mxCell dst) { if (bReflectingArchitectureModel) return false; DataTransferModel model = getModel(); - Channel srcCh = model.getChannel((String) src.getValue()); + + if (!(src.getValue() instanceof String)) return false; + + Channel srcCh = model.getChannel((String) src.getValue()); if (srcCh == null) { srcCh = model.getIOChannel((String) src.getValue()); if (srcCh == null) { diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java index 0889be8..f77ced3 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/PushPullSelectionStage.java @@ -78,6 +78,7 @@ if (terminals.size() == 2) { // cancel connect graph.removeCells(new mxCell[] {cell}); + graph.clearSelection(); } } };