Search in sources :

Example 31 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class MapController method newMap.

/**
 *@throws XMLException
 * @deprecated -- use MapIO
 */
@Deprecated
public boolean newMap(final URL url) throws FileNotFoundException, XMLParseException, IOException, URISyntaxException, XMLException {
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    if (mapViewManager.tryToChangeToMapView(url))
        return false;
    try {
        if (AddOnsController.getController().installIfAppropriate(url))
            return false;
        Controller.getCurrentController().getViewController().setWaitingCursor(true);
        final MapModel newModel = new MapModel();
        UrlManager.getController().loadCatchExceptions(url, newModel);
        newModel.setReadOnly(true);
        newModel.setSaved(true);
        fireMapCreated(newModel);
        newMapView(newModel);
        return true;
    } finally {
        Controller.getCurrentController().getViewController().setWaitingCursor(false);
    }
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager)

Example 32 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class AEditStylesAction method init.

protected void init() {
    this.controller = Controller.getCurrentController();
    if (dialog != null) {
        Controller.setCurrentController((Controller) dialog.getRootPane().getClientProperty(Controller.class));
        return;
    }
    dialog = new JDialog(Controller.getCurrentController().getViewController().getJFrame());
    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 controller = SModeControllerFactory.getInstance().createController(dialog);
    modeController = (SModeController) controller.getModeController();
    final ViewController viewController = controller.getViewController();
    viewController.init(controller);
    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);
            mapViewManager.close(true);
            Controller.setCurrentController(AEditStylesAction.this.controller);
            super.componentHidden(e);
            switch(modeController.getStatus()) {
                case JOptionPane.OK_OPTION:
                    if (undoHandler.canUndo()) {
                        commit();
                        break;
                    }
                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) ViewController(org.freeplane.features.ui.ViewController) JDialog(javax.swing.JDialog) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 33 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager 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);
    Controller.getCurrentModeController().getUserInputListenerFactory().getMenuBuilder(RibbonBuilder.class).setEnabled(true);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) Window(java.awt.Window) IUndoHandler(org.freeplane.core.undo.IUndoHandler) MapModel(org.freeplane.features.map.MapModel) RibbonBuilder(org.freeplane.core.ui.ribbon.RibbonBuilder)

Example 34 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class NodeHistory method go.

private void go(final boolean back) {
    final NodeHolder lastNodeHolder = currentNodeHolder;
    if (back) {
        if (canGoBack()) {
            nodeIterator.previous();
            nodeIterator.previous();
            currentNodeHolder = nodeIterator.next();
        } else {
            backAction.setEnabled(false);
            return;
        }
    } else {
        if (canGoForward()) {
            currentNodeHolder = nodeIterator.next();
        } else {
            forwardAction.setEnabled(false);
            return;
        }
    }
    if (lastNodeHolder.equals(currentNodeHolder)) {
        go(back);
        return;
    }
    final NodeModel toBeSelected = currentNodeHolder.getNode();
    if (removed(toBeSelected)) {
        currentNodeHolder = lastNodeHolder;
        go(back);
        return;
    }
    boolean changeModule = false;
    MapView newModule = null;
    if (lastNodeHolder.getHoldMapView() != currentNodeHolder.getHoldMapView()) {
        changeModule = true;
        newModule = currentNodeHolder.getMapView();
        if (newModule == null) {
            nodeIterator.remove();
            go(back);
            return;
        }
    }
    final boolean fChangeModule = changeModule;
    final MapView newView;
    if (fChangeModule) {
        newView = newModule;
        final Controller controller = newView.getModeController().getController();
        final IMapViewManager mapViewManager = controller.getMapViewManager();
        final boolean res = mapViewManager.changeToMapView(newView);
        if (!res) {
            LogUtils.warn("Can't change to map mapView " + newView);
            return;
        }
    } else {
        newView = currentNodeHolder.getHoldMapView();
    }
    if (!toBeSelected.isRoot()) {
        newView.getModeController().getMapController().setFolded(toBeSelected.getParentNode(), false);
    }
    newView.getModeController().getMapController().select(toBeSelected);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) NodeModel(org.freeplane.features.map.NodeModel) MapView(org.freeplane.view.swing.map.MapView) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LinkController(org.freeplane.features.link.LinkController)

Example 35 with IMapViewManager

use of org.freeplane.features.ui.IMapViewManager in project freeplane by freeplane.

the class EditNoteInDialogAction method actionPerformed.

/*
	 * (non-Javadoc)
	 * @see
	 * freeplane.controller.actions.ActorXml#act(freeplane.controller.actions.
	 * generated.instance.XmlAction)
	 */
public void actionPerformed(final ActionEvent arg0) {
    final Controller controller = Controller.getCurrentController();
    final NodeModel nodeModel = controller.getSelection().getSelected();
    final IMapViewManager viewController = controller.getMapViewManager();
    final Component node = viewController.getComponent(nodeModel);
    node.requestFocus();
    edit(nodeModel);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) NodeModel(org.freeplane.features.map.NodeModel) Controller(org.freeplane.features.mode.Controller) Component(java.awt.Component) EditedComponent(org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent)

Aggregations

IMapViewManager (org.freeplane.features.ui.IMapViewManager)35 Component (java.awt.Component)13 Controller (org.freeplane.features.mode.Controller)13 MapModel (org.freeplane.features.map.MapModel)12 ModeController (org.freeplane.features.mode.ModeController)11 JComponent (javax.swing.JComponent)7 URL (java.net.URL)5 ResourceController (org.freeplane.core.resources.ResourceController)5 NodeModel (org.freeplane.features.map.NodeModel)5 MapView (org.freeplane.view.swing.map.MapView)5 Point (java.awt.Point)4 JTextComponent (javax.swing.text.JTextComponent)4 IUndoHandler (org.freeplane.core.undo.IUndoHandler)3 LinkController (org.freeplane.features.link.LinkController)3 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)3 ViewController (org.freeplane.features.ui.ViewController)3 Color (java.awt.Color)2 Dimension (java.awt.Dimension)2 ComponentAdapter (java.awt.event.ComponentAdapter)2 ComponentEvent (java.awt.event.ComponentEvent)2