diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java index 7eadb4b..da0e8bd 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/Editor.java @@ -68,7 +68,7 @@ } public mxGraphComponent getGraphComponent() { - return this.graphComponent; + return graphComponent; } public DataTransferModel getModel() { @@ -188,7 +188,6 @@ if (extension.contains(".dtram")) { openDTRAM(file); } - setDAGLayout(); } private void openModel(File file) { @@ -200,17 +199,18 @@ // Update stage's model to new parsed one if (curStage instanceof DataFlowModelingStage) { - DataFlowModelingStage stage = (DataFlowModelingStage) curStage; - stage.setModel(model); + ((DataFlowModelingStage) curStage).setModel(model); } // Force to change PushPullSelectionStage to construct mxGraph - changeStage(STAGE_PUSH_PULL_SELECTION); - if (curStage instanceof PushPullSelectionStage) { - PushPullSelectionStage stage = (PushPullSelectionStage) curStage; - stage.constructGraph(); + boolean stageChanged = changeStage(STAGE_PUSH_PULL_SELECTION); + if (stageChanged && curStage instanceof PushPullSelectionStage) { + ((PushPullSelectionStage) curStage).constructGraph(); } + // Set layout + setDAGLayout(); + // Update current file info curFilePath = file.getAbsolutePath(); curFileName = file.getName(); @@ -235,20 +235,18 @@ // Update stage's model to new parsed one if (curStage instanceof DataFlowModelingStage) { - DataFlowModelingStage stage = (DataFlowModelingStage) curStage; - stage.setModel(model); + ((DataFlowModelingStage) curStage).setModel(model); } - // Parse Geometry - parser.doParseGeometry(graph); - // Force to change PushPullSelectionStage to construct mxGraph - changeStage(STAGE_PUSH_PULL_SELECTION); - if (curStage instanceof PushPullSelectionStage) { - PushPullSelectionStage stage = (PushPullSelectionStage) curStage; - stage.constructGraph(); + boolean stageChanged = changeStage(STAGE_PUSH_PULL_SELECTION); + if (stageChanged && curStage instanceof PushPullSelectionStage) { + ((PushPullSelectionStage) curStage).constructGraph(); } + // Restore the geometry + parser.doParseGeometry(graph); + // Update current file info curFilePath = file.getAbsolutePath(); curFileName = file.getName();