Search in sources :

Example 1 with INodeSelectionListener

use of org.freeplane.features.map.INodeSelectionListener in project freeplane by freeplane.

the class LinkController method init.

protected void init() {
    createActions();
    final MapController mapController = modeController.getMapController();
    final ReadManager readManager = mapController.getReadManager();
    LinkBuilder linkBuilder = new LinkBuilder(this);
    linkBuilder.registerBy(readManager);
    // this IContentTransformer is unconditional because the outcome
    // (#ID_1698830792 -> Nodename) is usually wanted
    final LinkTransformer textTransformer = new LinkTransformer(modeController, 10);
    TextController.getController(modeController).addTextTransformer(textTransformer);
    textTransformer.registerListeners(modeController);
    final INodeSelectionListener listener = new INodeSelectionListener() {

        public void onDeselect(final NodeModel node) {
        }

        public void onSelect(final NodeModel node) {
            final URI link = NodeLinks.getValidLink(node);
            final String linkString = (link != null ? link.toString() : null);
            if (linkString != null) {
                Controller.getCurrentController().getViewController().out(linkString);
            }
        }
    };
    Controller.getCurrentModeController().getMapController().addNodeSelectionListener(listener);
}
Also used : INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) ReadManager(org.freeplane.core.io.ReadManager) URI(java.net.URI) MapController(org.freeplane.features.map.MapController)

Example 2 with INodeSelectionListener

use of org.freeplane.features.map.INodeSelectionListener in project freeplane by freeplane.

the class NodeTooltipManager method getSharedInstance.

public static NodeTooltipManager getSharedInstance(ModeController modeController) {
    {
        final NodeTooltipManager instance = modeController.getExtension(NodeTooltipManager.class);
        if (instance != null) {
            return instance;
        }
    }
    final NodeTooltipManager instance = new NodeTooltipManager();
    setTooltipDelays(instance);
    UIManager.put("PopupMenu.consumeEventOnClose", Boolean.FALSE);
    ResourceController.getResourceController().addPropertyChangeListener(new IFreeplanePropertyListener() {

        public void propertyChanged(final String propertyName, final String newValue, final String oldValue) {
            if (propertyName.startsWith(TOOL_TIP_MANAGER)) {
                setTooltipDelays(instance);
            }
        }
    });
    IMapChangeListener mapChangeListener = new AMapChangeListenerAdapter() {

        @Override
        public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
            instance.hideTipWindow();
        }

        @Override
        public void onNodeInserted(NodeModel parent, NodeModel child, int newIndex) {
            instance.hideTipWindow();
        }

        @Override
        public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
            instance.hideTipWindow();
        }
    };
    MapController mapController = modeController.getMapController();
    mapController.addMapChangeListener(mapChangeListener);
    INodeSelectionListener nodeSelectionListener = new INodeSelectionListener() {

        public void onSelect(NodeModel node) {
            NodeView view = (NodeView) SwingUtilities.getAncestorOfClass(NodeView.class, instance.insideComponent);
            if (view != null && node.equals(view.getModel()))
                return;
            instance.hideTipWindow();
        }

        public void onDeselect(NodeModel node) {
        }
    };
    mapController.addNodeSelectionListener(nodeSelectionListener);
    modeController.addExtension(NodeTooltipManager.class, instance);
    return instance;
}
Also used : NodeMoveEvent(org.freeplane.features.map.NodeMoveEvent) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) NodeDeletionEvent(org.freeplane.features.map.NodeDeletionEvent) IFreeplanePropertyListener(org.freeplane.core.resources.IFreeplanePropertyListener) IMapChangeListener(org.freeplane.features.map.IMapChangeListener) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController)

Example 3 with INodeSelectionListener

use of org.freeplane.features.map.INodeSelectionListener in project freeplane by freeplane.

the class ReminderHook method createTimePanel.

