Difference between revisions of "Scripting: Freeplane Utility Classes"

From Freeplane - free mind mapping and knowledge management software
(Created page with 'There are a few utility classes in Freeplane that are of special use for scripting: == UITools == <groovy> public class UITools { public static final String MAIN_FREEPLANE_...')
 
Line 1: Line 1:
There are a few utility classes in Freeplane that are of special use for scripting:
+
There are a few utility classes in Freeplane that are of special use for scripting. (For details look up the code.) For example:
  
 
== UITools ==
 
== UITools ==
  
 +
[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]
 
<groovy>
 
<groovy>
 
public class UITools {
 
public class UITools {
     public static final String MAIN_FREEPLANE_FRAME = "mainFreeplaneFrame";
+
     public static String MAIN_FREEPLANE_FRAME = "mainFreeplaneFrame";
     public static void addEscapeActionToDialog(final JDialog dialog);
+
     public static void addEscapeActionToDialog(JDialog dialog);
     public static void addEscapeActionToDialog(final JDialog dialog, final Action action);
+
     public static void addEscapeActionToDialog(JDialog dialog, Action action);
     public static void addKeyActionToDialog(final JDialog dialog, final Action action, final String keyStroke,
+
     public static void addKeyActionToDialog(JDialog dialog, Action action, String keyStroke, String actionId);
     public static void convertPointFromAncestor(final Component source, final Point p, Component c);
+
     public static void convertPointFromAncestor(Component source, Point p, Component c);
     public static void convertPointToAncestor(final Component source, final Point point, final Class ancestorClass);
+
     public static void convertPointToAncestor(Component source, Point point, Class ancestorClass);
     public static void convertPointToAncestor(Component c, final Point p, final Component destination);
+
     public static void convertPointToAncestor(Component c, Point p, Component destination);
     public static void errorMessage(final Object message);
+
     public static void errorMessage(Object message);
 
     public static Frame getFrame();
 
     public static Frame getFrame();
     public static KeyStroke getKeyStroke(final String keyStrokeDescription);
+
     public static KeyStroke getKeyStroke(String keyStrokeDescription);
     public static void informationMessage(final Frame frame, final String message);
+
     public static void informationMessage(Frame frame, String message);
     public static void informationMessage(final Frame frame, final String message, final String title);
+
     public static void informationMessage(Frame frame, String message, String title);
     public static void informationMessage(final Frame frame, final String text, final String string, final int type);
+
     public static void informationMessage(Frame frame, String text, String string, int type);
     public static void setBounds(final Component frame, int win_x, int win_y, int win_width, int win_height);
+
     public static void setBounds(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(JDialog dialog, Component c);
     public static void setDialogLocationRelativeTo(final JDialog dialog, final Controller controller,
+
     public static void setDialogLocationRelativeTo(JDialog dialog, Controller controller,
     public static void setDialogLocationUnder(final JDialog dialog, final Controller controller, final NodeModel node);
+
     public static void setDialogLocationUnder(JDialog dialog, Controller controller, NodeModel node);
     public static int showConfirmDialog(final Controller controller, final NodeModel node, final Object message,
+
     public static int showConfirmDialog(Controller controller, NodeModel node, Object message, String title, int optionType);
     public static String showInputDialog(final Controller controller, final NodeModel node, final String text,
+
     public static String showInputDialog(Controller controller, NodeModel node, String text, String string);
     public static String showInputDialog(final Controller controller, final NodeModel node, final String text,
+
     public static String showInputDialog(Controller controller, NodeModel node, String text, String title, int type);
 
}
 
}
 
</groovy>
 
</groovy>
Line 31: Line 32:
 
== 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]
 
<groovy>
 
<groovy>
 
public class HtmlTools {
 
public class HtmlTools {
 
     public static HtmlTools getInstance();
 
     public static HtmlTools getInstance();
     public static String htmlToPlain(final String text);
+
     public static String htmlToPlain(String text);
     public static String htmlToPlain(final String text, final boolean strictHTMLOnly);
+
     public static String htmlToPlain(String text, boolean strictHTMLOnly);
     public static boolean isHtmlNode(final String text);
+
     public static boolean isHtmlNode(String text);
     public static String plainToHTML(final String text);
+
     public static String plainToHTML(String text);
     public static String removeAllTagsFromString(final String text);
+
     public static String removeAllTagsFromString(String text);
     public static String removeHtmlTagsFromString(final String text);
+
     public static String removeHtmlTagsFromString(String text);
     public static String toXMLEscapedText(final String text);
+
     public static String toXMLEscapedText(String text);
 
     public static String toXMLEscapedTextExpandingWhitespace(String text);
 
     public static String toXMLEscapedTextExpandingWhitespace(String text);
     public static String toXMLUnescapedText(final String text);
+
     public static String toXMLUnescapedText(String text);
     public static String unescapeHTMLUnicodeEntity(final String text);
+
     public static String unescapeHTMLUnicodeEntity(String text);
     public static String unicodeToHTMLUnicodeEntity(final String text);
+
     public static String unicodeToHTMLUnicodeEntity(String text);
     public static int endOfText(final String html);
+
     public static int endOfText(String html);
 
     // the remainder could/should be static as well:
 
     // the remainder could/should be static as well:
     public int getMaximalOriginalPosition(final int pI, final ArrayList pListOfIndices);
+
     public int getMaximalOriginalPosition(int pI, ArrayList pListOfIndices);
     public int getMinimalOriginalPosition(final int pI, final ArrayList pListOfIndices);
+
     public int getMinimalOriginalPosition(int pI, ArrayList pListOfIndices);
     public String getReplaceResult(final Pattern pattern, final String replacement, final String text);
+
     public String getReplaceResult(Pattern pattern, String replacement, String text);
     public boolean isWellformedXml(final String xml);
+
     public boolean isWellformedXml(String xml);
     public String toHtml(final String xhtmlText);
+
     public String toHtml(String xhtmlText);
 
     public String toXhtml(String htmlText);
 
     public String toXhtml(String htmlText);
 
}
 
}
Line 60: Line 62:
 
Gives access to Freeplane's standard logging facility:
 
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]
 
<groovy>
 
<groovy>
 
public class LogTool {
 
public class LogTool {
 
     public static void createLogger();
 
     public static void createLogger();
     public static void info(final String string);
+
     public static void info(String string);
     public static void info(final Transferable t);
+
     public static void info(Transferable t);
     public static void severe(final String message);
+
     public static void severe(String message);
     public static void severe(final String comment, final Throwable e);
+
     public static void severe(String comment, Throwable e);
     public static void severe(final Throwable e);
+
     public static void severe(Throwable e);
     public static void warn(final String msg);
+
     public static void warn(String msg);
     public static void warn(final String comment, final Throwable e);
+
     public static void warn(String comment, Throwable e);
     public static void warn(final Throwable e);
+
     public static void warn(Throwable e);
 
}
 
}
 
</groovy>
 
</groovy>

Revision as of 00:06, 20 January 2010

There are a few utility classes in Freeplane that are of special use for scripting. (For details look up the code.) For example:

UITools

UITools.java <groovy> public class UITools {

   public static String MAIN_FREEPLANE_FRAME = "mainFreeplaneFrame";
   public static void addEscapeActionToDialog(JDialog dialog);
   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 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 text, String string, 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,
   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.java <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);
   public static String removeHtmlTagsFromString(String text);
   public static String toXMLEscapedText(String text);
   public static String toXMLEscapedTextExpandingWhitespace(String text);
   public static String toXMLUnescapedText(String text);
   public static String unescapeHTMLUnicodeEntity(String text);
   public static String unicodeToHTMLUnicodeEntity(String text);
   public static int endOfText(String html);
   // the remainder could/should be static as well:
   public int getMaximalOriginalPosition(int pI, ArrayList pListOfIndices);
   public int getMinimalOriginalPosition(int pI, ArrayList pListOfIndices);
   public String getReplaceResult(Pattern pattern, String replacement, String text);
   public boolean isWellformedXml(String xml);
   public String toHtml(String xhtmlText);
   public String toXhtml(String htmlText);

} </groovy>

LogTool

Gives access to Freeplane's standard logging facility:

LogTool.java <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>