Search in sources :

Example 96 with ModeController

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

the class EditStylesAction method commit.

void commit() {
    final MapModel currentMap = Controller.getCurrentController().getMap();
    LogicalStyleController.getController().refreshMap(currentMap);
    final ModeController currentModeController = Controller.getCurrentModeController();
    currentModeController.commit();
}
Also used : MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController)

Example 97 with ModeController

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

the class SModeControllerFactory method createController.

Controller createController(final JDialog dialog) {
    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);
    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());
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController, false);
    userInputListenerFactory.setNodeMouseMotionListener(new DefaultNodeMouseMotionListener());
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addExtension(ModelessAttributeController.class, new ModelessAttributeController());
    new MMapController(modeController);
    userInputListenerFactory.getMenuBuilder(RibbonBuilder.class).setEnabled(false);
    TextController.install(new MTextController(modeController));
    SpellCheckerController.install(modeController);
    IconController.install(new MIconController(modeController));
    NodeStyleController.install(new MNodeStyleController(modeController));
    EdgeController.install(new MEdgeController(modeController));
    CloudController.install(new MCloudController(modeController));
    NoteController.install(new MNoteController(modeController));
    LinkController.install(new MLinkController());
    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());
    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);
    final SModeController modeController = this.modeController;
    final StyleEditorPanel styleEditorPanel = new StyleEditorPanel(modeController, null, false);
    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 && node.depth() >= 2) {
                return;
            }
            final NodeModel nextSelection;
            if (node.depth() < 2) {
                if (node.depth() == 1 && node.hasChildren()) {
                    nextSelection = (NodeModel) node.getChildAt(0);
                } else {
                    nextSelection = (NodeModel) (node.getMap().getRootNode().getChildAt(0).getChildAt(0));
                }
            } else {
                nextSelection = node;
            }
            EventQueue.invokeLater(new Runnable() {

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

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

        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);
    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) MAttributeController(org.freeplane.features.attribute.mindmapmode.MAttributeController) IMapSelection(org.freeplane.features.map.IMapSelection) MMapController(org.freeplane.features.map.mindmapmode.MMapController) FormatController(org.freeplane.features.format.FormatController) MMapMouseListener(org.freeplane.view.swing.ui.mindmapmode.MMapMouseListener) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) 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) MLogicalStyleController(org.freeplane.features.styles.mindmapmode.MLogicalStyleController) MCloudController(org.freeplane.features.cloud.mindmapmode.MCloudController) NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) JScrollPane(javax.swing.JScrollPane) MMapViewController(org.freeplane.view.swing.map.mindmapmode.MMapViewController) MIconController(org.freeplane.features.icon.mindmapmode.MIconController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) EditAttributesAction(org.freeplane.view.swing.map.attribute.EditAttributesAction) 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) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) ScannerController(org.freeplane.features.format.ScannerController) DefaultNodeMouseMotionListener(org.freeplane.view.swing.ui.DefaultNodeMouseMotionListener) ScannerController(org.freeplane.features.format.ScannerController) MMapViewController(org.freeplane.view.swing.map.mindmapmode.MMapViewController) MapViewController(org.freeplane.view.swing.map.MapViewController) RibbonBuilder(org.freeplane.core.ui.ribbon.RibbonBuilder) JPopupMenu(javax.swing.JPopupMenu) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController) MNoteController(org.freeplane.features.note.mindmapmode.MNoteController) ToggleToolbarAction(org.freeplane.features.ui.ToggleToolbarAction) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) ViewLayoutTypeAction(org.freeplane.view.swing.map.ViewLayoutTypeAction) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar) MTextController(org.freeplane.features.text.mindmapmode.MTextController) ShowSelectionAsRectangleAction(org.freeplane.core.ui.ShowSelectionAsRectangleAction)

Example 98 with ModeController

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

the class ActivatorImpl method startFramework.

