use of org.freeplane.features.map.mindmapmode.MMapModel in project freeplane by freeplane.
the class MModeController method delayedRollback.
public void delayedRollback() {
final MMapModel map = (MMapModel) getController().getMap();
final IUndoHandler undoHandler = map.getExtension(IUndoHandler.class);
undoHandler.delayedRollback();
}
use of org.freeplane.features.map.mindmapmode.MMapModel in project freeplane by freeplane.
the class MModeController method delayedCommit.
public void delayedCommit() {
final MMapModel map = (MMapModel) getController().getMap();
final IUndoHandler undoHandler = map.getExtension(IUndoHandler.class);
undoHandler.delayedCommit();
}
use of org.freeplane.features.map.mindmapmode.MMapModel 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.mindmapmode.MMapModel in project freeplane by freeplane.
the class ControllerProxy method deactivateUndo.
public void deactivateUndo() {
final MapModel map = Controller.getCurrentController().getMap();
if (map instanceof MapModel) {
MModeController modeController = ((MModeController) Controller.getCurrentModeController());
modeController.deactivateUndo((MMapModel) map);
}
}
use of org.freeplane.features.map.mindmapmode.MMapModel in project freeplane by freeplane.
the class XmlImporter method newMap.
private void newMap(final InputStream in, final File outputFile) throws IOException, XMLException, MalformedURLException {
final Reader reader = new XsltPipeReaderFactory(xsltResource).getReader(in);
final ModeController modeController = Controller.getCurrentModeController();
final MapController mapController = modeController.getMapController();
final MapModel map = new MMapModel();
modeController.getMapController().getMapReader().createNodeTreeFromXml(map, reader, Mode.FILE);
final URL mapUrl = Compat.fileToUrl(outputFile);
map.setURL(mapUrl);
map.setSaved(false);
mapController.fireMapCreated(map);
mapController.newMapView(map);
}
Aggregations