Search in sources :

Example 1 with UrlManager

use of org.freeplane.features.url.UrlManager in project freeplane by freeplane.

the class MapView method assignAbsoluteURI.

private URI assignAbsoluteURI(final String uriString) {
    final UrlManager urlManager = getModeController().getExtension(UrlManager.class);
    URI uri = null;
    try {
        uri = urlManager.getAbsoluteUri(model, new URI(uriString));
    } catch (final URISyntaxException e) {
        LogUtils.severe(e);
    } catch (MalformedURLException e) {
        LogUtils.severe(e);
    }
    return uri;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with UrlManager

use of org.freeplane.features.url.UrlManager in project freeplane by freeplane.

the class ViewerController method createURI.

protected URI createURI(final NodeModel node) {
    final Controller controller = Controller.getCurrentController();
    final ViewController viewController = controller.getViewController();
    final MapModel map = node.getMap();
    final File file = map.getFile();
    final boolean useRelativeUri = ResourceController.getResourceController().getProperty("links").equals("relative");
    if (file == null && useRelativeUri) {
        JOptionPane.showMessageDialog(viewController.getCurrentRootComponent(), TextUtils.getText("not_saved_for_image_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
        return null;
    }
    final UrlManager urlManager = controller.getModeController().getExtension(UrlManager.class);
    final JFileChooser chooser = urlManager.getFileChooser(null, false);
    chooser.setAcceptAllFileFilterUsed(false);
    final FileFilter fileFilter;
    if (factories.size() > 1) {
        fileFilter = getCombiFileFilter();
        chooser.addChoosableFileFilter(fileFilter);
        for (final IViewerFactory factory : factories) {
            chooser.addChoosableFileFilter(new FactoryFileFilter(factory));
        }
    } else {
        fileFilter = new FactoryFileFilter(factories.iterator().next());
    }
    chooser.setFileFilter(fileFilter);
    chooser.putClientProperty(FactoryFileFilter.class, fileFilter);
    chooser.setAccessory(new ImagePreview(chooser));
    final int returnVal = chooser.showOpenDialog(Controller.getCurrentController().getViewController().getCurrentRootComponent());
    if (returnVal != JFileChooser.APPROVE_OPTION) {
        return null;
    }
    final File input = chooser.getSelectedFile();
    if (input == null) {
        return null;
    }
    URI uri = uriOf(input);
    if (uri == null) {
        return null;
    }
    if (useRelativeUri && uri.getScheme().equals("file")) {
        uri = LinkController.toLinkTypeDependantURI(map.getFile(), input);
    }
    return uri;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) MapModel(org.freeplane.features.map.MapModel) MMapController(org.freeplane.features.map.mindmapmode.MMapController) Controller(org.freeplane.features.mode.Controller) ResourceController(org.freeplane.core.resources.ResourceController) ViewController(org.freeplane.features.ui.ViewController) LinkController(org.freeplane.features.link.LinkController) ModeController(org.freeplane.features.mode.ModeController) URI(java.net.URI) Point(java.awt.Point) JFileChooser(javax.swing.JFileChooser) ViewController(org.freeplane.features.ui.ViewController) FileFilter(javax.swing.filechooser.FileFilter) File(java.io.File)

Example 3 with UrlManager

use of org.freeplane.features.url.UrlManager in project freeplane by freeplane.

the class UITools method createHtmlLinkStyleButton.

public static JButton createHtmlLinkStyleButton(final URI uri, final String title) {
    final JButton button = new JButton("<html><a href='" + uri + "'>" + title);
    button.setBorderPainted(false);
    button.setOpaque(false);
    button.setBackground(Color.lightGray);
    button.setFocusable(false);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final ModeController modeController = Controller.getCurrentModeController();
            final UrlManager urlManager = modeController.getExtension(UrlManager.class);
            urlManager.loadURL(uri);
        }
    });
    return button;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) ModeController(org.freeplane.features.mode.ModeController)

