Search in sources :

Example 91 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class FreeplaneApplet method init.

@SuppressWarnings("serial")
@Override
public void init() {
    try {
        appletLock.lock();
        appletResourceController = new AppletResourceController(this);
        if (appletResourceController == null) {
            appletResourceController = new AppletResourceController(this);
        }
        new ParserDelegator() {

            {
                setDefaultDTD();
            }
        };
        updateLookAndFeel();
        createRootPane();
        controller = new Controller(appletResourceController);
        appletResourceController.init();
        Controller.setCurrentController(controller);
        final Container contentPane = getContentPane();
        contentPane.setLayout(new BorderLayout());
        MapViewController mapViewController = new MapViewController(controller);
        appletViewController = new AppletViewController(this, controller, mapViewController);
        controller.addAction(new ViewLayoutTypeAction(MapViewLayout.OUTLINE));
        FilterController.install();
        PrintController.install();
        HelpController.install();
        NodeHistory.install(controller);
        FormatController.install(new FormatController());
        ModelessAttributeController.install();
        TextController.install();
        MapController.install();
        TimeController.install();
        LinkController.install();
        IconController.install();
        FilterController.getCurrentFilterController().getConditionFactory().addConditionController(70, new LogicalStyleFilterController());
        final BModeController browseController = BModeControllerFactory.createModeController();
        final Set<String> emptySet = Collections.emptySet();
        FilterController.getController(controller).loadDefaultConditions();
        browseController.updateMenus("/xml/appletMenu.xml", emptySet);
        controller.addAction(new ShowSelectionAsRectangleAction());
        controller.addAction(new NextNodeAction(Direction.FORWARD));
        controller.addAction(new NextNodeAction(Direction.BACK));
        controller.addAction(new NextPresentationItemAction());
        controller.selectMode(browseController);
        appletResourceController.setPropertyByParameter(this, "browsemode_initial_map");
        appletViewController.init(controller);
        final GlassPane glassPane = new GlassPane();
        setGlassPane(glassPane);
        glassPane.setVisible(true);
        controller.getViewController().setMenubarVisible(false);
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
    } finally {
        appletLock.unlock();
    }
}
Also used : ParserDelegator(javax.swing.text.html.parser.ParserDelegator) LogicalStyleFilterController(org.freeplane.features.styles.LogicalStyleFilterController) FormatController(org.freeplane.features.format.FormatController) BModeController(org.freeplane.features.mode.browsemode.BModeController) PrintController(org.freeplane.features.print.PrintController) BModeController(org.freeplane.features.mode.browsemode.BModeController) FormatController(org.freeplane.features.format.FormatController) MapViewController(org.freeplane.view.swing.map.MapViewController) LinkController(org.freeplane.features.link.LinkController) TimeController(org.freeplane.features.time.TimeController) FilterController(org.freeplane.features.filter.FilterController) HelpController(org.freeplane.features.help.HelpController) MapController(org.freeplane.features.map.MapController) LogicalStyleFilterController(org.freeplane.features.styles.LogicalStyleFilterController) FrameController(org.freeplane.features.ui.FrameController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) ModelessAttributeController(org.freeplane.features.attribute.ModelessAttributeController) MapViewController(org.freeplane.view.swing.map.MapViewController) NextPresentationItemAction(org.freeplane.features.filter.NextPresentationItemAction) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) ViewLayoutTypeAction(org.freeplane.view.swing.map.ViewLayoutTypeAction) NextNodeAction(org.freeplane.features.filter.NextNodeAction) ShowSelectionAsRectangleAction(org.freeplane.core.ui.ShowSelectionAsRectangleAction)

