Package com.sun.javatest.exec
Class BasicSessionControl
- java.lang.Object
-
- com.sun.javatest.exec.BasicSessionControl
-
- All Implemented Interfaces:
ET_Control
,com.sun.javatest.exec.ET_RunTestControl.Observer
,ET_SessionControl
,InterviewEditor.Observer
,Session.Observer
public class BasicSessionControl extends java.lang.Object implements InterviewEditor.Observer, com.sun.javatest.exec.ET_RunTestControl.Observer, ET_SessionControl, Session.Observer
Class that encapsulate logic of user's actions on update session: operations on configuration and work directory. Some methods are added to preserve old functionality...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
BasicSessionControl.E_EditorVisibility
Event to be sent out when Editor become visible/invisibleprotected class
BasicSessionControl.SessionView
-
Field Summary
Fields Modifier and Type Field Description protected ContextManager
cm
protected InterviewEditor
interviewEditor
protected javax.swing.JComponent
parent
protected SessionExt
session
protected javax.swing.JPanel
sessionView
protected TestSuite
testSuite
protected UIFactory
uif
-
Constructor Summary
Constructors Constructor Description BasicSessionControl(javax.swing.JComponent parent, UIFactory uif, TestSuite ts, ContextManager cm)
Creates a control over new created session for the passed test suite.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
applyWorkDir(WorkDirectory wd)
Applies value of the selected work directory.void
changed(InterviewParameters p)
InterviewEditor.Observer method.void
changedVisibility(boolean isVisible, InterviewEditor editor)
InterviewEditor.Observer method.protected void
checkExcludeListUpdate(javax.swing.JComponent parent, boolean quietIfNoUpdate, Parameters params)
static Parameters
clone(Parameters p)
Clones passed parameters.void
configure()
Causes a series of actions to be performed to complete configuration:
If session is already ready - does nothing.
If work directory is not set - suggests creating or opening one
Opens configuration editor.protected SessionExt
createEmptySession()
Creates an empty configuration for the test suite.protected InterviewEditor
createInterviewEditor(InterviewParameters ip)
Creates an InterviewEditor instance.protected ToolAction
createNewWorkDirAction()
protected javax.swing.JPanel
createSessionView()
protected ToolAction
createSetWorkDirAction()
protected boolean
createWD()
Causes the dialog for new directory creating to appear.void
dispose()
void
edit()
Causes configuration editor to appear.void
ensureInterviewUpToDate()
void
finishTests(Parameters p)
Invoked when runTestHandler completed test executionjavax.swing.JMenu
getMenu()
Returts menu to be added to the menu marprotected boolean
getNeedToAutoCheckExcludeList(Parameters params)
Session
getSession()
Returns the session object under controljava.util.List<javax.swing.Action>
getToolBarActionList()
Returns list of actions to be added to the tool barprotected UIFactory
getUIFactory()
Method returning UIFactory to be used to create InterviewEditor instance.javax.swing.JComponent
getViewComponent()
Returns the panel reflecting the current state of the sessionprotected void
initActions()
protected boolean
initEditor()
Initializes interviewEditor.protected void
initHistoryListeners()
boolean
isConfiguring()
protected boolean
isEditorVisible()
void
restore(java.util.Map<java.lang.String,java.lang.String> m)
Restores saved state from the mapvoid
restoreConfigFromWD(WorkDirectory wd)
Tries to restore latest available configuration for the session.void
save(java.util.Map<java.lang.String,java.lang.String> m)
Saves current state to the mapprotected boolean
setWD()
Causes the dialog for work directory selecting to appear.protected void
showConfigureDialog()
protected void
showWorkDirDialog()
void
startTests(Parameters p)
Invoked when runTestHandler is going to start test executionvoid
updated(Session.Event ev)
Invoked when state of config has changedvoid
updateGUI()
Invoked when some change has happenedvoid
whatToDoWhenConfigNotReadyButUserPressedStartButton(javax.swing.Action startAction)
-
-
-
Field Detail
-
session
protected final SessionExt session
-
testSuite
protected final TestSuite testSuite
-
uif
protected UIFactory uif
-
parent
protected javax.swing.JComponent parent
-
sessionView
protected javax.swing.JPanel sessionView
-
interviewEditor
protected InterviewEditor interviewEditor
-
cm
protected ContextManager cm
-
-
Constructor Detail
-
BasicSessionControl
public BasicSessionControl(javax.swing.JComponent parent, UIFactory uif, TestSuite ts, ContextManager cm) throws Session.Fault
Creates a control over new created session for the passed test suite.- Parameters:
parent
-uif
-ts
-cm
-- Throws:
Session.Fault
-
-
Method Detail
-
clone
public static Parameters clone(Parameters p) throws Session.Fault
Clones passed parameters. Works only for InterviewParameters instances.- Parameters:
p
- instance to clone, might be null.- Returns:
- cloned object obtained for the passed one by performing save/load operations.
- Throws:
Session.Fault
-
getSession
public Session getSession()
Returns the session object under control- Specified by:
getSession
in interfaceET_SessionControl
- Returns:
- The session associated with this instance.
-
getViewComponent
public javax.swing.JComponent getViewComponent()
Returns the panel reflecting the current state of the session- Specified by:
getViewComponent
in interfaceET_SessionControl
-
getToolBarActionList
public java.util.List<javax.swing.Action> getToolBarActionList()
Description copied from interface:ET_Control
Returns list of actions to be added to the tool bar- Specified by:
getToolBarActionList
in interfaceET_Control
-
save
public void save(java.util.Map<java.lang.String,java.lang.String> m)
Description copied from interface:ET_Control
Saves current state to the map- Specified by:
save
in interfaceET_Control
-
restore
public void restore(java.util.Map<java.lang.String,java.lang.String> m)
Description copied from interface:ET_Control
Restores saved state from the map- Specified by:
restore
in interfaceET_Control
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceET_Control
-
createEmptySession
protected SessionExt createEmptySession() throws Session.Fault
Creates an empty configuration for the test suite. By default BasicSession is used. It's supposed for subclasses to override this method.- Returns:
- created session.
- Throws:
Session.Fault
-
ensureInterviewUpToDate
public void ensureInterviewUpToDate()
-
startTests
public void startTests(Parameters p)
Invoked when runTestHandler is going to start test execution- Specified by:
startTests
in interfacecom.sun.javatest.exec.ET_RunTestControl.Observer
-
finishTests
public void finishTests(Parameters p)
Invoked when runTestHandler completed test execution- Specified by:
finishTests
in interfacecom.sun.javatest.exec.ET_RunTestControl.Observer
-
whatToDoWhenConfigNotReadyButUserPressedStartButton
public void whatToDoWhenConfigNotReadyButUserPressedStartButton(javax.swing.Action startAction)
-
checkExcludeListUpdate
protected void checkExcludeListUpdate(javax.swing.JComponent parent, boolean quietIfNoUpdate, Parameters params)
-
getNeedToAutoCheckExcludeList
protected boolean getNeedToAutoCheckExcludeList(Parameters params)
-
getMenu
public javax.swing.JMenu getMenu()
Description copied from interface:ET_Control
Returts menu to be added to the menu mar- Specified by:
getMenu
in interfaceET_Control
-
initEditor
protected boolean initEditor()
Initializes interviewEditor.- Returns:
- true if initialized successfully, false if failed.
-
createInterviewEditor
protected InterviewEditor createInterviewEditor(InterviewParameters ip)
Creates an InterviewEditor instance. Subclasses might override this method to create an alternative editor.- Parameters:
ip
- parameters to be edited
-
getUIFactory
protected UIFactory getUIFactory()
Method returning UIFactory to be used to create InterviewEditor instance.
-
edit
public void edit()
Causes configuration editor to appear. If workdir is not set, suggests to create one first.- Specified by:
edit
in interfaceET_SessionControl
-
configure
public void configure()
Causes a series of actions to be performed to complete configuration:
If session is already ready - does nothing.
If work directory is not set - suggests creating or opening one
Opens configuration editor.- Specified by:
configure
in interfaceET_SessionControl
-
isConfiguring
public boolean isConfiguring()
- Specified by:
isConfiguring
in interfaceET_SessionControl
- Returns:
- true if configure() method is running or configuration is editing.
-
showWorkDirDialog
protected void showWorkDirDialog()
-
showConfigureDialog
protected void showConfigureDialog()
-
initActions
protected void initActions()
-
createNewWorkDirAction
protected ToolAction createNewWorkDirAction()
-
createSetWorkDirAction
protected ToolAction createSetWorkDirAction()
-
initHistoryListeners
protected void initHistoryListeners()
-
createSessionView
protected javax.swing.JPanel createSessionView()
-
updateGUI
public void updateGUI()
Description copied from interface:ET_Control
Invoked when some change has happened- Specified by:
updateGUI
in interfaceET_Control
-
isEditorVisible
protected boolean isEditorVisible()
- Returns:
- true if user has an interview editor open.
-
changed
public void changed(InterviewParameters p)
InterviewEditor.Observer method. Invoked when current session has changed from InterviewEditor- Specified by:
changed
in interfaceInterviewEditor.Observer
- Parameters:
p
-
-
changedVisibility
public void changedVisibility(boolean isVisible, InterviewEditor editor)
InterviewEditor.Observer method. Invoked when InterviewEditor is made either visible or invisible. Implementations call updateGUI() to enable/disable actions.- Specified by:
changedVisibility
in interfaceInterviewEditor.Observer
- Parameters:
isVisible
- - true or falseeditor
- editor that changed the state
-
createWD
protected boolean createWD()
Causes the dialog for new directory creating to appear. Invoked from createNewWorkDirAction. Subclasses might override this method to perform extra actions associated with creating new work directory, like setting template.- Returns:
- true if configuration editing is required after WorkDir created
-
setWD
protected boolean setWD()
Causes the dialog for work directory selecting to appear. Invoked from createSetWorkDirAction. Subclasses might override this method to perform extra actions associated with setting work directory, like setting template.- Returns:
- true if configuration editing is required after WorkDir set
-
applyWorkDir
protected void applyWorkDir(WorkDirectory wd)
Applies value of the selected work directory.- Parameters:
wd
-
-
restoreConfigFromWD
public void restoreConfigFromWD(WorkDirectory wd) throws Session.Fault
Tries to restore latest available configuration for the session.- Parameters:
wd
-- Throws:
Session.Fault
-
updated
public void updated(Session.Event ev)
Description copied from interface:Session.Observer
Invoked when state of config has changed- Specified by:
updated
in interfaceSession.Observer
- Parameters:
ev
- - Event describing the change
-
-