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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations