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(); + } + } + }; } /*************************************************************