Search in sources :

Example 11 with Controller

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);
    }
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) LinkController(org.freeplane.features.link.LinkController) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ScannerController(org.freeplane.features.format.ScannerController)

Example 12 with Controller

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);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) RootPaneContainer(javax.swing.RootPaneContainer) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) LinkController(org.freeplane.features.link.LinkController) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ScannerController(org.freeplane.features.format.ScannerController) EditedComponent(org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent) Component(java.awt.Component) IEditControl(org.freeplane.features.text.mindmapmode.EditNodeBase.IEditControl) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController)

Example 13 with Controller

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;
}
Also used : Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ScannerController(org.freeplane.features.format.ScannerController)

Example 14 with Controller

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());
}
Also used : MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 15 with Controller

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);
    }
}
Also used : Entry(java.util.Map.Entry) MapModel(org.freeplane.features.map.MapModel) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) Controller(org.freeplane.features.mode.Controller) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController) Component(java.awt.Component) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Aggregations

Controller (org.freeplane.features.mode.Controller)135 ModeController (org.freeplane.features.mode.ModeController)78 ResourceController (org.freeplane.core.resources.ResourceController)63 NodeModel (org.freeplane.features.map.NodeModel)44 MapController (org.freeplane.features.map.MapController)37 LinkController (org.freeplane.features.link.LinkController)32 MapModel (org.freeplane.features.map.MapModel)31 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)30 MMapController (org.freeplane.features.map.mindmapmode.MMapController)27 TextController (org.freeplane.features.text.TextController)24 ViewController (org.freeplane.features.ui.ViewController)22 IconController (org.freeplane.features.icon.IconController)20 Component (java.awt.Component)18 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)18 FilterController (org.freeplane.features.filter.FilterController)16 FormatController (org.freeplane.features.format.FormatController)15 ScannerController (org.freeplane.features.format.ScannerController)15 IMapSelection (org.freeplane.features.map.IMapSelection)15 MTextController (org.freeplane.features.text.mindmapmode.MTextController)14 IMapViewManager (org.freeplane.features.ui.IMapViewManager)14