use of org.freeplane.core.io.IElementHandler in project freeplane by freeplane.
the class TreeXmlReader method elementAttributesProcessed.
/*
* (non-Javadoc)
* @see
* freeplane.persistence.xml.n3.nanoxml.IXMLBuilder#elementAttributesProcessed
* (java.lang.String, java.lang.String, java.lang.String)
*/
public void elementAttributesProcessed(final String name, final String nsPrefix, final String nsURI) throws Exception {
xmlBuilder.elementAttributesProcessed(name, nsPrefix, nsURI);
if (saveAsXmlUntil != null || nodeCreator != null) {
return;
}
final Iterator<IElementHandler> iterator = getElementHandlers().iterator(tag);
final XMLElement lastBuiltElement = xmlBuilder.getLastBuiltElement();
while (iterator.hasNext() && currentElement == null) {
nodeCreator = iterator.next();
currentElement = nodeCreator.createElement(parentElement, name, lastBuiltElement);
}
if (currentElement != null) {
if (nodeCreator instanceof IElementContentHandler) {
parser.notParseNextElementContent();
}
attributeHandlersForTag = getAttributeLoaders().get(tag);
if (attributeHandlersForTag == null) {
return;
}
final Enumeration<String> attributeNames = lastBuiltElement.enumerateAttributeNames();
while (attributeNames.hasMoreElements()) {
final String atName = (String) attributeNames.nextElement();
if (addAttribute(atName, lastBuiltElement.getAttribute(atName, null))) {
lastBuiltElement.removeAttribute(atName);
}
}
} else {
currentElement = null;
nodeCreator = null;
saveAsXmlUntil = lastBuiltElement;
}
}
use of org.freeplane.core.io.IElementHandler in project freeplane by freeplane.
the class AttributeBuilder method registerAttributeHandlers.
private void registerAttributeHandlers(final ReadManager reader) {
reader.addAttributeHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME, "NAME", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final RegisteredAttributeProperties rap = (RegisteredAttributeProperties) userObject;
rap.attributeName = value;
AttributeRegistry.getRegistry(getMap()).registry(value);
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME, "VISIBLE", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final RegisteredAttributeProperties rap = (RegisteredAttributeProperties) userObject;
rap.visible = true;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME, "RESTRICTED", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final RegisteredAttributeProperties rap = (RegisteredAttributeProperties) userObject;
rap.restricted = true;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_NAME, "MANUAL", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final RegisteredAttributeProperties rap = (RegisteredAttributeProperties) userObject;
rap.manual = true;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_VALUE, "VALUE", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final AttributeProperties ap = (AttributeProperties) userObject;
ap.attributeValue = value;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_REGISTERED_ATTRIBUTE_VALUE, "OBJECT", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final AttributeProperties ap = (AttributeProperties) userObject;
ap.attributeObject = value;
}
});
reader.addElementHandler(XML_NODE_ATTRIBUTE_LAYOUT, new IElementHandler() {
public Object createElement(final Object parent, final String tag, final XMLElement attributes) {
return parent;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE_LAYOUT, "NAME_WIDTH", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final NodeModel node = (NodeModel) userObject;
attributeController.createAttributeTableModel(node);
final AttributeTableLayoutModel layout = NodeAttributeTableModel.getModel(node).getLayout();
layout.setColumnWidth(0, Integer.parseInt(value));
;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE_LAYOUT, "VALUE_WIDTH", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final NodeModel node = (NodeModel) userObject;
attributeController.createAttributeTableModel(node);
final AttributeTableLayoutModel layout = NodeAttributeTableModel.getModel(node).getLayout();
layout.setColumnWidth(1, Integer.parseInt(value));
;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE, "NAME", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final AttributeProperties ap = (AttributeProperties) userObject;
ap.attributeName = value;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE, "VALUE", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final AttributeProperties ap = (AttributeProperties) userObject;
ap.attributeValue = value;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE, "OBJECT", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final AttributeProperties ap = (AttributeProperties) userObject;
ap.attributeObject = value;
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE_REGISTRY, "RESTRICTED", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
AttributeRegistry.getRegistry(getMap()).setRestricted(true);
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE_REGISTRY, "SHOW_ATTRIBUTES", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final AttributeRegistry attributes = AttributeRegistry.getRegistry(getMap());
if (attributes != null)
attributes.setAttributeViewType(value);
}
});
reader.addAttributeHandler(AttributeBuilder.XML_NODE_ATTRIBUTE_REGISTRY, "FONT_SIZE", new IAttributeHandler() {
public void setAttribute(final Object userObject, final String value) {
final int size = Integer.parseInt(value.toString());
AttributeRegistry.getRegistry(getMap()).setFontSize(size);
}
});
}
Aggregations