Search in sources :

Example 6 with Attribute

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

the class ExtendedAttributeTableModelDecorator method moveRowUp.

/**
 */
public void moveRowUp(final int row) {
    final Attribute attribute = getAttributeController().performRemoveRow(getNodeAttributeModel(), row);
    getAttributeController().performInsertRow(getNodeAttributeModel(), (row - 1), attribute.getName(), attribute.getValue());
}
Also used : Attribute(org.freeplane.features.attribute.Attribute)

Example 7 with Attribute

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

the class ExtendedAttributeTableModelDecorator method moveRowDown.

/**
 */
public void moveRowDown(final int row) {
    final Attribute attribute = getAttributeController().performRemoveRow(getNodeAttributeModel(), row);
    getAttributeController().performInsertRow(getNodeAttributeModel(), (row + 1), attribute.getName(), attribute.getValue());
}
Also used : Attribute(org.freeplane.features.attribute.Attribute)

Example 8 with Attribute

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

the class AttributesProxy method getNames.

public List<String> getNames() {
    final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
    if (attributeTableModel == null) {
        return Collections.emptyList();
    }
    final ArrayList<String> result = new ArrayList<String>(attributeTableModel.getRowCount());
    for (final Attribute a : attributeTableModel.getAttributes()) {
        result.add(a.getName());
    }
    return result;
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel) ArrayList(java.util.ArrayList)

Example 9 with Attribute

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

the class AttributesProxy method iterator.

@SuppressWarnings("unchecked")
public Iterator<Map.Entry<String, Object>> iterator() {
    final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
    if (attributeTableModel == null) {
        return (Iterator<Map.Entry<String, Object>>) (Object) Collections.emptyMap().entrySet().iterator();
    }
    return new Iterator<Map.Entry<String, Object>>() {

        private final Iterator<Attribute> iterator = attributeTableModel.getAttributes().iterator();

        @Override
        public boolean hasNext() {
            return iterator.hasNext();
        }

        @Override
        public Map.Entry<String, Object> next() {
            final Attribute attribute = iterator.next();
            return new Map.Entry<String, Object>() {

                @Override
                public String getKey() {
                    return attribute.getName();
                }

                @Override
                public Object getValue() {
                    return attribute.getValue();
                }

                @Override
                public Object setValue(Object value) {
                    final Object oldValue = attribute.getValue();
                    attribute.setValue(value);
                    return oldValue;
                }
            };
        }

        @Override
        public void remove() {
            iterator.remove();
        }
    };
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel) Iterator(java.util.Iterator) IFormattedObject(org.freeplane.features.format.IFormattedObject) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 10 with Attribute

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

the class AttributesProxy method removeAll.

public boolean removeAll(final String name) {
    final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
    if (attributeTableModel == null) {
        return false;
    }
    final ArrayList<Integer> toRemove = new ArrayList<Integer>();
    final Vector<Attribute> attributes = attributeTableModel.getAttributes();
    for (int i = 0; i < attributes.size(); ++i) {
        if (attributes.get(i).getName().equals(name)) {
            toRemove.add(i);
        }
    }
    // do it backwards in order not to invalidate the first indexes
    for (int i = toRemove.size() - 1; i >= 0; --i) {
        getAttributeController().removeAttribute(getDelegate(), toRemove.get(i));
    }
    return !toRemove.isEmpty();
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel) ArrayList(java.util.ArrayList)

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