diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java index dcd8786..eff02d8 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java @@ -16,6 +16,8 @@ import application.editor.FlowCellEditor; import application.editor.Stage; import models.controlFlowModel.CallEdgeAttribute; +import models.controlFlowModel.ControlFlowDelegator; +import models.controlFlowModel.ObjectNode; import models.controlFlowModel.ObjectNodeAttribute; import models.dataFlowModel.PushPullValue; @@ -58,6 +60,7 @@ if( editingCell != null) stopEditing(true); System.out.println("state:" + curState.name()); + ControlFlowDelegationStage curStage = (ControlFlowDelegationStage)stage; switch(curState) { case SELECTING_AN_EDGE: @@ -84,17 +87,28 @@ case SHOWING_DELEGATABLE_NODES: if( graphComponent.getGraph().getModel().isVertex(cellObj) ) { + mxCell dstCell = null; + if(cellObj instanceof mxCell) dstCell = (mxCell)cellObj; + else throw new ClassCastException(); + // invocating delegation method - if(!(cellObj instanceof mxCell)) throw new ClassCastException(); + CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)graphComponent.getGraph().getModel().getValue(targetEdgeCell); + if(callEdgeAttr == null) return; - ((ControlFlowDelegationStage)stage) - .showDelegatedGraph(graphComponent.getGraph(), targetEdgeCell, (mxCell)cellObj); + ObjectNode dstObjNode = ((ObjectNodeAttribute)dstCell.getValue()).getObjectNode(); + if(dstObjNode == null) throw new ClassCastException(); + + if(!curStage.isExecutableDelegation(callEdgeAttr, dstObjNode)){ + JOptionPane.showMessageDialog(graphComponent, "It's impossible for the chose object to delegate."); + return; + } + curStage.showDelegatedGraph(graphComponent.getGraph(), targetEdgeCell, (mxCell)cellObj); curState = ControlFlowDelegationStageStatus.SELECTING_AN_EDGE; } else { System.out.println("cancel showing state."); - ((ControlFlowDelegationStage)stage). resetAllStyleOfCells(); + curStage.resetAllStyleOfCells(); curState = ControlFlowDelegationStageStatus.SELECTING_AN_EDGE; } break; @@ -109,7 +123,6 @@ } - /************************************************************* * [ *private ] /************************************************************* @@ -226,12 +239,6 @@ return; } - CallEdgeAttribute callEdgeAttr = null; - if(edgeCell.getValue() instanceof CallEdgeAttribute) { - callEdgeAttr = (CallEdgeAttribute)edgeCell.getValue(); - } - else throw new ClassCastException(); - if( isDuplicatedName(objName) ) { JOptionPane.showMessageDialog(graphComponent, "The named object has already existed."); return;