Class ContextManager
- All Implemented Interfaces:
BasicSession.OrderedObserver
,Session.Observer
,InterviewParameters.TemplateManager
,Report.CustomReportManager
The test manager (exec tool) will create an instance of the test suite's context
manager near the beginning of initialization. Throughout the lifecycle of
that tool instance, the context manager instance will be reused when
appropriate. For proper operation the context manager must be changed if
the test suite changes, in which case the current manager will be disposed,
although this is not a typical case, since a new tool is normally created in
this circumstance (in current implementation). After a test suite is loaded
into a exec tool instance, the associate context manager object will be reused.
The implementation of that manager can learn of changes in workdir association
by monitoring the setWorkDirectory()
method (be sure to call the
superclass implementation if overriding.
When the exec tool is itself disposed, the dispose()
method of
the associated context manager object will be invoked. If the exec tool were
to diassociate a context manager object from itself (not usually done),
dispose()
would be invoked.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Special class for creating dialogs which should be attached to the context of this test manager. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected File
protected boolean
protected File
protected InterviewParameters
protected InterviewParameters
protected FeatureManager
protected boolean
protected File
protected boolean
protected File
protected File
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canSaveTemplate
(File file) This method is invoked each time before saving template.void
dispose()
Called when the associated ExecTool instance is being destroyed.boolean
Get ability to load config outside default directoryboolean
Get ability to load config outside default directoryboolean
Get ability to load templates outside default directoryboolean
Get ability to save templates outside default directoryGet the context (popup) custom menus to be added in the GUI.Returns an InterviewParameters instance filled with the current interview values, or null if the interview is not loaded.Returns an InterviewParameters instance filled with the current template values, or null if the template is not loaded.Get custom report types.Get the context custom test result viewers to be added in the GUI.Get the default path from which configuration files are loaded.Get the default path from which configuration files are loaded.Get the default path from which template files are loaded.Get the default path to which template files are saved.Get the default path for work directory.getExecToolControlFactory
(ExecTool et, UIFactory uif) Get feature manager from this ContextManager instance.Get the permanent instance of the interview object used as a holder for both the configuration and the template.Get the custom menu manager for this Test Manager instance.Get the active template.Get the active test suite.Get the active work directory.void
loadConfiguration
(File file) protected void
int
order()
BasicSession.OrderedObserver interface method.void
Request that the harness reload the test suite structure from the test suite.protected void
registerCustomQuestionRenderer
(Class<? extends Question> question, com.sun.interview.wizard.QuestionRenderer renderer) Register custom config editor's question renderer for specified question class.void
setAllowConfigLoadOutsideDefault
(boolean state) Set ability to load config outside default directory.void
setAllowConfigSaveOutsideDefault
(boolean state) Set ability to save config outside default directory.void
setAllowTemplateLoadOutsideDefault
(boolean state) Set ability to load templates outside default directory.void
setAllowTemplateSaveOutsideDefault
(boolean state) Set ability to save templates outside default directory.void
Set the default path from which configuration files are loaded.void
Set the default path to which configuration files are saved.void
Set the default path from which template files are loaded.void
Set the default path to which template files are saved.void
Default path presented to user when they are prompted to create a work directory.void
setFeatureManager
(FeatureManager featureManager) Set given feature manager for this ContextManager instance.protected void
protected void
Deprecated.use #setWorkDirectory(WorkDirectory) insteadprotected void
void
Write the active interview to disk if possible.void
updated
(Session.Event ev) Invoked when session has been changed.protected void
Invoked when the value of the current configuration has been modified.protected void
Invoked when the value of the current template has been modified.protected void
Invoked when the value of the work directory has been modified.
-
Field Details
-
configLoadPath
-
configSavePath
-
configLoadOutside
protected boolean configLoadOutside -
configSaveOutside
protected boolean configSaveOutside -
templateLoadPath
-
templateSavePath
-
templateLoadOutside
protected boolean templateLoadOutside -
templateSaveOutside
protected boolean templateSaveOutside -
wdPath
-
featureManager
-
currentConfig
-
currentTemplate
-
-
Constructor Details
-
ContextManager
public ContextManager()
-
-
Method Details
-
getMenuManager
Get the custom menu manager for this Test Manager instance.- Returns:
- The custom menu manager. If null, it can be assumed that there are no custom menus.
-
getToolBarManager
-
dispose
public void dispose()Called when the associated ExecTool instance is being destroyed. Great care should be taken in using references to objects, as they maybe already be disposed - especially GUI components. The exact order in which the exec tool disposes it's associated objects is not currently defined, although exec tool is primarily responsible for GUI objects, so itself will not dispose of core objects (TestSuite objects, work directories, etc). -
getContextMenus
Get the context (popup) custom menus to be added in the GUI. This method is only called when the GUI is initialized, so the value should not change after its first invocation. Any state changes (enable, disable, hide, text changes) with the menu items should occur inside the JavaTestContextMenu instances, not be adding and removing them from the array returned by this method.- Returns:
- The menus to be added. Null if there are no custom menus (the default).
- See Also:
-
getCustomReports
Get custom report types.- Specified by:
getCustomReports
in interfaceReport.CustomReportManager
- Returns:
- Null if no custom types are requested.
-
getCustomResultViewers
Get the context custom test result viewers to be added in the GUI. This method is only called when the GUI is initialized, so the value should not change after its first invocation.- Returns:
- The menus to be added. Null if there are no custom viewers (the default).
- See Also:
-
getTestSuite
Get the active test suite.- Returns:
- The current test suite.
-
setTestSuite
-
getWorkDirectory
Get the active work directory.- Returns:
- The current work directory, null if it has not been set.
-
setWorkDirectory
-
getInterview
Get the permanent instance of the interview object used as a holder for both the configuration and the template. This instance is filled with the current values when the user finishes editing values and commits changes. Depending on what has been committed later, it will be filled either with the current configuration or the current template values.
Note that there is currently no API support for "locking" the interview, which means that multiple parts of the system could work against each other.- Returns:
- The active interview instance.
-
getTemplate
Get the active template.- Returns:
- null, if there is no interview or template in context yet; current interview in case it actually represents template; new instance of InterviewParameters, representing template, in case there exist template, associated with interview
- Throws:
IOException
Interview.Fault
-
getCurrentInterview
Returns an InterviewParameters instance filled with the current interview values, or null if the interview is not loaded. -
getCurrentTemplate
Returns an InterviewParameters instance filled with the current template values, or null if the template is not loaded. -
refreshTests
public void refreshTests()Request that the harness reload the test suite structure from the test suite. If called on the GUI event thread, it will start a new thread before executing the operation, to avoid blocking the GUI. It is recommended that the caller use a different thread and probably show the user a "Please wait" message until this method returns. -
syncInterview
public void syncInterview()Write the active interview to disk if possible. For this to work, getInterview() must be non-null. This also implies that there is a test suite and work directory selected already.- Throws:
IllegalStateException
- if there is no interview available.
-
getFeatureManager
Get feature manager from this ContextManager instance.- Returns:
- current feature manager
-
setFeatureManager
Set given feature manager for this ContextManager instance.- Parameters:
featureManager
- new feature manager
-
canSaveTemplate
This method is invoked each time before saving template. The template will be saved only if this method returns true. The default implementation always returns true.- Specified by:
canSaveTemplate
in interfaceInterviewParameters.TemplateManager
- Parameters:
file
- template file- Returns:
- true if this operation is allowed, false otherwise
-
getDefaultWorkDirPath
Get the default path for work directory.- Returns:
- The initial directory to load and create work directories.
- See Also:
-
setDefaultWorkDirPath
Default path presented to user when they are prompted to create a work directory. This method does not imply any requirement that the user actually load/save the workdir in the given location.- Parameters:
dir
- The initial directory where workdirs should be loaded/saved to.- Throws:
NullPointerException
- if the parameter given is null.- See Also:
-
getDefaultTemplateLoadPath
Get the default path from which template files are loaded.- Returns:
- The initial directory where template files should be loaded from. Null if not set.
- See Also:
-
setDefaultTemplateLoadPath
Set the default path from which template files are loaded. Does not imply a requirement that the template be loaded from that location.- Parameters:
dir
- The initial directory where template files should be loaded from.- Throws:
NullPointerException
- if the parameter given is null.- See Also:
-
getDefaultTemplateSavePath
Get the default path to which template files are saved.- Returns:
- The initial directory where template files should be saved to. Null if not set.
- See Also:
-
setDefaultTemplateSavePath
Set the default path to which template files are saved. Does not imply a requirement that the template must be saved to that location.- Parameters:
dir
- The initial directory where template should be saved to.- Throws:
NullPointerException
- if the parameter given is null.- See Also:
-
getAllowTemplateLoadOutsideDefault
public boolean getAllowTemplateLoadOutsideDefault()Get ability to load templates outside default directory- Returns:
- true if the loading outside default directory is allowed or false otherwise
- See Also:
-
setAllowTemplateLoadOutsideDefault
public void setAllowTemplateLoadOutsideDefault(boolean state) Set ability to load templates outside default directory.- Parameters:
state
- new state- See Also:
-
getAllowTemplateSaveOutsideDefault
public boolean getAllowTemplateSaveOutsideDefault()Get ability to save templates outside default directory- Returns:
- true if the saving outside default directory is allowed or false otherwise
- See Also:
-
setAllowTemplateSaveOutsideDefault
public void setAllowTemplateSaveOutsideDefault(boolean state) Set ability to save templates outside default directory.- Parameters:
state
- new state- See Also:
-
getDefaultConfigLoadPath
Get the default path from which configuration files are loaded.- Returns:
- The initial directory where configuration files should be loaded from. Null if not set.
- See Also:
-
setDefaultConfigLoadPath
Set the default path from which configuration files are loaded. Does not imply a requirement that the config be loaded from that location.- Parameters:
dir
- The initial directory where configuration files should be loaded from.- Throws:
NullPointerException
- if the parameter given is null.- See Also:
-
getDefaultConfigSavePath
Get the default path from which configuration files are loaded.- Returns:
- The initial directory where configuration files should be loaded from. Null if not set.
- See Also:
-
setDefaultConfigSavePath
Set the default path to which configuration files are saved. Does not imply a requirement that the config must be saved to that location.- Parameters:
dir
- The initial directory where workdirs should be saved to.- Throws:
NullPointerException
- if the parameter given is null.- See Also:
-
getAllowConfigLoadOutsideDefault
public boolean getAllowConfigLoadOutsideDefault()Get ability to load config outside default directory- Returns:
- true if the loading outside default directory is allowed or false otherwise
- See Also:
-
setAllowConfigLoadOutsideDefault
public void setAllowConfigLoadOutsideDefault(boolean state) Set ability to load config outside default directory.- Parameters:
state
- new state- See Also:
-
getAllowConfigSaveOutsideDefault
public boolean getAllowConfigSaveOutsideDefault()Get ability to load config outside default directory- Returns:
- true if the saving outside default directory is allowed or false otherwise
- See Also:
-
setAllowConfigSaveOutsideDefault
public void setAllowConfigSaveOutsideDefault(boolean state) Set ability to save config outside default directory.- Parameters:
state
- new state- See Also:
-
loadConfiguration
-
setWorkDir
Deprecated.use #setWorkDirectory(WorkDirectory) instead- See Also:
-
openTree
-
getCustomRenderersMap
-
registerCustomQuestionRenderer
protected void registerCustomQuestionRenderer(Class<? extends Question> question, com.sun.interview.wizard.QuestionRenderer renderer) Register custom config editor's question renderer for specified question class. It is better to register custom renderer BEFORE Configuration Editor is constructed, for example in ContextManager's constructor.- Parameters:
question
- Question's classrenderer
- Custom question renderer fot this question
-
getExecToolControlFactory
-
updated
Invoked when session has been changed.- Specified by:
updated
in interfaceSession.Observer
- Parameters:
ev
-
-
order
public int order()BasicSession.OrderedObserver interface method. Returns Integer.MAX_VALUE - 100 to be notified after controls, but before ExecTool.- Specified by:
order
in interfaceBasicSession.OrderedObserver
-
updatedWorkDirectory
Invoked when the value of the work directory has been modified. This implementation just invokes setWorkDirectory(). Subclasses might implement alternative reaction on configuration change.- Parameters:
wd
-
-
updatedCurrentConfig
Invoked when the value of the current configuration has been modified. This implementation does nothing. Subclasses might implement some reaction on configuration change.- Parameters:
ip
- - InterviewParameters object with new values
-
updatedCurrentTemplate
Invoked when the value of the current template has been modified. This implementation does nothing. Subclasses might implement some reaction on configuration change.- Parameters:
ip
- - InterviewParameters object with new values
-