use of org.freeplane.features.attribute.NodeAttributeTableModel in project freeplane by freeplane.
the class AttributesProxy method getMap.
public Map<String, Object> getMap() {
final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
if (attributeTableModel == null) {
return Collections.emptyMap();
}
final LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(attributeTableModel.getRowCount());
for (final Attribute a : attributeTableModel.getAttributes()) {
result.put(a.getName(), a.getValue());
}
return result;
}
use of org.freeplane.features.attribute.NodeAttributeTableModel in project freeplane by freeplane.
the class AttributesProxy method getValues.
public List<? extends Convertible> getValues() {
final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
if (attributeTableModel == null) {
return Collections.emptyList();
}
final ArrayList<Convertible> result = new ArrayList<Convertible>(attributeTableModel.getRowCount());
for (final Attribute a : attributeTableModel.getAttributes()) {
result.add(ProxyUtils.attributeValueToConvertible(getDelegate(), getScriptContext(), a.getValue()));
}
return result;
}
use of org.freeplane.features.attribute.NodeAttributeTableModel in project freeplane by freeplane.
the class AttributesProxy method findValues.
public List<? extends Convertible> findValues(Closure<Boolean> closure) {
try {
final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
if (attributeTableModel == null) {
return Collections.emptyList();
}
final ArrayList<Convertible> result = new ArrayList<Convertible>(attributeTableModel.getRowCount());
for (final Attribute a : attributeTableModel.getAttributes()) {
final Object bool = closure.call(new Object[] { a.getName(), a.getValue() });
if (result == null) {
throw new RuntimeException("findValues(): closure returned null instead of boolean/Boolean");
}
if ((Boolean) bool)
result.add(ProxyUtils.attributeValueToConvertible(getDelegate(), getScriptContext(), a.getValue()));
}
return result;
} catch (final MissingMethodException e) {
throw new RuntimeException("findValues(): closure needs to accept two args and must return boolean/Boolean" + " e.g. findValues{k,v -> k != 'TOTAL'}", e);
} catch (final ClassCastException e) {
throw new RuntimeException("findValues(): closure returned " + e.getMessage() + " instead of boolean/Boolean");
}
}
use of org.freeplane.features.attribute.NodeAttributeTableModel in project freeplane by freeplane.
the class AttributesProxy method clear.
public void clear() {
final NodeAttributeTableModel attributeTableModel = getNodeAttributeTableModel();
final int size = attributeTableModel.getRowCount();
for (int i = size - 1; i >= 0; i--) {
getAttributeController().removeAttribute(getDelegate(), i);
}
}
use of org.freeplane.features.attribute.NodeAttributeTableModel in project freeplane by freeplane.
the class AddStyleAttributes method setEnabled.
@Override
public void setEnabled() {
final NodeModel node = Controller.getCurrentModeController().getMapController().getSelectedNode();
if (node != null) {
final NodeAttributeTableModel model = NodeAttributeTableModel.getModel(node);
setEnabled(model != null && model.getAttributeTableLength() > 0);
} else
setEnabled(false);
}
Aggregations