Class CommandLine
java.lang.Object
com.nomagic.magicdraw.commandline.CommandLine
- Direct Known Subclasses:
ProjectCommandLine
MagicDraw commandline launcher.
Extend it and implement
Extend it and implement
execute()
method.
Code sample:
public class TestCommandLine extends CommandLine { public static void main(String[] args) { new TestCommandLine().launch(args); } protected void execute() { // 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); } }Check documentation ("Running programs in batch mode") on how to start command line.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract byte
execute()
Override this method to execute your custom task(s) in running MagicDraw environment.final void
Launch MagicDraw in commandline mode (without GUI).
Method starts MagicDraw application, callsexecute()
method, and shuts down the application.protected void
Override to parse arguments before launching MagicDraw.
-
Constructor Details
-
CommandLine
public CommandLine()
-
-
Method Details
-
launch
Launch MagicDraw in commandline mode (without GUI).
Method starts MagicDraw application, callsexecute()
method, and shuts down the application.- Parameters:
args
- command line arguments passed to MagicDraw.- Throws:
InstantiationException
- if the failed return code needs to be indicated
-
parseArgs
Override to parse arguments before launching MagicDraw.- Parameters:
args
- program arguments- Throws:
Exception
- if arguments are not correct and MagicDraw should not be started
-
execute
protected abstract byte execute()Override this method to execute your custom task(s) in running MagicDraw environment. Do not explicitly call this method - calllaunch(String[])
to launch the commandline.- Returns:
- application exit status
-