use of org.freeplane.features.attribute.Attribute 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.Attribute 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.Attribute in project freeplane by freeplane.
the class AttributesProxy method add.
public void add(final String name, final Object value) {
final Attribute attribute = new Attribute(name, ProxyUtils.transformObject(value, null));
getAttributeController().addAttribute(getDelegate(), attribute);
}
use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.
the class ScriptEditor method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentModeController();
final NodeModel node = modeController.getMapController().getSelectedNode();
final ArrayList<AttributeHolder> scripts = new ArrayList<AttributeHolder>();
for (int position = 0; position < NodeAttributeTableModel.getModel(node).getAttributeTableLength(); position++) {
final Attribute attribute = NodeAttributeTableModel.getModel(node).getAttribute(position);
if (attribute.getName().startsWith(ScriptingEngine.SCRIPT_PREFIX)) {
scripts.add(new AttributeHolder(new Attribute(attribute), position));
}
}
final NodeScriptModel nodeScriptModel = new NodeScriptModel(scripts, node);
final ScriptEditorPanel scriptEditorPanel = new ScriptEditorPanel(nodeScriptModel, true);
scriptEditorPanel.setVisible(true);
}
use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.
the class AddStyleAttributes method pasteAttributes.
/**
*/
private void pasteAttributes(final NodeModel node) {
Object[] attributes = CopyAttributes.getAttributes();
if (attributes == null) {
JOptionPane.showMessageDialog(Controller.getCurrentController().getViewController().getContentPane(), TextUtils.getText("no_copy_attributes_before_paste_attributes"), "", /*=Title*/
JOptionPane.ERROR_MESSAGE);
return;
}
final MAttributeController controller = MAttributeController.getController();
for (int i = 0; i < attributes.length; ) {
final String name = attributes[i++].toString();
final Object value = attributes[i++];
controller.addAttribute(node, new Attribute(name, value));
}
}
Aggregations