use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class AddOnInstallerPanel method createInstallActionListener.
private ActionListener createInstallActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Controller controller = Controller.getCurrentController();
try {
LogUtils.info("installing add-on from " + urlField.getText());
controller.getViewController().setWaitingCursor(true);
final URL url = toURL(urlField.getText());
setStatusInfo(getText("status.installing"));
final ModeController modeController = controller.getModeController(MModeController.MODENAME);
final MFileManager fileManager = (MFileManager) MFileManager.getController(modeController);
MapModel newMap = new MMapModel();
if (!fileManager.loadCatchExceptions(url, newMap)) {
LogUtils.warn("can not load " + url);
return;
}
controller.getModeController().getMapController().fireMapCreated(newMap);
AddOnProperties addOn = (AddOnProperties) ScriptingEngine.executeScript(newMap.getRootNode(), getInstallScriptSource(), ScriptingPermissions.getPermissiveScriptingPermissions());
if (addOn != null) {
setStatusInfo(getText("status.success", addOn.getName()));
AddOnsController.getController().registerInstalledAddOn(addOn);
final ManageAddOnsPanel managementPanel = addOn.isTheme() ? manageThemesPanel : manageAddOnsPanel;
managementPanel.getTableModel().addAddOn(addOn);
urlField.setText("");
((JTabbedPane) getParent()).setSelectedComponent(managementPanel);
selectLastAddOn(managementPanel);
}
} catch (Exception ex) {
UITools.errorMessage(getText("error", ex.toString()));
} finally {
controller.getViewController().setWaitingCursor(false);
}
}
private String getInstallScriptSource() throws IOException {
final ResourceController resourceController = ResourceController.getResourceController();
final File scriptDir = new File(resourceController.getInstallationBaseDir(), "scripts");
final File installScript = new File(scriptDir, "installScriptAddOn.groovy");
if (!installScript.exists())
throw new RuntimeException("internal error: installer not found at " + installScript);
return FileUtils.slurpFile(installScript);
}
private URL toURL(String urlText) throws MalformedURLException {
try {
return new URL(urlText);
} catch (Exception e2) {
return new File(urlText).toURI().toURL();
}
}
};
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class ConvertibleTest method convertible.
private Convertible convertible(String text) {
final MapModel mapModel = Controller.getCurrentModeController().getMapController().newModel();
NodeModel nodeModel = new NodeModel(mapModel);
return new TestConvertible(nodeModel, text);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class ControllerProxy method getOpenMaps.
public List<Map> getOpenMaps() {
Collection<MapModel> mapModels = getMapViewManager().getMaps().values();
ArrayList<Map> mapProxies = new ArrayList<Map>(mapModels.size());
for (MapModel mapModel : mapModels) {
mapProxies.add(new MapProxy(mapModel, scriptContext));
}
return mapProxies;
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class ControllerProxy method newMapFromTemplate.
public Map newMapFromTemplate(File templateFile) {
final MapModel oldMap = Controller.getCurrentController().getMap();
final MMapIO mapIO = (MMapIO) Controller.getCurrentModeController().getExtension(MapIO.class);
final MapModel newMap = mapIO.newMapFromTemplate(templateFile);
restartTransaction(oldMap, newMap);
return new MapProxy(newMap, scriptContext);
}
use of org.freeplane.features.map.MapModel in project freeplane by freeplane.
the class ControllerProxy method undo.
public void undo() {
final MapModel map = Controller.getCurrentController().getMap();
final IUndoHandler undoHandler = (IUndoHandler) map.getExtension(IUndoHandler.class);
undoHandler.undo();
}
Aggregations