Package org.freeplane.launcher
Class Launcher
java.lang.Object
org.freeplane.launcher.Launcher
public class Launcher
extends java.lang.Object
This class can be used to run freeplane instance from an application and to obtain its
Controller
object.
To run a headless Freeplane instance use Launcher.create().launchHeadless()
,
to run a freeplane with complete user UI use Launcher.create().launch()
Code Example:
public static void createNewMindMap(File freeplaneInstallationDirectory, final File newMapFile) {
final Launcher launcher = Launcher.createForInstallation(freeplaneInstallationDirectory).disableSecurityManager();
HeadlessMapCreator mapCreator = launcher.launchHeadless();
final Map map = mapCreator.load(TestApp.class.getResource("/templateFile.mm")).unsetMapLocation().getMap();
final Node childNode = map.getRoot().createChild();
String value = "hello world";
childNode.setText(value);
final String nodeText = (String) mapCreator.script("node.to.text", "groovy").executeOn(childNode);
System.out.println("Read node value: " + nodeText);
if(! nodeText.equals(value))
throw new AssertionError("unexpected value returned");
map.saveAs(newMapFile);
System.out.println("Saved file " + newMapFile.getAbsolutePath());
launcher.shutdown();
}
-
Method Summary
Modifier and Type Method Description static Launcher
create()
Creates Launcher for starting embedded Freeplane instance.static Launcher
createForInstallation(java.io.File freeplaneInstallationDirectory)
Creates Launcher for starting embedded Freeplane instance.Launcher
disableSecurityManager()
Disables security manager for launched Freeplane instance.HeadlessMapCreator
launchHeadless()
Launchs Freeplane without UI and returns HeadlessMapCreator instance.Controller
launchWithUI(java.lang.String[] args)
Launchs Freeplane with UI and returns Controller instance.static void
main(java.lang.String[] args)
void
shutdown()
The method should be call on application exit to shutdown embedded Freeplane instance.Launcher
userDirectory(java.io.File userDirectory)
Sets user configuration directory (without the version).Launcher
userDirectory(java.lang.String userDirectory)
Sets user configuration directory (without the version).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
main
public static void main(java.lang.String[] args) -
createForInstallation
Creates Launcher for starting embedded Freeplane instance.- Parameters:
freeplaneInstallationDirectory
- Path to freeplane installation directory Only one Launcher per JVM can be created.- Throws:
java.lang.IllegalStateException
- is launcher already was created.
-
create
Creates Launcher for starting embedded Freeplane instance. Freeplane installation directory is defined by location of jar file containing this class. Only one Launcher per JVM can be created.- Throws:
java.lang.IllegalStateException
- is launcher already was created.
-
launchHeadless
Launchs Freeplane without UI and returns HeadlessMapCreator instance.- Throws:
java.lang.IllegalStateException
- is Freeplane was already launched.
-
launchWithUI
Launchs Freeplane with UI and returns Controller instance. All API methods should be called from the swing event thread to avoid race conditions.- Throws:
java.lang.IllegalStateException
- is Freeplane was already launched.
-
shutdown
public void shutdown()The method should be call on application exit to shutdown embedded Freeplane instance. No Freeplane objects may be used after the shutdown is called. It destroys some class loaders and invalidates all related classes and objects. -
disableSecurityManager
Disables security manager for launched Freeplane instance. -
userDirectory
Sets user configuration directory (without the version). -
userDirectory
Sets user configuration directory (without the version).
-