Package org.freeplane.launcher
Class Launcher
- java.lang.Object
-
- org.freeplane.launcher.Launcher
-
public class Launcher extends java.lang.ObjectThis class can be used to run freeplane instance from an application and to obtain itsControllerobject. To run a headless Freeplane instance useLauncher.create().launchHeadless(), to run a freeplane with complete user UI useLauncher.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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Launchercreate()Creates Launcher for starting embedded Freeplane instance.static LaunchercreateForInstallation(java.io.File freeplaneInstallationDirectory)Creates Launcher for starting embedded Freeplane instance.LauncherdisableSecurityManager()Disables security manager for launched Freeplane instance.HeadlessMapCreatorlaunchHeadless()Launchs Freeplane without UI and returns HeadlessMapCreator instance.ControllerlaunchWithUI(java.lang.String[] args)Launchs Freeplane with UI and returns Controller instance.static voidmain(java.lang.String[] args)voidshutdown()The method should be call on application exit to shutdown embedded Freeplane instance.LauncheruserDirectory(java.io.File userDirectory)Sets user configuration directory (without the version).LauncheruserDirectory(java.lang.String userDirectory)Sets user configuration directory (without the version).
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
-
createForInstallation
public static Launcher createForInstallation(java.io.File freeplaneInstallationDirectory)
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
public static Launcher 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
public HeadlessMapCreator launchHeadless()
Launchs Freeplane without UI and returns HeadlessMapCreator instance.- Throws:
java.lang.IllegalStateException- is Freeplane was already launched.
-
launchWithUI
public Controller launchWithUI(java.lang.String[] args)
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
public Launcher disableSecurityManager()
Disables security manager for launched Freeplane instance.
-
userDirectory
public Launcher userDirectory(java.io.File userDirectory)
Sets user configuration directory (without the version).
-
userDirectory
public Launcher userDirectory(java.lang.String userDirectory)
Sets user configuration directory (without the version).
-
-