Search in sources :

Example 6 with MapChangeEvent

use of org.freeplane.features.map.MapChangeEvent 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()) {
        final IUserInputListenerFactory userInputListenerFactory = modeController.getUserInputListenerFactory();
        final MenuBuilder menuBuilder = userInputListenerFactory.getMenuBuilder(MenuBuilder.class);
        // TODO RIBBONS - apply to ribbons as well
        Controller.getCurrentController().getMapViewManager().addMapSelectionListener(new IMapSelectionListener() {

            public void beforeMapChange(final MapModel oldMap, final MapModel newMap) {
                removeStyleMenu(menuBuilder, "main_menu_styles");
                removeStyleMenu(menuBuilder, "node_popup_styles");
            }

            public void afterMapChange(final MapModel oldMap, final MapModel newMap) {
                addStyleMenu(menuBuilder, "main_menu_styles", newMap);
                addStyleMenu(menuBuilder, "node_popup_styles", newMap);
            }
        });
        final MapController mapController = modeController.getMapController();
        mapController.addMapChangeListener(new IMapChangeListener() {

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

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

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

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

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

            public void mapChanged(final MapChangeEvent event) {
                if (event.getProperty().equals(MapStyle.MAP_STYLES)) {
                    removeStyleMenu(menuBuilder, "main_menu_styles");
                    addStyleMenu(menuBuilder, "main_menu_styles", event.getMap());
                    removeStyleMenu(menuBuilder, "node_popup_styles");
                    addStyleMenu(menuBuilder, "node_popup_styles", event.getMap());
                }
            }
        });
        mapController.addNodeSelectionListener(new INodeSelectionListener() {

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

            public void onDeselect(final NodeModel node) {
            }
        });
    }
}
Also used : IMapSelectionListener(org.freeplane.features.map.IMapSelectionListener) IMapChangeListener(org.freeplane.features.map.IMapChangeListener) IUserInputListenerFactory(org.freeplane.core.ui.IUserInputListenerFactory) 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) MenuBuilder(org.freeplane.core.ui.MenuBuilder) MapController(org.freeplane.features.map.MapController) INodeSelectionListener(org.freeplane.features.map.INodeSelectionListener) NodeModel(org.freeplane.features.map.NodeModel) MapBackgroundClearAction(org.freeplane.view.swing.features.filepreview.MapBackgroundClearAction) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Example 7 with MapChangeEvent

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

the class MapStyle method setBackgroundColor.

public void setBackgroundColor(final MapStyleModel model, final Color actionColor) {
    final Color oldColor = model.getBackgroundColor();
    if (actionColor == oldColor || actionColor != null && actionColor.equals(oldColor)) {
        return;
    }
    final IActor actor = new IActor() {

        public void act() {
            model.setBackgroundColor(actionColor);
            Controller.getCurrentModeController().getMapController().fireMapChanged(new MapChangeEvent(MapStyle.this, Controller.getCurrentController().getMap(), MapStyle.RESOURCES_BACKGROUND_COLOR, oldColor, actionColor));
        }

        public String getDescription() {
            return "MapStyle.setBackgroundColor";
        }

        public void undo() {
            model.setBackgroundColor(oldColor);
            Controller.getCurrentModeController().getMapController().fireMapChanged(new MapChangeEvent(MapStyle.this, Controller.getCurrentController().getMap(), MapStyle.RESOURCES_BACKGROUND_COLOR, actionColor, oldColor));
        }
    };
    Controller.getCurrentModeController().execute(actor, Controller.getCurrentController().getMap());
}
Also used : Color(java.awt.Color) IActor(org.freeplane.core.undo.IActor) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Example 8 with MapChangeEvent

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

the class MapStyle method setProperty.

public void setProperty(final MapModel model, final String key, final String newValue) {
    final MapStyleModel styleModel = MapStyleModel.getExtension(model);
    final String oldValue = styleModel.getProperty(key);
    if (oldValue == newValue || oldValue != null && oldValue.equals(newValue)) {
        return;
    }
    IActor actor = new IActor() {

        public void undo() {
            setPropertyWithoutUndo(model, key, oldValue);
        }

        public String getDescription() {
            return "set map style property";
        }

        public void act() {
            setPropertyWithoutUndo(model, key, newValue);
        }

        private void setPropertyWithoutUndo(final MapModel model, final String key, final String newValue) {
            styleModel.setProperty(key, newValue);
            Controller.getCurrentModeController().getMapController().fireMapChanged(new MapChangeEvent(MapStyle.this, model, key, oldValue, newValue));
        }
    };
    Controller.getCurrentModeController().execute(actor, model);
}
Also used : IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

Example 9 with MapChangeEvent

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

the class ModelessAttributeController method setAttributeViewType.

protected void setAttributeViewType(final MapModel map, final String type) {
    final String attributeViewType = getAttributeViewType(map);
    if (attributeViewType != null && attributeViewType != type) {
        final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
        attributes.setAttributeViewType(type);
        final MapChangeEvent mapChangeEvent = new MapChangeEvent(this, map, ATTRIBUTE_VIEW_TYPE, attributeViewType, type);
        Controller.getCurrentModeController().getMapController().fireMapChanged(mapChangeEvent);
    }
}
Also used : MapChangeEvent(org.freeplane.features.map.MapChangeEvent)

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