use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class FileOpener method drop.
@SuppressWarnings("unchecked")
public void drop(final DropTargetDropEvent dtde) {
if (!isDropAcceptable(dtde)) {
dtde.rejectDrop();
return;
}
dtde.acceptDrop(DnDConstants.ACTION_COPY);
try {
final Transferable transferable = dtde.getTransferable();
Controller.getCurrentController().selectMode(MModeController.MODENAME);
ModeController modeController = Controller.getCurrentModeController();
if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
final List<File> list = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
for (final File file : list) {
String fileName = file.getName();
if (file.isDirectory() || !isMindMapUrl(fileName)) {
continue;
}
modeController.getMapController().newMap(Compat.fileToUrl(file));
}
}
if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
final String urls = (String) transferable.getTransferData(DataFlavor.stringFlavor);
if (urls.startsWith("file:")) {
final Matcher matcher = filePattern.matcher(urls);
while (matcher.find()) {
final String urlString = matcher.group();
if (!isMindMapUrl(urlString)) {
continue;
}
try {
final URI uri = new URI(urlString);
final URL url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
final File file = Compat.urlToFile(url);
if (!file.exists() || file.isDirectory())
continue;
modeController.getMapController().newMap(url);
} catch (final Exception e) {
e.printStackTrace();
continue;
}
}
} else if (urls.startsWith("http://") && isMindMapUrl(urls)) {
final URL url = new URL(urls);
modeController.getMapController().newMap(url);
}
}
} catch (final Exception e) {
UITools.errorMessage(TextUtils.format("dropped_file_error", e.getMessage()));
dtde.dropComplete(false);
return;
}
dtde.dropComplete(true);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NewMapAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
MFileManager.getController(modeController).newMapFromDefaultTemplate();
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class OpenAction method actionPerformed.
public void actionPerformed(final ActionEvent e) {
final ModeController modeController = Controller.getCurrentController().getModeController(MModeController.MODENAME);
MFileManager.getController(modeController).open();
Controller.getCurrentController().getMapViewManager().setTitle();
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class AddOnsController method registerInstalledAddOn.
public void registerInstalledAddOn(final AddOnProperties addOn) {
installedAddOns.add(addOn);
final ResourceController resourceController = ResourceController.getResourceController();
if (addOn.getDefaultProperties() != null)
resourceController.addDefaults(addOn.getDefaultProperties());
if (addOn.getPreferencesXml() != null) {
final ModeController modeController = Controller.getCurrentModeController();
if (modeController instanceof MModeController) {
((MModeController) modeController).getOptionPanelBuilder().load(new StringReader(addOn.getPreferencesXml()));
}
}
if (addOn.getTranslations() != null)
registerAddOnResources(addOn, resourceController);
}
use of org.freeplane.features.mode.ModeController in project freeplane by freeplane.
the class NodeHistory method install.
public static void install(final ModeController modeController) {
final Controller controller = modeController.getController();
final NodeHistory history = (NodeHistory) controller.getExtension(NodeHistory.class);
modeController.getMapController().addNodeSelectionListener(history.getMapSelectionListener());
LinkController.getController(modeController).addNodeSelectionListener(history.getLinkSelectionListener());
history.backAction = new BackAction(controller, history);
modeController.addAction(history.backAction);
history.forwardAction = new ForwardAction(controller, history);
modeController.addAction(history.forwardAction);
}
Aggregations