Example 92 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class ExportBranchAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final NodeModel existingNode = Controller.getCurrentModeController().getMapController().getSelectedNode();
    final Controller controller = Controller.getCurrentController();
    final MapModel parentMap = controller.getMap();
    if (parentMap == null || existingNode == null || existingNode.isRoot()) {
        controller.getViewController().err("Could not export branch.");
        return;
    }
    if (parentMap.getFile() == null) {
        controller.getViewController().out("You must save the current map first!");
        ((MModeController) Controller.getCurrentModeController()).save();
    }
    JFileChooser chooser;
    final File file = parentMap.getFile();
    if (file == null) {
        return;
    }
    chooser = new JFileChooser(file.getParentFile());
    chooser.setSelectedFile(new File(createFileName(TextController.getController().getShortText(existingNode))));
    if (((MFileManager) UrlManager.getController()).getFileFilter() != null) {
        chooser.addChoosableFileFilter(((MFileManager) UrlManager.getController()).getFileFilter());
    }
    final int returnVal = chooser.showSaveDialog(controller.getViewController().getContentPane());
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        File chosenFile = chooser.getSelectedFile();
        final String ext = FileUtils.getExtension(chosenFile.getName());
        if (!ext.equals(org.freeplane.features.url.UrlManager.FREEPLANE_FILE_EXTENSION_WITHOUT_DOT)) {
            chosenFile = new File(chosenFile.getParent(), chosenFile.getName() + org.freeplane.features.url.UrlManager.FREEPLANE_FILE_EXTENSION);
        }
        try {
            Compat.fileToUrl(chosenFile);
        } catch (final MalformedURLException ex) {
            UITools.errorMessage(TextUtils.getText("invalid_url"));
            return;
        }
        if (chosenFile.exists()) {
            final int overwriteMap = JOptionPane.showConfirmDialog(controller.getMapViewManager().getMapViewComponent(), TextUtils.getText("map_already_exists"), "Freeplane", JOptionPane.YES_NO_OPTION);
            if (overwriteMap != JOptionPane.YES_OPTION) {
                return;
            }
        }
        /*
			 * Now make a copy from the node, remove the node from the map and
			 * create a new Map with the node as root, store the new Map, add
			 * the copy of the node to the parent, and set a link from the copy
			 * to the new Map.
			 */
        final NodeModel parent = existingNode.getParentNode();
        final File oldFile = parentMap.getFile();
        final URI newUri = LinkController.toLinkTypeDependantURI(oldFile, chosenFile);
        final URI oldUri = LinkController.toLinkTypeDependantURI(chosenFile, file);
        ((MLinkController) LinkController.getController()).setLink(existingNode, oldUri, LinkController.LINK_ABSOLUTE);
        final int nodePosition = parent.getChildPosition(existingNode);
        final ModeController modeController = Controller.getCurrentModeController();
        modeController.undoableResolveParentExtensions(LogicalStyleKeys.NODE_STYLE, existingNode);
        final MMapController mMapController = (MMapController) modeController.getMapController();
        mMapController.deleteNode(existingNode);
        {
            final IActor actor = new IActor() {

                private final boolean wasFolded = existingNode.isFolded();

                public void undo() {
                    PersistentNodeHook.removeMapExtensions(existingNode);
                    existingNode.setMap(parentMap);
                    existingNode.setFolded(wasFolded);
                }

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

                public void act() {
                    existingNode.setParent(null);
                    existingNode.setFolded(false);
                    mMapController.newModel(existingNode);
                }
            };
            Controller.getCurrentModeController().execute(actor, parentMap);
        }
        final MapModel map = existingNode.getMap();
        IExtension[] oldExtensions = map.getRootNode().getSharedExtensions().values().toArray(new IExtension[] {});
        for (final IExtension extension : oldExtensions) {
            final Class<? extends IExtension> clazz = extension.getClass();
            if (PersistentNodeHook.isMapExtension(clazz)) {
                existingNode.removeExtension(clazz);
            }
        }
        final Collection<IExtension> newExtensions = parentMap.getRootNode().getSharedExtensions().values();
        for (final IExtension extension : newExtensions) {
            final Class<? extends IExtension> clazz = extension.getClass();
            if (PersistentNodeHook.isMapExtension(clazz)) {
                existingNode.addExtension(extension);
            }
        }
        ((MFileManager) UrlManager.getController()).save(map, chosenFile);
        final NodeModel newNode = mMapController.addNewNode(parent, nodePosition, existingNode.isLeft());
        ((MTextController) TextController.getController()).setNodeText(newNode, existingNode.getText());
        modeController.undoableCopyExtensions(LogicalStyleKeys.NODE_STYLE, existingNode, newNode);
        map.getFile();
        ((MLinkController) LinkController.getController()).setLink(newNode, newUri, LinkController.LINK_ABSOLUTE);
        map.destroy();
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) MMapController(org.freeplane.features.map.mindmapmode.MMapController) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MTextController(org.freeplane.features.text.mindmapmode.MTextController) MMapController(org.freeplane.features.map.mindmapmode.MMapController) LinkController(org.freeplane.features.link.LinkController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) ModeController(org.freeplane.features.mode.ModeController) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) URI(java.net.URI) NodeModel(org.freeplane.features.map.NodeModel) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) JFileChooser(javax.swing.JFileChooser) IExtension(org.freeplane.core.extension.IExtension) IActor(org.freeplane.core.undo.IActor) MTextController(org.freeplane.features.text.mindmapmode.MTextController) File(java.io.File) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 93 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class ApplicationViewController method removeSplitPane.

