Search in sources :

Example 1 with EditedComponent

use of org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent 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)

Aggregations

Component (java.awt.Component)1 RootPaneContainer (javax.swing.RootPaneContainer)1 ResourceController (org.freeplane.core.resources.ResourceController)1 FormatController (org.freeplane.features.format.FormatController)1 ScannerController (org.freeplane.features.format.ScannerController)1 IconController (org.freeplane.features.icon.IconController)1 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)1 LinkController (org.freeplane.features.link.LinkController)1 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)1 MapController (org.freeplane.features.map.MapController)1 MMapController (org.freeplane.features.map.mindmapmode.MMapController)1 Controller (org.freeplane.features.mode.Controller)1 ModeController (org.freeplane.features.mode.ModeController)1 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)1 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)1 MNodeStyleController (org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController)1 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)1 TextController (org.freeplane.features.text.TextController)1 EditedComponent (org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent)1 IEditControl (org.freeplane.features.text.mindmapmode.EditNodeBase.IEditControl)1