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);
}
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);
}
}
}
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);
}
}
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);
}
}
}
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();
}
}
Aggregations