Search in sources :

Example 66 with ModeController

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

the class FileOpener method drop.

@SuppressWarnings("unchecked")
public void drop(final DropTargetDropEvent dtde) {
    if (!isDropAcceptable(dtde)) {
        dtde.rejectDrop();
        return;
    }
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    try {
        final Transferable transferable = dtde.getTransferable();
        Controller.getCurrentController().selectMode(MModeController.MODENAME);
        ModeController modeController = Controller.getCurrentModeController();
        if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
            final List<File> list = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
            for (final File file : list) {
                String fileName = file.getName();
                if (file.isDirectory() || !isMindMapUrl(fileName)) {
                    continue;
                }
                modeController.getMapController().newMap(Compat.fileToUrl(file));
            }
        }
        if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
            final String urls = (String) transferable.getTransferData(DataFlavor.stringFlavor);
            if (urls.startsWith("file:")) {
                final Matcher matcher = filePattern.matcher(urls);
                while (matcher.find()) {
                    final String urlString = matcher.group();
                    if (!isMindMapUrl(urlString)) {
                        continue;
                    }
                    try {
                        final URI uri = new URI(urlString);
                        final URL url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
                        final File file = Compat.urlToFile(url);
                        if (!file.exists() || file.isDirectory())
                            continue;
                        modeController.getMapController().newMap(url);
                    } catch (final Exception e) {
                        e.printStackTrace();
                        continue;
                    }
                }
            } else if (urls.startsWith("http://") && isMindMapUrl(urls)) {
                final URL url = new URL(urls);
                modeController.getMapController().newMap(url);
            }
        }
    } catch (final Exception e) {
        UITools.errorMessage(TextUtils.format("dropped_file_error", e.getMessage()));
        dtde.dropComplete(false);
        return;
    }
    dtde.dropComplete(true);
}
Also used : Matcher(java.util.regex.Matcher) Transferable(java.awt.datatransfer.Transferable) List(java.util.List) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) File(java.io.File) URI(java.net.URI) URL(java.net.URL)

Example 67 with ModeController

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

the class NewMapAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
    MFileManager.getController(modeController).newMapFromDefaultTemplate();
}
Also used : MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController)

Example 68 with ModeController

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

the class OpenAction method actionPerformed.

public void actionPerformed(final ActionEvent e) {
    final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
    MFileManager.getController(modeController).open();
    Controller.getCurrentController().getMapViewManager().setTitle();
}
Also used : MModeController(org.freeplane.features.mode.mindmapmode.MModeController) ModeController(org.freeplane.features.mode.ModeController)

Example 69 with ModeController

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

the class AddOnsController method registerInstalledAddOn.

public void registerInstalledAddOn(final AddOnProperties addOn) {
    installedAddOns.add(addOn);
    final ResourceController resourceController = ResourceController.getResourceController();
    if (addOn.getDefaultProperties() != null)
        resourceController.addDefaults(addOn.getDefaultProperties());
    if (addOn.getPreferencesXml() != null) {
        final ModeController modeController = Controller.getCurrentModeController();
        if (modeController instanceof MModeController) {
            ((MModeController) modeController).getOptionPanelBuilder().load(new StringReader(addOn.getPreferencesXml()));
        }
    }
    if (addOn.getTranslations() != null)
        registerAddOnResources(addOn, resourceController);
}
Also used : ResourceController(org.freeplane.core.resources.ResourceController) StringReader(java.io.StringReader) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 70 with ModeController

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

the class NodeHistory method install.

public static void install(final ModeController modeController) {
    final Controller controller = modeController.getController();
    final NodeHistory history = (NodeHistory) controller.getExtension(NodeHistory.class);
    modeController.getMapController().addNodeSelectionListener(history.getMapSelectionListener());
    LinkController.getController(modeController).addNodeSelectionListener(history.getLinkSelectionListener());
    history.backAction = new BackAction(controller, history);
    modeController.addAction(history.backAction);
    history.forwardAction = new ForwardAction(controller, history);
    modeController.addAction(history.forwardAction);
}
Also used : Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) LinkController(org.freeplane.features.link.LinkController)

Aggregations

ModeController (org.freeplane.features.mode.ModeController)222 NodeModel (org.freeplane.features.map.NodeModel)90 Controller (org.freeplane.features.mode.Controller)56 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)48 MapModel (org.freeplane.features.map.MapModel)37 IActor (org.freeplane.core.undo.IActor)31 MapController (org.freeplane.features.map.MapController)30 ResourceController (org.freeplane.core.resources.ResourceController)29 MMapController (org.freeplane.features.map.mindmapmode.MMapController)20 File (java.io.File)17 TextController (org.freeplane.features.text.TextController)17 Color (java.awt.Color)16 Point (java.awt.Point)16 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)15 MapView (org.freeplane.view.swing.map.MapView)13 NodeView (org.freeplane.view.swing.map.NodeView)13 Component (java.awt.Component)12 URL (java.net.URL)12 LinkController (org.freeplane.features.link.LinkController)12 MenuBuilder (org.freeplane.core.ui.MenuBuilder)11