private void startFramework(final BundleContext context) {
    registerClasspathUrlHandler(context);
    if (null == System.getProperty("org.freeplane.core.dir.lib", null)) {
        final File root = new File(FreeplaneGUIStarter.getResourceBaseDir()).getAbsoluteFile().getParentFile();
        try {
            String rootUrl = root.toURI().toURL().toString();
            if (!rootUrl.endsWith("/")) {
                rootUrl = rootUrl + "/";
            }
            final String libUrl = rootUrl + "core/org.freeplane.core/lib/";
            System.setProperty("org.freeplane.core.dir.lib", libUrl);
        } catch (final MalformedURLException e) {
        }
    }
    // initialize ApplicationController - SingleInstanceManager needs the configuration
    starter = createStarter();
    final SingleInstanceManager singleInstanceManager = new SingleInstanceManager(starter);
    singleInstanceManager.start(getCallParameters());
    if (singleInstanceManager.isSlave()) {
        LogUtils.info("opened files in master - exiting now");
        System.exit(0);
    } else if (singleInstanceManager.isMasterPresent()) {
        starter.setDontLoadLastMaps();
    }
    loadPlugins(context);
    final Controller controller = starter.createController();
    starter.createModeControllers(controller);
    try {
        final ServiceReference[] controllerProviders = context.getServiceReferences(IControllerExtensionProvider.class.getName(), null);
        if (controllerProviders != null) {
            for (int i = 0; i < controllerProviders.length; i++) {
                final ServiceReference controllerProvider = controllerProviders[i];
                final IControllerExtensionProvider service = (IControllerExtensionProvider) context.getService(controllerProvider);
                service.installExtension(controller);
                context.ungetService(controllerProvider);
            }
        }
    } catch (final InvalidSyntaxException e) {
        e.printStackTrace();
    }
    try {
        final Set<String> modes = controller.getModes();
        for (final String modeName : modes) {
            final ServiceReference[] modeControllerProviders = context.getServiceReferences(IModeControllerExtensionProvider.class.getName(), "(mode=" + modeName + ")");
            if (modeControllerProviders != null) {
                final ModeController modeController = controller.getModeController(modeName);
                Controller.getCurrentController().selectModeForBuild(modeController);
                for (int i = 0; i < modeControllerProviders.length; i++) {
                    final ServiceReference modeControllerProvider = modeControllerProviders[i];
                    final IModeControllerExtensionProvider service = (IModeControllerExtensionProvider) context.getService(modeControllerProvider);
                    service.installExtension(modeController);
                    context.ungetService(modeControllerProvider);
                }
            }
        }
    } catch (final InvalidSyntaxException e) {
        e.printStackTrace();
    }
    if ("true".equals(System.getProperty("org.freeplane.exit_on_start", null))) {
        controller.getViewController().invokeLater(new Runnable() {

            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (final InterruptedException e) {
                }
                System.exit(0);
            }
        });
        return;
    }
    controller.getViewController().invokeLater(new Runnable() {

        public void run() {
            final Bundle[] bundles = context.getBundles();
            final HashSet<String> plugins = new HashSet<String>();
            for (Bundle bundle : bundles) {
                plugins.add(bundle.getSymbolicName());
            }
            FilterController.getController(controller).loadDefaultConditions();
            starter.buildMenus(controller, plugins);
            starter.createFrame(getCallParameters());
        }
    });
}
Also used : MalformedURLException(java.net.MalformedURLException) SingleInstanceManager(org.freeplane.main.application.SingleInstanceManager) Bundle(org.osgi.framework.Bundle) ModeController(org.freeplane.features.mode.ModeController) ResourceController(org.freeplane.core.resources.ResourceController) FilterController(org.freeplane.features.filter.FilterController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) ServiceReference(org.osgi.framework.ServiceReference) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) File(java.io.File) HashSet(java.util.HashSet)

Example 99 with ModeController

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

the class UpdateCheckAction method addUpdateButton.

private void addUpdateButton(final FreeplaneVersion lastVersion) {
    Controller controller = Controller.getCurrentController();
    final Set<String> modes = controller.getModes();
    for (final String mode : modes) {
        ModeController modeController = controller.getModeController(mode);
        if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
            final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
            if (lastVersion == null || lastVersion.compareTo(FreeplaneVersion.getVersion()) <= 0) {
                ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, "");
                if (menuBuilder.get(UPDATE_BUTTON_PATH) != null) {
                    menuBuilder.removeElement(UPDATE_BUTTON_PATH);
                }
                continue;
            }
            ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, lastVersion.toString());
            final String updateAvailable = TextUtils.format("new_version_available", lastVersion.toString());
            controller.getViewController().out(updateAvailable);
            putValue(SHORT_DESCRIPTION, updateAvailable);
            putValue(LONG_DESCRIPTION, updateAvailable);
            if (menuBuilder.get(UPDATE_BUTTON_PATH) == null) {
                menuBuilder.addAction(UPDATE_BUTTON_LOCATION, UPDATE_BUTTON_PATH, UpdateCheckAction.this, MenuBuilder.AS_CHILD);
            }
        }
    }
}
Also used : ModeController(org.freeplane.features.mode.ModeController) AddOnsController(org.freeplane.main.addons.AddOnsController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MenuBuilder(org.freeplane.core.ui.MenuBuilder)

Example 100 with ModeController

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

the class NodeView method isShortened.

public boolean isShortened() {
    final ModeController modeController = getMap().getModeController();
    final TextController textController = TextController.getController(modeController);
    final boolean textShortened = textController.isMinimized(getModel());
    return textShortened;
}
Also used : TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController)

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