Package com.sun.javatest.exec
Class JavaTestContextMenu
java.lang.Object
com.sun.javatest.exec.JavaTestContextMenu
Class to encapsulate a custom context menu item to be added to the GUI by a
test suite. The method
getMenuApplication
determines which type
of situations the menu should be presented in. Processing the actual selection
action event for the menu item(s) should be processed as you normally would
with the Swing-provided Action mechanisms.
All methods in this API will be invoked on the GUI event thread.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract JMenuItem
getMenu()
Get the actual component for this menu.abstract int
Determine the contexts in which this menu is applicable.boolean
May multiple nodes be selected at one time for this menu item to be enabled.abstract JavaTestContextMenu
Create a new instance, based on this instance.void
Called upon when a test is selected by the user.void
updateState
(String path) Called upon when a folder is selected by the user.void
updateState
(String[] folders, TestResult... trs) Called upon when multiple items have been selected by the user.
-
Field Details
-
TESTS_AND_FOLDERS
public static final int TESTS_AND_FOLDERS- See Also:
-
TESTS_ONLY
public static final int TESTS_ONLY- See Also:
-
FOLDERS_ONLY
public static final int FOLDERS_ONLY- See Also:
-
CUSTOM
public static final int CUSTOM- See Also:
-
-
Constructor Details
-
JavaTestContextMenu
public JavaTestContextMenu()
-
-
Method Details
-
newInstance
Create a new instance, based on this instance. The purpose of this is to allow this menu item to appear in multiple places in the interface. -
getMenu
Get the actual component for this menu. A single menu item is recommended, but a it may also be a submenu. The reference returned should not change after this method has been invoked the first time. This allows for lazy initialization, but then permits caching by the client of the API.- Returns:
- A menu to be displayed to the user. Must never be null.
-
getMenuApplication
public abstract int getMenuApplication()Determine the contexts in which this menu is applicable. Unless the value is set toCUSTOM
, the system managing the menus assumes that it is allowed to control the enabled/disabled state of the menu item.- See Also:
-
isMultiSelectAllowed
public boolean isMultiSelectAllowed()May multiple nodes be selected at one time for this menu item to be enabled. If not allowed and multiple items are currently selected, updateState() methods will not be called. The default state of this setting isfalse
, override this method to change.If you need to enable/disabled based on the composition of the selection, you should return
true
, then overrideupdateState(String[], TestResult[])
and disable if needed.- Returns:
- True if multiselect is permitted for this menu action. False otherwise.
-
updateState
Called upon when a test is selected by the user. This callback allows the implementation to dynamically adjust it's state. It is recommended that this method remain unimplemented unless really needed, since it is processed synchronously on the event thread. It is critical that the implementation of this method be reasonably fast and non-blocking because it will may be invoked each time the user requests a popup to be displayed.Implementations which return
CUSTOM
fromgetMenuApplication
will generally override this. This method is called regardless of what application type the object indicates.The controlling class will first enable/disable the menu based on the application type (unless
CUSTOM
).This method will be invoked on the GUI event thread.
- Parameters:
tr
- The test result object which the users is acting upon.
-
updateState
Called upon when a folder is selected by the user. It is in canonical internal form - forward slash separated.This method will be invoked on the GUI event thread.
- Parameters:
path
-
-
updateState
Called upon when multiple items have been selected by the user. The union of the two parameters represents the leafs selected by the user to act upon. The intersection of those two parameters is empty.This method will be invoked on the GUI event thread.
- Parameters:
folders
- The test paths which the user is acting upon, only the folders. The strings are forward slash separated locations within the test suite, a substring of that which would be returned byTestDescription.getRootRelativeURL()
. Null if none.trs
- The tests which the user is acting upon. Null if none.- See Also:
-