Search in sources :

Example 1 with MapChangeEvent

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

the class LogicalStyleController method registerChangeListener.

private void registerChangeListener() {
    ModeController modeController = Controller.getCurrentModeController();
    final MapController mapController = modeController.getMapController();
    mapController.addMapChangeListener(new IMapChangeListener() {

        public void onPreNodeMoved(NodeModel oldParent, int oldIndex, NodeModel newParent, NodeModel child, int newIndex) {
            clearCache();
        }

        public void onPreNodeDelete(NodeModel oldParent, NodeModel selectedNode, int index) {
            clearCache();
        }

        public void onNodeMoved(NodeModel oldParent, int oldIndex, NodeModel newParent, NodeModel child, int newIndex) {
            clearCache();
        }

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

        public void onNodeDeleted(NodeModel parent, NodeModel child, int index) {
            clearCache();
        }

        public void mapChanged(MapChangeEvent event) {
            clearCache();
        }
    });
    mapController.addNodeChangeListener(new INodeChangeListener() {

        public void nodeChanged(NodeChangeEvent event) {
            clearCache();
        }
    });
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) NodeModel(org.freeplane.features.map.NodeModel) IMapChangeListener(org.freeplane.features.map.IMapChangeListener) INodeChangeListener(org.freeplane.features.map.INodeChangeListener) ModeController(org.freeplane.features.mode.ModeController) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) MapController(org.freeplane.features.map.MapController)

Example 2 with MapChangeEvent

use of org.freeplane.features.map.MapChangeEvent 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 3 with MapChangeEvent

use of org.freeplane.features.map.MapChangeEvent 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 4 with MapChangeEvent

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

the class MFileManager method save.

/**
 *@deprecated -- use MMapIO
 */
@Deprecated
public boolean save(final MapModel map, final File file) {
    if (file == null) {
        return saveAs(map);
    }
    try {
        if (null == map.getExtension(BackupFlag.class)) {
            map.addExtension(new BackupFlag());
            backup(file);
        }
        final String lockingUser = tryToLock(map, file);
        if (lockingUser != null) {
            UITools.informationMessage(Controller.getCurrentController().getViewController().getFrame(), TextUtils.format("map_locked_by_save_as", file.getName(), lockingUser));
            return false;
        }
    } catch (final Exception e) {
        UITools.informationMessage(Controller.getCurrentController().getViewController().getFrame(), TextUtils.format("locking_failed_by_save_as", file.getName()));
        return false;
    }
    final URL urlBefore = map.getURL();
    final boolean saved = saveInternal((MMapModel) map, file, false);
    if (!saved) {
        return false;
    }
    map.setReadOnly(false);
    final URL urlAfter = map.getURL();
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    mapController.fireMapChanged(new MapChangeEvent(this, map, UrlManager.MAP_URL, urlBefore, urlAfter));
    mapController.setSaved(map, true);
    return true;
}
Also used : MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapChangeEvent(org.freeplane.features.map.MapChangeEvent) XMLException(org.freeplane.n3.nanoxml.XMLException) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) XMLParseException(org.freeplane.n3.nanoxml.XMLParseException) MapConversionException(org.freeplane.features.url.MapConversionException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) URL(java.net.URL)

Example 5 with MapChangeEvent

use of org.freeplane.features.map.MapChangeEvent 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) {
                setStyle(node);
            }
        }

        public void onDeselect(final NodeModel node) {
        }
    });
    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);
        }
    });
    final IMapViewManager mapViewManager = controller.getMapViewManager();
    mapViewManager.addMapViewChangeListener(new IMapViewChangeListener() {

        public void beforeViewChange(final Component oldView, final Component newView) {
        }

        public void afterViewCreated(final Component mapView) {
        }

        public void afterViewClose(final Component oldView) {
        }

        public void afterViewChange(final Component oldView, final Component newView) {
            final Container panel = (Container) getComponent(0);
            for (int i = 0; i < panel.getComponentCount(); i++) {
                panel.getComponent(i).setEnabled(newView != null);
            }
        }
    });
}
Also used : NodeChangeEvent(org.freeplane.features.map.NodeChangeEvent) IMapViewChangeListener(org.freeplane.features.ui.IMapViewChangeListener) IMapSelection(org.freeplane.features.map.IMapSelection) ModeController(org.freeplane.features.mode.ModeController) EdgeController(org.freeplane.features.edge.EdgeController) MapController(org.freeplane.features.map.MapController) 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) MEdgeController(org.freeplane.features.edge.mindmapmode.MEdgeController) FormatController(org.freeplane.features.format.FormatController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ResourceController(org.freeplane.core.resources.ResourceController) 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) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) AMapChangeListenerAdapter(org.freeplane.features.map.AMapChangeListenerAdapter) MapController(org.freeplane.features.map.MapController) IMapViewManager(org.freeplane.features.ui.IMapViewManager) 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) Component(java.awt.Component)

Aggregations

MapChangeEvent (org.freeplane.features.map.MapChangeEvent)9 MapController (org.freeplane.features.map.MapController)5 NodeModel (org.freeplane.features.map.NodeModel)5 ModeController (org.freeplane.features.mode.ModeController)5 INodeChangeListener (org.freeplane.features.map.INodeChangeListener)4 INodeSelectionListener (org.freeplane.features.map.INodeSelectionListener)4 NodeChangeEvent (org.freeplane.features.map.NodeChangeEvent)4 IMapSelection (org.freeplane.features.map.IMapSelection)3 Controller (org.freeplane.features.mode.Controller)3 Container (java.awt.Container)2 ResourceController (org.freeplane.core.resources.ResourceController)2 IActor (org.freeplane.core.undo.IActor)2 CloudController (org.freeplane.features.cloud.CloudController)2 MCloudController (org.freeplane.features.cloud.mindmapmode.MCloudController)2 EdgeController (org.freeplane.features.edge.EdgeController)2 MEdgeController (org.freeplane.features.edge.mindmapmode.MEdgeController)2 FormatController (org.freeplane.features.format.FormatController)2 LinkController (org.freeplane.features.link.LinkController)2 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)2 AMapChangeListenerAdapter (org.freeplane.features.map.AMapChangeListenerAdapter)2