Lets you save the attributes of controls hosted inside ControlNode objects.
Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming
Java Copy Code |
---|
public void serializeControl ( |
A ControlNodeEvent instance providing more information about the event.
By default, the diagram component saves and loads hosted controls by getting or setting their property values via the Java introspection API. If the default mechanism cannot serialize the content of nodes automatically, the serializeControl and deserializeControl events can be handled to implement custom serialization.
Java Copy Code |
---|
diagram.addDiagramListener(new DiagramAdapter() { @Override public void serializeControl(ControlNodeEvent e) { JButton button = (JButton)e.getNode().getControl(); e.getContext().writeString(button.getText(), "Text", e.getXmlElement()); e.setHandled(true); }; @Override public void deserializeControl(ControlNodeEvent e) { JButton button = new JButton(); try { button.setText(e.getContext().readString("Text", e.getXmlElement())); } catch (TransformerException ex) { ex.printStackTrace(); } e.getNode().setControl(button); e.setHandled(true); }; } |