Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javatest.exec
Class JavaTestContextMenu

    java.lang.Object
      com.sun.javatest.exec.JavaTestContextMenu

    public abstract class JavaTestContextMenu

extends java.lang.Object

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
`static int` | `CUSTOM`
`static int` | `FOLDERS_ONLY`
`static int` | `TESTS_AND_FOLDERS`
`static int` | `TESTS_ONLY`

Constructor Summary
`JavaTestContextMenu()`

Method Summary
`abstract javax.swing.JMenuItem` | `getMenu()` Get the actual component for this menu.
`abstract int` | `getMenuApplication()` Determine the contexts in which this menu is applicable.
`boolean` | `isMultiSelectAllowed()` May multiple nodes be selected at one time for this menu item to be enabled.
`abstract JavaTestContextMenu` | `newInstance()` Create a new instance, based on this instance.
`void` | `updateState(java.lang.String path)` Called upon when a folder is selected by the user.
`void` | `updateState(java.lang.String[] folders, TestResult[] trs)` Called upon when multiple items have been selected by the user.
`void` | `updateState(TestResult tr)` Called upon when a test is selected by the user.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TESTS_AND_FOLDERS

    public static final int TESTS_AND_FOLDERS

See Also:
  Constant Field Values

### TESTS_ONLY

    public static final int TESTS_ONLY

See Also:
  Constant Field Values

### FOLDERS_ONLY

    public static final int FOLDERS_ONLY

See Also:
  Constant Field Values

### CUSTOM

    public static final int CUSTOM

See Also:
  Constant Field Values

Constructor Detail

### JavaTestContextMenu

    public JavaTestContextMenu()

Method Detail

### newInstance

    public abstract JavaTestContextMenu 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

    public abstract javax.swing.JMenuItem 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 to `CUSTOM`, the system managing the menus assumes that it is allowed to control the enabled/disabled state of the menu item.

  See Also:
    `TESTS_AND_FOLDERS`, `TESTS_ONLY`, `FOLDERS_ONLY`, `CUSTOM`

### 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 is `false`, override this method to change. If you need to enable/disabled based on the composition of the selection, you should return `true`, then override `updateState(String[], TestResult[])` and disable if needed.

  Returns:
    True if multiselect is permitted for this menu action. False otherwise.

### updateState

    public void updateState(TestResult tr)

  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` from `getMenuApplication` 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

    public void updateState(java.lang.String path)

  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

    public void updateState(java.lang.String[] folders,
                            TestResult[] trs)

  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 by `TestDescription.getRootRelativeURL()`. Null if none.
    `trs` - The tests which the user is acting upon. Null if none.
  See Also:
    `TestDescription.getRootRelativeURL()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.