Search in sources :

Example 96 with MapModel

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

the class EditStylesAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final Controller currentController = Controller.getCurrentController();
    final MapModel map = currentController.getMap();
    final MapStyleModel mapStyleModel = MapStyleModel.getExtension(map);
    final MapModel styleMap = mapStyleModel.getStyleMap();
    if (styleMap == null) {
        UITools.errorMessage(TextUtils.getText("no_styles_found_in_map"));
        return;
    }
    final IMapViewManager mapViewManager = currentController.getMapViewManager();
    currentMapView = mapViewManager.getMapViewComponent();
    mapViewManager.changeToMapView((Component) null);
    final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
    undoHandler.startTransaction();
    init();
    SModeController modeController = getModeController();
    modeController.getMapController().newMapView(styleMap);
    Controller controller = modeController.getController();
    Component mapViewComponent = controller.getMapViewManager().getMapViewComponent();
    ((DialogController) controller.getViewController()).setMapView(mapViewComponent);
    dialog.setLocationRelativeTo(currentController.getViewController().getCurrentRootComponent());
    dialog.setVisible(true);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) MapStyleModel(org.freeplane.features.styles.MapStyleModel) IUndoHandler(org.freeplane.core.undo.IUndoHandler) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ViewController(org.freeplane.features.ui.ViewController) Component(java.awt.Component)

Example 97 with MapModel

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

the class NewLevelStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final MapModel map = Controller.getCurrentController().getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    NodeModel levelStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_AUTOMATIC_LAYOUT);
    final String styleName = "AutomaticLayout.level," + levelStyleParentNode.getChildCount();
    final IStyle styleObject = StyleFactory.create(TranslatedObject.format(styleName));
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel node = new NodeModel(map);
    node.setUserObject(styleObject);
    mapController.insertNode(node, levelStyleParentNode, false, false, true);
    mapController.select(node);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(node);
        }

        public String getDescription() {
            return "NewLevelStyle";
        }

        public void act() {
            styleModel.addStyleNode(node);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel)

Example 98 with MapModel

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

the class NewUserStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final String styleName = JOptionPane.showInputDialog(TextUtils.getText("enter_new_style_name"));
    if (styleName == null) {
        return;
    }
    final Controller controller = Controller.getCurrentController();
    final NodeModel selectedNode = controller.getSelection().getSelected();
    final MapModel map = controller.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final IStyle style = StyleFactory.create(styleName);
    if (null != styleModel.getStyleNode(style)) {
        UITools.errorMessage(TextUtils.getText("style_already_exists"));
        return;
    }
    final MMapController mapController = (MMapController) Controller.getCurrentModeController().getMapController();
    final NodeModel newNode = new NodeModel(map);
    newNode.setUserObject(style);
    Controller.getCurrentModeController().copyExtensions(LogicalStyleKeys.NODE_STYLE, selectedNode, newNode);
    Controller.getCurrentModeController().copyExtensions(Keys.ICONS, selectedNode, newNode);
    NodeModel userStyleParentNode = styleModel.getStyleNodeGroup(map, MapStyleModel.STYLES_USER_DEFINED);
    if (userStyleParentNode == null) {
        userStyleParentNode = new NodeModel(map);
        userStyleParentNode.setUserObject(new StyleTranslatedObject(MapStyleModel.STYLES_USER_DEFINED));
        mapController.insertNode(userStyleParentNode, map.getRootNode(), false, false, true);
    }
    mapController.insertNode(newNode, userStyleParentNode, false, false, true);
    mapController.select(newNode);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.removeStyleNode(newNode);
        }

        public String getDescription() {
            return "NewStyle";
        }

        public void act() {
            styleModel.addStyleNode(newNode);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : IStyle(org.freeplane.features.styles.IStyle) StyleTranslatedObject(org.freeplane.features.styles.StyleTranslatedObject) NodeModel(org.freeplane.features.map.NodeModel) MapStyleModel(org.freeplane.features.styles.MapStyleModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) Controller(org.freeplane.features.mode.Controller) MMapController(org.freeplane.features.map.mindmapmode.MMapController)

Example 99 with MapModel

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

the class SModeController method tryToCloseDialog.

void tryToCloseDialog() {
    final IMapViewManager mapViewManager = getController().getMapViewManager();
    final MapModel map = mapViewManager.getModel();
    final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
    final Window dialog = ((DialogController) getController().getViewController()).getDialog();
    if (!undoHandler.canUndo()) {
        dialog.setVisible(false);
        return;
    }
    final String text = TextUtils.getText("save_unsaved_styles");
    final String title = TextUtils.getText("SaveAction.text");
    final int returnVal = JOptionPane.showOptionDialog(dialog, text, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
    if ((returnVal == JOptionPane.CANCEL_OPTION) || (returnVal == JOptionPane.CLOSED_OPTION)) {
        return;
    }
    setStatus(returnVal == JOptionPane.YES_OPTION ? JOptionPane.OK_OPTION : JOptionPane.CANCEL_OPTION);
    dialog.setVisible(false);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) Window(java.awt.Window) IUndoHandler(org.freeplane.core.undo.IUndoHandler) MapModel(org.freeplane.features.map.MapModel)

Example 100 with MapModel

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

the class NodeList method exportSelectedRowsAndClose.

protected void exportSelectedRowsAndClose() {
    final int[] selectedRows = tableView.getSelectedRows();
    final List<NodeModel> selectedNodes = new ArrayList<NodeModel>();
    for (int i = 0; i < selectedRows.length; i++) {
        final int row = selectedRows[i];
        selectedNodes.add(getMindMapNode(row));
    }
    final ModeController mindMapController = Controller.getCurrentModeController();
    MFileManager.getController(mindMapController).newMapFromDefaultTemplate();
    final MapModel newMap = Controller.getCurrentController().getMap();
    for (final NodeModel node : selectedNodes) {
        final NodeModel copy = ClipboardController.getController().duplicate(node, false);
        if (copy != null) {
            mindMapController.getMapController().insertNodeIntoWithoutUndo(copy, newMap.getRootNode());
        }
    }
    disposeDialog();
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) ArrayList(java.util.ArrayList) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MapModel(org.freeplane.features.map.MapModel) Point(java.awt.Point)

Aggregations

MapModel (org.freeplane.features.map.MapModel)143 NodeModel (org.freeplane.features.map.NodeModel)47 ModeController (org.freeplane.features.mode.ModeController)35 Controller (org.freeplane.features.mode.Controller)31 IActor (org.freeplane.core.undo.IActor)27 MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)16 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)16 IUndoHandler (org.freeplane.core.undo.IUndoHandler)15 AttributeRegistry (org.freeplane.features.attribute.AttributeRegistry)14 IStyle (org.freeplane.features.styles.IStyle)14 File (java.io.File)13 MMapController (org.freeplane.features.map.mindmapmode.MMapController)13 URL (java.net.URL)12 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)11 MapStyleModel (org.freeplane.features.styles.MapStyleModel)10 IMapViewManager (org.freeplane.features.ui.IMapViewManager)10 MapController (org.freeplane.features.map.MapController)9 URI (java.net.URI)8 ResourceController (org.freeplane.core.resources.ResourceController)8 IOException (java.io.IOException)7