Search in sources :

Example 11 with Attribute

use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.

the class MAttributeController method copyAttributesToNode.

public void copyAttributesToNode(NodeModel source, NodeModel target) {
    if (source == null)
        return;
    final NodeAttributeTableModel model = NodeAttributeTableModel.getModel(source);
    if (model.getRowCount() == 0)
        return;
    final int attributeTableLength = model.getAttributeTableLength();
    for (int i = 0; i < attributeTableLength; i++) {
        final Attribute attribute = model.getAttribute(i);
        addAttribute(target, new Attribute(attribute.getName(), attribute.getValue()));
    }
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 12 with Attribute

use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.

the class AttributesProxy method set.

public void set(final String name, final Object value) {
    final int index = findFirst(name);
    if (index == -1) {
        final Attribute attribute = new Attribute(name, ProxyUtils.transformObject(value, null));
        getAttributeController().addAttribute(getDelegate(), attribute);
    } else {
        final String oldPattern = getOldValueFormatPattern(getNodeAttributeTableModel(), index);
        final Attribute attribute = new Attribute(name, ProxyUtils.transformObject(value, oldPattern));
        getAttributeController().setAttribute(getDelegate(), index, attribute);
    }
}
Also used : Attribute(org.freeplane.features.attribute.Attribute)

Example 13 with Attribute

use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.

the class AttributesProxy method set.

public void set(final int index, final String name, final Object value) {
    final NodeAttributeTableModel attributeTableModel = getAndCheckNodeAttributeTableModelForIndex(index, "set2:");
    String oldPattern = getOldValueFormatPattern(attributeTableModel, index);
    getAttributeController().setAttribute(getDelegate(), index, new Attribute(name, ProxyUtils.transformObject(value, oldPattern)));
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 14 with Attribute

use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.

the class AttributesProxy method getAll.

public List<Object> getAll(final String name) {
    final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
    if (attributeTableModel == null) {
        return Collections.emptyList();
    }
    final ArrayList<Object> result = new ArrayList<Object>();
    for (final Attribute attribute : attributeTableModel.getAttributes()) {
        if (attribute.getName().equals(name)) {
            result.add(attribute.getValue());
        }
    }
    return result;
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel) ArrayList(java.util.ArrayList) IFormattedObject(org.freeplane.features.format.IFormattedObject)

Example 15 with Attribute

use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.

the class AttributesProxy method getMap.

public Map<String, Object> getMap() {
    final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
    if (attributeTableModel == null) {
        return Collections.emptyMap();
    }
    final LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(attributeTableModel.getRowCount());
    for (final Attribute a : attributeTableModel.getAttributes()) {
        result.put(a.getName(), a.getValue());
    }
    return result;
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel) IFormattedObject(org.freeplane.features.format.IFormattedObject) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Attribute (org.freeplane.features.attribute.Attribute)20 NodeAttributeTableModel (org.freeplane.features.attribute.NodeAttributeTableModel)12 ArrayList (java.util.ArrayList)6 IFormattedObject (org.freeplane.features.format.IFormattedObject)4 LinkedHashMap (java.util.LinkedHashMap)2 IActor (org.freeplane.core.undo.IActor)2 MissingMethodException (groovy.lang.MissingMethodException)1 URI (java.net.URI)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)1 AttributeRegistryElement (org.freeplane.features.attribute.AttributeRegistryElement)1 MapModel (org.freeplane.features.map.MapModel)1 NodeModel (org.freeplane.features.map.NodeModel)1 ModeController (org.freeplane.features.mode.ModeController)1