diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java index 11a6b86..df78af7 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/DependencyModelingStage.java @@ -73,16 +73,18 @@ model = prevStage.getModel(); DataFlowGraph dataFlowGraph = ((PushPullSelectionStage) prevStage).getDataFlowGraph(); - //ControlFlowGraph controlFlowGraph = new ControlFlowGraph(dataFlowGraph, model); dependencyGraph = new DependencyGraph(dataFlowGraph, model); resNodeToCell = ((PushPullSelectionStage) prevStage).getResNodeToCell(); eventChannelToCell = ((PushPullSelectionStage) prevStage).getEventChannelToCell(); + mxCell parent = (mxCell) graph.getDefaultParent(); + mxCell layer = (mxCell) parent.getChildAt(DEPENDENCY_LAYER); - CheckMxCellLayer.printGraphLayers(graph); - clearDependencyGraphCells(graph); - graph = constructGraph(graph, dependencyGraph); + if (layer.getChildCount() == 0) { + clearDependencyGraphCells(graph); + graph = constructGraph(graph, dependencyGraph); + } CheckMxCellLayer.printGraphLayers(graph); } @@ -180,14 +182,14 @@ mxCell root = (mxCell) graph.getDefaultParent(); mxCell dependencyLayer = (mxCell) root.getChildAt(DEPENDENCY_LAYER); - if (dependencyLayer == null) return; - graph.getModel().beginUpdate(); try { int childCount = dependencyLayer.getChildCount(); for (int i = childCount - 1; i >= 0; i--) { - dependencyLayer.remove(dependencyLayer.getChildAt(i)); + mxCell child = (mxCell) dependencyLayer.getChildAt(i); + graph.getModel().remove(child); } + CheckMxCellLayer.printGraphLayers(graph); } finally { graph.getModel().endUpdate(); graph.refresh(); @@ -269,22 +271,16 @@ mxCell root = (mxCell) graph.getDefaultParent(); mxCell dependencyLayer = (mxCell) root.getChildAt(DEPENDENCY_LAYER); - - graph.getModel().beginUpdate(); - try { - // Recursively copy the EventChannel hierarchy - for (ChannelNode channelNode : dependencyGraph.getDataFlowGraph().getRootChannelNodes()) { - DataTransferChannel channel = channelNode.getChannel(); - if (channel.getInputResources().isEmpty()) { - mxCell oldCell = eventChannelToCell.get(channel); - if (oldCell != null && !eventChannelCells.containsKey(channel)) { - mxCell newCell = cloneEventChannelHierarchy(oldCell, dependencyLayer, eventChannelCells, channel); - eventChannelCells.put(channel, newCell); - } + // Recursively copy the EventChannel hierarchy + for (ChannelNode channelNode : dependencyGraph.getDataFlowGraph().getRootChannelNodes()) { + DataTransferChannel channel = channelNode.getChannel(); + if (channel.getInputResources().isEmpty()) { + mxCell oldCell = eventChannelToCell.get(channel); + if (oldCell != null && !eventChannelCells.containsKey(channel)) { + mxCell newCell = cloneEventChannelHierarchy(oldCell, dependencyLayer, eventChannelCells, channel); + eventChannelCells.put(channel, newCell); } } - } finally { - graph.getModel().endUpdate(); } return eventChannelCells;