use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class MTextController method edit.
public void edit(final FirstAction action, final boolean editLong) {
final Controller controller = Controller.getCurrentController();
final IMapSelection selection = controller.getSelection();
if (selection == null)
return;
final NodeModel selectedNode = selection.getSelected();
if (selectedNode == null)
return;
if (FirstAction.EDIT_CURRENT.equals(action)) {
edit(selectedNode, selectedNode, false, false, editLong);
} else if (!Controller.getCurrentModeController().isBlocked()) {
final int mode = FirstAction.ADD_CHILD.equals(action) ? MMapController.NEW_CHILD : MMapController.NEW_SIBLING_BEHIND;
((MMapController) Controller.getCurrentModeController().getMapController()).addNewNode(mode);
}
}
use of org.freeplane.features.mode.Controller 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.Controller in project freeplane by freeplane.
the class FrameController method quit.
@Override
public boolean quit() {
final Controller controller = Controller.getCurrentController();
controller.selectMode(MModeController.MODENAME);
final boolean allMapsClosed = controller.closeAllMaps();
if (allMapsClosed)
getController().getMapViewManager().onQuitApplication();
return allMapsClosed;
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class SaveAction method setEnabled.
@Override
public void setEnabled() {
final Controller controller = Controller.getCurrentController();
MapModel map = controller.getMap();
setEnabled(map != null && !map.isSaved());
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class SaveAll method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final Controller controller = Controller.getCurrentController();
final Component initialMapView = controller.getMapViewManager().getMapViewComponent();
final Map<String, MapModel> mapViews = getMapViews();
final Iterator<Entry<String, MapModel>> iterator = mapViews.entrySet().iterator();
while (iterator.hasNext()) {
final Entry<String, MapModel> entry = iterator.next();
controller.getMapViewManager().changeToMapView(entry.getKey());
final ModeController modeController = controller.getModeController();
if (modeController instanceof MModeController) {
((MModeController) modeController).save();
}
}
if (initialMapView != null) {
controller.getMapViewManager().changeToMapView(initialMapView);
}
}
Aggregations