Search in sources :

Example 1 with SortedComboBoxModel

use of org.freeplane.core.util.collection.SortedComboBoxModel in project freeplane by freeplane.

the class ImportAttributesDialog method createValueSubTrees.

private void createValueSubTrees(final DefaultMutableTreeNode attributeInfo, final AttributeRegistryElement element, final AttributeRegistry currentAttributes) {
    final String attributeName = element.getKey().toString();
    final SortedComboBoxModel values = element.getValues();
    for (int i = 0; i < values.getSize(); i++) {
        final Object nextElement = values.getElementAt(i);
        if (!currentAttributes.exist(attributeName, nextElement)) {
            final TreeNodeInfo treeNodeInfo = new TreeNodeInfo(nextElement.toString());
            final DefaultMutableTreeNode valueInfo = new DefaultMutableTreeNode(treeNodeInfo);
            attributeInfo.add(valueInfo);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel)

Example 2 with SortedComboBoxModel

use of org.freeplane.core.util.collection.SortedComboBoxModel in project freeplane by freeplane.

the class AttributeConditionController method getValuesForProperty.

public ComboBoxModel getValuesForProperty(final Object selectedItem, TranslatedObject simpleCond) {
    final MapModel map = Controller.getCurrentController().getMap();
    final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
    try {
        final AttributeRegistryElement element = registry.getElement(selectedItem.toString());
        final SortedComboBoxModel list = element.getValues();
        SortedComboBoxModel linkedList = new SortedComboBoxModel();
        for (int i = 0; i < list.getSize(); i++) {
            final Object value = list.getElementAt(i);
            final TextController textController = TextController.getController();
            if (!textController.isFormula(value, null, null)) {
                try {
                    final Object transformedValue = textController.getTransformedObject(value, map.getRootNode(), null);
                    linkedList.add(transformedValue);
                } catch (TransformationException e) {
                    LogUtils.severe(e);
                }
            }
        }
        values.setExtensionList(linkedList);
    } catch (NoSuchElementException e) {
        values.setExtensionList(null);
    }
    return values;
}
Also used : TransformationException(org.freeplane.features.text.TransformationException) TextController(org.freeplane.features.text.TextController) TranslatedObject(org.freeplane.core.resources.TranslatedObject) MapModel(org.freeplane.features.map.MapModel) SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel) NoSuchElementException(java.util.NoSuchElementException)

Example 3 with SortedComboBoxModel

use of org.freeplane.core.util.collection.SortedComboBoxModel in project freeplane by freeplane.

the class IconRegistry method addIcons.

public void addIcons(final MapModel map) {
    final IconRegistry newRegistry = map.getIconRegistry();
    final SortedComboBoxModel newMapIcons = newRegistry.mapIcons;
    for (final Object uiIcon : newMapIcons) {
        mapIcons.add(uiIcon);
    }
}
Also used : SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel)

Example 4 with SortedComboBoxModel

use of org.freeplane.core.util.collection.SortedComboBoxModel in project freeplane by freeplane.

the class AttributeRegistry method exist.

public boolean exist(final String attributeName, final Object element) {
    final int index = indexOf(attributeName);
    if (index == -1) {
        return false;
    }
    final SortedComboBoxModel values = getElement(index).getValues();
    for (int i = 0; i < values.getSize(); i++) {
        if (element.equals(values.getElementAt(i))) {
            return true;
        }
    }
    return false;
}
Also used : SortedComboBoxModel(org.freeplane.core.util.collection.SortedComboBoxModel)

Example 5 with SortedComboBoxModel

use of org.freeplane.core.util.collection.SortedComboBoxModel 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)

Aggregations

SortedComboBoxModel (org.freeplane.core.util.collection.SortedComboBoxModel)5 MapModel (org.freeplane.features.map.MapModel)2 NoSuchElementException (java.util.NoSuchElementException)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TranslatedObject (org.freeplane.core.resources.TranslatedObject)1 IActor (org.freeplane.core.undo.IActor)1 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)1 AttributeRegistryElement (org.freeplane.features.attribute.AttributeRegistryElement)1 NodeModel (org.freeplane.features.map.NodeModel)1 ModeController (org.freeplane.features.mode.ModeController)1 TextController (org.freeplane.features.text.TextController)1 TransformationException (org.freeplane.features.text.TransformationException)1