Search in sources :

Example 1 with MMapModel

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();
}
Also used : MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) IUndoHandler(org.freeplane.core.undo.IUndoHandler)

Example 2 with MMapModel

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();
}
Also used : MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) IUndoHandler(org.freeplane.core.undo.IUndoHandler)

Example 3 with MMapModel

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();
            }
        }
    };
}
Also used : ActionEvent(java.awt.event.ActionEvent) MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) JTabbedPane(javax.swing.JTabbedPane) MFileManager(org.freeplane.features.url.mindmapmode.MFileManager) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) MapModel(org.freeplane.features.map.MapModel) AddOnsController(org.freeplane.main.addons.AddOnsController) ResourceController(org.freeplane.core.resources.ResourceController) Controller(org.freeplane.features.mode.Controller) ModeController(org.freeplane.features.mode.ModeController) MModeController(org.freeplane.features.mode.mindmapmode.MModeController) URL(java.net.URL) AddOnProperties(org.freeplane.main.addons.AddOnProperties) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) ActionListener(java.awt.event.ActionListener) ResourceController(org.freeplane.core.resources.ResourceController) File(java.io.File)

Example 4 with MMapModel

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);
    }
}
Also used : MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) MapModel(org.freeplane.features.map.MapModel) MModeController(org.freeplane.features.mode.mindmapmode.MModeController)

Example 5 with MMapModel

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);
}
Also used : MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) Reader(java.io.Reader) ModeController(org.freeplane.features.mode.ModeController) MMapModel(org.freeplane.features.map.mindmapmode.MMapModel) MapModel(org.freeplane.features.map.MapModel) XsltPipeReaderFactory(org.freeplane.core.util.XsltPipeReaderFactory) URL(java.net.URL) MapController(org.freeplane.features.map.MapController)

Aggregations

MMapModel (org.freeplane.features.map.mindmapmode.MMapModel)7 URL (java.net.URL)3 IUndoHandler (org.freeplane.core.undo.IUndoHandler)3 MapModel (org.freeplane.features.map.MapModel)3 ModeController (org.freeplane.features.mode.ModeController)3 MModeController (org.freeplane.features.mode.mindmapmode.MModeController)3 File (java.io.File)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 JTabbedPane (javax.swing.JTabbedPane)1 ResourceController (org.freeplane.core.resources.ResourceController)1 XsltPipeReaderFactory (org.freeplane.core.util.XsltPipeReaderFactory)1 MapController (org.freeplane.features.map.MapController)1 Controller (org.freeplane.features.mode.Controller)1 MFileManager (org.freeplane.features.url.mindmapmode.MFileManager)1