|
|
(9 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
− | There are a few utility classes in Freeplane that are of special use for scripting: | + | [[Scripting|Back to Scripting overview]] |
| + | |
| + | __TOC__ |
| + | |
| + | There are a few utility classes in Freeplane that are of special use for scripting. Look up their API in the Freeplane scripting API docs, for example coming from the menu - ''Help -> Scripting API''. Here are the direct links: |
| | | |
| == UITools == | | == UITools == |
| + | Available via the shortcut ''ui'', e.h. ''ui.frame'' instead of ''UITools.getFrame()''. See it's [http://www.freeplane.org/doc/api/org/freeplane/core/ui/components/UITools.html API]. |
| | | |
− | <groovy>
| + | == TextUtils == |
− | public class UITools {
| + | Mainly gives acces to available translations. Use the shortcut ''textUtils'', e.h. ''textUtils.getText('invalid_url', 'The URL is invalid')''. See it's [http://www.freeplane.org/doc/api/org/freeplane/core/util/TextUtils.html API]. |
− | public static final String MAIN_FREEPLANE_FRAME = "mainFreeplaneFrame";
| |
− | public static void addEscapeActionToDialog(final JDialog dialog);
| |
− | public static void addEscapeActionToDialog(final JDialog dialog, final Action action);
| |
− | public static void addKeyActionToDialog(final JDialog dialog, final Action action, final String keyStroke,
| |
− | public static void convertPointFromAncestor(final Component source, final Point p, Component c);
| |
− | public static void convertPointToAncestor(final Component source, final Point point, final Class ancestorClass);
| |
− | public static void convertPointToAncestor(Component c, final Point p, final Component destination);
| |
− | public static void errorMessage(final Object message);
| |
− | public static Frame getFrame();
| |
− | public static KeyStroke getKeyStroke(final String keyStrokeDescription);
| |
− | public static void informationMessage(final Frame frame, final String message);
| |
− | public static void informationMessage(final Frame frame, final String message, final String title);
| |
− | public static void informationMessage(final Frame frame, final String text, final String string, final int type);
| |
− | public static void setBounds(final Component frame, int win_x, int win_y, int win_width, int win_height);
| |
− | public static void setDialogLocationRelativeTo(final JDialog dialog, final Component c);
| |
− | public static void setDialogLocationRelativeTo(final JDialog dialog, final Controller controller,
| |
− | public static void setDialogLocationUnder(final JDialog dialog, final Controller controller, final NodeModel node);
| |
− | public static int showConfirmDialog(final Controller controller, final NodeModel node, final Object message,
| |
− | public static String showInputDialog(final Controller controller, final NodeModel node, final String text,
| |
− | public static String showInputDialog(final Controller controller, final NodeModel node, final String text,
| |
− | }
| |
− | </groovy>
| |
| | | |
| + | == HtmlTools == |
| | | |
− | == HtmlTools == | + | Available via the shortcut ''htmlUtils'', e.h. ''htmlUtils.toHtml("bla\nbla")''. See it's [http://www.freeplane.org/doc/api/org/freeplane/core/util/HtmlUtils.html API]. |
| + | |
| + | == LogUtils == |
| | | |
− | <groovy>
| + | Gives access to Freeplane's standard logging facility, see it's [http://www.freeplane.org/doc/api/org/freeplane/core/util/LogUtils.html API]. |
− | public class HtmlTools {
| |
− | public static HtmlTools getInstance();
| |
− | public static String htmlToPlain(final String text);
| |
− | public static String htmlToPlain(final String text, final boolean strictHTMLOnly);
| |
− | public static boolean isHtmlNode(final String text);
| |
− | public static String plainToHTML(final String text);
| |
− | public static String removeAllTagsFromString(final String text);
| |
− | public static String removeHtmlTagsFromString(final String text);
| |
− | public static String toXMLEscapedText(final String text);
| |
− | public static String toXMLEscapedTextExpandingWhitespace(String text);
| |
− | public static String toXMLUnescapedText(final String text);
| |
− | public static String unescapeHTMLUnicodeEntity(final String text);
| |
− | public static String unicodeToHTMLUnicodeEntity(final String text);
| |
− | public static int endOfText(final String html);
| |
− | // the remainder could/should be static as well:
| |
− | public int getMaximalOriginalPosition(final int pI, final ArrayList pListOfIndices);
| |
− | public int getMinimalOriginalPosition(final int pI, final ArrayList pListOfIndices);
| |
− | public String getReplaceResult(final Pattern pattern, final String replacement, final String text);
| |
− | public boolean isWellformedXml(final String xml);
| |
− | public String toHtml(final String xhtmlText);
| |
− | public String toXhtml(String htmlText);
| |
− | }
| |
− | </groovy>
| |
| | | |
− | == LogTool == | + | == FreeplaneVersion == |
| | | |
− | Gives access to Freeplane's standard logging facility:
| + | ''FreeplaneVersion.version'' is the full current version (like "1.2.20") but FreeplaneVersion has also accessors for major, minor versions etc. See it's [http://www.freeplane.org/doc/api/org/freeplane/core/util/FreeplaneVersion.html API]. |
| | | |
− | <groovy>
| + | [[Category:Script]] |
− | public class LogTool {
| |
− | public static void createLogger();
| |
− | public static void info(final String string);
| |
− | public static void info(final Transferable t);
| |
− | public static void severe(final String message);
| |
− | public static void severe(final String comment, final Throwable e);
| |
− | public static void severe(final Throwable e);
| |
− | public static void warn(final String msg);
| |
− | public static void warn(final String comment, final Throwable e);
| |
− | public static void warn(final Throwable e);
| |
− | }
| |
− | </groovy>
| |
Back to Scripting overview
There are a few utility classes in Freeplane that are of special use for scripting. Look up their API in the Freeplane scripting API docs, for example coming from the menu - Help -> Scripting API. Here are the direct links:
UITools
Available via the shortcut ui, e.h. ui.frame instead of UITools.getFrame(). See it's API.
TextUtils
Mainly gives acces to available translations. Use the shortcut textUtils, e.h. textUtils.getText('invalid_url', 'The URL is invalid'). See it's API.
HtmlTools
Available via the shortcut htmlUtils, e.h. htmlUtils.toHtml("bla\nbla"). See it's API.
LogUtils
Gives access to Freeplane's standard logging facility, see it's API.
FreeplaneVersion
FreeplaneVersion.version is the full current version (like "1.2.20") but FreeplaneVersion has also accessors for major, minor versions etc. See it's API.