Search in sources :

Example 6 with UrlManager

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

the class ExternalImagePopupMenu method getOpen.

/**
 * @return Returns the open menu item.
 */
private JMenuItem getOpen() {
    if (open == null) {
        open = new JMenuItem(TextUtils.getText("ExternalImage_popupMenu_Open"));
        open.addActionListener(new ActionListener() {

            public void actionPerformed(final ActionEvent e) {
                final ExternalResource extRes = node.getExtension(ExternalResource.class);
                if (extRes == null)
                    return;
                final UrlManager urlManager = Controller.getCurrentModeController().getExtension(UrlManager.class);
                urlManager.loadURL(extRes.getUri());
            }
        });
    }
    return open;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JMenuItem(javax.swing.JMenuItem)

Example 7 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 8 with UrlManager

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

the class BModeControllerFactory method createModeController.

public static BModeController createModeController() {
    final Controller controller = Controller.getCurrentController();
    modeController = new BModeController(controller);
    final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
    modeController.setUserInputListenerFactory(userInputListenerFactory);
    controller.addModeController(modeController);
    controller.selectModeForBuild(modeController);
    new MapController(modeController);
    new IconController(modeController).install(modeController);
    UrlManager.install(new UrlManager());
    MapIO.install(modeController);
    AttributeController.install(new AttributeController(modeController));
    NodeStyleController.install(new NodeStyleController(modeController));
    EdgeController.install(new EdgeController(modeController));
    CloudController.install(new CloudController(modeController));
    NoteController.install(new NoteController());
    new TextController(modeController).install(modeController);
    LinkController.install(new LinkController(modeController));
    LogicalStyleController.install(new LogicalStyleController(modeController));
    try {
        ClipboardController.install(new ClipboardController());
    } catch (final AccessControlException e) {
        LogUtils.warn("can not access system clipboard, clipboard controller disabled");
    }
    LocationController.install(new LocationController());
    SummaryNode.install();
    FreeNode.install();
    MapStyle.install(true);
    final BToolbarContributor toolbarContributor = new BToolbarContributor();
    modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_url", toolbarContributor);
    controller.getMapViewManager().addMapViewChangeListener(toolbarContributor);
    userInputListenerFactory.setNodePopupMenu(new JPopupMenu());
    final FreeplaneToolBar toolBar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
    FrameController frameController = (FrameController) controller.getViewController();
    UIComponentVisibilityDispatcher.install(frameController, toolBar, "toolbarVisible");
    userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolBar);
    userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
    userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, controller.getViewController().getStatusBar());
    FoldingController.install(new FoldingController());
    new ViewerController();
    EncryptionController.install(new EncryptionController(modeController));
    new AutomaticLayoutController();
    return modeController;
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ClipboardController(org.freeplane.features.clipboard.ClipboardController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) LinkController(org.freeplane.features.link.LinkController) LocationController(org.freeplane.features.nodelocation.LocationController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) IconController(org.freeplane.features.icon.IconController) FoldingController(org.freeplane.features.map.FoldingController) FrameController(org.freeplane.features.ui.FrameController) NoteController(org.freeplane.features.note.NoteController) EdgeController(org.freeplane.features.edge.EdgeController) AttributeController(org.freeplane.features.attribute.AttributeController) TextController(org.freeplane.features.text.TextController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) UserInputListenerFactory(org.freeplane.view.swing.ui.UserInputListenerFactory) AccessControlException(java.security.AccessControlException) AttributeController(org.freeplane.features.attribute.AttributeController) EncryptionController(org.freeplane.features.encrypt.EncryptionController) ViewerController(org.freeplane.view.swing.features.filepreview.ViewerController) ClipboardController(org.freeplane.features.clipboard.ClipboardController) NoteController(org.freeplane.features.note.NoteController) LogicalStyleController(org.freeplane.features.styles.LogicalStyleController) EdgeController(org.freeplane.features.edge.EdgeController) ViewController(org.freeplane.features.ui.ViewController) CloudController(org.freeplane.features.cloud.CloudController) LinkController(org.freeplane.features.link.LinkController) FilterController(org.freeplane.features.filter.FilterController) MapController(org.freeplane.features.map.MapController) LocationController(org.freeplane.features.nodelocation.LocationController) FoldingController(org.freeplane.features.map.FoldingController) FrameController(org.freeplane.features.ui.FrameController) IconController(org.freeplane.features.icon.IconController) Controller(org.freeplane.features.mode.Controller) TextController(org.freeplane.features.text.TextController) AutomaticLayoutController(org.freeplane.features.styles.AutomaticLayoutController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) JPopupMenu(javax.swing.JPopupMenu) MapController(org.freeplane.features.map.MapController) EncryptionController(org.freeplane.features.encrypt.EncryptionController) NodeStyleController(org.freeplane.features.nodestyle.NodeStyleController) CloudController(org.freeplane.features.cloud.CloudController) FreeplaneToolBar(org.freeplane.core.ui.components.FreeplaneToolBar)

Example 9 with UrlManager

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

the class MTextController method setImageByFileChooser.

