Search in sources :

Example 26 with ModeController

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());
}
Also used : IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController) MapController(org.freeplane.features.map.MapController)

Example 27 with ModeController

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());
}
Also used : NodeStyleModel(org.freeplane.features.nodestyle.NodeStyleModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 28 with ModeController

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);
}
Also used : ModeController(org.freeplane.features.mode.ModeController)

Example 29 with ModeController

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);
}
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 30 with ModeController

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

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