Search in sources :

Example 76 with Controller

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

the class MTextController method joinNodes.

public void joinNodes(final List<NodeModel> selectedNodes, final String separator) {
    if (selectedNodes.isEmpty())
        return;
    final NodeModel selectedNode = selectedNodes.get(0);
    for (final NodeModel node : selectedNodes) {
        if (node != selectedNode && node.subtreeContainsCloneOf(selectedNode)) {
            UITools.errorMessage(TextUtils.getText("cannot_move_into_child_node"));
            return;
        }
    }
    String joinedContent = "";
    final Controller controller = Controller.getCurrentController();
    boolean isHtml = false;
    final LinkedHashSet<MindIcon> icons = new LinkedHashSet<MindIcon>();
    for (final NodeModel node : selectedNodes) {
        final String nodeContent = node.getText();
        icons.addAll(node.getIcons());
        final boolean isHtmlNode = HtmlUtils.isHtmlNode(nodeContent);
        joinedContent = addContent(joinedContent, isHtml, nodeContent, isHtmlNode, separator);
        if (node != selectedNode) {
            final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
            mapController.moveNodes(node.getChildren(), selectedNode, selectedNode.getChildCount());
            mapController.deleteNode(node);
        }
        isHtml = isHtml || isHtmlNode;
    }
    controller.getSelection().selectAsTheOnlyOneSelected(selectedNode);
    setNodeText(selectedNode, joinedContent);
    final MIconController iconController = (MIconController) IconController.getController();
    iconController.removeAllIcons(selectedNode);
    for (final MindIcon icon : icons) {
        iconController.addIcon(selectedNode, icon);
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) NodeModel(org.freeplane.features.map.NodeModel) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MindIcon(org.freeplane.features.icon.MindIcon) 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)

Example 77 with Controller

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

the class StyleEditorPanel method addListeners.

private void addListeners() {
    final Controller controller = Controller.getCurrentController();
    final ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addNodeSelectionListener(new INodeSelectionListener() {

        public void onSelect(final NodeModel node) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            if (selection.size() == 1) {
                setComponentsEnabled(true);
                setStyle(node);
            }
        }

        public void setComponentsEnabled(boolean enabled) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
                panel.getComponent(i).setEnabled(enabled);
            }
        }

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

        public void nodeChanged(final NodeChangeEvent event) {
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = event.getNode();
            if (selection.getSelected().equals(node)) {
                setStyle(node);
            }
        }
    });
    mapController.addMapChangeListener(new AMapChangeListenerAdapter() {

        @Override
        public void mapChanged(MapChangeEvent event) {
            if (!MapStyle.MAP_STYLES.equals(event.getProperty()))
                return;
            final IMapSelection selection = controller.getSelection();
            if (selection == null) {
                return;
            }
            final NodeModel node = selection.getSelected();
            setStyle(node);
        }
    });
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) IMapSelection(org.freeplane.features.map.IMapSelection) ModeController(org.freeplane.features.mode.ModeController) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) Container(java.awt.Container) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Example 78 with Controller

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

the class FilterController method install.

public static void install() {
    final Controller controller = Controller.getCurrentController();
    final FilterController extension = new FilterController();
    controller.addExtension(FilterController.class, extension);
    controller.getExtension(HighlightController.class).addNodeHighlighter(new NodeHighlighter() {

        @Override
        public boolean isNodeHighlighted(NodeModel node, boolean isPrinting) {
            return !isPrinting && FilterController.getController(controller).isNodeHighlighted(node);
        }

        @Override
        public void configure(Graphics2D g, boolean isPrinting) {
            g.setColor(Color.MAGENTA);
        }
    });
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) NodeHighlighter(org.freeplane.features.highlight.NodeHighlighter) HighlightController(org.freeplane.features.highlight.HighlightController) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) HighlightController(org.freeplane.features.highlight.HighlightController) FrameController(org.freeplane.features.ui.FrameController) Graphics2D(java.awt.Graphics2D)

Example 79 with Controller

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

the class MapViewDockingWindows method selectMap.

