Difference between revisions of "Scripting: API Changes"

From Freeplane - free mind mapping and knowledge management software
m (Text replacement - "freeplane.sourceforge.net" to "www.freeplane.org")
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The [[Scripting_API|Scripting API]], which is defined by the <groovy>org.freeplane.plugin.script.proxy.Proxy</groovy> interface, will evolve over time but Freeplane's developers will do whatever possible to keep new API versions downward compatible. On the other hand there might be changes in parts of the Freeplane code that are not part of the official API but on which some scripts might depend nevertheless. This mostly applies to the [[Scripting:_Freeplane_Utility_Classes|utility classes]].
+
The [[Scripting_API|Scripting API]], which is defined by the [http://www.freeplane.org/doc/api/org/freeplane/plugin/script/proxy/Proxy.html org.freeplane.plugin.script.proxy.Proxy] interface and is [http://www.freeplane.org/doc/api/ documented as JavaDoc], will evolve over time but Freeplane's developers will do whatever possible to keep new API versions downward compatible. On the other hand there might be changes in parts of the Freeplane code that are not part of the official API but on which some scripts might depend nevertheless. This mostly applies to the [[Scripting:_Freeplane_Utility_Classes|utility classes]].
  
This page lists changes in Freeplane that you might want or sometimes have to care about when changing to new Freeplane versions.
+
Changes to the API are indicated per method by version numbers in the [http://www.freeplane.org/doc/api/org/freeplane/plugin/script/proxy/Proxy.html JavaDoc of the Proxy class].
  
 +
Here a possibly incomplete list of changes from 1.3 to 1.5:
  
== Before Release 1.1==
+
* node.attributes.containsKey(String)
===1.41 beta===
+
* node.attributes.optimizeWidths()
 +
* node.icons.addAll(Collection<String>)
 +
* node.icons.addAll(otherNode.icons)
 +
* node.link.remove()
 +
* node.sortChildrenBy{ Closure }
 +
* support units like mm, cm, pt for lengths and dimensions
 +
* c.select(Collection<Node>)
 +
* c.getOpenMaps()
 +
* textUtils.setClipboardContentsToHtml()
  
Attributes:
+
Clones
<groovy>
 
List<String> getAll(String)
 
public List<String> getAttributeNames()
 
String get(final int index)
 
void set(final int index, final String value)
 
void set(final int index, final String name, final String value)
 
boolean removeAll(final String name)
 
void remove(final int index)
 
void add(final String name, final String value)
 
int size()
 
</groovy>
 
  
===1.43 rc===
+
* c.pasteAsClone()
<groovy>
+
* node.appendAsCloneWithSubtree(NodeRO toBeCloned)
  File Map.getFile()
+
* node.appendAsCloneWithoutSubtree(NodeRO toBeCloned)
</groovy>
+
* node.getCountNodesSharingContent()
 +
* node.getCountNodesSharingContentAndSubtree()
 +
* node.getNodesSharingContent()
 +
* node.getNodesSharingContentAndSubtree()
  
== After Release 1.1==
 
  
===Refactoring of utility classes===
+
[[Category:Script]]
 
 
In package <tt>org.freeplane.core.util</tt>:
 
 
 
* <tt>ResUtil</tt> => <tt>FileUtils</tt>
 
* <tt>HtmlTools</tt> => <tt>HtmlUtils</tt>
 
* <tt>LogTool</tt> => <tt>LogUtils</tt>
 
* <tt>MenuTools</tt> => <tt>MenuUtils</tt>
 
* <tt>SysUtil</tt> => <tt>SysUtils</tt>
 
* <tt>XmlTool</tt> => <tt>XmlUtils</tt>
 
 
 
Other:
 
* <tt>org.freeplane.core.resources.FpStringUtils</tt> => <tt>org.freeplane.core.util.TextUtil</tt>
 
* <tt>org.freeplane.core.util.MultipleValueMap</tt> => <tt>org.freeplane.core.util.collection.MultipleValueMap</tt>
 
 
 
The following Perl script will adjust all scripts in the current directory with a ".groovy" suffix. The original file will be saved with a ".bak" suffix.
 
<groovy>
 
perl -i.bak -pe 's,\b(Res|Sys)Util\b,$1Utils,g;
 
  s,\b(Html|Log|Menu|Xml)Tools?\b,$1Utils,g;
 
  s,resources\.FpStringUtils\b,util\.FpStringUtils,g;
 
  s,\bFpStringUtils\b,TextUtils,g;
 
  s,(util).(MultipleValueMap)\b,$1.collection.$2,g' *.groovy
 
</groovy>
 
 
 
===Adjustments for Formulas===
 
 
 
The new [[Formula]] plugin has driven changes that allows to write more compact code. For the newest development API version and the changes therein see [[Scripting API (Pre-Release)]]
 
 
 
[[Category:Scripting]]
 

Latest revision as of 19:24, 18 November 2018

The Scripting API, which is defined by the org.freeplane.plugin.script.proxy.Proxy interface and is documented as JavaDoc, will evolve over time but Freeplane's developers will do whatever possible to keep new API versions downward compatible. On the other hand there might be changes in parts of the Freeplane code that are not part of the official API but on which some scripts might depend nevertheless. This mostly applies to the utility classes.

Changes to the API are indicated per method by version numbers in the JavaDoc of the Proxy class.

Here a possibly incomplete list of changes from 1.3 to 1.5:

  • node.attributes.containsKey(String)
  • node.attributes.optimizeWidths()
  • node.icons.addAll(Collection<String>)
  • node.icons.addAll(otherNode.icons)
  • node.link.remove()
  • node.sortChildrenBy{ Closure }
  • support units like mm, cm, pt for lengths and dimensions
  • c.select(Collection<Node>)
  • c.getOpenMaps()
  • textUtils.setClipboardContentsToHtml()

Clones

  • c.pasteAsClone()
  • node.appendAsCloneWithSubtree(NodeRO toBeCloned)
  • node.appendAsCloneWithoutSubtree(NodeRO toBeCloned)
  • node.getCountNodesSharingContent()
  • node.getCountNodesSharingContentAndSubtree()
  • node.getNodesSharingContent()
  • node.getNodesSharingContentAndSubtree()