private void createTimePanel() {
    final TimeManagement timeManagement = new TimeManagement(this);
    final int axis = BoxLayout.Y_AXIS;
    final JTimePanel timePanel = timeManagement.createTimePanel(null, false, 1);
    modeController.getMapController().addNodeSelectionListener(new INodeSelectionListener() {

        public void onSelect(NodeModel node) {
            timePanel.update(node);
        }

        public void onDeselect(NodeModel node) {
        }
    });
    modeController.getMapController().addNodeChangeListener(new INodeChangeListener() {

        public void nodeChanged(NodeChangeEvent event) {
            final NodeModel node = event.getNode();
            if (event.getProperty().equals(getExtensionClass()) && node.equals(modeController.getMapController().getSelectedNode()))
                timePanel.update(node);
        }
    });
    timePanel.setBorder(BorderFactory.createTitledBorder(TextUtils.getText("calendar_panel")));
    final JPanel tablePanel = new AttributePanelManager(modeController).getTablePanel();
    tablePanel.setBorder(BorderFactory.createTitledBorder(TextUtils.getText("attributes_attribute")));
    final Box panel = new Box(axis);
    panel.add(timePanel);
    panel.add(tablePanel);
    final JTabbedPane tabs = (JTabbedPane) modeController.getUserInputListenerFactory().getToolBar("/format").getComponent(1);
    final JScrollPane timeScrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    UITools.setScrollbarIncrement(timeScrollPane);
    tabs.add(TextUtils.getText("calendar_attributes_panel"), timeScrollPane);
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) JScrollPane(javax.swing.JScrollPane) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) JPanel(javax.swing.JPanel) NodeModel(org.freeplane.features.map.NodeModel) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) JTabbedPane(javax.swing.JTabbedPane) AttributePanelManager(org.freeplane.view.swing.map.attribute.AttributePanelManager) Box(javax.swing.Box) JTimePanel(org.freeplane.view.swing.features.time.mindmapmode.TimeManagement.JTimePanel)

Example 4 with INodeSelectionListener

use of org.freeplane.features.map.INodeSelectionListener in project freeplane by freeplane.

the class SModeControllerFactory method createController.

Controller createController(final JDialog dialog) {
    Controller currentController = Controller.getCurrentController();
    final Controller controller = new Controller(ResourceController.getResourceController());
    Controller.setCurrentController(controller);
    final MapViewController mapViewController = new MMapViewController(controller);
    final DialogController viewController = new DialogController(controller, mapViewController, dialog);
    controller.setViewController(viewController);
    controller.addExtension(HighlightController.class, new HighlightController());
    controller.addAction(currentController.getAction("AboutAction"));
    FilterController.install();
    TextController.install();
    controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
    controller.addAction(new ShowSelectionAsRectangleAction());
    modeController = new SModeController(controller);
    controller.selectModeForBuild(modeController);
    modeController.addAction(new NewUserStyleAction());
    modeController.addAction(new DeleteUserStyleAction());
    modeController.addAction(new NewLevelStyleAction());
    modeController.addAction(new DeleteLevelStyleAction());
    modeController.addAction(new SetAcceleratorOnNextClickAction());
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
    userInputListenerFactory.setNodeMouseMotionListener(new DefaultNodeMouseMotionListener());
    userInputListenerFactory.setNodeMouseWheelListener(new MNodeMouseWheelListener(userInputListenerFactory.getMapMouseWheelListener()));
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addExtension(ModelessAttributeController.class, new ModelessAttributeController());
    new MMapController(modeController);
    ModelessAttributeController.installConditions();
    new MTextController(modeController).install(modeController);
    SpellCheckerController.install(modeController);
    new MIconController(modeController).install(modeController);
    NodeStyleController.install(new MNodeStyleController(modeController));
    LocationController.install(new MLocationController());
    EdgeController.install(new MEdgeController(modeController));
    CloudController.install(new MCloudController(modeController));
    NoteController.install(new MNoteController(modeController));
    LinkController.install(new MLinkController(modeController));
    MFileManager.install(new MFileManager());
    MMapIO.install(modeController);
    final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
    logicalStyleController.initS();
    LogicalStyleController.install(logicalStyleController);
    AttributeController.install(new MAttributeController(modeController));
    FormatController.install(new FormatController());
    IconController.installConditionControllers();
    final ScannerController scannerController = new ScannerController();
    ScannerController.install(scannerController);
    scannerController.addParsersForStandardFormats();
    modeController.addAction(new EditAttributesAction());
    userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
    final JPopupMenu popupmenu = new JPopupMenu();
    userInputListenerFactory.setNodePopupMenu(popupmenu);
    final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
    UIComponentVisibilityDispatcher.install(viewController, toolBar, "toolbarVisible");
    userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
    userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
    userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
    modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
    MapStyle.install(false);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    if (extentionInstaller != null)
        extentionInstaller.installExtensions(controller);
    final SModeController modeController = this.modeController;
    final StyleEditorPanel styleEditorPanel = new StyleEditorPanel(modeController, null, false);
    modeController.addAction(new ShowFormatPanelAction());
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(new INodeSelectionListener() {

        @Override
        public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            if (selection.size() == 1 && node.depth() >= 2) {
                return;
            }
            final NodeModel nextSelection;
            if (node.depth() < 2) {
                if (node.depth() == 1 && node.hasChildren()) {
                    nextSelection = node.getChildAt(0);
                } else {
                    nextSelection = (node.getMap().getRootNode().getChildAt(0).getChildAt(0));
                }
            } else {
                nextSelection = node;
            }
            EventQueue.invokeLater(new Runnable() {

                @Override
                public void run() {
                    selection.selectAsTheOnlyOneSelected(nextSelection);
                }
            });
        }

        @Override
        public void onDeselect(final NodeModel node) {
        }
    });
    mapController.addNodeChangeListener(new INodeChangeListener() {

        @Override
        public void nodeChanged(NodeChangeEvent event) {
            final NodeModel node = event.getNode();
            if (node.getUserObject().equals(MapStyleModel.DEFAULT_STYLE)) {
                mapController.fireMapChanged(new MapChangeEvent(this, node.getMap(), MapStyle.MAP_STYLES, null, null));
            }
        }
    });
    final JScrollPane styleScrollPane = new JScrollPane(styleEditorPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    UITools.setScrollbarIncrement(styleScrollPane);
    // styleEditorPanel.setPreferredSize(new Dimension(200, 200));
    userInputListenerFactory.addToolBar("/format", ViewController.RIGHT, styleScrollPane);
    UIComponentVisibilityDispatcher.install(viewController, styleScrollPane, "styleScrollPaneVisible");
    modeController.addExtension(MUIFactory.class, new MUIFactory());
    final Set<String> emptySet = Collections.emptySet();
    modeController.updateMenus("/xml/stylemodemenu.xml", emptySet);
    this.modeController = null;
    return controller;
}
Also used : MUIFactory(org.freeplane.features.styles.mindmapmode.MUIFactory) StyleEditorPanel(org.freeplane.features.styles.mindmapmode.styleeditorpanel.StyleEditorPanel) MAttributeController(org.freeplane.features.attribute.mindmapmode.MAttributeController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) ShowFormatPanelAction(org.freeplane.features.styles.mindmapmode.ShowFormatPanelAction) ModelessAttributeController(org.freeplane.features.attribute.ModelessAttributeController) NodeModel(org.freeplane.features.map.NodeModel) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) SetAcceleratorOnNextClickAction(org.freeplane.core.ui.SetAcceleratorOnNextClickAction) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) EditAttributesAction(org.freeplane.view.swing.map.attribute.EditAttributesAction) DefaultNodeMouseMotionListener(org.freeplane.view.swing.ui.DefaultNodeMouseMotionListener) MMapViewController(org.freeplane.view.swing.map.mindmapmode.MMapViewController) MapViewController(org.freeplane.view.swing.map.MapViewController) MNoteController(org.freeplane.features.note.mindmapmode.MNoteController) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) ViewLayoutTypeAction(org.freeplane.view.swing.map.ViewLayoutTypeAction) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) IMapSelection(org.freeplane.features.map.IMapSelection) FormatController(org.freeplane.features.format.FormatController) MMapMouseListener(org.freeplane.view.swing.ui.mindmapmode.MMapMouseListener) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) MNodeMouseWheelListener(org.freeplane.view.swing.ui.mindmapmode.MNodeMouseWheelListener) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) JScrollPane(javax.swing.JScrollPane) MMapViewController(org.freeplane.view.swing.map.mindmapmode.MMapViewController) HighlightController(org.freeplane.features.highlight.HighlightController) AttributeController(org.freeplane.features.attribute.AttributeController) MNoteController(org.freeplane.features.note.mindmapmode.MNoteController) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) EdgeController(org.freeplane.features.edge.EdgeController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MAttributeController(org.freeplane.features.attribute.mindmapmode.MAttributeController) FilterController(org.freeplane.features.filter.FilterController) 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) MMapViewController(org.freeplane.view.swing.map.mindmapmode.MMapViewController) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) ModelessAttributeController(org.freeplane.features.attribute.ModelessAttributeController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) SpellCheckerController(org.freeplane.features.spellchecker.mindmapmode.SpellCheckerController) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) NoteController(org.freeplane.features.note.NoteController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) MapViewController(org.freeplane.view.swing.map.MapViewController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) HighlightController(org.freeplane.features.highlight.HighlightController) LocationController(org.freeplane.features.nodelocation.LocationController) ModeController(org.freeplane.features.mode.ModeController) MLocationController(org.freeplane.features.nodelocation.mindmapmode.MLocationController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) ScannerController(org.freeplane.features.format.ScannerController) ScannerController(org.freeplane.features.format.ScannerController) JPopupMenu(javax.swing.JPopupMenu) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) ToggleToolbarAction(org.freeplane.features.ui.ToggleToolbarAction) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) MTextController(org.freeplane.features.text.mindmapmode.MTextController) ShowSelectionAsRectangleAction(org.freeplane.core.ui.ShowSelectionAsRectangleAction)