Example 4 with UrlManager

use of org.freeplane.features.url.UrlManager in project freeplane by freeplane.

the class MapStyle method copyStyle.

public void copyStyle(final URL source, final MapModel targetMap, boolean undoable) {
    final MapModel styleMapContainer = new MapModel();
    final IExtension oldStyleModel = targetMap.getRootNode().removeExtension(MapStyleModel.class);
    final ModeController modeController = Controller.getCurrentModeController();
    final UrlManager urlManager = modeController.getExtension(UrlManager.class);
    if (!urlManager.loadCatchExceptions(source, styleMapContainer))
        return;
    onCreate(styleMapContainer);
    moveStyle(styleMapContainer, targetMap, true);
    modeController.getExtension(AutomaticLayoutController.class).moveExtension(modeController, styleMapContainer, targetMap);
    modeController.getExtension(AutomaticEdgeColorHook.class).moveExtension(modeController, styleMapContainer, targetMap);
    LogicalStyleController.getController().refreshMap(targetMap);
    if (!undoable) {
        return;
    }
    final IExtension newStyleModel = targetMap.getRootNode().getExtension(MapStyleModel.class);
    IActor actor = new IActor() {

        public void undo() {
            targetMap.getRootNode().putExtension(oldStyleModel);
        }

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

        public void act() {
            targetMap.getRootNode().putExtension(newStyleModel);
        }
    };
    Controller.getCurrentModeController().execute(actor, targetMap);
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) AutomaticEdgeColorHook(org.freeplane.features.edge.AutomaticEdgeColorHook) IExtension(org.freeplane.core.extension.IExtension) IActor(org.freeplane.core.undo.IActor) MapModel(org.freeplane.features.map.MapModel) ModeController(org.freeplane.features.mode.ModeController)

Example 5 with UrlManager

use of org.freeplane.features.url.UrlManager in project freeplane by freeplane.

the class MapStyle method createDefaultStyleMap.

private void createDefaultStyleMap(final MapModel map) {
    UrlManager loader = UrlManager.getController();
    final File file = loader.defaultTemplateFile();
    if (file != null) {
        try {
            MapModel styleMapContainer = new MapModel();
            loader.load(Compat.fileToUrl(file), styleMapContainer);
            if (null != MapStyleModel.getExtension(styleMapContainer)) {
                moveStyle(styleMapContainer, map, false);
                return;
            }
        } catch (Exception e) {
            LogUtils.warn(e);
            UITools.errorMessage(TextUtils.format("error_in_template", file));
        }
    }
    ;
    MapModel styleMapContainer = new MapModel();
    try {
        loader.load(ResourceController.getResourceController().getResource("/styles/viewer_standard.mm"), styleMapContainer);
        moveStyle(styleMapContainer, map, false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) MapModel(org.freeplane.features.map.MapModel) File(java.io.File) IOException(java.io.IOException)

Aggregations

UrlManager (org.freeplane.features.url.UrlManager)12 URI (java.net.URI)4 LinkController (org.freeplane.features.link.LinkController)4 MapModel (org.freeplane.features.map.MapModel)4 Controller (org.freeplane.features.mode.Controller)4 ModeController (org.freeplane.features.mode.ModeController)4 ViewController (org.freeplane.features.ui.ViewController)4 File (java.io.File)3 IconController (org.freeplane.features.icon.IconController)3 MapController (org.freeplane.features.map.MapController)3 MMapController (org.freeplane.features.map.mindmapmode.MMapController)3 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)3 LogicalStyleController (org.freeplane.features.styles.LogicalStyleController)3 TextController (org.freeplane.features.text.TextController)3 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 MalformedURLException (java.net.MalformedURLException)2 JFileChooser (javax.swing.JFileChooser)2 JPopupMenu (javax.swing.JPopupMenu)2 ResourceController (org.freeplane.core.resources.ResourceController)2