Search in sources :

Example 56 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 57 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MNodeStyleController method setNodeFormat.

public void setNodeFormat(final NodeModel node, final String format) {
    final ModeController modeController = Controller.getCurrentModeController();
    final String oldFormat = NodeStyleModel.getNodeFormat(node);
    final IActor actor = new IActor() {

        public void act() {
            NodeStyleModel.setNodeFormat(node, format);
            modeController.getMapController().nodeChanged(node);
        }

        public String getDescription() {
            return "setNodeFormat";
        }

        public void undo() {
            NodeStyleModel.setNodeFormat(node, oldFormat);
            modeController.getMapController().nodeChanged(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 58 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class MNodeStyleController method setShape.

public void setShape(final NodeModel node, final String shape) {
    final ModeController modeController = Controller.getCurrentModeController();
    final String oldShape = NodeStyleModel.getShape(node);
    final IActor actor = new IActor() {

        public void act() {
            NodeStyleModel.setShape(node, shape);
            modeController.getMapController().nodeChanged(node);
            childShapeRefresh(node);
        }

        public String getDescription() {
            return "setShape";
        }

        private void childShapeRefresh(final NodeModel node) {
            for (final NodeModel child : modeController.getMapController().childrenFolded(node)) {
                if (child.getViewers().isEmpty())
                    continue;
                final String childShape = NodeStyleModel.getShape(child);
                if (childShape == null || NodeStyleModel.SHAPE_AS_PARENT.equals(childShape)) {
                    modeController.getMapController().nodeRefresh(child);
                    childShapeRefresh(child);
                }
            }
        }

        public void undo() {
            NodeStyleModel.setShape(node, oldShape);
            modeController.getMapController().nodeChanged(node);
            childShapeRefresh(node);
        }
    };
    modeController.execute(actor, node.getMap());
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IActor(org.freeplane.core.undo.IActor) ModeController(org.freeplane.features.mode.ModeController)

Example 59 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 || mCurrentEditDialog != 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() {

        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();
                mapController.select(prevSelectedModel);
                if (parentFolded) {
                    mapController.setFolded(prevSelectedModel, true);
                }
            }
            stop();
        }

        private void stop() {
            Controller.getCurrentModeController().setBlocked(false);
            viewController.obtainFocusForSelected();
            mCurrentEditDialog = null;
        }

        public void ok(final String text) {
            String processedText = makePlainIfNoFormattingFound(text);
            setGuessedNodeObject(nodeModel, processedText);
            stop();
        }

        public void split(final String newText, final int position) {
            splitNode(nodeModel, position, newText);
            viewController.obtainFocusForSelected();
            stop();
        }

        public boolean canSplit() {
            return true;
        }

        public EditedComponent getEditType() {
            return EditedComponent.TEXT;
        }
    };
    mCurrentEditDialog = createEditor(nodeModel, editControl, nodeModel.getText(), isNewNode, editLong, true);
    final JFrame frame = controller.getViewController().getJFrame();
    mCurrentEditDialog.show(frame);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) JFrame(javax.swing.JFrame) 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) 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 60 with ModeController

use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.

the class FreeplaneGUIStarter method buildMenus.

private void buildMenus(final Controller controller, final Set<String> plugins, String mode, String xml) {
    ModeController modeController = controller.getModeController(mode);
    controller.selectModeForBuild(modeController);
    modeController.updateMenus(xml, plugins);
    controller.selectModeForBuild(null);
}
Also used : FModeController(org.freeplane.features.mode.filemode.FModeController) BModeController(org.freeplane.features.mode.browsemode.BModeController) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)222 NodeModel (org.freeplane.features.map.NodeModel)90 Controller (org.freeplane.features.mode.Controller)56 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)48 MapModel (org.freeplane.features.map.MapModel)37 IActor (org.freeplane.core.undo.IActor)31 MapController (org.freeplane.features.map.MapController)30 ResourceController (org.freeplane.core.resources.ResourceController)29 MMapController (org.freeplane.features.map.mindmapmode.MMapController)20 File (java.io.File)17 TextController (org.freeplane.features.text.TextController)17 Color (java.awt.Color)16 Point (java.awt.Point)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MapView (org.freeplane.view.swing.map.MapView)13 NodeView (org.freeplane.view.swing.map.NodeView)13 Component (java.awt.Component)12 URL (java.net.URL)12 LinkController (org.freeplane.features.link.LinkController)12 MenuBuilder (org.freeplane.core.ui.MenuBuilder)11