Search in sources :

Example 1 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class ActionAcceleratorManager method loadAcceleratorPreset.

private void loadAcceleratorPreset(final String shortcutKey, final String keystrokeString, Properties allPresets) {
    if (!shortcutKey.startsWith(SHORTCUT_PROPERTY_PREFIX)) {
        LogUtils.warn("wrong property key " + shortcutKey);
        return;
    }
    final int pos = shortcutKey.indexOf("/", SHORTCUT_PROPERTY_PREFIX.length());
    if (pos <= 0) {
        LogUtils.warn("wrong property key " + shortcutKey);
        return;
    }
    final String modeName = shortcutKey.substring(SHORTCUT_PROPERTY_PREFIX.length(), pos);
    final String itemKey = shortcutKey.substring(pos + 1);
    Controller controller = Controller.getCurrentController();
    final ModeController modeController = controller.getModeController(modeName);
    if (modeController != null) {
        final KeyStroke keyStroke;
        if (!keystrokeString.equals("")) {
            keyStroke = UITools.getKeyStroke(keystrokeString);
            final AFreeplaneAction oldAction = accelerators.get(key(modeController, keyStroke));
            if (!acceleratorIsDefinedByUserProperties(oldAction, modeController, allPresets))
                setAccelerator(modeController, oldAction, null);
        } else {
            keyStroke = null;
        }
        final AFreeplaneAction action = modeController.getAction(itemKey);
        if (action != null) {
            setAccelerator(modeController, action, keyStroke);
        }
    }
    setKeysetProperty(shortcutKey, keystrokeString);
}
Also used : KeyStroke(javax.swing.KeyStroke) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Example 2 with ModeController

use of org.freeplane.features.mode.ModeController 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 3 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MAttributeController method performReplaceAttributeValue.

@Override
public void performReplaceAttributeValue(final String name, final Object oldValue, final Object 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 4 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MAttributeController method createActions.

/**
 */
private void createActions() {
    ModeController modeController = Controller.getCurrentModeController();
    modeController.addAction(new AssignAttributesAction());
    modeController.addAction(new ShowAttributeDialogAction());
    modeController.addAction(new CopyAttributes());
    modeController.addAction(new PasteAttributes());
    modeController.addAction(new AddStyleAttributes());
}
Also used : ModeController(org.freeplane.features.mode.ModeController)

Example 5 with ModeController

use of org.freeplane.features.mode.ModeController 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)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)185 NodeModel (org.freeplane.features.map.NodeModel)80 Controller (org.freeplane.features.mode.Controller)43 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)36 MapController (org.freeplane.features.map.MapController)31 MapModel (org.freeplane.features.map.MapModel)30 IActor (org.freeplane.core.undo.IActor)28 ResourceController (org.freeplane.core.resources.ResourceController)21 MMapController (org.freeplane.features.map.mindmapmode.MMapController)21 Point (java.awt.Point)16 TextController (org.freeplane.features.text.TextController)16 Component (java.awt.Component)13 MapView (org.freeplane.view.swing.map.MapView)13 LinkController (org.freeplane.features.link.LinkController)12 NodeView (org.freeplane.view.swing.map.NodeView)12 Color (java.awt.Color)11 File (java.io.File)11 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)11 IMapSelection (org.freeplane.features.map.IMapSelection)10 ViewController (org.freeplane.features.ui.ViewController)10