Search in sources :

Example 11 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager 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 12 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class NodeList method selectMap.

private void selectMap(final MapModel map) {
    if (map.equals(Controller.getCurrentController().getMap())) {
        return;
    }
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    final Map<String, MapModel> maps = mapViewManager.getMaps(MModeController.MODENAME);
    for (final Map.Entry<String, MapModel> entry : maps.entrySet()) {
        if (map.equals(entry.getValue())) {
            mapViewManager.tryToChangeToMapView(entry.getKey());
        }
    }
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) MapModel(org.freeplane.features.map.MapModel) Map(java.util.Map)

Example 13 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class UserInputListenerFactory method updateMapList.

private void updateMapList(final String mapsMenuPosition) {
    if (!getMenuBuilder(MenuBuilder.class).contains(mapsMenuPosition))
        return;
    getMenuBuilder(MenuBuilder.class).removeChildElements(mapsMenuPosition);
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    final List<? extends Component> mapViewVector = mapViewManager.getMapViewVector();
    if (mapViewVector == null) {
        return;
    }
    final ButtonGroup group = new ButtonGroup();
    int i = 0;
    for (final Component mapView : mapViewVector) {
        final String displayName = mapView.getName();
        final JRadioButtonMenuItem newItem = new JRadioButtonMenuItem(displayName);
        newItem.setSelected(false);
        group.add(newItem);
        newItem.addActionListener(mapsMenuActionListener);
        if (displayName.length() > 0) {
            newItem.setMnemonic(displayName.charAt(0));
        }
        final MapView currentMapView = (MapView) mapViewManager.getMapViewComponent();
        if (currentMapView != null) {
            if (mapView == currentMapView) {
                newItem.setSelected(true);
            }
        }
        getMenuBuilder(MenuBuilder.class).addMenuItem(mapsMenuPosition, newItem, mapsMenuPosition + '-' + i++, UIBuilder.AS_CHILD);
    }
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) ButtonGroup(javax.swing.ButtonGroup) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) MapView(org.freeplane.view.swing.map.MapView) JComponent(javax.swing.JComponent) Component(java.awt.Component) MenuBuilder(org.freeplane.core.ui.MenuBuilder)

Example 14 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class UserInputListenerFactory method updateMenus.

public void updateMenus(String menuStructureResource, Set<String> plugins) {
    mapsPopupMenu = new JPopupMenu();
    getMenuBuilder(MenuBuilder.class).addPopupMenu(mapsPopupMenu, FreeplaneMenuBar.MAP_POPUP_MENU);
    getMenuBuilder(MenuBuilder.class).addPopupMenu(getNodePopupMenu(), UserInputListenerFactory.NODE_POPUP);
    final URL popupStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "popup.xml"));
    loadStructure(plugins, popupStructure);
    if (useRibbonMenu()) {
        final URL ribbonStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "ribbon.xml"));
        if (ribbonStructure != null) {
            getMenuBuilder(RibbonBuilder.class).updateRibbon(ribbonStructure);
        }
    } else {
        final FreeplaneMenuBar menuBar = getMenuBar();
        getMenuBuilder(MenuBuilder.class).addMenuBar(menuBar, FreeplaneMenuBar.MENU_BAR_PREFIX);
        getMenuBuilder(MenuBuilder.class).addToolbar((JToolBar) getToolBar("/main_toolbar"), "/main_toolbar");
        final URL menuStructure = ResourceController.getResourceController().getResource(menuStructureResource);
        loadStructure(plugins, menuStructure);
        final URL toolbarStructure = ResourceController.getResourceController().getResource(menuStructureResource.replace("menu.xml", "toolbar.xml"));
        loadStructure(plugins, toolbarStructure);
        final IMapViewManager viewController = Controller.getCurrentController().getMapViewManager();
        viewController.updateMenus(getMenuBuilder(MenuBuilder.class));
    }
    mapsPopupMenu.setName(TextUtils.getText("mindmaps"));
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) FreeplaneMenuBar(org.freeplane.core.ui.components.FreeplaneMenuBar) MenuBuilder(org.freeplane.core.ui.MenuBuilder) RibbonBuilder(org.freeplane.core.ui.ribbon.RibbonBuilder) JPopupMenu(javax.swing.JPopupMenu) URL(java.net.URL)

Example 15 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class EditNodeTextField method hideMe.

private void hideMe() {
    if (textfield == null) {
        return;
    }
    textfield.getDocument().removeDocumentListener(documentListener);
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    mapViewManager.removeMapViewChangeListener(mapViewChangeListener);
    mapViewChangeListener = null;
    parent.setPreferredSize(null);
    if (SwingUtilities.getAncestorOfClass(MapView.class, nodeView) != null)
        nodeView.update();
    if (nodeView.isRoot() && parent instanceof MainView)
        parent.setHorizontalAlignment(JLabel.CENTER);
    final Dimension textFieldSize = textfield.getSize();
    final Point textFieldCoordinate = new Point();
    final MapView mapView = nodeView.getMap();
    UITools.convertPointToAncestor(textfield, textFieldCoordinate, mapView);
    textfield.getParent().remove(textfield);
    parent.revalidate();
    parent.repaint();
    mapView.repaint(textFieldCoordinate.x, textFieldCoordinate.y, textFieldSize.width, textFieldSize.height);
    textfield = null;
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) MainView(org.freeplane.view.swing.map.MainView) MapView(org.freeplane.view.swing.map.MapView) Dimension(java.awt.Dimension) Point(java.awt.Point)

Aggregations

IMapViewManager (org.freeplane.features.ui.IMapViewManager)35 Component (java.awt.Component)13 Controller (org.freeplane.features.mode.Controller)13 MapModel (org.freeplane.features.map.MapModel)12 ModeController (org.freeplane.features.mode.ModeController)11 JComponent (javax.swing.JComponent)7 URL (java.net.URL)5 ResourceController (org.freeplane.core.resources.ResourceController)5 NodeModel (org.freeplane.features.map.NodeModel)5 MapView (org.freeplane.view.swing.map.MapView)5 Point (java.awt.Point)4 JTextComponent (javax.swing.text.JTextComponent)4 IUndoHandler (org.freeplane.core.undo.IUndoHandler)3 LinkController (org.freeplane.features.link.LinkController)3 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)3 ViewController (org.freeplane.features.ui.ViewController)3 Color (java.awt.Color)2 Dimension (java.awt.Dimension)2 ComponentAdapter (java.awt.event.ComponentAdapter)2 ComponentEvent (java.awt.event.ComponentEvent)2