use of org.freeplane.core.extension.IExtension in project freeplane by freeplane.
the class TreeXmlWriter method addExtensionNodes.
public void addExtensionNodes(final Object map, final Collection<IExtension> extensions) throws IOException {
final Iterator<IExtension> extensionIterator = extensions.iterator();
while (extensionIterator.hasNext()) {
final IExtension extension = extensionIterator.next();
final Iterator<IExtensionElementWriter> writerIterator = writeManager.getExtensionElementWriters().iterator(extension.getClass());
while (writerIterator.hasNext()) {
writerIterator.next().writeContent(this, map, extension);
}
}
}
use of org.freeplane.core.extension.IExtension in project freeplane by freeplane.
the class TreeXmlWriter method addExtensionAttributes.
public void addExtensionAttributes(final Object map, final Collection<IExtension> extensions) {
final Iterator<IExtension> extensionIterator = extensions.iterator();
while (extensionIterator.hasNext()) {
final IExtension extension = extensionIterator.next();
final Iterator<IExtensionAttributeWriter> writerIterator = writeManager.getExtensionAttributeWriters().iterator(extension.getClass());
while (writerIterator.hasNext()) {
writerIterator.next().writeAttributes(this, map, extension);
}
}
}
use of org.freeplane.core.extension.IExtension in project freeplane by freeplane.
the class AttributeBuilder method registerBy.
/**
*/
public void registerBy(final ReadManager reader, final WriteManager writer) {
reader.addElementHandler("attribute_registry", this);
reader.addElementHandler(AttributeBuilder.XML_NODE_ATTRIBUTE, this);
reader.addElementHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME, this);
reader.addElementHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_VALUE, this);
writer.addExtensionElementWriter(NodeAttributeTableModel.class, new IExtensionElementWriter() {
public void writeContent(final ITreeWriter writer, final Object node, final IExtension extension) throws IOException {
final NodeAttributeTableModel attributes = (NodeAttributeTableModel) extension;
save((NodeModel) node, attributes, writer);
}
});
writer.addExtensionElementWriter(AttributeRegistry.class, new IExtensionElementWriter() {
public void writeContent(final ITreeWriter writer, final Object node, final IExtension extension) throws IOException {
final AttributeRegistry attributes = (AttributeRegistry) extension;
attributes.write(writer);
}
});
registerAttributeHandlers(reader);
}
use of org.freeplane.core.extension.IExtension in project freeplane by freeplane.
the class MMapController method moveNodeAsChild.
public void moveNodeAsChild(final NodeModel node, final NodeModel selectedParent, final boolean isLeft, final boolean changeSide) {
int position = selectedParent.getChildCount();
if (selectedParent.clones().contains(node.getParentNode())) {
position--;
}
FreeNode r = Controller.getCurrentModeController().getExtension(FreeNode.class);
final IExtension extension = node.getExtension(FreeNode.class);
if (extension != null) {
r.undoableToggleHook(node, extension);
if (MapStyleModel.FLOATING_STYLE.equals(LogicalStyleModel.getStyle(node)))
((MLogicalStyleController) MLogicalStyleController.getController(getMModeController())).setStyle(node, null);
}
moveNode(node, selectedParent, position, isLeft, changeSide);
}
use of org.freeplane.core.extension.IExtension in project freeplane by freeplane.
the class PersistentNodeHook method createExtension.
protected IExtension createExtension(final NodeModel node, final XMLElement element) {
try {
final Class<? extends IExtension> extensionClass = getExtensionClass();
if (extensionClass.isEnum()) {
final String value = element.getAttribute("VALUE");
final Method factory = extensionClass.getMethod("valueOf", String.class);
return (IExtension) factory.invoke(null, value);
}
return extensionClass.newInstance();
} catch (SecurityException e) {
e.printStackTrace();
} catch (Exception e) {
}
return null;
}
Aggregations