use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class MNodeStyleController method setNodeNumbering.
public void setNodeNumbering(final NodeModel node, final Boolean enableNodeNumbering) {
final ModeController modeController = Controller.getCurrentModeController();
final Boolean oldValue = NodeStyleModel.getNodeNumbering(node);
final IActor actor = new IActor() {
public void act() {
NodeStyleModel.setNodeNumbering(node, enableNodeNumbering);
final MapController mapController = modeController.getMapController();
mapController.setSaved(node.getMap(), false);
mapController.delayedNodeRefresh(node, NodeStyleController.NODE_NUMBERING, oldValue, enableNodeNumbering);
}
public String getDescription() {
return "setNodeNumbering";
}
public void undo() {
NodeStyleModel.setNodeNumbering(node, oldValue);
final MapController mapController = modeController.getMapController();
mapController.setSaved(node.getMap(), false);
modeController.getMapController().delayedNodeRefresh(node, NodeStyleController.NODE_NUMBERING, enableNodeNumbering, oldValue);
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class MNodeStyleController method setFontFamily.
/**
* @param fontFamily
*/
public void setFontFamily(final NodeModel node, final String fontFamily) {
final String oldFontFamily = NodeStyleModel.getFontFamilyName(node);
if (oldFontFamily == fontFamily || oldFontFamily != null && oldFontFamily.equals(fontFamily)) {
return;
}
createOwnStyleModel(node);
final ModeController modeController = Controller.getCurrentModeController();
final IActor actor = new IActor() {
public void act() {
final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
styleModel.setFontFamilyName(fontFamily);
Controller.getCurrentModeController().getMapController().nodeChanged(node);
}
public String getDescription() {
return "setFontFamily";
}
public void undo() {
final NodeStyleModel styleModel = NodeStyleModel.getModel(node);
styleModel.setFontFamilyName(oldFontFamily);
Controller.getCurrentModeController().getMapController().nodeChanged(node);
}
};
modeController.execute(actor, node.getMap());
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class LocationController method install.
public static void install(final LocationController locationController) {
final ModeController modeController = Controller.getCurrentModeController();
modeController.addExtension(LocationController.class, locationController);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class MTextController method edit.
public void edit(final NodeModel nodeModel, final NodeModel prevSelectedModel, final boolean isNewNode, final boolean parentFolded, final boolean editLong) {
if (nodeModel == null || mCurrentEditor != null) {
return;
}
final Controller controller = Controller.getCurrentController();
if (controller.getMap() != nodeModel.getMap()) {
return;
}
final IMapViewManager viewController = controller.getMapViewManager();
final Component map = viewController.getMapViewComponent();
map.validate();
map.invalidate();
final Component node = viewController.getComponent(nodeModel);
if (node == null) {
return;
}
node.requestFocus();
stopEditing();
if (isNewNode && !eventQueue.isActive() && !ResourceController.getResourceController().getBooleanProperty("display_inline_editor_for_all_new_nodes")) {
keyEventDispatcher = new EditEventDispatcher(Controller.getCurrentModeController(), nodeModel, prevSelectedModel, isNewNode, parentFolded, editLong);
keyEventDispatcher.install();
return;
}
;
final IEditControl editControl = new IEditControl() {
@Override
public void cancel() {
if (isNewNode && nodeModel.getMap().equals(controller.getMap())) {
if (nodeModel.getParentNode() != null) {
controller.getSelection().selectAsTheOnlyOneSelected(nodeModel);
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
modeController.undo();
modeController.resetRedo();
}
final MapController mapController = Controller.getCurrentModeController().getMapController();
if (parentFolded) {
mapController.fold(prevSelectedModel);
}
}
stop();
}
private void stop() {
Controller.getCurrentModeController().setBlocked(false);
viewController.obtainFocusForSelected();
mCurrentEditor = null;
}
@Override
public void ok(final String text) {
String processedText = makePlainIfNoFormattingFound(text);
keepNodePosition();
setGuessedNodeObject(nodeModel, processedText);
stop();
}
private void keepNodePosition() {
Controller.getCurrentController().getSelection().keepNodePosition(nodeModel, 0, 0);
}
@Override
public void split(final String text, final int position) {
String processedText = HtmlUtils.isHtmlNode(text) ? removeHtmlHead(text) : text;
splitNode(nodeModel, position, processedText);
viewController.obtainFocusForSelected();
stop();
}
@Override
public boolean canSplit() {
return true;
}
@Override
public EditedComponent getEditType() {
return EditedComponent.TEXT;
}
};
mCurrentEditor = createEditor(nodeModel, editControl, nodeModel.getText(), isNewNode, editLong, true);
final RootPaneContainer frame = (RootPaneContainer) UITools.getCurrentRootComponent();
mCurrentEditor.show(frame);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NewMapAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
MFileManager.getController(modeController).newMapFromDefaultTemplate();
}
Aggregations