Search in sources :

Example 16 with AttributeRegistry

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);
}
Also used : AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) AttributeRegistryElement(org.freeplane.features.attribute.AttributeRegistryElement) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) NoSuchElementException(java.util.NoSuchElementException)

Example 17 with AttributeRegistry

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);
}
Also used : AttributeRegistryElement(org.freeplane.features.attribute.AttributeRegistryElement) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel) NodeModel(org.freeplane.features.map.NodeModel) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor)

Example 18 with AttributeRegistry

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());
}
Also used : AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Example 19 with AttributeRegistry

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);
    }
}
Also used : AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) MapModel(org.freeplane.features.map.MapModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) ComboBoxModel(javax.swing.ComboBoxModel)

Aggregations

AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)19 MapModel (org.freeplane.features.map.MapModel)17 IActor (org.freeplane.core.undo.IActor)13 NodeModel (org.freeplane.features.map.NodeModel)7 NoSuchElementException (java.util.NoSuchElementException)6 AttributeRegistryElement (org.freeplane.features.attribute.AttributeRegistryElement)6 ModeController (org.freeplane.features.mode.ModeController)6 ComboBoxModel (javax.swing.ComboBoxModel)5 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)3 JComboBox (javax.swing.JComboBox)2 AttributeController (org.freeplane.features.attribute.AttributeController)2 ClonedComboBoxModel (org.freeplane.features.attribute.mindmapmode.AssignAttributeDialog.ClonedComboBoxModel)2 Controller (org.freeplane.features.mode.Controller)2 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 HierarchyEvent (java.awt.event.HierarchyEvent)1 HierarchyListener (java.awt.event.HierarchyListener)1