Package com.nomagic.magicdraw.core
Class Application
java.lang.Object
com.nomagic.magicdraw.core.Application
Main class which connects main parts of MagicDraw.
This class is singleton, only one instance of this class can exist.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classContains application environment specific constants and utility methods.static classContains application runtime related constants and utility methods. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActivityAfterStartup(Runnable activity) Registered runnable is executed right after MagicDraw application startup.voidaddActivityOnUICreation(Runnable activity) Runnablewhich will be run on UI creation.voidvoidaddApplicationEventListener(com.nomagic.magicdraw.core.ApplicationEventListener listener) Adds application event listener to application listeners.voidaddNewDiagramType(DiagramDescriptor descriptor) Registers new diagram type in the MagicDraw application.final voidaddProjectEventListener(ProjectEventListener listener) Method adds new ProjectEventListener.voidaddSaveParticipant(SaveParticipant participant) Registers SaveParticipant for custom actions on project saving.static Application.EnvironmentGets application environment.static com.nomagic.magicdraw.core.Application.EnvironmentInternalfinal voidExecutes registered UI activities.voidexit()Exits the application with Application.STARTUP_ERROR exit code.voidexit(byte exitStatus) Exits the application.com.nomagic.magicdraw.actions.ActionsManagerReturns the actionsManager.com.nomagic.magicdraw.core.AliasgetAlias()final CookieSetReturns cookie set of the application.getDiagramDescriptor(String diagramType) Gets application environment options.com.nomagic.rcpf.product.lic.floating.client.internal.FLManagerMethod getFLManager.Returns the interface to log window.static ApplicationReturns single instance of Application.com.nomagic.magicdraw.integrations.IntegratorsManagerReturns the mainFrame - main MagicDraw GUI component.Version of OpenAPIcom.nomagic.magicdraw.plugins.PluginsManagerMethod getPluginManager.Returns current active Project.Returns the projectsManager.com.nomagic.magicdraw.properties.PropertyResourceManagerReturns propertyResourceManager for managing property resources.com.nomagic.magicdraw.ui.RecentFilesManagerReturns the recentFilesManager.List of registered SaveParticipants.com.nomagic.magicdraw.core.TipsManagerReturns the tipsManager.com.nomagic.magicdraw.lic.MDVersionManagervoidinsertActivityAfterStartup(Runnable activity) byteinternalStart(com.nomagic.magicdraw.core.Application.MainFrameController mfController, boolean silentMode, boolean tryToLoadProject, StartupParticipant participant) Starts the application.booleanbooleanChecks if plug-ins already initialized.booleanChecks if first startup dialog should be shown.booleanChecks if it is allowed to load project on startup.voidLoads alias.properties file into memory.voidNotifies application event listeners that plugins were initialized.voidMethod removes ProjectEventListener.voidremoveSaveParticipant(SaveParticipant participant) Unregister custom SaveParticipant.resolveAlias(String type, String name) static Application.Runtimeruntime()Gets application runtime.static com.nomagic.magicdraw.core.Application.RuntimeInternalvoidSaves environment options to file.voidsetApplicationName(String name) Set the name of the application.voidsetApplicationTitleConfigurator(Function<String, String> configurator) voidsetCanCreateNewProject(boolean canCreateNewProject) voidvoidSet initial L&FvoidsetShowFirstStartupDlg(Supplier<Boolean> showFirstStartupDlg) Sets flag which indicates if first startup dialog should be shown.voidsetTryToLoadProject(Supplier<Boolean> tryToLoadProject) Sets flag which indicates if it is allowed to load project on startup.voidshutdown()Shutdowns the application.voidshutdown(boolean force) Shutdowns the application.voidshutdown(byte exitStatus, boolean force) voidstart(boolean visible, boolean silentMode, boolean tryToLoadProject, String[] args, StartupParticipant participant) Starts the application.voidStarts the application.static com.nomagic.magicdraw.core.Application.WebInternal
-
Field Details
-
STARTUP_SUCCESSFUL
public static final byte STARTUP_SUCCESSFUL- See Also:
-
STARTUP_CANCELED
public static final byte STARTUP_CANCELED- See Also:
-
STARTUP_ERROR
public static final byte STARTUP_ERROR- See Also:
-
-
Constructor Details
-
Application
@OpenApi protected Application()Constructor of Application.
-
-
Method Details
-
resolveAlias
-
loadAliases
Loads alias.properties file into memory. If alias were already loaded reload it.- Throws:
Exception- in case of some error
-
addAlias
-
setApplicationTitleConfigurator
-
getEnvironmentOptions
Gets application environment options.- Returns:
- application environment options.
-
saveEnvironmentOptions
public void saveEnvironmentOptions()Saves environment options to file. -
getInstance
Returns single instance of Application.- Returns:
- single instance of Application.
-
getPluginManager
public com.nomagic.magicdraw.plugins.PluginsManager getPluginManager()Method getPluginManager.- Returns:
- PluginsManager manager for loading, starting stopping plugins.
-
getPropertyResourceManager
public com.nomagic.magicdraw.properties.PropertyResourceManager getPropertyResourceManager()Returns propertyResourceManager for managing property resources.- Returns:
- manager for providing custom property resources.
-
getFLManager
public com.nomagic.rcpf.product.lic.floating.client.internal.FLManager getFLManager()Method getFLManager.- Returns:
- PluginsManager manager for loading, starting stopping plugins.
-
getProject
Returns current active Project.- Returns:
- current project, null if there is no current project.
-
getProjectsManager
Returns the projectsManager.- Returns:
- ProjectsManager
-
getMainFrame
Returns the mainFrame - main MagicDraw GUI component.- Returns:
- MainFrame
-
setApplicationName
Set the name of the application.- Parameters:
name- application name
-
getActionsManager
public com.nomagic.magicdraw.actions.ActionsManager getActionsManager()Returns the actionsManager.- Returns:
- ActionsManager
-
getTipsManager
public com.nomagic.magicdraw.core.TipsManager getTipsManager()Returns the tipsManager.- Returns:
- TipsManager
-
start
Starts the application.- Parameters:
args- command line arguments passed to MagicDraw.- Throws:
ApplicationExitedException- in case of some error
-
start
@OpenApi public void start(boolean visible, boolean silentMode, boolean tryToLoadProject, String[] args, @CheckForNull StartupParticipant participant) throws ApplicationExitedException Starts the application.- Parameters:
visible- start MagicDraw as visible frame?silentMode- true if GUI must be in silent mode(batch mode).tryToLoadProject- true if application should try to load file passed as argument.args- command line arguments passed to MagicDraw.participant- the participant of startup process. May be null.- Throws:
ApplicationExitedException- if application exists during the startup.
-
setInitialLF
public void setInitialLF()Set initial L&F -
internalStart
public byte internalStart(com.nomagic.magicdraw.core.Application.MainFrameController mfController, boolean silentMode, boolean tryToLoadProject, @CheckForNull StartupParticipant participant) Starts the application.- Parameters:
mfController- the controller for controlling the main window appearance.silentMode- true if GUI must be in silent mode.tryToLoadProject- true if application should try to load file passed as argument.participant- the participant of startup process. May be null.- Returns:
- STARTUP_SUCCESSFUL if starting was without fatal errors, STARTUP_CANCELED - canceled by the user on dialogs, STARTUP_ERROR - on any error
-
executeActivitiesOnUICreation
public final void executeActivitiesOnUICreation()Executes registered UI activities. -
shutdown
Shutdowns the application. User will be asked to save all opened projects before exiting the application.- Throws:
ApplicationExitedException- in case of some error
-
shutdown
public void shutdown(boolean force) Shutdowns the application. User will be asked to save all opened projects before exiting the application.- Parameters:
force- exit the application in any case (ignore if project is not saved if plugin is not closed).
-
shutdown
public void shutdown(byte exitStatus, boolean force) -
getGUILog
Returns the interface to log window.- Returns:
- window for writing messages.
-
setGUILog
-
getOpenAPIVersion
Version of OpenAPI- Returns:
- version of OpenAPI.
-
getRecentFilesManager
public com.nomagic.magicdraw.ui.RecentFilesManager getRecentFilesManager()Returns the recentFilesManager.- Returns:
- RecentFilesManager
-
addProjectEventListener
Method adds new ProjectEventListener.- Parameters:
listener- listener to be added.
-
removeProjectEventListener
Method removes ProjectEventListener.- Parameters:
listener- to be removed.
-
addActivityAfterStartup
Registered runnable is executed right after MagicDraw application startup.- Parameters:
activity- runnable to execute.
-
addActivityOnUICreation
Runnablewhich will be run on UI creation.- Parameters:
activity- instance ofRunnable
-
insertActivityAfterStartup
-
getCookieSet
Returns cookie set of the application.
This cookie set may be used for example to replace standard application CloseCookie with some other.
The example:
CookieSet set = application.getCookieSet();
CloseCookie newCloseCookie = ...;
CloseCookie close = (CloseCookie) set.getCookie(CloseCookie.class);
set.remove(close);
set.add(newCloseCookie);- Returns:
- cookie set of the application.
-
exit
public void exit(byte exitStatus) Exits the application. Calls close method for registered CloseCookie.- Parameters:
exitStatus- exit code
-
exit
public void exit()Exits the application with Application.STARTUP_ERROR exit code. Calls close method for registered CloseCookie. -
addNewDiagramType
Registers new diagram type in the MagicDraw application.- Parameters:
descriptor- descriptor of the new diagram.
-
getAlias
public com.nomagic.magicdraw.core.Alias getAlias() -
getSaveParticipants
List of registered SaveParticipants.- Returns:
- list of registered Save Participants.
-
addSaveParticipant
Registers SaveParticipant for custom actions on project saving.- Parameters:
participant- the custom SaveParticipant.
-
removeSaveParticipant
Unregister custom SaveParticipant.- Parameters:
participant- the custom SaveParticipant.
-
getVersionManager
public com.nomagic.magicdraw.lic.MDVersionManager getVersionManager() -
isCanCreateNewProject
public boolean isCanCreateNewProject() -
setCanCreateNewProject
public void setCanCreateNewProject(boolean canCreateNewProject) -
getDiagramDescriptor
- Parameters:
diagramType- diagram type to get its descriptor.- Returns:
- DiagramDescriptor for given type. If type is unknown return null.
-
getIntegrationsManager
public com.nomagic.magicdraw.integrations.IntegratorsManager getIntegrationsManager()- Returns:
- an Integrations manager.
-
addApplicationEventListener
public void addApplicationEventListener(com.nomagic.magicdraw.core.ApplicationEventListener listener) Adds application event listener to application listeners.- Parameters:
listener- listener to add.
-
notifyPluginsInitialized
public void notifyPluginsInitialized()Notifies application event listeners that plugins were initialized. -
isTryToLoadProject
@OpenApi public boolean isTryToLoadProject()Checks if it is allowed to load project on startup. Under integrations loading may cause deadlock and is disabled.- Returns:
- true if project may be loaded on application startup.
-
setTryToLoadProject
Sets flag which indicates if it is allowed to load project on startup.- Parameters:
tryToLoadProject- flag which indicates if it is allowed to load project on startup
-
isShowFirstStartupDlg
public boolean isShowFirstStartupDlg()Checks if first startup dialog should be shown.- Returns:
- true if first startup dialog should be shown.
-
setShowFirstStartupDlg
Sets flag which indicates if first startup dialog should be shown.- Parameters:
showFirstStartupDlg- flag which indicates if first startup dialog should be shown.
-
isPluginsInitialized
public boolean isPluginsInitialized()Checks if plug-ins already initialized.- Returns:
- true if plug-ins already initialized.
-
runtimeInternal
public static com.nomagic.magicdraw.core.Application.RuntimeInternal runtimeInternal() -
runtime
Gets application runtime.- Returns:
- application runtime.
-
environmentInternal
public static com.nomagic.magicdraw.core.Application.EnvironmentInternal environmentInternal() -
environment
Gets application environment.- Returns:
- application environment.
-
webInternal
public static com.nomagic.magicdraw.core.Application.WebInternal webInternal()
-