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;
}
}
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;
}
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);
}
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);
}
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);
}
Aggregations