use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.
the class ExtendedAttributeTableModelDecorator method moveRowUp.
/**
*/
public void moveRowUp(final int row) {
final Attribute attribute = getAttributeController().performRemoveRow(getNodeAttributeModel(), row);
getAttributeController().performInsertRow(getNodeAttributeModel(), (row - 1), attribute.getName(), attribute.getValue());
}
use of org.freeplane.features.attribute.Attribute in project freeplane by freeplane.
the class ExtendedAttributeTableModelDecorator method moveRowDown.
/**
*/
public void moveRowDown(final int row) {
final Attribute attribute = getAttributeController().performRemoveRow(getNodeAttributeModel(), row);
getAttributeController().performInsertRow(getNodeAttributeModel(), (row + 1), attribute.getName(), attribute.getValue());
}
use of org.freeplane.features.attribute.Attribute 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.Attribute 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.Attribute 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