diff --git a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java index 3d5098d..f3caaaf 100644 --- a/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java +++ b/AlgebraicDataflowArchitectureModel/src/application/editor/stages/ControlFlowDelegationCellEditor.java @@ -1,12 +1,15 @@ package application.editor.stages; import java.util.EventObject; +import java.util.logging.Level; +import javax.swing.CellEditor; import javax.swing.JOptionPane; import com.mxgraph.model.mxCell; import com.mxgraph.swing.mxGraphComponent; +import application.ApplicationWindow; import application.editor.FlowCellEditor; import models.controlFlowModel.CallEdgeAttribute; import models.controlFlowModel.EntryPointObjectNode; @@ -37,17 +40,25 @@ */ @Override public void startEditing(Object cellObj, EventObject eventObj) { - if (editingCell != null) - stopEditing(true); + if (editingCell != null) stopEditing(true); ControlFlowDelegationStage cfdStage = (ControlFlowDelegationStage) stage; switch (cfdStage.getCurState()) { case SELECTING_AN_EDGE: // Branching based on the edge click event. - // | double clicked > Showing delegatable nodes. + // | double clicked > Showing delegaeatable nodes. + ApplicationWindow.logger.log(Level.INFO, "Double clicked"); + if (graphComponent.getGraph().getModel().isEdge(cellObj)) { // cache a target edge of cell; targetEdgeCell = (mxCell) cellObj; + + // Logging + CallEdgeAttribute callEdgeAttr = (CallEdgeAttribute) graphComponent.getGraph().getModel().getValue(targetEdgeCell); + if (callEdgeAttr == null) return; + + String pairNodeStr = "(" + callEdgeAttr.getSourceObjectNode().getName() + ", " + callEdgeAttr.getDestinationObjectNode().getName() + ")" ; + ApplicationWindow.logger.log(Level.INFO, "Selecting Control-Flow (src, dst) = " + pairNodeStr); showDelegatableNodesBySelectedEdge(cellObj); cfdStage.setState(ControlFlowDelegationStageStatus.SHOWING_DELEGATABLE_NODES); @@ -68,12 +79,19 @@ if (dstObjNode == null) throw new ClassCastException(); if (!cfdStage.isExecutableDelegation(callEdgeAttr, dstObjNode)) { - JOptionPane.showMessageDialog(graphComponent, "It's impossible for the chose object to delegate."); + JOptionPane.showMessageDialog(graphComponent, "It's impossible for \"" + dstObjNode.getName() + "\" to delegate."); + ApplicationWindow.logger.log(Level.INFO, "\"" + dstObjNode.getName() + "\"" + " wasn't able to apply to CFD"); return; } + cfdStage.showDelegatedGraph(graphComponent.getGraph(), targetEdgeCell, (mxCell) cellObj); + ApplicationWindow.logger.log(Level.INFO, "Apply CFD to \"" + dstObjNode.getName() + "\""); + cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); } else { + // Logging + ApplicationWindow.logger.log(Level.INFO, "CFD was canceled because it was selected a control-flow"); + cfdStage.resetAllStyleOfCells(); cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); } @@ -96,15 +114,22 @@ ObjectNode targetObjNode = targetObjNodeAttr.getObjectNode(); if (isNotStatelessObject(targetObjNode)) { - JOptionPane.showMessageDialog(graphComponent, "It's impossible for the chose object to dependent."); + JOptionPane.showMessageDialog(graphComponent, "It's impossible for \"" + targetObjNode.getName() + "\" to dependent."); + ApplicationWindow.logger.log(Level.INFO, "\"" + targetObjNode.getName() + "\"" + " wasn't able to apply to Depends on Mediator"); return; } dependentObjectNode(targetObjCell); + + // Logging + ApplicationWindow.logger.log(Level.INFO, "Apply Depedents on Mediator to " + "\"" + targetObjNode.getName() + "\""); cfdStage.resetAllStyleOfCells(); cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); } else { + // Logging + ApplicationWindow.logger.log(Level.INFO, "Depends on Mediator was canceled because it was selected a control-flow"); + cfdStage.resetAllStyleOfCells(); cfdStage.setState(ControlFlowDelegationStageStatus.SELECTING_AN_EDGE); }