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 class
Contains application environment specific constants and utility methods.static class
Contains application runtime related constants and utility methods. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte
static final byte
static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addActivityAfterStartup
(Runnable activity) Registered runnable is executed right after MagicDraw application startup.void
addActivityOnUICreation
(Runnable activity) Runnable
which will be run on UI creation.void
void
addApplicationEventListener
(com.nomagic.magicdraw.core.ApplicationEventListener listener) Adds application event listener to application listeners.void
addNewDiagramType
(DiagramDescriptor descriptor) Registers new diagram type in the MagicDraw application.final void
addProjectEventListener
(ProjectEventListener listener) Method adds new ProjectEventListener.void
addSaveParticipant
(SaveParticipant participant) Registers SaveParticipant for custom actions on project saving.static Application.Environment
Gets application environment.static com.nomagic.magicdraw.core.Application.EnvironmentInternal
final void
Executes registered UI activities.void
exit()
Exits the application with Application.STARTUP_ERROR exit code.void
exit
(byte exitStatus) Exits the application.com.nomagic.magicdraw.actions.ActionsManager
Returns the actionsManager.com.nomagic.magicdraw.core.Alias
getAlias()
final CookieSet
Returns cookie set of the application.getDiagramDescriptor
(String diagramType) Gets application environment options.com.nomagic.rcpf.product.lic.floating.client.internal.FLManager
Method getFLManager.Returns the interface to log window.static Application
Returns single instance of Application.com.nomagic.magicdraw.integrations.IntegratorsManager
Returns the mainFrame - main MagicDraw GUI component.Version of OpenAPIcom.nomagic.magicdraw.plugins.PluginsManager
Method getPluginManager.Returns current active Project.Returns the projectsManager.com.nomagic.magicdraw.properties.PropertyResourceManager
Returns propertyResourceManager for managing property resources.com.nomagic.magicdraw.ui.RecentFilesManager
Returns the recentFilesManager.List of registered SaveParticipants.com.nomagic.magicdraw.core.TipsManager
Returns the tipsManager.com.nomagic.magicdraw.lic.MDVersionManager
void
insertActivityAfterStartup
(Runnable activity) byte
internalStart
(com.nomagic.magicdraw.core.Application.MainFrameController mfController, boolean silentMode, boolean tryToLoadProject, StartupParticipant participant) Starts the application.boolean
boolean
Checks if plug-ins already initialized.boolean
Checks if first startup dialog should be shown.boolean
Checks if it is allowed to load project on startup.void
Loads alias.properties file into memory.void
Notifies application event listeners that plugins were initialized.void
Method removes ProjectEventListener.void
removeSaveParticipant
(SaveParticipant participant) Unregister custom SaveParticipant.resolveAlias
(String type, String name) static Application.Runtime
runtime()
Gets application runtime.static com.nomagic.magicdraw.core.Application.RuntimeInternal
void
Saves environment options to file.void
setApplicationName
(String name) Set the name of the application.void
setApplicationTitleConfigurator
(Function<String, String> configurator) void
setCanCreateNewProject
(boolean canCreateNewProject) void
void
Set initial L&Fvoid
setShowFirstStartupDlg
(Supplier<Boolean> showFirstStartupDlg) Sets flag which indicates if first startup dialog should be shown.void
setTryToLoadProject
(Supplier<Boolean> tryToLoadProject) Sets flag which indicates if it is allowed to load project on startup.void
shutdown()
Shutdowns the application.void
shutdown
(boolean force) Shutdowns the application.void
shutdown
(byte exitStatus, boolean force) void
start
(boolean visible, boolean silentMode, boolean tryToLoadProject, String[] args, StartupParticipant participant) Starts the application.void
Starts 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
Runnable
which 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()
-