Search in sources :

Example 1 with NodeAttributeTableModel

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

the class MAttributeController method editAttribute.

public int editAttribute(final NodeModel pNode, final String pName, final String pNewValue) {
    createAttributeTableModel(pNode);
    final Attribute newAttribute = new Attribute(pName, pNewValue);
    final NodeAttributeTableModel attributes = NodeAttributeTableModel.getModel(pNode);
    for (int i = 0; i < attributes.getRowCount(); i++) {
        if (pName.equals(attributes.getAttribute(i).getName())) {
            if (pNewValue != null) {
                setAttribute(pNode, i, newAttribute);
            } else {
                removeAttribute(pNode, i);
            }
            return i;
        }
    }
    if (pNewValue == null) {
        return -1;
    }
    return addAttribute(pNode, newAttribute);
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 2 with NodeAttributeTableModel

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

the class RemoveAllAttributesAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e, final NodeModel node) {
    final AttributeUtilities atrUtil = new AttributeUtilities();
    if (atrUtil.hasAttributes(node)) {
        final NodeAttributeTableModel natm = NodeAttributeTableModel.getModel(node);
        final int j = natm.getRowCount();
        for (int i = 0; i < j; i++) {
            AttributeController.getController().performRemoveRow(natm, 0);
        }
    }
}
Also used : NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 3 with NodeAttributeTableModel

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

the class RemoveLastAttributeAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e, final NodeModel node) {
    final AttributeUtilities atrUtil = new AttributeUtilities();
    if (atrUtil.hasAttributes(node)) {
        final NodeAttributeTableModel natm = NodeAttributeTableModel.getModel(node);
        AttributeController.getController().performRemoveRow(natm, natm.getRowCount() - 1);
    }
}
Also used : NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 4 with NodeAttributeTableModel

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

the class AddAttributeAction method actionPerformed.

public void actionPerformed(final ActionEvent arg0) {
    final Collection<NodeModel> nodes = Controller.getCurrentModeController().getMapController().getSelectedNodes();
    final int selection = UITools.showConfirmDialog(Controller.getCurrentController().getSelection().getSelected(), getPanel(), TextUtils.getText("attributes_AddAttributeAction.text"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
    // OK button pressed
    if (selection == JOptionPane.OK_OPTION) {
        if (attributeNames.getSelectedItem() == null) {
            UITools.showAttributeEmptyStringErrorMessage();
            return;
        }
        final String name = attributeNames.getSelectedItem().toString();
        if (name.equals("")) {
            UITools.showAttributeEmptyStringErrorMessage();
            return;
        }
        final Object valueSelectedItem = attributeValues.getSelectedItem();
        final String value = valueSelectedItem != null ? valueSelectedItem.toString() : "";
        // Add attributes to nodes
        for (final NodeModel node : nodes) {
            final NodeAttributeTableModel attributes = attrContr.createAttributeTableModel(node);
            attrContr.performInsertRow(attributes, attributes.getRowCount(), name, value);
        }
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Example 5 with NodeAttributeTableModel

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

the class AddStyleAttributes method copyAttributes.

/**
 */
private void copyAttributes(final NodeModel node) {
    final NodeAttributeTableModel model = NodeAttributeTableModel.getModel(node);
    if (model == null) {
        attributes = null;
        return;
    }
    final int attributeTableLength = model.getAttributeTableLength();
    attributes = new Object[attributeTableLength * 2];
    for (int i = 0; i < attributeTableLength; i++) {
        final Attribute attribute = model.getAttribute(i);
        attributes[2 * i] = attribute.getName();
        attributes[2 * i + 1] = attribute.getValue();
    }
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) NodeAttributeTableModel(org.freeplane.features.attribute.NodeAttributeTableModel)

Aggregations

NodeAttributeTableModel (org.freeplane.features.attribute.NodeAttributeTableModel)25 Attribute (org.freeplane.features.attribute.Attribute)12 ArrayList (java.util.ArrayList)5 IFormattedObject (org.freeplane.features.format.IFormattedObject)5 NodeModel (org.freeplane.features.map.NodeModel)3 LinkedHashMap (java.util.LinkedHashMap)2 MissingMethodException (groovy.lang.MissingMethodException)1 URI (java.net.URI)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1