use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class HeadlessMModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
IconController.install(new MIconController(modeController));
new ProgressFactory().installActions(modeController);
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
final MTextController textController = new MTextController(modeController);
TextController.install(textController);
LinkController.install(new MLinkController());
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
new RevisionPlugin();
FoldingController.install(new FoldingController());
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class UpdateCheckAction method addUpdateButton.
private void addUpdateButton(final FreeplaneVersion lastVersion) {
Controller controller = Controller.getCurrentController();
final Set<String> modes = controller.getModes();
for (final String mode : modes) {
ModeController modeController = controller.getModeController(mode);
if (!modeController.getUserInputListenerFactory().useRibbonMenu()) {
final MenuBuilder menuBuilder = modeController.getUserInputListenerFactory().getMenuBuilder(MenuBuilder.class);
if (lastVersion == null || lastVersion.compareTo(FreeplaneVersion.getVersion()) <= 0) {
ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, "");
if (menuBuilder.get(UPDATE_BUTTON_PATH) != null) {
menuBuilder.removeElement(UPDATE_BUTTON_PATH);
}
continue;
}
ResourceController.getResourceController().setProperty(LAST_UPDATE_VERSION, lastVersion.toString());
final String updateAvailable = TextUtils.format("new_version_available", lastVersion.toString());
controller.getViewController().out(updateAvailable);
putValue(SHORT_DESCRIPTION, updateAvailable);
putValue(LONG_DESCRIPTION, updateAvailable);
if (menuBuilder.get(UPDATE_BUTTON_PATH) == null) {
menuBuilder.addAction(UPDATE_BUTTON_LOCATION, UPDATE_BUTTON_PATH, UpdateCheckAction.this, MenuBuilder.AS_CHILD);
}
}
}
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class ManualBugReporter method openBugTracker.
private void openBugTracker(final String log, final String hash) {
final String option = showBugReportDialog(log, hash);
if (!BugReportDialogManager.ALLOWED.equals(option)) {
return;
}
try {
final ResourceController resourceController = ResourceController.getResourceController();
final String location = resourceController.getProperty("bugTrackerLocation");
final Controller controller = Controller.getCurrentController();
controller.getViewController().openDocument(new URL(location));
} catch (final MalformedURLException ex) {
UITools.errorMessage(TextUtils.getText("url_error") + "\n" + ex);
LogUtils.warn(ex);
} catch (final Exception ex) {
UITools.errorMessage(ex);
LogUtils.warn(ex);
}
}
use of org.freeplane.features.mode.Controller in project freeplane by freeplane.
the class NodeIdHighLighter method deHighlight.
public void deHighlight() {
if (originallySelectedNode == null)
return;
final Controller controller = Controller.getCurrentController();
if (controller == null)
return;
final MapController mapController = controller.getModeController().getMapController();
mapController.displayNode(originallySelectedNode);
mapController.select(originallySelectedNode);
foldOriginallyFolded(mapController);
originallySelectedNode = null;
pane.setToolTipText(null);
}
use of org.freeplane.features.mode.Controller 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();
}
}
};
}
Aggregations