}
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.getContentPane(), 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);
if (factories.size() > 1) {
final FileFilter combiFileFilter = getCombiFileFilter();
chooser.addChoosableFileFilter(combiFileFilter);
for (final IViewerFactory factory : factories) {
chooser.addChoosableFileFilter(new FactoryFileFilter(factory));
}
chooser.setFileFilter(combiFileFilter);
}
else {
chooser.setFileFilter(new FactoryFileFilter(factories.iterator().next()));
}
chooser.setAccessory(new ImagePreview(chooser));
final int returnVal = chooser.showOpenDialog(Controller.getCurrentController().getViewController()
.getContentPane());
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;
}