Example 5 with INodeSelectionListener

use of org.freeplane.features.map.INodeSelectionListener in project freeplane by freeplane.

the class MLogicalStyleController method initM.

public void initM() {
    final ModeController modeController = Controller.getCurrentModeController();
    modeController.getMapController().addNodeChangeListener(new StyleRemover());
    modeController.registerExtensionCopier(new ExtensionCopier());
    modeController.addAction(new RedefineStyleAction());
    modeController.addAction(new NewUserStyleAction());
    modeController.addAction(new ManageMapConditionalStylesAction());
    modeController.addAction(new ManageNodeConditionalStylesAction());
    modeController.addAction(new CopyStyleExtensionsAction());
    if (modeController.getModeName().equals("MindMap")) {
        modeController.addAction(new MapBackgroundColorAction());
        modeController.addAction(new MapBackgroundImageAction());
        modeController.addAction(new MapBackgroundClearAction());
        modeController.addAction(new SetBooleanMapPropertyAction(MapStyle.FIT_TO_VIEWPORT));
        modeController.addAction(new CopyMapStylesAction());
    }
    if (!modeController.getController().getViewController().isHeadless()) {
        modeController.addUiBuilder(Phase.ACTIONS, "style_actions", new StyleMenuBuilder(modeController), new ChildActionEntryRemover(modeController));
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {

            public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
            }

            public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
                userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
            }
        });
        final MapController mapController = modeController.getMapController();
        mapController.addMapChangeListener(new IMapChangeListener() {

            public void onPreNodeMoved(NodeMoveEvent nodeMoveEvent) {
            }

            public void onPreNodeDelete(NodeDeletionEvent nodeDeletionEvent) {
            }

            public void onNodeMoved(NodeMoveEvent nodeMoveEvent) {
            }

            public void onNodeInserted(final NodeModel parent, final NodeModel child, final int newIndex) {
            }

            public void onNodeDeleted(NodeDeletionEvent nodeDeletionEvent) {
            }

            public void mapChanged(final MapChangeEvent event) {
                if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
                    userInputListenerFactory.rebuildMenus(STYLE_ACTIONS);
                }
            }
        });
        mapController.addNodeSelectionListener(new INodeSelectionListener() {

            public void onSelect(final NodeModel node) {
                selectActions();
            }

            public void onDeselect(final NodeModel node) {
            }
        });
    }
}
Also used : IMapChangeListener(org.freeplane.features.map.IMapChangeListener) ChildActionEntryRemover(org.freeplane.core.ui.menubuilders.generic.ChildActionEntryRemover) MapBackgroundImageAction(org.freeplane.view.swing.features.filepreview.MapBackgroundImageAction) IExtensionCopier(org.freeplane.features.map.IExtensionCopier) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) NodeModel(org.freeplane.features.map.NodeModel) NodeDeletionEvent(org.freeplane.features.map.NodeDeletionEvent) MapBackgroundClearAction(org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) SetBooleanMapPropertyAction(org.freeplane.features.styles.SetBooleanMapPropertyAction) MapController(org.freeplane.features.map.MapController) NodeMoveEvent(org.freeplane.features.map.NodeMoveEvent) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener)

Aggregations

INodeSelectionListener (org.freeplane.features.map.INodeSelectionListener)7 NodeModel (org.freeplane.features.map.NodeModel)7 MapController (org.freeplane.features.map.MapController)5 INodeChangeListener (org.freeplane.features.map.INodeChangeListener)4 NodeChangeEvent (org.freeplane.features.map.NodeChangeEvent)4 MapChangeEvent (org.freeplane.features.map.MapChangeEvent)3 JScrollPane (javax.swing.JScrollPane)2 AMapChangeListenerAdapter (org.freeplane.features.map.AMapChangeListenerAdapter)2 IMapChangeListener (org.freeplane.features.map.IMapChangeListener)2 IMapSelection (org.freeplane.features.map.IMapSelection)2 NodeDeletionEvent (org.freeplane.features.map.NodeDeletionEvent)2 NodeMoveEvent (org.freeplane.features.map.NodeMoveEvent)2 Controller (org.freeplane.features.mode.Controller)2 ModeController (org.freeplane.features.mode.ModeController)2 Container (java.awt.Container)1 ActionEvent (java.awt.event.ActionEvent)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 URI (java.net.URI)1 AbstractAction (javax.swing.AbstractAction)1