Package org.freeplane.launcher
Class Launcher
java.lang.Object
org.freeplane.launcher.Launcher
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 TypeMethodDescriptionstatic Launcher
create()
Creates Launcher for starting embedded Freeplane instance.static Launcher
createForInstallation
(File freeplaneInstallationDirectory) Creates Launcher for starting embedded Freeplane instance.Disables security manager for launched Freeplane instance.Launchs Freeplane without UI and returns HeadlessMapCreator instance.launchWithUI
(String[] args) Launchs Freeplane with UI and returns Controller instance.static void
void
shutdown()
The method should be call on application exit to shutdown embedded Freeplane instance.userDirectory
(File userDirectory) Sets user configuration directory (without the version).userDirectory
(String userDirectory) Sets user configuration directory (without the version).
-
Method Details
-
main
-
createForInstallation
Creates Launcher for starting embedded Freeplane instance.- Parameters:
freeplaneInstallationDirectory
- Path to freeplane installation directory Only one Launcher per JVM can be created.- Throws:
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:
IllegalStateException
- is launcher already was created.
-
launchHeadless
Launchs Freeplane without UI and returns HeadlessMapCreator instance.- Throws:
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:
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).
-