Search in sources :

Example 26 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MAttributeController method performRegistryAttributeValue.

@Override
public void performRegistryAttributeValue(final String name, final String value, boolean manual) {
    if (name.equals("")) {
        return;
    }
    final MapModel map = Controller.getCurrentModeController().getController().getMap();
    final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
    try {
        final AttributeRegistryElement element = attributeRegistry.getElement(name);
        if (element.getValues().contains(value)) {
            return;
        }
        final IActor actor = new RegistryAttributeValueActor(element, value, manual);
        Controller.getCurrentModeController().execute(actor, map);
        return;
    } catch (final NoSuchElementException ex) {
        final IActor nameActor = new RegistryAttributeActor(name, true, false, attributeRegistry, map);
        Controller.getCurrentModeController().execute(nameActor, map);
        final AttributeRegistryElement element = attributeRegistry.getElement(name);
        final IActor valueActor = new RegistryAttributeValueActor(element, value, false);
        Controller.getCurrentModeController().execute(valueActor, 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 27 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MAttributeController method performRegistryAttribute.

@Override
public void performRegistryAttribute(final String name) {
    if (name.equals("")) {
        return;
    }
    final MapModel map = Controller.getCurrentModeController().getController().getMap();
    final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
    try {
        attributeRegistry.getElement(name);
    } catch (final NoSuchElementException ex) {
        final IActor actor = new RegistryAttributeActor(name, true, false, attributeRegistry, map);
        Controller.getCurrentModeController().execute(actor, map);
        return;
    }
}
Also used : AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) NoSuchElementException(java.util.NoSuchElementException)

Example 28 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MAttributeController method performReplaceAttributeValue.

@Override
public void performReplaceAttributeValue(final String name, final String oldValue, final String newValue) {
    Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
    ModeController modeController = controller.getModeController();
    final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
    final IActor actor = new ReplaceAttributeValueActor(registry, name, oldValue, newValue);
    Controller.getCurrentModeController().execute(actor, map);
    final IVisitor replacer = new AttributeChanger(name, oldValue, newValue);
    final Iterator iterator = new Iterator(replacer);
    final NodeModel root = modeController.getMapController().getRootNode();
    iterator.iterate(root);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) AttributeController(org.freeplane.features.attribute.AttributeController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Example 29 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MAttributeController method performSetValueAt.

@Override
public void performSetValueAt(final NodeAttributeTableModel model, final Object o, final int row, final int col) {
    final Attribute attribute = model.getAttribute(row);
    final MapModel map = model.getNode().getMap();
    final AttributeRegistry registry = AttributeRegistry.getRegistry(map);
    switch(col) {
        case 0:
            {
                final String name = o.toString().trim();
                final String oldName = attribute.getName();
                if (oldName.equals(name)) {
                    return;
                }
                final IActor nameActor = new SetAttributeNameActor(model, name, oldName, row);
                Controller.getCurrentModeController().execute(nameActor, map);
                try {
                    final AttributeRegistryElement element = registry.getElement(name);
                    final String value = model.getValueAt(row, 1).toString();
                    final int index = element.getValues().getIndexOf(value);
                    if (index == -1) {
                        final IActor valueActor = new SetAttributeValueActor(model, row, element.getValues().firstElement());
                        Controller.getCurrentModeController().execute(valueActor, map);
                    }
                } catch (final NoSuchElementException ex) {
                    final IActor registryActor = new RegistryAttributeActor(name, false, false, registry, map);
                    Controller.getCurrentModeController().execute(registryActor, map);
                }
                break;
            }
        case 1:
            {
                if (attribute.getValue().equals(o)) {
                    return;
                }
                final IActor actor = new SetAttributeValueActor(model, row, o);
                Controller.getCurrentModeController().execute(actor, map);
                final String name = model.getValueAt(row, 0).toString();
                final AttributeRegistryElement element = registry.getElement(name);
                final int index = element.getValues().getIndexOf(o);
                if (index == -1) {
                    final IActor registryActor = new RegistryAttributeValueActor(element, o, false);
                    Controller.getCurrentModeController().execute(registryActor, map);
                }
                break;
            }
    }
}
Also used : Attribute(org.freeplane.features.attribute.Attribute) 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 30 with MapModel

use of org.freeplane.features.map.MapModel in project freeplane by freeplane.

the class MindMapHTMLWriter method writeHTML.

void writeHTML(final Collection<NodeModel> selectedNodes) throws IOException {
    fileout.write("<html>" + MindMapHTMLWriter.el + "<head>" + MindMapHTMLWriter.el);
    if (!selectedNodes.isEmpty()) {
        final MapModel map = selectedNodes.iterator().next().getMap();
        setDefaultsFrom(map);
        writeStyle();
    }
    fileout.write(MindMapHTMLWriter.el + "</head>" + MindMapHTMLWriter.el + "<body>" + MindMapHTMLWriter.el);
    for (NodeModel node : selectedNodes) {
        writeHTML(node, "1", 0, /* isRoot */
        true, true, /* depth */
        1);
    }
    fileout.write("</body>" + MindMapHTMLWriter.el);
    fileout.write("</html>" + MindMapHTMLWriter.el);
    fileout.close();
    resetDefaults();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) MapModel(org.freeplane.features.map.MapModel)

Aggregations

MapModel (org.freeplane.features.map.MapModel)161 NodeModel (org.freeplane.features.map.NodeModel)53 ModeController (org.freeplane.features.mode.ModeController)42 Controller (org.freeplane.features.mode.Controller)34 IActor (org.freeplane.core.undo.IActor)31 File (java.io.File)18 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)17 MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)17 IUndoHandler (org.freeplane.core.undo.IUndoHandler)16 URL (java.net.URL)14 MMapController (org.freeplane.features.map.mindmapmode.MMapController)14 IStyle (org.freeplane.features.styles.IStyle)14 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)14 MapController (org.freeplane.features.map.MapController)12 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)12 IMapViewManager (org.freeplane.features.ui.IMapViewManager)12 MapStyleModel (org.freeplane.features.styles.MapStyleModel)10 IOException (java.io.IOException)9 MalformedURLException (java.net.MalformedURLException)9 URI (java.net.URI)9