import com.mxgraph.model.mxGraphModel.mxChildChange;
import com.mxgraph.model.mxGraphModel.mxStyleChange;
import com.mxgraph.model.mxICell;
+import com.mxgraph.model.mxIGraphModel;
import com.mxgraph.model.mxIGraphModel.mxAtomicGraphModelChange;
import com.mxgraph.util.mxEvent;
import com.mxgraph.util.mxEventObject;
import com.mxgraph.util.mxRectangle;
import com.mxgraph.util.mxUndoableEdit;
import com.mxgraph.util.mxUndoableEdit.mxUndoableChange;
+import com.mxgraph.util.mxUtils;
import com.mxgraph.view.mxGraphSelectionModel;
import com.mxgraph.view.mxMultiplicity;
import com.mxgraph.view.mxStylesheet;
@Override
public boolean filter(Object cell) {
if (cell instanceof BasicBlock) {
+ final BasicBlock blk = (BasicBlock) cell;
+
// Update parent on cell addition
- ((BasicBlock) cell).setParentDiagram(diagram);
+ blk.setParentDiagram(diagram);
// update port numbering
- diagram.updateIOBlocks((BasicBlock) cell);
+ diagram.updateIOBlocks(blk);
+
+ // Fire an identifier update to let the I/O ports update their labels
+ mxCell identifier = diagram.getCellIdentifier(blk);
+ if (identifier != null) {
+ final Object current = diagram.getModel().getValue(identifier);
+ if (current != null) {
+ final String text = mxUtils.getBodyMarkup(current.toString(), false);
+ diagram.fireEvent(new mxEventObject(mxEvent.LABEL_CHANGED, "cell", identifier, "value", text, "parent", blk));
+ }
+ }
+
+ diagram.getView().invalidate();
}
return false;
}
for (final Object object : changedCells) {
if (object instanceof BasicBlock) {
final BasicBlock current = (BasicBlock) object;
+ final XcosDiagram graph = current.getParentDiagram();
// When we change the style property we have to update
// some BasiBlock fields
// update the superblock container ports if the block is
// inside a superblock diagram
- if (current.getParentDiagram() instanceof SuperBlockDiagram) {
+ if (graph instanceof SuperBlockDiagram) {
SuperBlockDiagram superdiagram = (SuperBlockDiagram) current.getParentDiagram();
SuperBlock superblock = superdiagram.getContainer();
superblock.updateExportedPort();
// force a refresh of the block ports and links
// connected to these ports
- final int childCount = current.getParentDiagram().getModel().getChildCount(current);
+ final int childCount = model.getChildCount(current);
for (int i = 0; i < childCount; i++) {
- final Object port = current.getParentDiagram().getModel().getChildAt(current, i);
- current.getParentDiagram().getView().clear(port, true, true);
- final int edgeCount = current.getParentDiagram().getModel().getEdgeCount(port);
+ final Object port = model.getChildAt(current, i);
+ graph.getView().clear(port, true, true);
+ final int edgeCount = model.getEdgeCount(port);
for (int j = 0; j < edgeCount; j++) {
- final Object edge = current.getParentDiagram().getModel().getEdgeAt(port, j);
- current.getParentDiagram().getView().clear(edge, true, true);
+ final Object edge = model.getEdgeAt(port, j);
+ graph.getView().clear(edge, true, true);
}
}
// force a refresh of the block
- current.getParentDiagram().getView().clear(current, true, true);
+ graph.getView().clear(current, true, true);
- current.getParentDiagram().getView().validate();
- current.getParentDiagram().repaint();
+ graph.getView().validate();
+ graph.repaint();
}
}
} finally {
diagram.getView().clear(updatedBlock, true, true);
+ // validate display errors
+ diagram.getAsComponent().clearCellOverlays();
diagram.getAsComponent().validateGraph();
+
diagram.getView().validate();
} finally {
diagram.getModel().endUpdate();