Class ElementTreeSelectionDialog

  • All Implemented Interfaces:
    IShellProvider

    public class ElementTreeSelectionDialog
    extends SelectionStatusDialog
    A class to select elements out of a tree structure.
    Since:
    2.0
    • Constructor Detail

      • ElementTreeSelectionDialog

        public ElementTreeSelectionDialog​(Shell parent,
                                          ILabelProvider labelProvider,
                                          ITreeContentProvider contentProvider)
        Constructs an instance of ElementTreeSelectionDialog.
        Parameters:
        parent - The parent shell for the dialog
        labelProvider - the label provider to render the entries
        contentProvider - the content provider to evaluate the tree structure
      • ElementTreeSelectionDialog

        public ElementTreeSelectionDialog​(Shell parent,
                                          IBaseLabelProvider labelProvider,
                                          ITreeContentProvider contentProvider)
        Constructs an instance of ElementTreeSelectionDialog.
        Parameters:
        parent - The parent shell for the dialog
        labelProvider - the label provider to render the entries. It must be compatible with the Viewerreturned from doCreateTreeViewer(Composite, int)
        contentProvider - the content provider to evaluate the tree structure
        Since:
        3.106
    • Method Detail

      • setInitialSelection

        public void setInitialSelection​(Object selection)
        Sets the initial selection. Convenience method.
        Parameters:
        selection - the initial selection.
      • setEmptyListMessage

        public void setEmptyListMessage​(String message)
        Sets the message to be displayed if the list is empty.
        Parameters:
        message - the message to be displayed.
      • setAllowMultiple

        public void setAllowMultiple​(boolean allowMultiple)
        Specifies if multiple selection is allowed.
        Parameters:
        allowMultiple - true if allowed.
      • setDoubleClickSelects

        public void setDoubleClickSelects​(boolean doubleClickSelects)
        Specifies if default selected events (double click) are created.
        Parameters:
        doubleClickSelects - true or false.
      • setComparator

        public void setComparator​(ViewerComparator comparator)
        Sets the comparator used by the tree viewer.
        Parameters:
        comparator - the ViewerComparator
        Since:
        3.3
      • addFilter

        public void addFilter​(ViewerFilter filter)
        Adds a filter to the tree viewer.
        Parameters:
        filter - a filter.
      • setValidator

        public void setValidator​(ISelectionStatusValidator validator)
        Sets an optional validator to check if the selection is valid. The validator is invoked whenever the selection changes.
        Parameters:
        validator - the validator to validate the selection.
      • setInput

        public void setInput​(Object input)
        Sets the tree input.
        Parameters:
        input - the tree input.
      • setSize

        public void setSize​(int width,
                            int height)
        Sets the size of the tree in unit of characters.
        Parameters:
        width - the width of the tree.
        height - the height of the tree.
      • updateOKStatus

        protected void updateOKStatus()
        Validate the receiver and update the ok status.
      • open

        public int open()
        Description copied from class: Window
        Opens this window, creating it first if it has not yet been created.

        If this window has been configured to block on open ( setBlockOnOpen), this method waits until the window is closed by the end user, and then it returns the window's return code; otherwise, this method returns immediately. A window's return codes are window-specific, although two standard return codes are predefined: OK and CANCEL.

        Overrides:
        open in class Window
        Returns:
        the return code
        See Also:
        Window.create()
      • cancelPressed

        protected void cancelPressed()
        Handles cancel button pressed event.
        Overrides:
        cancelPressed in class Dialog
      • create

        public void create()
        Description copied from class: Window
        Creates this window's widgetry in a new top-level shell.

        The default implementation of this framework method creates this window's shell (by calling createShell), and its controls (by calling createContents), then initializes this window's shell bounds (by calling initializeBounds).

        Overrides:
        create in class SelectionStatusDialog
      • createDialogArea

        protected Control createDialogArea​(Composite parent)
        Description copied from class: Dialog
        Creates and returns the contents of the upper part of this dialog (above the button bar).

        The Dialog implementation of this framework method creates and returns a new Composite with standard margins and spacing.

        The returned control's layout data must be an instance of GridData. This method must not modify the parent's layout.

        Subclasses must override this method but may call super as in the following example:

         Composite composite = (Composite) super.createDialogArea(parent);
         //add controls to composite as necessary
         return composite;
         
        Overrides:
        createDialogArea in class Dialog
        Parameters:
        parent - the parent composite to contain the dialog area
        Returns:
        the dialog area control
      • doCreateTreeViewer

        protected TreeViewer doCreateTreeViewer​(Composite parent,
                                                int style)
        Creates the tree viewer.
        Parameters:
        parent - the parent composite
        style - the SWT style bits
        Returns:
        the tree viewer
        Since:
        3.4
      • getTreeViewer

        protected TreeViewer getTreeViewer()
        Returns the tree viewer.
        Returns:
        the tree viewer
      • access$superButtonPressed

        protected void access$superButtonPressed​(int id)
        Set the result using the super class implementation of buttonPressed.
        Parameters:
        id - the id of the button that was pressed (see IDialogConstants.*_ID constants)
        See Also:
        Dialog.buttonPressed(int)
      • access$setResult

        protected void access$setResult​(List result)
        Set the result using the super class implementation of setResult.
        Parameters:
        result - list of selected elements, or null if Cancel was pressed
        See Also:
        SelectionStatusDialog.setResult(int, Object)
      • handleShellCloseEvent

        protected void handleShellCloseEvent()
        Description copied from class: Window
        Notifies that the window's close button was pressed, the close menu was selected, or the ESCAPE key pressed.

        The default implementation of this framework method sets the window's return code to CANCEL and closes the window using close. Subclasses may extend or reimplement.

        Overrides:
        handleShellCloseEvent in class TrayDialog