@Override
public void removeSplitPane() {
    saveSplitPanePosition();
    mMindMapComponent = null;
    mSplitPane.setLeftComponent(null);
    mSplitPane.setRightComponent(null);
    mSplitPane.setLeftComponent(mapPane);
    setSplitPaneLayoutManager();
    final Controller controller = Controller.getCurrentModeController().getController();
    final IMapSelection selection = controller.getSelection();
    if (selection == null) {
        return;
    }
    final NodeModel node = selection.getSelected();
    EventQueue.invokeLater(new Runnable() {

        public void run() {
            final Component component = controller.getMapViewManager().getComponent(node);
            if (component != null) {
                component.requestFocus();
            }
        }
    });
}
Also used : NodeModel(org.freeplane.features.map.NodeModel) IMapSelection(org.freeplane.features.map.IMapSelection) ResourceController(org.freeplane.core.resources.ResourceController) FrameController(org.freeplane.features.ui.FrameController) Controller(org.freeplane.features.mode.Controller) JComponent(javax.swing.JComponent) Component(java.awt.Component)

Example 94 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class FreeplaneSplashModern method main.

public static void main(String[] args) {
    ApplicationResourceController applicationResourceController = new ApplicationResourceController();
    Controller controller = new Controller(applicationResourceController);
    Controller.setCurrentController(controller);
    FreeplaneSplashModern freeplaneSplashModern = new FreeplaneSplashModern(null);
    freeplaneSplashModern.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            System.out.println("x = " + e.getX() + " y = " + e.getY());
            if (e.getClickCount() == 2)
                System.exit(0);
        }
    });
    freeplaneSplashModern.setVisible(true);
}
Also used : MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController)

Example 95 with Controller

use of org.freeplane.features.mode.Controller in project freeplane by freeplane.

the class MapViewSerializer method readView.

public View readView(ObjectInputStream in) throws IOException {
    try {
        if (in.readBoolean()) {
            String modeName = in.readUTF();
            URL mapUrl = (URL) in.readObject();
            if (mapUrl == null)
                return newViewToBeRemoved();
            Controller controller = Controller.getCurrentController();
            controller.selectMode(modeName);
            ModeController modeController = Controller.getCurrentModeController();
            MapController mapController = modeController.getMapController();
            boolean newMapLoaded = mapController.newMap(mapUrl);
            if (!newMapLoaded) {
                MapModel map = controller.getMap();
                if (map.getURL().equals(mapUrl)) {
                    mapController.newMapView(map);
                }
            }
            Component mapViewComponent = controller.getMapViewManager().getMapViewComponent();
            if (mapViewComponent.getParent() == null) {
                return newDockedView(mapViewComponent);
            } else
                return newViewToBeRemoved();
        }
        return newViewToBeRemoved();
    } catch (Exception e) {
        return newViewToBeRemoved();
    }
}
Also used : ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MapModel(org.freeplane.features.map.MapModel) MapController(org.freeplane.features.map.MapController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) Component(java.awt.Component) URL(java.net.URL) IOException(java.io.IOException) MapController(org.freeplane.features.map.MapController)

Aggregations

Controller (org.freeplane.features.mode.Controller)152 ModeController (org.freeplane.features.mode.ModeController)92 ResourceController (org.freeplane.core.resources.ResourceController)69 NodeModel (org.freeplane.features.map.NodeModel)46 MapController (org.freeplane.features.map.MapController)41 MapModel (org.freeplane.features.map.MapModel)34 LinkController (org.freeplane.features.link.LinkController)32 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)32 TextController (org.freeplane.features.text.TextController)27 MMapController (org.freeplane.features.map.mindmapmode.MMapController)24 ViewController (org.freeplane.features.ui.ViewController)23 IconController (org.freeplane.features.icon.IconController)22 Component (java.awt.Component)19 FilterController (org.freeplane.features.filter.FilterController)17 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)17 FormatController (org.freeplane.features.format.FormatController)16 ScannerController (org.freeplane.features.format.ScannerController)16 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)15 File (java.io.File)14 MTextController (org.freeplane.features.text.mindmapmode.MTextController)14