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