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