Package com.nomagic.magicdraw.core
Class Application
- java.lang.Object
-
- com.nomagic.magicdraw.core.Application
-
@OpenApi public class Application extends java.lang.Object
Main class which connects main parts of MagicDraw. This class is singleton, only one instance of this class can exist.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
com.nomagic.magicdraw.core.Application.ClipboardSweeper
static class
Application.Environment
Contains application environment specific constants and utility methods.static class
com.nomagic.magicdraw.core.Application.EnvironmentInternal
static class
com.nomagic.magicdraw.core.Application.MainFrameController
static class
Application.Runtime
Contains application runtime related constants and utility methods.static class
com.nomagic.magicdraw.core.Application.RuntimeEnvironmentHolder
static class
com.nomagic.magicdraw.core.Application.RuntimeInternal
static class
com.nomagic.magicdraw.core.Application.WebInternal
-
Field Summary
Fields Modifier and Type Field Description private com.nomagic.magicdraw.actions.ActionsManager
actionsManager
Manages main Actions.private java.util.List<java.lang.Runnable>
activitiesAfterStartup
List of Runnable to be run after startup.private java.util.List<java.lang.Runnable>
activitiesOnUICreation
List of Runnable to be run on UI creation.private com.nomagic.magicdraw.core.Alias
alias
private java.util.Collection<com.nomagic.magicdraw.core.ApplicationEventListener>
applicationEventListeners
Holds application event listeners.private static java.util.function.Function<java.lang.String,java.lang.String>
applicationTitleConfigurator
private boolean
canCreateNewProject
private CookieSet
cookieSet
private static com.nomagic.magicdraw.core.Application.EnvironmentInternal
environmentInternal
private EnvironmentOptions
environmentOptions
Environment options.private GUILog
guiLog
Log for displaying messages.private static Application
instance
Single instance of Application.private com.nomagic.magicdraw.integrations.IntegratorsManager
integratorsManager
private boolean
isPluginsInitialized
Flag which shows if plug-ins already initialized.private MainFrame
mainFrame
GUI Frame.private com.nomagic.magicdraw.plugins.PluginsManager
pluginsManager
Manager manages plugins.private ProjectsManager
projectsManager
Manages projects.private com.nomagic.magicdraw.properties.PropertyResourceManager
propertyResourceManager
Manager of property resources.private com.nomagic.magicdraw.ui.RecentFilesManager
recentFilesManager
Manager manages recent files.private static com.nomagic.magicdraw.core.Application.RuntimeInternal
runtimeInternal
private java.util.List<SaveParticipant>
saveParticipants
List of Save Participants.private java.util.function.Supplier<java.lang.Boolean>
showFirstStartupDlg
Indicates if first startup dialog should be shown.static byte
STARTUP_CANCELED
static byte
STARTUP_ERROR
static byte
STARTUP_SUCCESSFUL
private com.nomagic.magicdraw.core.TipsManager
tipsManager
Tips manager instance.private java.util.function.Supplier<java.lang.Boolean>
tryToLoadProject
private static com.nomagic.magicdraw.core.Application.WebInternal
webInternal
-
Constructor Summary
Constructors Modifier Constructor Description protected
Application()
Constructor of Application.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addActivityAfterStartup(java.lang.Runnable activity)
Registered runnable is executed right after MagicDraw application startup.void
addActivityOnUICreation(java.lang.Runnable activity)
Runnable
which will be run on UI creation.void
addAlias(java.lang.String type, java.lang.String alias, java.lang.String value)
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.void
addProjectEventListener(ProjectEventListener listener)
Method adds new ProjectEventListener.void
addSaveParticipant(SaveParticipant participant)
Registers SaveParticipant for custom actions on project saving.private static java.lang.String[]
checkFilePassedWithSpaces(java.lang.String[] args)
static Application.Environment
environment()
Gets application environment.static com.nomagic.magicdraw.core.Application.EnvironmentInternal
environmentInternal()
(package private) static void
executeActivities(java.util.Collection<java.lang.Runnable> activities)
Execute given activities.(package private) void
executeActivitiesAfterStartup()
Executes activitiesvoid
executeActivitiesOnUICreation()
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
getActionsManager()
Returns the actionsManager.private java.util.List<java.lang.Runnable>
getActivitiesAfterStartup()
Returns the activitiesAfterStartup.private java.util.List<java.lang.Runnable>
getActivitiesOnUICreation()
Returns list for UI creation activities.com.nomagic.magicdraw.core.Alias
getAlias()
CookieSet
getCookieSet()
Returns cookie set of the application.DiagramDescriptor
getDiagramDescriptor(java.lang.String diagramType)
EnvironmentOptions
getEnvironmentOptions()
Gets application environment options.com.nomagic.rcpf.product.lic.floating.client.internal.FLManager
getFLManager()
Method getFLManager.GUILog
getGUILog()
Returns the interface to log window.static Application
getInstance()
Returns single instance of Application.com.nomagic.magicdraw.integrations.IntegratorsManager
getIntegrationsManager()
MainFrame
getMainFrame()
Returns the mainFrame - main MagicDraw GUI component.java.lang.String
getOpenAPIVersion()
Version of OpenAPIcom.nomagic.magicdraw.plugins.PluginsManager
getPluginManager()
Method getPluginManager.Project
getProject()
Returns current active Project.ProjectsManager
getProjectsManager()
Returns the projectsManager.com.nomagic.magicdraw.properties.PropertyResourceManager
getPropertyResourceManager()
Returns propertyResourceManager for managing property resources.com.nomagic.magicdraw.ui.RecentFilesManager
getRecentFilesManager()
Returns the recentFilesManager.java.util.List<SaveParticipant>
getSaveParticipants()
List of registered SaveParticipants.com.nomagic.magicdraw.core.TipsManager
getTipsManager()
Returns the tipsManager.com.nomagic.magicdraw.lic.MDVersionManager
getVersionManager()
private static void
initMacFeatures()
void
insertActivityAfterStartup(java.lang.Runnable activity)
byte
internalStart(com.nomagic.magicdraw.core.Application.MainFrameController mfController, boolean silentMode, boolean tryToLoadProject, StartupParticipant participant)
Starts the application.boolean
isCanCreateNewProject()
boolean
isPluginsInitialized()
Checks if plug-ins already initialized.boolean
isShowFirstStartupDlg()
Checks if first startup dialog should be shown.boolean
isTryToLoadProject()
Checks if it is allowed to load project on startup.void
loadAliases()
Loads alias.properties file into memory.void
notifyPluginsInitialized()
Notifies application event listeners that plugins were initialized.private static void
provideProperAppNameForLinux()
Oracle bug JDK-6528430 official workaround.void
removeProjectEventListener(ProjectEventListener listener)
Method removes ProjectEventListener.void
removeSaveParticipant(SaveParticipant participant)
Unregister custom SaveParticipant.java.lang.String
resolveAlias(java.lang.String type, java.lang.String name)
static Application.Runtime
runtime()
Gets application runtime.static com.nomagic.magicdraw.core.Application.RuntimeInternal
runtimeInternal()
void
saveEnvironmentOptions()
Saves environment options to file.void
setApplicationName(java.lang.String name)
Set the name of the application.void
setApplicationTitleConfigurator(java.util.function.Function<java.lang.String,java.lang.String> configurator)
void
setCanCreateNewProject(boolean canCreateNewProject)
void
setGUILog(GUILog log)
void
setInitialLF()
Set initial L&F(package private) void
setMainFrame(MainFrame mainFrame)
void
setShowFirstStartupDlg(java.util.function.Supplier<java.lang.Boolean> showFirstStartupDlg)
Sets flag which indicates if first startup dialog should be shown.void
setTryToLoadProject(java.util.function.Supplier<java.lang.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, java.lang.String[] args, StartupParticipant participant)
Starts the application.void
start(java.lang.String[] args)
Starts the application.static com.nomagic.magicdraw.core.Application.WebInternal
webInternal()
-
-
-
Field Detail
-
cookieSet
private final CookieSet cookieSet
-
instance
private static Application instance
Single instance of Application.
-
projectsManager
private ProjectsManager projectsManager
Manages projects.
-
environmentOptions
private EnvironmentOptions environmentOptions
Environment options.
-
mainFrame
private MainFrame mainFrame
GUI Frame.
-
actionsManager
private com.nomagic.magicdraw.actions.ActionsManager actionsManager
Manages main Actions.
-
tipsManager
private com.nomagic.magicdraw.core.TipsManager tipsManager
Tips manager instance.
-
pluginsManager
private com.nomagic.magicdraw.plugins.PluginsManager pluginsManager
Manager manages plugins.
-
propertyResourceManager
private com.nomagic.magicdraw.properties.PropertyResourceManager propertyResourceManager
Manager of property resources.
-
guiLog
private GUILog guiLog
Log for displaying messages.
-
recentFilesManager
private com.nomagic.magicdraw.ui.RecentFilesManager recentFilesManager
Manager manages recent files.
-
activitiesAfterStartup
@CheckForNull private java.util.List<java.lang.Runnable> activitiesAfterStartup
List of Runnable to be run after startup.
-
activitiesOnUICreation
@CheckForNull private java.util.List<java.lang.Runnable> activitiesOnUICreation
List of Runnable to be run on UI creation.
-
saveParticipants
private final java.util.List<SaveParticipant> saveParticipants
List of Save Participants.
-
applicationEventListeners
private final java.util.Collection<com.nomagic.magicdraw.core.ApplicationEventListener> applicationEventListeners
Holds application event listeners.
-
canCreateNewProject
private boolean canCreateNewProject
-
showFirstStartupDlg
private java.util.function.Supplier<java.lang.Boolean> showFirstStartupDlg
Indicates if first startup dialog should be shown.
-
STARTUP_SUCCESSFUL
public static final byte STARTUP_SUCCESSFUL
- See Also:
- Constant Field Values
-
STARTUP_CANCELED
public static final byte STARTUP_CANCELED
- See Also:
- Constant Field Values
-
STARTUP_ERROR
public static final byte STARTUP_ERROR
- See Also:
- Constant Field Values
-
integratorsManager
private final com.nomagic.magicdraw.integrations.IntegratorsManager integratorsManager
-
tryToLoadProject
private java.util.function.Supplier<java.lang.Boolean> tryToLoadProject
-
isPluginsInitialized
private boolean isPluginsInitialized
Flag which shows if plug-ins already initialized.
-
alias
private final com.nomagic.magicdraw.core.Alias alias
-
runtimeInternal
private static com.nomagic.magicdraw.core.Application.RuntimeInternal runtimeInternal
-
environmentInternal
private static final com.nomagic.magicdraw.core.Application.EnvironmentInternal environmentInternal
-
webInternal
private static final com.nomagic.magicdraw.core.Application.WebInternal webInternal
-
applicationTitleConfigurator
@CheckForNull private static java.util.function.Function<java.lang.String,java.lang.String> applicationTitleConfigurator
-
-
Method Detail
-
resolveAlias
public java.lang.String resolveAlias(java.lang.String type, java.lang.String name)
-
loadAliases
@OpenApi public void loadAliases() throws java.lang.Exception
Loads alias.properties file into memory. If alias were already loaded reload it.- Throws:
java.lang.Exception
- in case of some error
-
addAlias
public void addAlias(java.lang.String type, java.lang.String alias, java.lang.String value)
-
setApplicationTitleConfigurator
public void setApplicationTitleConfigurator(java.util.function.Function<java.lang.String,java.lang.String> configurator)
-
getEnvironmentOptions
@OpenApi public EnvironmentOptions getEnvironmentOptions()
Gets application environment options.- Returns:
- application environment options.
-
saveEnvironmentOptions
public void saveEnvironmentOptions()
Saves environment options to file.
-
getInstance
@OpenApi public static Application 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
@CheckForNull @OpenApi public Project getProject()
Returns current active Project.- Returns:
- current project, null if there is no current project.
-
getProjectsManager
@OpenApi public ProjectsManager getProjectsManager()
Returns the projectsManager.- Returns:
- ProjectsManager
-
getMainFrame
@OpenApi public MainFrame getMainFrame()
Returns the mainFrame - main MagicDraw GUI component.- Returns:
- MainFrame
-
setMainFrame
void setMainFrame(MainFrame mainFrame)
-
setApplicationName
@OpenApi public void setApplicationName(java.lang.String name)
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
@OpenApi public void start(java.lang.String[] args) throws ApplicationExitedException
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, java.lang.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.
-
checkFilePassedWithSpaces
private static java.lang.String[] checkFilePassedWithSpaces(java.lang.String[] args)
-
setInitialLF
public void setInitialLF()
Set initial L&F
-
provideProperAppNameForLinux
private static void provideProperAppNameForLinux()
Oracle bug JDK-6528430 official workaround.
-
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
-
executeActivitiesAfterStartup
void executeActivitiesAfterStartup()
Executes activities
-
executeActivitiesOnUICreation
public final void executeActivitiesOnUICreation()
Executes registered UI activities.
-
executeActivities
static void executeActivities(java.util.Collection<java.lang.Runnable> activities)
Execute given activities. During the execution new activities can be added into a source collection, so repeat execution until all activities are executed- Parameters:
activities
- activities
-
shutdown
@OpenApi public void shutdown() throws ApplicationExitedException
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
@OpenApi public GUILog getGUILog()
Returns the interface to log window.- Returns:
- window for writing messages.
-
setGUILog
public void setGUILog(GUILog log)
-
getOpenAPIVersion
public java.lang.String getOpenAPIVersion()
Version of OpenAPI- Returns:
- version of OpenAPI.
-
getRecentFilesManager
public com.nomagic.magicdraw.ui.RecentFilesManager getRecentFilesManager()
Returns the recentFilesManager.- Returns:
- RecentFilesManager
-
addProjectEventListener
@OpenApi public final void addProjectEventListener(ProjectEventListener listener)
Method adds new ProjectEventListener.- Parameters:
listener
- listener to be added.
-
removeProjectEventListener
@OpenApi public void removeProjectEventListener(ProjectEventListener listener)
Method removes ProjectEventListener.- Parameters:
listener
- to be removed.
-
addActivityAfterStartup
@OpenApi public void addActivityAfterStartup(java.lang.Runnable activity)
Registered runnable is executed right after MagicDraw application startup.- Parameters:
activity
- runnable to execute.
-
addActivityOnUICreation
public void addActivityOnUICreation(java.lang.Runnable activity)
Runnable
which will be run on UI creation.- Parameters:
activity
- instance ofRunnable
-
insertActivityAfterStartup
public void insertActivityAfterStartup(java.lang.Runnable activity)
-
getActivitiesAfterStartup
private java.util.List<java.lang.Runnable> getActivitiesAfterStartup()
Returns the activitiesAfterStartup.- Returns:
- List
-
getActivitiesOnUICreation
private java.util.List<java.lang.Runnable> getActivitiesOnUICreation()
Returns list for UI creation activities.- Returns:
- list of
Runnable
-
getCookieSet
@OpenApi public final CookieSet 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
@OpenApi public void addNewDiagramType(DiagramDescriptor descriptor)
Registers new diagram type in the MagicDraw application.- Parameters:
descriptor
- descriptor of the new diagram.
-
getAlias
public com.nomagic.magicdraw.core.Alias getAlias()
-
getSaveParticipants
@OpenApi public java.util.List<SaveParticipant> getSaveParticipants()
List of registered SaveParticipants.- Returns:
- list of registered Save Participants.
-
addSaveParticipant
@OpenApi public void addSaveParticipant(SaveParticipant participant)
Registers SaveParticipant for custom actions on project saving.- Parameters:
participant
- the custom SaveParticipant.
-
removeSaveParticipant
@OpenApi public void removeSaveParticipant(SaveParticipant participant)
Unregister custom SaveParticipant.- Parameters:
participant
- the custom SaveParticipant.
-
getVersionManager
public com.nomagic.magicdraw.lic.MDVersionManager getVersionManager()
-
initMacFeatures
private static void initMacFeatures()
-
isCanCreateNewProject
public boolean isCanCreateNewProject()
-
setCanCreateNewProject
public void setCanCreateNewProject(boolean canCreateNewProject)
-
getDiagramDescriptor
@CheckForNull public DiagramDescriptor getDiagramDescriptor(java.lang.String diagramType)
- 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
public void setTryToLoadProject(java.util.function.Supplier<java.lang.Boolean> tryToLoadProject)
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
public void setShowFirstStartupDlg(java.util.function.Supplier<java.lang.Boolean> showFirstStartupDlg)
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
@OpenApi public static Application.Runtime runtime()
Gets application runtime.- Returns:
- application runtime.
-
environmentInternal
public static com.nomagic.magicdraw.core.Application.EnvironmentInternal environmentInternal()
-
environment
@OpenApi public static Application.Environment environment()
Gets application environment.- Returns:
- application environment.
-
webInternal
public static com.nomagic.magicdraw.core.Application.WebInternal webInternal()
-
-