|
|
(6 intermediate revisions by 4 users not shown) |
Line 3: |
Line 3: |
| __TOC__ | | __TOC__ |
| | | |
− | There are a few utility classes in Freeplane that are of special use for scripting. (For details look up the code.) For example: | + | 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]. |
| | | |
− | [http://freeplane.bzr.sf.net/bzr/freeplane/freeplane_program/release_branches/1_0_x/annotate/head%3A/freeplane/src/org/freeplane/core/ui/components/UITools.java UITools.java] | + | == TextUtils == |
− | <groovy>
| + | 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 class UITools {
| |
− | public static String MAIN_FREEPLANE_FRAME = "mainFreeplaneFrame";
| |
− | | |
− | public static void addEscapeActionToDialog(JDialog dialog);
| |
− | /**
| |
− | *
| |
− | */
| |
− | public void actionPerformed(ActionEvent e);
| |
− | public static void addEscapeActionToDialog(JDialog dialog, Action action);
| |
− | public static void addKeyActionToDialog(JDialog dialog, Action action,
| |
− | String keyStroke, String actionId);
| |
− | public static void convertPointFromAncestor(Component source, Point p,
| |
− | Component c);
| |
− | public static void convertPointToAncestor(Component source, Point point,
| |
− | Class ancestorClass);
| |
− | public static void convertPointToAncestor(Component c, Point p,
| |
− | Component destination);
| |
− | public static void errorMessage(Object message);
| |
− | public void run();
| |
− | public static Frame getFrame();
| |
− | public static KeyStroke getKeyStroke(String keyStrokeDescription);
| |
− | public static void informationMessage(Frame frame, String message);
| |
− | public static void informationMessage(Frame frame, String message, String title);
| |
− | public static void informationMessage(Frame frame, String message, String title,
| |
− | int type);
| |
− | public static void setBounds(Component frame, int win_x, int win_y,
| |
− | int win_width, int win_height);
| |
− | public static void setDialogLocationRelativeTo(JDialog dialog, Component c);
| |
− | public static void setDialogLocationRelativeTo(JDialog dialog,
| |
− | Controller controller, NodeModel node);
| |
− | public static void setDialogLocationUnder(JDialog dialog, Controller controller,
| |
− | NodeModel node);
| |
− | public static int showConfirmDialog(Controller controller, NodeModel node,
| |
− | Object message, String title, int optionType);
| |
− | public static String showInputDialog(Controller controller, NodeModel node,
| |
− | String text, String string);
| |
− | public static String showInputDialog(Controller controller, NodeModel node,
| |
− | String text, String title, int type);
| |
− | }
| |
− | </groovy>
| |
− | | |
| | | |
| == HtmlTools == | | == HtmlTools == |
| | | |
− | [http://freeplane.bzr.sf.net/bzr/freeplane/freeplane_program/release_branches/1_0_x/annotate/head%3A/freeplane/src/org/freeplane/core/util/HtmlTools.java HtmlTools.java] | + | 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]. |
− | <groovy>
| |
− | public class HtmlTools {
| |
− | public static HtmlTools getInstance();
| |
− | public static String htmlToPlain(String text);
| |
− | public static String htmlToPlain(String text, boolean strictHTMLOnly);
| |
− | public static boolean isHtmlNode(String text);
| |
− | public static String plainToHTML(String text);
| |
− | public static String removeAllTagsFromString(String text);
| |
− | /**
| |
− | * Removes all tags (<..>) from a string if it starts with "<html>..." to
| |
− | * make it compareable.
| |
− | */
| |
− | public static String removeHtmlTagsFromString(String text);
| |
− | public static String toXMLEscapedText(String text);
| |
− | public static String toXMLEscapedTextExpandingWhitespace(String text);
| |
− | public static String toXMLUnescapedText(String text);
| |
− | /**
| |
− | * warning: only decodes unicode entities like ä. Use
| |
− | * toXMLUnescapedText(unescapeHTMLUnicodeEntity(text)) to decode &
| |
− | * etc. too.
| |
− | */
| |
− | public static String unescapeHTMLUnicodeEntity(String text);
| |
− | public static String unicodeToHTMLUnicodeEntity(String text);
| |
| | | |
− | // the remainder could/should be static as well (use getInstance() to get the singleton
| + | == LogUtils == |
| | | |
− | /**
| + | Gives access to Freeplane's standard logging facility, see it's [http://www.freeplane.org/doc/api/org/freeplane/core/util/LogUtils.html API]. |
− | * @return the maximal index i such that pI is mapped to i by removing all
| |
− | * tags from the original input.
| |
− | */
| |
− | public int getMaximalOriginalPosition(int pI, ArrayList pListOfIndices);
| |
− | public int getMinimalOriginalPosition(int pI, ArrayList pListOfIndices);
| |
− | /**
| |
− | * Replaces text in node content without replacing tags. fc, 19.12.06: This
| |
− | * method is very difficult. If you have a simplier method, please supply
| |
− | * it. But look that it complies with FindTextTests!!!
| |
− | */
| |
− | public String getReplaceResult(Pattern pattern, String replacement, String text);
| |
− | /**
| |
− | * @return true, if well formed XML.
| |
− | */
| |
− | public boolean isWellformedXml(String xml);
| |
− | public String toHtml(String xhtmlText);
| |
− | public String toXhtml(String htmlText);
| |
− | static public int endOfText(String html);
| |
− | }
| |
− | </groovy>
| |
| | | |
− | == LogTool == | + | == FreeplaneVersion == |
− | | |
− | Gives access to Freeplane's standard logging facility:
| |
| | | |
− | [http://freeplane.bzr.sf.net/bzr/freeplane/freeplane_program/release_branches/1_0_x/annotate/head%3A/freeplane/src/org/freeplane/core/util/LogTool.java LogTool.java] | + | ''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>
| |
− | public class LogTool {
| |
− | public static void createLogger();
| |
− | public static void info(String string);
| |
− | public static void info(Transferable t);
| |
− | public static void severe(String message);
| |
− | public static void severe(String comment, Throwable e);
| |
− | public static void severe(Throwable e);
| |
− | public static void warn(String msg);
| |
− | public static void warn(String comment, Throwable e);
| |
− | public static void warn(Throwable e);
| |
− | }
| |
− | </groovy>
| |
− | | |
− | == FreeplaneVersion ==
| |
| | | |
− | [http://freeplane.bzr.sf.net/bzr/freeplane/freeplane_program/release_branches/1_0_x/annotate/head%3A/freeplane/src/org/freeplane/core/controller/FreeplaneVersion.java FreeplaneVersion.java] | + | [[Category:Script]] |
− | <groovy>
| |
− | </groovy>
| |