Search in sources :

Example 61 with MapModel

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

the class DeleteUserStyleAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    final Controller controller = modeController.getController();
    final NodeModel selected = controller.getSelection().getSelected();
    if (selected.depth() < 2) {
        UITools.errorMessage(TextUtils.getText("can_not_delete_style_group"));
        return;
    }
    final MapModel map = selected.getMap();
    final MapStyleModel styleModel = MapStyleModel.getExtension(map);
    final NodeModel styleNodeGroup = styleModel.getStyleNodeGroup(selected);
    if (!((StyleTranslatedObject) styleNodeGroup.getUserObject()).getObject().equals("styles.user-defined")) {
        UITools.errorMessage(TextUtils.getText("can_not_delete_predefined_style"));
        return;
    }
    final MMapController mapController = (MMapController) modeController.getMapController();
    mapController.deleteNode(selected);
    final IActor actor = new IActor() {

        public void undo() {
            styleModel.addStyleNode(selected);
        }

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

        public void act() {
            styleModel.removeStyleNode(selected);
        }
    };
    Controller.getCurrentModeController().execute(actor, map);
}
Also used : 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) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController)

Example 62 with MapModel

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

the class LastOpenedList method selectLastVisitedNode.

private boolean selectLastVisitedNode(RecentFile recentFile) {
    if (recentFile != null && recentFile.lastVisitedNodeId != null) {
        final MapModel map = Controller.getCurrentController().getMap();
        final NodeModel node = map.getNodeForID(recentFile.lastVisitedNodeId);
        if (node != null && node.hasVisibleContent()) {
            IMapSelection selection = Controller.getCurrentController().getSelection();
            // don't override node selection done by UriManager.loadURI()
            if (selection.isSelected(map.getRootNode()))
                selection.selectAsTheOnlyOneSelected(node);
            return true;
        }
    }
    return false;
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) MapModel(org.freeplane.features.map.MapModel)

Example 63 with MapModel

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

the class EditStylesAction method init.

private void init() {
    this.mainController = Controller.getCurrentController();
    if (dialog != null) {
        Controller.setCurrentController((Controller) dialog.getRootPane().getClientProperty(Controller.class));
        return;
    }
    dialog = new JDialog(UITools.getCurrentFrame());
    final WindowConfigurationStorage windowConfigurationStorage = new WindowConfigurationStorage(getKey() + ".dialog");
    windowConfigurationStorage.restoreDialogPositions(dialog);
    dialog.setModal(true);
    dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            getModeController().tryToCloseDialog();
        }
    });
    Controller styleDialogController = SModeControllerFactory.getInstance().createController(dialog);
    modeController = (SModeController) styleDialogController.getModeController();
    final ViewController viewController = styleDialogController.getViewController();
    viewController.init(styleDialogController);
    dialog.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentHidden(final ComponentEvent e) {
            final WindowConfigurationStorage windowConfigurationStorage = new WindowConfigurationStorage(getKey() + ".dialog");
            windowConfigurationStorage.storeDialogPositions(dialog);
            final IMapViewManager mapViewManager = modeController.getController().getMapViewManager();
            final MapModel map = mapViewManager.getModel();
            final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
            modeController.getMapController().closeWithoutSaving(map);
            Controller.setCurrentController(mainController);
            super.componentHidden(e);
            mainController.getMapViewManager().changeToMapView(currentMapView);
            currentMapView = null;
            switch(modeController.getStatus()) {
                case JOptionPane.OK_OPTION:
                    if (undoHandler.canUndo()) {
                        commit();
                        break;
                    }
                // $FALL-THROUGH$
                case JOptionPane.CANCEL_OPTION:
                    rollback();
            }
        }
    });
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) ViewController(org.freeplane.features.ui.ViewController) WindowEvent(java.awt.event.WindowEvent) WindowConfigurationStorage(org.freeplane.core.resources.WindowConfigurationStorage) WindowAdapter(java.awt.event.WindowAdapter) IUndoHandler(org.freeplane.core.undo.IUndoHandler) ComponentEvent(java.awt.event.ComponentEvent) 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) JDialog(javax.swing.JDialog) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 64 with MapModel

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

the class EditStylesAction method commit.

void commit() {
    final Controller currentController = Controller.getCurrentController();
    final MapModel currentMap = currentController.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) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) ViewController(org.freeplane.features.ui.ViewController)

Example 65 with MapModel

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

the class ShowNotesInMapAction method setSelected.

@Override
public void setSelected() {
    final MapModel map = Controller.getCurrentController().getMap();
    final boolean notesShown = map != null && NoteController.getController().showNotesInMap(map);
    setSelected(notesShown);
}
Also used : MapModel(org.freeplane.features.map.MapModel)

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