use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.
the class MAttributeController method performSetValueAt.
@Override
public void performSetValueAt(final NodeAttributeTableModel model, final Object o, final int row, final int col) {
final Attribute attribute = model.getAttribute(row);
final MapModel map = model.getNode().getMap();
final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
switch(col) {
case 0:
{
final String name = o.toString().trim();
final String oldName = attribute.getName();
if (oldName.equals(name)) {
return;
}
final IActor nameActor = new SetAttributeNameActor(model, name, oldName, row);
Controller.getCurrentModeController().execute(nameActor, map);
try {
final AttributeRegistryElement element = registry.getElement(name);
final String value = model.getValueAt(row, 1).toString();
final int index = element.getValues().getIndexOf(value);
if (index == -1) {
final IActor valueActor = new SetAttributeValueActor(model, row, element.getValues().firstElement());
Controller.getCurrentModeController().execute(valueActor, map);
}
} catch (final NoSuchElementException ex) {
final IActor registryActor = new RegistryAttributeActor(name, false, false, registry, map);
Controller.getCurrentModeController().execute(registryActor, map);
}
break;
}
case 1:
{
if (attribute.getValue().equals(o)) {
return;
}
final IActor actor = new SetAttributeValueActor(model, row, o);
Controller.getCurrentModeController().execute(actor, map);
final String name = model.getValueAt(row, 0).toString();
final AttributeRegistryElement element = registry.getElement(name);
final int index = element.getValues().getIndexOf(o);
if (index == -1) {
final IActor registryActor = new RegistryAttributeValueActor(element, o, false);
Controller.getCurrentModeController().execute(registryActor, map);
}
break;
}
}
}
use of org.freeplane.features.attribute.Attribute 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.Attribute in project freeplane by freeplane.
the class MAttributeController method performRemoveRow.
@Override
public Attribute performRemoveRow(final NodeAttributeTableModel model, final int row) {
final Vector<Attribute> attributes = model.getAttributes();
final Object o = attributes.elementAt(row);
final IActor actor = new RemoveAttributeActor(model, row);
Controller.getCurrentModeController().execute(actor, model.getNode().getMap());
return (Attribute) o;
}
use of org.freeplane.features.attribute.Attribute 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();
}
}
use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.
the class HyperLinkCondition method checkNode.
public boolean checkNode(final NodeModel node) {
final URI nodeLink = NodeLinks.getValidLink(node);
if (nodeLink != null && checkLink(nodeLink))
return true;
final NodeAttributeTableModel attributes = NodeAttributeTableModel.getModel(node);
if (attributes == null) {
return false;
}
final int rowCount = attributes.getRowCount();
for (int i = 0; i < rowCount; i++) {
final Attribute attribute = attributes.getAttribute(i);
final Object value = attribute.getValue();
if (value instanceof URI && checkLink((URI) value))
return true;
}
return false;
}
Aggregations