org.csstudio.startup.module.defaults
Class DefaultProject

java.lang.Object
  extended by org.csstudio.startup.module.defaults.DefaultProject
All Implemented Interfaces:
CSSStartupExtensionPoint, ProjectExtPoint

public class DefaultProject
extends java.lang.Object
implements ProjectExtPoint

DefaultProject opens and closes the application's default project. The name of the project is localized.

Author:
Jaka Bobnar, Kay Kasemir

Field Summary
 
Fields inherited from interface org.csstudio.startup.module.ProjectExtPoint
NAME, PROJECTS
 
Constructor Summary
DefaultProject()
           
 
Method Summary
 java.lang.Object closeProjects(Display display, IApplicationContext context, java.util.Map<java.lang.String,java.lang.Object> parameters)
          Called by Application to allow implementors of the CSSStartupExtensionPoint to perform project cleanup in case that is considered necessary.
 java.lang.Object openProjects(Display display, IApplicationContext context, java.util.Map<java.lang.String,java.lang.Object> parameters)
          Opens the projects defined by the given application context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultProject

public DefaultProject()
Method Detail

openProjects

public java.lang.Object openProjects(Display display,
                                     IApplicationContext context,
                                     java.util.Map<java.lang.String,java.lang.Object> parameters)
Opens the projects defined by the given application context. The implementation should also take care of initialization of projects and any other actions required for them to run properly. The projects that were run should be placed inside the parameters map under the tag "css.projects" to enable their usage by other extension point.

Specified by:
openProjects in interface ProjectExtPoint
context - the application's context
parameters - contains additional parameters, which can define some special behaviour during the execution of this method (the keys are parameters names and the values are parameters values)
Returns:
the exit code if something happened which requires to exit or restart application or null if everything is alright

closeProjects

public java.lang.Object closeProjects(Display display,
                                      IApplicationContext context,
                                      java.util.Map<java.lang.String,java.lang.Object> parameters)
                               throws java.lang.Exception
Called by Application to allow implementors of the CSSStartupExtensionPoint to perform project cleanup in case that is considered necessary.

In principle this method could close all those projects that were previously opened by #openProjects(IApplicationContext) method but it is not mandatory that the implementation follows the rules.

In most cases, one should actually NOT close any projects in here. The suggested way to assert that all resources are properly saved on exiting CSS is to call ResourcesPlugin.getWorkspace().save(true, new NullProgressMonitor()); from the WorkbenchAdvisor's preShutdown() method. RCP will invoke that preShutdown() when the workbench is about to close as part of the workbench run cycle. This closeProjects() method is actually called later from the Application code and in fact results in an "exited with unsaved changes" warning on the following startup of CSS.

Specified by:
closeProjects in interface ProjectExtPoint
context - the application's context
parameters - contains additional parameters, which can define some special behaviour during the execution of this method (the keys are parameters names and the values are parameters values)
Returns:
the exit code if something happened which requires to exit or restart application or null if everything is alright
Throws:
java.lang.Exception - if an error occurred during the operation