use of org.freeplane.features.attribute.AttributeRegistry 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.AttributeRegistry 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);
}
use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class MAttributeController method performSetFontSize.
@Override
public void performSetFontSize(final AttributeRegistry registry, final int size) {
final int oldSize = registry.getFontSize();
if (size == oldSize) {
return;
}
final IActor actor = new IActor() {
public void act() {
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
attributeRegistry.setFontSize(size);
}
public String getDescription() {
return "SetAttributeFontSizeActor";
}
public void undo() {
final MapModel map = Controller.getCurrentModeController().getController().getMap();
final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
attributeRegistry.setFontSize(oldSize);
}
};
Controller.getCurrentModeController().execute(actor, Controller.getCurrentModeController().getController().getMap());
}
use of org.freeplane.features.attribute.AttributeRegistry in project freeplane by freeplane.
the class AssignAttributeDialog method attributesChanged.
private void attributesChanged() {
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
final ComboBoxModel names = attributes.getComboBoxModel();
attributeNames.setModel(new ClonedComboBoxModel(names));
attributeNames.setEditable(!attributes.isRestricted());
replacingAttributeNames.setModel(new ClonedComboBoxModel(names));
replacingAttributeNames.setEditable(!attributes.isRestricted());
if (attributes.size() > 0) {
final Object first = names.getElementAt(0);
attributeNames.setSelectedItem(first);
replacingAttributeNames.setSelectedItem(first);
selectedAttributeChanged(attributeNames.getSelectedItem(), attributeValues);
selectedAttributeChanged(replacingAttributeNames.getSelectedItem(), replacingAttributeValues);
} else {
attributeValues.setModel(new DefaultComboBoxModel());
attributeValues.setEditable(false);
replacingAttributeValues.setModel(new DefaultComboBoxModel());
replacingAttributeValues.setEditable(false);
}
}
Aggregations