private void selectMap(final int tabIndexChange) {
    final Controller controller = Controller.getCurrentController();
    MapView mapView = (MapView) controller.getMapViewManager().getMapViewComponent();
    if (mapView != null) {
        AbstractTabWindow tabWindow = (AbstractTabWindow) SwingUtilities.getAncestorOfClass(AbstractTabWindow.class, mapView);
        if (tabWindow != null) {
            final DockingWindow selectedWindow = tabWindow.getSelectedWindow();
            final int childWindowIndex = tabWindow.getChildWindowIndex(selectedWindow);
            final int childWindowCount = tabWindow.getChildWindowCount();
            final int nextWindowIndex = (childWindowIndex + childWindowCount + tabIndexChange) % childWindowCount;
            final View nextWindow = (View) tabWindow.getChildWindow(nextWindowIndex);
            final Component nextMapView = getContainedMapView(nextWindow);
            Controller.getCurrentController().getMapViewManager().changeToMapView(nextMapView);
        }
    }
}
Also used : AbstractTabWindow(net.infonode.docking.AbstractTabWindow) DockingWindow(net.infonode.docking.DockingWindow) MapView(org.freeplane.view.swing.map.MapView) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) Component(java.awt.Component) JComponent(javax.swing.JComponent) NodeView(org.freeplane.view.swing.map.NodeView) MapView(org.freeplane.view.swing.map.MapView) View(net.infonode.docking.View)

Example 80 with Controller

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

the class BModeControllerFactory method createModeController.

public static BModeController createModeController() {
    final Controller controller = Controller.getCurrentController();
    modeController = new BModeController(controller);
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    new MapController(modeController);
    new IconController(modeController).install(modeController);
    UrlManager.install(new UrlManager());
    MapIO.install(modeController);
    AttributeController.install(new AttributeController(modeController));
    NodeStyleController.install(new NodeStyleController(modeController));
    EdgeController.install(new EdgeController(modeController));
    CloudController.install(new CloudController(modeController));
    NoteController.install(new NoteController());
    new TextController(modeController).install(modeController);
    LinkController.install(new LinkController(modeController));
    LogicalStyleController.install(new LogicalStyleController(modeController));
    try {
        ClipboardController.install(new ClipboardController());
    } catch (final AccessControlException e) {
        LogUtils.warn("can not access system clipboard, clipboard controller disabled");
    }
    LocationController.install(new LocationController());
    SummaryNode.install();
    FreeNode.install();
    MapStyle.install(true);
    final BToolbarContributor toolbarContributor = new BToolbarContributor();
    modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_url", toolbarContributor);
    controller.getMapViewManager().addMapViewChangeListener(toolbarContributor);
    userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
    final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
    FrameController frameController = (FrameController) controller.getViewController();
    UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
    userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
    userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
    userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
    FoldingController.install(new FoldingController());
    new ViewerController();
    EncryptionController.install(new EncryptionController(modeController));
    new AutomaticLayoutController();
    return modeController;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ClipboardController(org.freeplane.features.clipboard.ClipboardController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) LinkController(org.freeplane.features.link.LinkController) LocationController(org.freeplane.features.nodelocation.LocationController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) IconController(org.freeplane.features.icon.IconController) FoldingController(org.freeplane.features.map.FoldingController) FrameController(org.freeplane.features.ui.FrameController) NoteController(org.freeplane.features.note.NoteController) EdgeController(org.freeplane.features.edge.EdgeController) AttributeController(org.freeplane.features.attribute.AttributeController) TextController(org.freeplane.features.text.TextController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) AccessControlException(java.security.AccessControlException) AttributeController(org.freeplane.features.attribute.AttributeController) EncryptionController(org.freeplane.features.encrypt.EncryptionController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) NoteController(org.freeplane.features.note.NoteController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) EdgeController(org.freeplane.features.edge.EdgeController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) FilterController(org.freeplane.features.filter.FilterController) MapController(org.freeplane.features.map.MapController) LocationController(org.freeplane.features.nodelocation.LocationController) FoldingController(org.freeplane.features.map.FoldingController) FrameController(org.freeplane.features.ui.FrameController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) JPopupMenu(javax.swing.JPopupMenu) MapController(org.freeplane.features.map.MapController) EncryptionController(org.freeplane.features.encrypt.EncryptionController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CloudController(org.freeplane.features.cloud.CloudController) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar)

Aggregations

Controller (org.freeplane.features.mode.Controller)152 ModeController (org.freeplane.features.mode.ModeController)92 ResourceController (org.freeplane.core.resources.ResourceController)69 NodeModel (org.freeplane.features.map.NodeModel)46 MapController (org.freeplane.features.map.MapController)41 MapModel (org.freeplane.features.map.MapModel)34 LinkController (org.freeplane.features.link.LinkController)32 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)32 TextController (org.freeplane.features.text.TextController)27 MMapController (org.freeplane.features.map.mindmapmode.MMapController)24 ViewController (org.freeplane.features.ui.ViewController)23 IconController (org.freeplane.features.icon.IconController)22 Component (java.awt.Component)19 FilterController (org.freeplane.features.filter.FilterController)17 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)17 FormatController (org.freeplane.features.format.FormatController)16 ScannerController (org.freeplane.features.format.ScannerController)16 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)15 File (java.io.File)14 MTextController (org.freeplane.features.text.mindmapmode.MTextController)14