Search in sources :

Example 1 with ViewController

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

the class MapViewScrollPane method setScrollbarsVisiblilty.

private void setScrollbarsVisiblilty() {
    final ViewController viewController = Controller.getCurrentController().getViewController();
    boolean areScrollbarsVisible = viewController.areScrollbarsVisible();
    setHorizontalScrollBarPolicy(areScrollbarsVisible ? JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS : JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    setVerticalScrollBarPolicy(areScrollbarsVisible ? JScrollPane.VERTICAL_SCROLLBAR_ALWAYS : JScrollPane.VERTICAL_SCROLLBAR_NEVER);
    final boolean isFullScreenEnabled = !UITools.getCurrentFrame().isResizable();
    setBorder(isFullScreenEnabled && !areScrollbarsVisible ? null : defaultBorder);
}
Also used : ViewController(org.freeplane.features.ui.ViewController)

Example 2 with ViewController

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

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

the class UserInputListenerFactory method createMapActions.

private void createMapActions(final Entry mapsMenuEntry) {
    final IMapViewManager mapViewManager = Controller.getCurrentController().getMapViewManager();
    final ViewController viewController = Controller.getCurrentController().getViewController();
    final List<? extends Component> mapViewVector = viewController.getMapViewVector();
    if (mapViewVector == null) {
        return;
    }
    EntryAccessor entryAccessor = new EntryAccessor();
    for (final Component mapView : mapViewVector) {
        final String displayName = mapView.getName();
        Entry actionEntry = new Entry();
        final MapsMenuAction action = new MapsMenuAction(displayName);
        actionEntry.setName(action.getKey());
        modeController.addActionIfNotAlreadySet(action);
        entryAccessor.setAction(actionEntry, action);
        final MapView currentMapView = (MapView) mapViewManager.getMapViewComponent();
        if (currentMapView != null) {
            if (mapView == currentMapView) {
                actionEntry.setAttribute("selected", true);
            }
        }
        mapsMenuEntry.addChild(actionEntry);
    }
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) Entry(org.freeplane.core.ui.menubuilders.generic.Entry) ViewController(org.freeplane.features.ui.ViewController) EntryAccessor(org.freeplane.core.ui.menubuilders.generic.EntryAccessor) MapView(org.freeplane.view.swing.map.MapView) Component(java.awt.Component) JComponent(javax.swing.JComponent)

Example 4 with ViewController

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

the class IconSelectionPlugin method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentModeController();
    ArrayList<IIconInformation> actions = new ArrayList<IIconInformation>();
    final Controller controller = Controller.getCurrentController();
    final MapModel map = controller.getMap();
    final IconRegistry iconRegistry = map.getIconRegistry();
    final ListModel usedIcons = iconRegistry.getIconsAsListModel();
    for (int i = 0; i < usedIcons.getSize(); i++) {
        final Object icon = usedIcons.getElementAt(i);
        if (icon instanceof MindIcon) {
            actions.add(new IconAction((MindIcon) icon));
        }
    }
    final MIconController mIconController = (MIconController) IconController.getController();
    for (AFreeplaneAction aFreeplaneAction : mIconController.getIconActions()) actions.add((IIconInformation) aFreeplaneAction);
    actions.add((IIconInformation) modeController.getAction("RemoveIcon_0_Action"));
    actions.add((IIconInformation) modeController.getAction("RemoveIconAction"));
    actions.add((IIconInformation) modeController.getAction("RemoveAllIconsAction"));
    final ViewController viewController = controller.getViewController();
    final IconSelectionPopupDialog selectionDialog = new IconSelectionPopupDialog(viewController.getJFrame(), actions);
    final NodeModel selected = controller.getSelection().getSelected();
    controller.getMapViewManager().scrollNodeToVisible(selected);
    selectionDialog.pack();
    UITools.setDialogLocationRelativeTo(selectionDialog, selected);
    selectionDialog.setModal(true);
    selectionDialog.show();
    final int result = selectionDialog.getResult();
    if (result >= 0) {
        final Action action = (Action) actions.get(result);
        action.actionPerformed(new ActionEvent(action, 0, NodeModel.NODE_ICON, selectionDialog.getModifiers()));
    }
}
Also used : Action(javax.swing.Action) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) MindIcon(org.freeplane.features.icon.MindIcon) ModeController(org.freeplane.features.mode.ModeController) MapModel(org.freeplane.features.map.MapModel) IconSelectionPopupDialog(org.freeplane.core.ui.components.IconSelectionPopupDialog) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) ViewController(org.freeplane.features.ui.ViewController) AFreeplaneAction(org.freeplane.core.ui.AFreeplaneAction) NodeModel(org.freeplane.features.map.NodeModel) ViewController(org.freeplane.features.ui.ViewController) ListModel(javax.swing.ListModel) IIconInformation(org.freeplane.features.icon.IIconInformation) IconRegistry(org.freeplane.features.icon.IconRegistry)

