use of org.freeplane.features.mode.mindmapmode.MModeController 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.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class MIconController method createPreferences.
private void createPreferences() {
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
final OptionPanelBuilder optionPanelBuilder = modeController.getOptionPanelBuilder();
final List<AFreeplaneAction> actions = new ArrayList<AFreeplaneAction>();
actions.addAll(iconActions.values());
actions.add(modeController.getAction("RemoveIcon_0_Action"));
actions.add(modeController.getAction("RemoveIconAction"));
actions.add(modeController.getAction("RemoveAllIconsAction"));
for (final AFreeplaneAction iconAction : actions) {
final IIconInformation info = (IIconInformation) iconAction;
optionPanelBuilder.addCreator("Keystrokes/icons", new IPropertyControlCreator() {
public IPropertyControl createControl() {
final KeyProperty keyProperty = new KeyProperty(info.getShortcutKey(), info.getTranslationValueLabel());
keyProperty.setIcon(info.getIcon());
keyProperty.disableModifiers();
return keyProperty;
}
}, IndexedTree.AS_CHILD);
}
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class ScriptingRegistration method addPropertiesToOptionPanel.
private void addPropertiesToOptionPanel() {
final URL preferences = this.getClass().getResource("preferences.xml");
if (preferences == null)
throw new RuntimeException("cannot open preferences");
Controller.getCurrentController().addOptionValidator(new IValidator() {
@Override
public ValidationResult validate(Properties properties) {
final ValidationResult result = new ValidationResult();
final String readAccessString = properties.getProperty(ScriptingPermissions.RESOURCES_EXECUTE_SCRIPTS_WITHOUT_READ_RESTRICTION);
final String writeAccessString = properties.getProperty(ScriptingPermissions.RESOURCES_EXECUTE_SCRIPTS_WITHOUT_WRITE_RESTRICTION);
final String classpath = properties.getProperty(ScriptResources.RESOURCES_SCRIPT_CLASSPATH);
final boolean readAccess = readAccessString != null && Boolean.parseBoolean(readAccessString);
final boolean writeAccess = writeAccessString != null && Boolean.parseBoolean(writeAccessString);
final boolean classpathIsSet = classpath != null && classpath.length() > 0;
if (classpathIsSet && !readAccess) {
result.addError(TextUtils.getText("OptionPanel.validate_classpath_needs_readaccess"));
}
if (writeAccess && !readAccess) {
result.addWarning(TextUtils.getText("OptionPanel.validate_write_without_read"));
}
return result;
}
});
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
modeController.getOptionPanelBuilder().load(preferences);
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class Activator method registerMindMapModeExtension.
private void registerMindMapModeExtension(final BundleContext context) {
final Hashtable<String, String[]> props = new Hashtable<String, String[]>();
props.put("mode", new String[] { MModeController.MODENAME, SModeController.MODENAME });
context.registerService(IModeControllerExtensionProvider.class.getName(), new IModeControllerExtensionProvider() {
public void installExtension(final ModeController modeController) {
// LattexNodeHook -> Menu insert
final LatexNodeHook nodeHook = new LatexNodeHook();
//
modeController.getExtension(TextController.class).addTextTransformer(new ConditionalContentTransformer(new LatexRenderer(), Activator.TOGGLE_PARSE_LATEX));
modeController.getController().getExtension(FormatController.class).addPatternFormat(new LatexFormat());
modeController.getController().getExtension(FormatController.class).addPatternFormat(new UnparsedLatexFormat());
if (modeController.getModeName().equals("MindMap")) {
modeController.addAction(new InsertLatexAction(nodeHook));
modeController.addAction(new EditLatexAction(nodeHook));
modeController.addAction(new DeleteLatexAction(nodeHook));
addPreferencesToOptionPanel();
}
}
private void addPreferencesToOptionPanel() {
final URL preferences = this.getClass().getResource(PREFERENCES_RESOURCE);
if (preferences == null)
throw new RuntimeException("cannot open preferences");
final Controller controller = Controller.getCurrentController();
MModeController modeController = (MModeController) controller.getModeController();
modeController.getOptionPanelBuilder().load(preferences);
}
}, props);
}
use of org.freeplane.features.mode.mindmapmode.MModeController in project freeplane by freeplane.
the class ExecuteScriptAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
Controller.getCurrentController().getViewController().setWaitingCursor(true);
try {
final List<NodeModel> nodes = new ArrayList<NodeModel>();
final IMapSelection selection = Controller.getCurrentController().getSelection();
if (mode == ExecutionMode.ON_SINGLE_NODE) {
nodes.add(selection.getSelected());
} else {
nodes.addAll(selection.getSelection());
}
final MModeController modeController = (MModeController) Controller.getCurrentModeController();
modeController.startTransaction();
for (final NodeModel node : nodes) {
try {
if (mode == ExecutionMode.ON_SELECTED_NODE_RECURSIVELY) {
// TODO: ensure that a script is invoked only once on every node?
// (might be a problem with recursive actions if parent and child
// are selected.)
executeScriptRecursive(node);
} else {
script.execute(node);
}
} catch (ExecuteScriptException ex) {
final String cause;
// that, it is what we want to know.
if (ex.getCause() != null) {
if (ex.getCause().getCause() != null) {
LogUtils.warn("ExecuteScriptAction failed:", ex.getCause().getCause());
cause = ex.getCause().getCause().toString();
} else {
LogUtils.warn("ExecuteScriptAction failed:", ex.getCause());
cause = ex.getCause().toString();
}
} else {
LogUtils.warn("ExecuteScriptAction failed:", ex);
cause = ex.toString();
}
LogUtils.warn("error executing script " + scriptFile + " - giving up\n" + cause);
modeController.delayedRollback();
ScriptingEngine.showScriptExceptionErrorMessage(ex);
return;
}
}
modeController.delayedCommit();
} finally {
Controller.getCurrentController().getViewController().setWaitingCursor(false);
}
}
Aggregations