| |
---|
| | |
---|
| | 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; |
---|
| | |
---|
| | /************************************************************* |
---|
| |
---|
| | public void startEditing(Object cellObj, EventObject eventObj) { |
---|
| | if( editingCell != null) stopEditing(true); |
---|
| | |
---|
| | System.out.println("state:" + curState.name()); |
---|
| | ControlFlowDelegationStage curStage = (ControlFlowDelegationStage)stage; |
---|
| | |
---|
| | switch(curState) { |
---|
| | case SELECTING_AN_EDGE: |
---|
| | |
---|
| |
---|
| | break; |
---|
| | |
---|
| | 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(); |
---|
| | |
---|
| | ((ControlFlowDelegationStage)stage) |
---|
| | .showDelegatedGraph(graphComponent.getGraph(), targetEdgeCell, (mxCell)cellObj); |
---|
| | CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute)graphComponent.getGraph().getModel().getValue(targetEdgeCell); |
---|
| | if(callEdgeAttr == null) return; |
---|
| | |
---|
| | 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; |
---|
| | } |
---|
| |
---|
| | public void stopEditing(boolean cancel) { |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |
---|
| | /************************************************************* |
---|
| | * [ *private ] |
---|
| | /************************************************************* |
---|
| | * [ view ] |
---|
| |
---|
| | JOptionPane.showMessageDialog(graphComponent, "You must input a name. \nIt mustn't be empty."); |
---|
| | 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; |
---|
| | } |
---|
| |
---|
| | |