Class ColumnBrowserWidget

  • All Implemented Interfaces:
    org.eclipse.swt.graphics.Drawable

    public class ColumnBrowserWidget
    extends org.eclipse.swt.custom.ScrolledComposite
    Instances of this class provide a data browser similar to the ones used in Mac OS X. Look at http://en.wikipedia.org/wiki/Miller_Columns

    Styles:
    BORDER
    Events:
    Selection
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private org.eclipse.swt.graphics.Image columnArrow  
      private java.util.List<org.eclipse.swt.widgets.Table> columns  
      private org.eclipse.swt.widgets.Composite composite  
      private java.util.List<org.eclipse.swt.events.SelectionListener> selectionListeners  
      • Fields inherited from class org.eclipse.swt.widgets.Composite

        embeddedHandle
      • Fields inherited from class org.eclipse.swt.widgets.Widget

        handle
    • Constructor Summary

      Constructors 
      Constructor Description
      ColumnBrowserWidget​(org.eclipse.swt.widgets.Composite parent, int style)
      Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in the SelectionListener interface.
      private void addTableListeners​(org.eclipse.swt.widgets.Table table)  
      void clear​(boolean needPacking)
      Clear the selection
      private void createTable()
      Create a column that displays data
      private void findElement​(ColumnItem item, java.util.List<ColumnItem> items)
      Build an array that contains the hierarchy of ColumnItem from the root node to a given item.
      private int findSelectedColumn​(org.eclipse.swt.widgets.TableItem tableItem)
      Find which column has been selected
      private boolean fireSelectionListeners​(org.eclipse.swt.widgets.Event selectionEvent)
      Fire the selection listeners
      (package private) ColumnItem getRootItem()  
      ColumnItem getSelection()
      Returns the ColumnItems that is currently selected in the receiver.
      void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
      Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.
      void select​(ColumnItem item)
      Selects an item in the receiver.
      private void selectItem​(org.eclipse.swt.widgets.TableItem tableItem)
      Perform actions when an item is selected (ie fill the next column and force focus on it)
      void setBackground​(org.eclipse.swt.graphics.Color color)
      Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.
      void setBackgroundImage​(org.eclipse.swt.graphics.Image image)
      Sets the receiver's background image to the image specified by the argument, or to the default system color for the control if the argument is null.
      void setBackgroundMode​(int mode)
      Sets the background drawing mode to the argument which should be one of the following constants defined in class SWT: INHERIT_NONE, INHERIT_DEFAULT, INHERIT_FORCE.
      void setCursor​(org.eclipse.swt.graphics.Cursor cursor)
      Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.
      void setFont​(org.eclipse.swt.graphics.Font font)
      Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
      void setForeground​(org.eclipse.swt.graphics.Color color)
      Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.
      void setMenu​(org.eclipse.swt.widgets.Menu menu)
      Sets the receiver's pop up menu to the argument.
      void setToolTipText​(java.lang.String tooltipText)
      Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.
      (package private) void updateContent()
      Update the content of the widget
      • Methods inherited from class org.eclipse.swt.custom.ScrolledComposite

        getAlwaysShowScrollBars, getContent, getExpandHorizontal, getExpandVertical, getMinHeight, getMinWidth, getOrigin, getShowFocusedControl, setAlwaysShowScrollBars, setContent, setExpandHorizontal, setExpandVertical, setLayout, setMinHeight, setMinSize, setMinSize, setMinWidth, setOrigin, setOrigin, setShowFocusedControl, showControl
      • Methods inherited from class org.eclipse.swt.widgets.Composite

        changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setFocus, setLayoutDeferred, setTabList
      • Methods inherited from class org.eclipse.swt.widgets.Scrollable

        computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isAutoScalable, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBounds, setBounds, setCapture, setDragDetect, setEnabled, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
      • Methods inherited from class org.eclipse.swt.widgets.Widget

        addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • columns

        private final java.util.List<org.eclipse.swt.widgets.Table> columns
      • composite

        private final org.eclipse.swt.widgets.Composite composite
      • columnArrow

        private final org.eclipse.swt.graphics.Image columnArrow
      • selectionListeners

        private final java.util.List<org.eclipse.swt.events.SelectionListener> selectionListeners
    • Constructor Detail

      • ColumnBrowserWidget

        public ColumnBrowserWidget​(org.eclipse.swt.widgets.Composite parent,
                                   int style)
        Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

        The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

        Parameters:
        parent - a widget which will be the parent of the new instance (cannot be null)
        style - the style of widget to construct
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the parent is null
        org.eclipse.swt.SWTException -
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
        See Also:
        Composite(Composite, int), SWT.BORDER, Widget.getStyle()
    • Method Detail

      • createTable

        private void createTable()
        Create a column that displays data
      • addTableListeners

        private void addTableListeners​(org.eclipse.swt.widgets.Table table)
      • fireSelectionListeners

        private boolean fireSelectionListeners​(org.eclipse.swt.widgets.Event selectionEvent)
        Fire the selection listeners
        Parameters:
        selectionEvent - mouse event
        Returns:
        true if the selection could be changed, false otherwise
      • selectItem

        private void selectItem​(org.eclipse.swt.widgets.TableItem tableItem)
        Perform actions when an item is selected (ie fill the next column and force focus on it)
        Parameters:
        tableItem - selected item
      • findSelectedColumn

        private int findSelectedColumn​(org.eclipse.swt.widgets.TableItem tableItem)
        Find which column has been selected
        Parameters:
        tableItem - selected table item
        Returns:
        the index of the selected column
      • updateContent

        void updateContent()
        Update the content of the widget
      • addSelectionListener

        public void addSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
        Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in the SelectionListener interface.
        Parameters:
        listener - the listener which should be notified when the user changes the receiver's selection
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent
      • clear

        public void clear​(boolean needPacking)
        Clear the selection
        Parameters:
        needPacking - if true, the widget is packed
      • getSelection

        public ColumnItem getSelection()
        Returns the ColumnItems that is currently selected in the receiver.
        Returns:
        the selected item, or null if no one is selected
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      • removeSelectionListener

        public void removeSelectionListener​(org.eclipse.swt.events.SelectionListener listener)
        Removes the listener from the collection of listeners who will be notified when the user changes the receiver's selection.
        Parameters:
        listener - the listener which should no longer be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        SelectionListener, addSelectionListener(org.eclipse.swt.events.SelectionListener)
      • select

        public void select​(ColumnItem item)
        Selects an item in the receiver. If the item was already selected, it remains selected.
        Parameters:
        item - the item to be selected
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the item is null
        • ERROR_INVALID_ARGUMENT - if the item has been disposed
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
      • findElement

        private void findElement​(ColumnItem item,
                                 java.util.List<ColumnItem> items)
        Build an array that contains the hierarchy of ColumnItem from the root node to a given item.
        Parameters:
        item - item to find
        items - the lists of item that composes the hierarchy
      • setBackground

        public void setBackground​(org.eclipse.swt.graphics.Color color)
        Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

        Note: This operation is a hint and may be overridden by the platform. For example, on Windows the background of a Button cannot be changed.

        Overrides:
        setBackground in class org.eclipse.swt.widgets.Control
        Parameters:
        color - the new color (or null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_ARGUMENT - if the argument has been disposed
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setBackground(org.eclipse.swt.graphics.Color)
      • setBackgroundMode

        public void setBackgroundMode​(int mode)
        Sets the background drawing mode to the argument which should be one of the following constants defined in class SWT: INHERIT_NONE, INHERIT_DEFAULT, INHERIT_FORCE.
        Overrides:
        setBackgroundMode in class org.eclipse.swt.widgets.Composite
        Parameters:
        mode - the new background mode
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        SWT, Composite.setBackgroundMode(int)
      • setBackgroundImage

        public void setBackgroundImage​(org.eclipse.swt.graphics.Image image)
        Sets the receiver's background image to the image specified by the argument, or to the default system color for the control if the argument is null. The background image is tiled to fill the available space.

        Note: This operation is a hint and may be overridden by the platform. For example, on Windows the background of a Button cannot be changed.

        Overrides:
        setBackgroundImage in class org.eclipse.swt.widgets.Control
        Parameters:
        image - the new image (or null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_ARGUMENT - if the argument has been disposed
        • ERROR_INVALID_ARGUMENT - if the argument is not a bitmap
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setBackgroundImage(org.eclipse.swt.graphics.Image)
      • setCursor

        public void setCursor​(org.eclipse.swt.graphics.Cursor cursor)
        Sets the receiver's cursor to the cursor specified by the argument, or to the default cursor for that kind of control if the argument is null.

        When the mouse pointer passes over a control its appearance is changed to match the control's cursor.

        Overrides:
        setCursor in class org.eclipse.swt.widgets.Control
        Parameters:
        cursor - the new cursor (or null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_ARGUMENT - if the argument has been disposed
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setCursor(org.eclipse.swt.graphics.Cursor)
      • setFont

        public void setFont​(org.eclipse.swt.graphics.Font font)
        Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
        Overrides:
        setFont in class org.eclipse.swt.widgets.Control
        Parameters:
        font - the new font (or null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_ARGUMENT - if the argument has been disposed
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setFont(org.eclipse.swt.graphics.Font)
      • setForeground

        public void setForeground​(org.eclipse.swt.graphics.Color color)
        Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

        Note: This operation is a hint and may be overridden by the platform.

        Overrides:
        setForeground in class org.eclipse.swt.widgets.Control
        Parameters:
        color - the new color (or null)
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_INVALID_ARGUMENT - if the argument has been disposed
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setForeground(org.eclipse.swt.graphics.Color)
      • setMenu

        public void setMenu​(org.eclipse.swt.widgets.Menu menu)
        Sets the receiver's pop up menu to the argument. All controls may optionally have a pop up menu that is displayed when the user requests one for the control. The sequence of key strokes, button presses and/or button releases that are used to request a pop up menu is platform specific.

        Note: Disposing of a control that has a pop up menu will dispose of the menu. To avoid this behavior, set the menu to null before the control is disposed.

        Overrides:
        setMenu in class org.eclipse.swt.widgets.Control
        Parameters:
        menu - the new pop up menu
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu
        • ERROR_INVALID_PARENT - if the menu is not in the same widget tree
        • ERROR_INVALID_ARGUMENT - if the menu has been disposed
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setMenu(org.eclipse.swt.widgets.Menu)
      • setToolTipText

        public void setToolTipText​(java.lang.String tooltipText)
        Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.

        The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.

        Overrides:
        setToolTipText in class org.eclipse.swt.widgets.Control
        Parameters:
        string - the new tool tip text (or null)
        Throws:
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        Control.setToolTipText(java.lang.String)
      • getRootItem

        ColumnItem getRootItem()
        Returns:
        the root item, or null if there is no data