Search in sources :

Example 71 with NodeModel

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

the class ClipboardController method duplicate.

public NodeModel duplicate(final NodeModel source, boolean withChildren) {
    try {
        final StringWriter writer = new StringWriter();
        ModeController modeController = Controller.getCurrentModeController();
        modeController.getMapController().getMapWriter().writeNodeAsXml(writer, source, Mode.CLIPBOARD, true, withChildren, false);
        final String result = writer.toString();
        final NodeModel copy = modeController.getMapController().getMapReader().createNodeTreeFromXml(source.getMap(), new StringReader(result), Mode.CLIPBOARD);
        copy.setFolded(false);
        return copy;
    } catch (final Exception e) {
        LogUtils.severe(e);
        return null;
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) StringWriter(java.io.StringWriter) StringReader(java.io.StringReader) ModeController(org.freeplane.features.mode.ModeController) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException)

Example 72 with NodeModel

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

the class ClipboardController method createForNodesFlavor.

public String createForNodesFlavor(final Collection<NodeModel> selectedNodes, final boolean copyInvisible) throws UnsupportedFlavorException, IOException {
    String forNodesFlavor = "";
    boolean firstLoop = true;
    for (final NodeModel tmpNode : selectedNodes) {
        if (firstLoop) {
            firstLoop = false;
        } else {
            forNodesFlavor += "<nodeseparator>";
        }
        forNodesFlavor += copy(tmpNode, copyInvisible).getTransferData(MindMapNodesSelection.mindMapNodesFlavor);
    }
    return forNodesFlavor;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel)

Example 73 with NodeModel

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

the class ClipboardController method copySingle.

public Transferable copySingle(final Collection<NodeModel> source) {
    final int size = source.size();
    final Vector<NodeModel> target = new Vector<NodeModel>(size);
    target.setSize(size);
    int i = 0;
    for (NodeModel node : source) {
        target.set(i, new SingleCopySource(node));
        i++;
    }
    return copy(target, false);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) Vector(java.util.Vector)

Example 74 with NodeModel

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

the class MAttributeController method performRemoveAttribute.

@Override
public void performRemoveAttribute(final String name) {
    final IVisitor remover = new AttributeRemover(name);
    final Iterator iterator = new Iterator(remover);
    ModeController modeController = Controller.getCurrentModeController();
    final NodeModel root = modeController.getMapController().getRootNode();
    iterator.iterate(root);
    final MapModel map = Controller.getCurrentModeController().getController().getMap();
    final AttributeRegistry attributeRegistry = AttributeRegistry.getRegistry(map);
    final IActor actor = new UnregistryAttributeActor(name, attributeRegistry, map);
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) AttributeRegistry(org.freeplane.features.attribute.AttributeRegistry) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel)

Example 75 with NodeModel

use of org.freeplane.features.map.NodeModel 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)

Aggregations

NodeModel (org.freeplane.features.map.NodeModel)450 ModeController (org.freeplane.features.mode.ModeController)100 MapModel (org.freeplane.features.map.MapModel)53 Controller (org.freeplane.features.mode.Controller)46 MapStyleModel (org.freeplane.features.styles.MapStyleModel)46 MMapController (org.freeplane.features.map.mindmapmode.MMapController)39 MapController (org.freeplane.features.map.MapController)38 Point (java.awt.Point)37 IStyle (org.freeplane.features.styles.IStyle)36 IActor (org.freeplane.core.undo.IActor)34 IMapSelection (org.freeplane.features.map.IMapSelection)33 ArrayList (java.util.ArrayList)22 NodeView (org.freeplane.view.swing.map.NodeView)20 URI (java.net.URI)19 Color (java.awt.Color)18 Component (java.awt.Component)17 ResourceController (org.freeplane.core.resources.ResourceController)17 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)15