use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class MAttributeController method performInsertRow.
@Override
public void performInsertRow(final NodeAttributeTableModel model, final int row, final String name, Object value) {
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
if (name.equals("")) {
return;
}
try {
final AttributeRegistryElement element = attributes.getElement(name);
final int index = element.getValues().getIndexOf(value);
if (index == -1) {
if (element.isRestricted()) {
value = element.getValues().firstElement().toString();
} else {
final IActor actor = new RegistryAttributeValueActor(element, value, false);
Controller.getCurrentModeController().execute(actor, map);
}
}
} catch (final NoSuchElementException ex) {
final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
final IActor nameActor = new RegistryAttributeActor(name, false, false, registry, map);
Controller.getCurrentModeController().execute(nameActor, map);
final AttributeRegistryElement element = registry.getElement(name);
final IActor valueActor = new RegistryAttributeValueActor(element, value, false);
Controller.getCurrentModeController().execute(valueActor, map);
}
final Object newValue = value;
final IActor actor = new InsertAttributeActor(model, row, name, newValue);
Controller.getCurrentModeController().execute(actor, map);
}
use of org.freeplane.features.attribute.AttributeRegistryElement in project freeplane by freeplane.
the class MAttributeController method performReplaceAtributeName.
@Override
public void performReplaceAtributeName(final String oldName, final String newName) {
if (oldName.equals("") || newName.equals("") || oldName.equals(newName)) {
return;
}
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
final int iOld = registry.getElements().indexOf(oldName);
final AttributeRegistryElement oldElement = registry.getElement(iOld);
final SortedComboBoxModel values = oldElement.getValues();
final IActor registryActor = new RegistryAttributeActor(newName, oldElement.isManual(), oldElement.isVisible(), registry, map);
Controller.getCurrentModeController().execute(registryActor, map);
final AttributeRegistryElement newElement = registry.getElement(newName);
for (int i = 0; i < values.getSize(); i++) {
final IActor registryValueActor = new RegistryAttributeValueActor(newElement, values.getElementAt(i).toString(), false);
Controller.getCurrentModeController().execute(registryValueActor, map);
}
final IVisitor replacer = new AttributeRenamer(oldName, newName);
final Iterator iterator = new Iterator(replacer);
ModeController modeController = Controller.getCurrentModeController();
final NodeModel root = modeController.getMapController().getRootNode();
iterator.iterate(root);
final IActor unregistryActor = new UnregistryAttributeActor(oldName, registry, map);
Controller.getCurrentModeController().execute(unregistryActor, map);
}
Aggregations