use of org.freeplane.features.attribute.NodeAttributeTableModel 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;
}
use of org.freeplane.features.attribute.NodeAttributeTableModel in project freeplane by freeplane.
the class ScriptingEngine method performScriptOperation.
static void performScriptOperation(final NodeModel node) {
final NodeAttributeTableModel attributes = NodeAttributeTableModel.getModel(node);
if (attributes == null) {
return;
}
for (int row = 0; row < attributes.getRowCount(); ++row) {
final String attrKey = (String) attributes.getName(row);
final Object value = attributes.getValue(row);
if (value instanceof String) {
final String script = (String) value;
if (attrKey.startsWith(ScriptingEngine.SCRIPT_PREFIX)) {
executeScript(node, script);
}
}
}
return;
}
use of org.freeplane.features.attribute.NodeAttributeTableModel 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;
}
use of org.freeplane.features.attribute.NodeAttributeTableModel 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();
}
};
}
use of org.freeplane.features.attribute.NodeAttributeTableModel 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();
}
Aggregations