@OpenApiAll public abstract class CommandLine extends java.lang.Object implements ApplicationLauncher
run()
method.
Code sample:
public class TestCommandLine extends CommandLine { public static void main(String[] args) { new TestCommandLine().launch(args); } protected void run() { // load project File fileToLoad = new File("myProject.mdzip"); ProjectDescriptor descriptor = ProjectDescriptorsFactory.createProjectDescriptor(fileToLoad.toURI()); ProjectsManager projectsManager = Application.getInstance().getProjectsManager(); projectsManager.loadProject(descriptor, true); Project project = Application.getInstance().getProject(); // "save as" project File fileToSave = new File("myProject2.mdzip"); ProjectDescriptor localProjectDescriptor = ProjectDescriptorsFactory.createLocalProjectDescriptor(project, fileToSave); projectsManager.saveProject(localProjectDescriptor, true); } }Startup sample:
java -cp <MagicDraw libraries> -Dinstall.root=<MagicDraw installation directory> -Xmx300M -Xss16M TestCommandLine
<MagicDraw libraries>
- all jar's
(except md_commontw.jar
and md_commontw_api.jar
) recursively from
<MagicDraw installation directory>/lib
Constructor and Description |
---|
CommandLine() |
Modifier and Type | Method and Description |
---|---|
protected byte |
execute()
Override this method to execute your custom task(s) in running MagicDraw environment.
|
void |
launch(java.lang.String[] args)
Launch MagicDraw in commandline mode (without GUI).
Method starts MagicDraw application, calls run() method, and shuts down the application. |
protected void |
parseArgs(java.lang.String[] args)
Override to parse arguments before launching MagicDraw.
|
protected void |
run()
Deprecated.
see
execute() method. |
public final void launch(java.lang.String[] args) throws java.lang.InstantiationException
run()
method, and shuts down the application.launch
in interface ApplicationLauncher
args
- command line arguments passed to MagicDraw.java.lang.InstantiationException
- if the failed return code needs to be indicatedprotected void parseArgs(java.lang.String[] args) throws java.lang.Exception
args
- program argumentsjava.lang.Exception
- if arguments are not correct and MagicDraw should not be startedprotected byte execute()
launch(String[])
to launch the commandline.
Default implementation calls run()
to ensure compatibility with older versions.