public void setImageByFileChooser() {
    boolean picturesAmongSelecteds = false;
    final ModeController modeController = Controller.getCurrentModeController();
    for (final NodeModel node : modeController.getMapController().getSelectedNodes()) {
        final URI link = NodeLinks.getLink(node);
        if (link != null) {
            final String linkString = link.toString();
            final String lowerCase = linkString.toLowerCase();
            if (lowerCase.endsWith(".png") || lowerCase.endsWith(".jpg") || lowerCase.endsWith(".jpeg") || lowerCase.endsWith(".gif")) {
                picturesAmongSelecteds = true;
                final String encodedLinkString = HtmlUtils.unicodeToHTMLUnicodeEntity(linkString);
                final String strText = "<html><img src=\"" + encodedLinkString + "\">";
                ((MLinkController) LinkController.getController()).setLink(node, (URI) null, LinkController.LINK_ABSOLUTE);
                setNodeText(node, strText);
            }
        }
    }
    if (picturesAmongSelecteds) {
        return;
    }
    final Controller controller = modeController.getController();
    final ViewController viewController = controller.getViewController();
    final NodeModel selectedNode = modeController.getMapController().getSelectedNode();
    final MapModel map = selectedNode.getMap();
    final File file = map.getFile();
    if (file == null && LinkController.getLinkType() == LinkController.LINK_RELATIVE_TO_MINDMAP) {
        JOptionPane.showMessageDialog(viewController.getContentPane(), TextUtils.getText("not_saved_for_image_error"), "Freeplane", JOptionPane.WARNING_MESSAGE);
        return;
    }
    final ExampleFileFilter filter = new ExampleFileFilter();
    filter.addExtension("jpg");
    filter.addExtension("jpeg");
    filter.addExtension("png");
    filter.addExtension("gif");
    filter.setDescription(TextUtils.getText("bitmaps"));
    final UrlManager urlManager = (UrlManager) modeController.getExtension(UrlManager.class);
    final JFileChooser chooser = urlManager.getFileChooser(null, false);
    chooser.setFileFilter(filter);
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setAccessory(new BitmapImagePreview(chooser));
    final int returnVal = chooser.showOpenDialog(viewController.getContentPane());
    if (returnVal != JFileChooser.APPROVE_OPTION) {
        return;
    }
    final File input = chooser.getSelectedFile();
    URI uri = input.toURI();
    if (uri == null) {
        return;
    }
    // bad hack: try to interpret file as http link
    if (!input.exists()) {
        uri = LinkController.toRelativeURI(map.getFile(), input, LinkController.LINK_RELATIVE_TO_MINDMAP);
        if (uri == null || !"http".equals(uri.getScheme())) {
            UITools.errorMessage(TextUtils.format("file_not_found", input.toString()));
            return;
        }
    } else if (LinkController.getLinkType() != LinkController.LINK_ABSOLUTE) {
        uri = LinkController.toLinkTypeDependantURI(map.getFile(), input);
    }
    String uriString = uri.toString();
    if (uriString.startsWith("http:/")) {
        uriString = "http://" + uriString.substring("http:/".length());
    }
    final String strText = "<html><img src=\"" + uriString + "\">";
    setNodeText(selectedNode, strText);
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MapModel(org.freeplane.features.map.MapModel) 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) URI(java.net.URI) NodeModel(org.freeplane.features.map.NodeModel) MLinkController(org.freeplane.features.link.mindmapmode.MLinkController) JFileChooser(javax.swing.JFileChooser) ViewController(org.freeplane.features.ui.ViewController) BitmapImagePreview(org.freeplane.core.ui.components.BitmapImagePreview) ExampleFileFilter(org.freeplane.core.ui.ExampleFileFilter) File(java.io.File)

Example 10 with UrlManager

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

the class MapIO method install.

public static void install(ModeController modeController) {
    UrlManager urlManager = modeController.getExtension(UrlManager.class);
    MapController mapController = modeController.getMapController();
    final MapIO mapIO = new MapIO(urlManager, mapController);
    modeController.addExtension(MapIO.class, mapIO);
}
Also used : UrlManager(org.freeplane.features.url.UrlManager) MapController(org.freeplane.features.map.MapController)

Aggregations

UrlManager (org.freeplane.features.url.UrlManager)12 LinkController (org.freeplane.features.link.LinkController)5 Controller (org.freeplane.features.mode.Controller)5 ViewController (org.freeplane.features.ui.ViewController)5 URI (java.net.URI)4 IconController (org.freeplane.features.icon.IconController)4 MapController (org.freeplane.features.map.MapController)4 NodeStyleController (org.freeplane.features.nodestyle.NodeStyleController)4 TextController (org.freeplane.features.text.TextController)4 File (java.io.File)3 JPopupMenu (javax.swing.JPopupMenu)3 FreeplaneToolBar (org.freeplane.core.ui.components.FreeplaneToolBar)3 ClipboardController (org.freeplane.features.clipboard.ClipboardController)3 CloudController (org.freeplane.features.cloud.CloudController)3 EdgeController (org.freeplane.features.edge.EdgeController)3 FilterController (org.freeplane.features.filter.FilterController)3 MapModel (org.freeplane.features.map.MapModel)3 MMapController (org.freeplane.features.map.mindmapmode.MMapController)3 ModeController (org.freeplane.features.mode.ModeController)3 LocationController (org.freeplane.features.nodelocation.LocationController)3