Example 5 with ViewController

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

the class MTextController method edit.

public void edit(final NodeModel nodeModel, final NodeModel prevSelectedModel, final boolean isNewNode, final boolean parentFolded, final boolean editLong) {
    if (nodeModel == null || mCurrentEditDialog != null) {
        return;
    }
    final Controller controller = Controller.getCurrentController();
    if (controller.getMap() != nodeModel.getMap()) {
        return;
    }
    final IMapViewManager viewController = controller.getMapViewManager();
    final Component map = viewController.getMapViewComponent();
    map.validate();
    map.invalidate();
    final Component node = viewController.getComponent(nodeModel);
    if (node == null) {
        return;
    }
    node.requestFocus();
    stopEditing();
    if (isNewNode && !eventQueue.isActive() && !ResourceController.getResourceController().getBooleanProperty("display_inline_editor_for_all_new_nodes")) {
        keyEventDispatcher = new EditEventDispatcher(Controller.getCurrentModeController(), nodeModel, prevSelectedModel, isNewNode, parentFolded, editLong);
        keyEventDispatcher.install();
        return;
    }
    ;
    final IEditControl editControl = new IEditControl() {

        public void cancel() {
            if (isNewNode && nodeModel.getMap().equals(controller.getMap())) {
                if (nodeModel.getParentNode() != null) {
                    controller.getSelection().selectAsTheOnlyOneSelected(nodeModel);
                    final MModeController modeController = (MModeController) Controller.getCurrentModeController();
                    modeController.undo();
                    modeController.resetRedo();
                }
                final MapController mapController = Controller.getCurrentModeController().getMapController();
                mapController.select(prevSelectedModel);
                if (parentFolded) {
                    mapController.setFolded(prevSelectedModel, true);
                }
            }
            stop();
        }

        private void stop() {
            Controller.getCurrentModeController().setBlocked(false);
            viewController.obtainFocusForSelected();
            mCurrentEditDialog = null;
        }

        public void ok(final String text) {
            String processedText = makePlainIfNoFormattingFound(text);
            setGuessedNodeObject(nodeModel, processedText);
            stop();
        }

        public void split(final String newText, final int position) {
            splitNode(nodeModel, position, newText);
            viewController.obtainFocusForSelected();
            stop();
        }

        public boolean canSplit() {
            return true;
        }

        public EditedComponent getEditType() {
            return EditedComponent.TEXT;
        }
    };
    mCurrentEditDialog = createEditor(nodeModel, editControl, nodeModel.getText(), isNewNode, editLong, true);
    final JFrame frame = controller.getViewController().getJFrame();
    mCurrentEditDialog.show(frame);
}
Also used : IMapViewManager(org.freeplane.features.ui.IMapViewManager) JFrame(javax.swing.JFrame) MMapController(org.freeplane.features.map.mindmapmode.MMapController) 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) TextController(org.freeplane.features.text.TextController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) FormatController(org.freeplane.features.format.FormatController) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) LinkController(org.freeplane.features.link.LinkController) ModeController(org.freeplane.features.mode.ModeController) MNodeStyleController(org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ScannerController(org.freeplane.features.format.ScannerController) EditedComponent(org.freeplane.features.text.mindmapmode.EditNodeBase.EditedComponent) Component(java.awt.Component) IEditControl(org.freeplane.features.text.mindmapmode.EditNodeBase.IEditControl) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapController(org.freeplane.features.map.MapController)

Aggregations

ViewController (org.freeplane.features.ui.ViewController)20 Controller (org.freeplane.features.mode.Controller)8 ResourceController (org.freeplane.core.resources.ResourceController)6 ModeController (org.freeplane.features.mode.ModeController)6 MapModel (org.freeplane.features.map.MapModel)5 File (java.io.File)4 IconController (org.freeplane.features.icon.IconController)4 LinkController (org.freeplane.features.link.LinkController)4 MMapController (org.freeplane.features.map.mindmapmode.MMapController)4 IMapViewManager (org.freeplane.features.ui.IMapViewManager)4 URI (java.net.URI)3 JFileChooser (javax.swing.JFileChooser)3 FormatController (org.freeplane.features.format.FormatController)3 ScannerController (org.freeplane.features.format.ScannerController)3 MIconController (org.freeplane.features.icon.mindmapmode.MIconController)3 MLinkController (org.freeplane.features.link.mindmapmode.MLinkController)3 MapController (org.freeplane.features.map.MapController)3 NodeModel (org.freeplane.features.map.NodeModel)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 MNodeStyleController (org.freeplane.features.nodestyle.mindmapmode.MNodeStyleController)3