Class PGroup

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

    public class PGroup
    extends org.eclipse.swt.widgets.Canvas
    Instances of this class provide a decorated border as well as an optional toggle to expand and collapse the control.

    This widget is customizable through alternative AbstractGroupStrategys. Each strategy determines the size and appearance of the widget.

    Styles:
    SMOOTH
    Events:
    Expand, Collapse
    • Constructor Summary

      Constructors 
      Constructor Description
      PGroup​(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 Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addExpandListener​(org.eclipse.swt.events.ExpandListener listener)
      Adds the listener to the collection of listeners who will be notified when the receiver is expanded or collapsed by sending it one of the messages defined in the ExpandListener interface.
      (package private) void addToolItem​(PGroupToolItem toolitem)  
      private static int checkStyle​(int style)  
      org.eclipse.swt.graphics.Point computeSize​(int arg0, int arg1, boolean arg2)  
      org.eclipse.swt.graphics.Rectangle computeTrim​(int x, int y, int width, int height)
      org.eclipse.swt.graphics.Color getBackground()  
      org.eclipse.swt.graphics.Rectangle getClientArea()
      boolean getExpanded()
      Returns the expanded/collapsed state.
      org.eclipse.swt.graphics.Image getImage()
      Returns the image.
      int getImagePosition()
      Returns the image position.
      int getLinePosition()
      Returns the line position.
      AbstractGroupStrategy getStrategy()
      Returns the strategy.
      java.lang.String getText()
      Returns the text.
      int getTogglePosition()
      Returns the toggle position.
      AbstractRenderer getToggleRenderer()
      Returns the toggle renderer or null.
      AbstractToolItemRenderer getToolItemRenderer()  
      PGroupToolItem[] getToolItems()  
      private void initListeners()  
      (package private) org.eclipse.swt.graphics.Color internalGetBackground()  
      private void onDispose()  
      private void onKeyDown​(org.eclipse.swt.widgets.Event e)  
      private void onMouseDown​(org.eclipse.swt.widgets.Event e)  
      private void onMouseExit​(org.eclipse.swt.widgets.Event e)  
      private void onMouseMove​(org.eclipse.swt.widgets.Event e)  
      private void onPaint​(org.eclipse.swt.events.PaintEvent e)  
      private void paintToolItems​(org.eclipse.swt.graphics.GC gc)  
      void removeExpandListener​(org.eclipse.swt.events.ExpandListener listener)
      Removes the listener from the collection of listeners who will be notified when the receiver are expanded or collapsed.
      (package private) void removeToolItem​(PGroupToolItem toolitem)  
      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 setExpanded​(boolean expanded)
      Sets the expanded state of the group.
      void setFont​(org.eclipse.swt.graphics.Font font)  
      void setImage​(org.eclipse.swt.graphics.Image image)
      Sets the image.
      void setImagePosition​(int imagePosition)
      Sets the image position.
      void setLinePosition​(int linePosition)
      Sets the line position.
      void setStrategy​(AbstractGroupStrategy strategy)
      Sets the strategy.
      void setText​(java.lang.String text)
      Sets the text.
      void setTogglePosition​(int togglePosition)
      Sets the toggle position.
      void setToggleRenderer​(AbstractRenderer toggleRenderer)
      Sets the toggle renderer.
      void setToolItemRenderer​(AbstractToolItemRenderer toolItemRenderer)  
      • Methods inherited from class org.eclipse.swt.widgets.Canvas

        drawBackground, getCaret, getIME, scroll, setCaret, setIME
      • Methods inherited from class org.eclipse.swt.widgets.Composite

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

        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, dragDetect, dragDetect, forceFocus, getAccessible, 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, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, 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

      • image

        private org.eclipse.swt.graphics.Image image
      • text

        private java.lang.String text
      • initialFont

        private org.eclipse.swt.graphics.Font initialFont
      • imagePosition

        private int imagePosition
      • togglePosition

        private int togglePosition
      • linePosition

        private int linePosition
      • expanded

        private boolean expanded
      • overToggle

        private boolean overToggle
      • backgroundColor

        private org.eclipse.swt.graphics.Color backgroundColor
      • toolitems

        private java.util.List toolitems
    • Constructor Detail

      • PGroup

        public PGroup​(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.

        To ensure that the color of corners is equal to one of the underlying control invoke the parent composites Composite.setBackgroundMode(int) with SWT.INHERIT_DEFAULT or SWT.INHERIT_DEFAULT

        Parameters:
        parent - a composite control which will be the parent of the new instance (cannot be null)
        style - the style of control 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
        • ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
        See Also:
        SWT, Widget.checkSubclass(), Widget.getStyle()
    • Method Detail

      • checkStyle

        private static int checkStyle​(int style)
      • getBackground

        public org.eclipse.swt.graphics.Color getBackground()
        Overrides:
        getBackground in class org.eclipse.swt.widgets.Control
        See Also:
        Control.getBackground()
      • internalGetBackground

        org.eclipse.swt.graphics.Color internalGetBackground()
      • 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.

        To ensure that the color of corners is equal to one of the underlying control invoke the parent composites Composite.setBackgroundMode(int) with SWT.INHERIT_DEFAULT or SWT.INHERIT_DEFAULT

        Note: If a new strategy is set on the receiver it may overwrite the existing background color.

        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
      • getToggleRenderer

        public AbstractRenderer getToggleRenderer()
        Returns the toggle renderer 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
      • setToggleRenderer

        public void setToggleRenderer​(AbstractRenderer toggleRenderer)
        Sets the toggle renderer. If the toggle renderer is set to null the control will not show a toggle or allow the user to expand/collapse the group by clicking on the title.
        Parameters:
        toggleRenderer - the toggleRenderer to set 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
      • initListeners

        private void initListeners()
      • onPaint

        private void onPaint​(org.eclipse.swt.events.PaintEvent e)
      • paintToolItems

        private void paintToolItems​(org.eclipse.swt.graphics.GC gc)
      • onKeyDown

        private void onKeyDown​(org.eclipse.swt.widgets.Event e)
      • onMouseMove

        private void onMouseMove​(org.eclipse.swt.widgets.Event e)
      • onMouseExit

        private void onMouseExit​(org.eclipse.swt.widgets.Event e)
      • onMouseDown

        private void onMouseDown​(org.eclipse.swt.widgets.Event e)
      • getStrategy

        public AbstractGroupStrategy getStrategy()
        Returns the strategy.
        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
      • setStrategy

        public void setStrategy​(AbstractGroupStrategy strategy)
        Sets the strategy.
        Parameters:
        strategy - the strategy to set
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the strategy 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
      • getImage

        public org.eclipse.swt.graphics.Image getImage()
        Returns the image.
        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
      • setImage

        public void setImage​(org.eclipse.swt.graphics.Image image)
        Sets the image.
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the image is 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
      • setFont

        public void setFont​(org.eclipse.swt.graphics.Font font)
        Overrides:
        setFont in class org.eclipse.swt.widgets.Canvas
        See Also:
        Canvas.setFont(org.eclipse.swt.graphics.Font)
      • getText

        public java.lang.String getText()
        Returns the text.
        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
      • setText

        public void setText​(java.lang.String text)
        Sets the text.
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the text 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
      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(int arg0,
                                                          int arg1,
                                                          boolean arg2)
        Overrides:
        computeSize in class org.eclipse.swt.widgets.Control
        See Also:
        Control.computeSize(int, int, boolean)
      • getExpanded

        public boolean getExpanded()
        Returns the expanded/collapsed state.
        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
      • setExpanded

        public void setExpanded​(boolean expanded)
        Sets the expanded state of the group.
        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
      • onDispose

        private void onDispose()
      • addExpandListener

        public void addExpandListener​(org.eclipse.swt.events.ExpandListener listener)
        Adds the listener to the collection of listeners who will be notified when the receiver is expanded or collapsed by sending it one of the messages defined in the ExpandListener interface.
        Parameters:
        listener - the listener which should 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:
        ExpandListener, removeExpandListener(org.eclipse.swt.events.ExpandListener)
      • removeExpandListener

        public void removeExpandListener​(org.eclipse.swt.events.ExpandListener listener)
        Removes the listener from the collection of listeners who will be notified when the receiver are expanded or collapsed.
        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:
        ExpandListener, addExpandListener(org.eclipse.swt.events.ExpandListener)
      • getImagePosition

        public int getImagePosition()
        Returns the image position. The image position is a combination of integer constants OR'ed together.
        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
      • setImagePosition

        public void setImagePosition​(int imagePosition)
        Sets the image position. The image position is a combination of integer constants OR'ed together. Valid values are SWT.LEFT and SWT.RIGHT (mutually exclusive). SWT.TOP is hint interpreted by some strategies.
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the strategy 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
      • getTogglePosition

        public int getTogglePosition()
        Returns the toggle position. The toggle position is a combination of integer constants OR'ed together.
        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
      • setTogglePosition

        public void setTogglePosition​(int togglePosition)
        Sets the toggle position. The toggle position is a combination of integer constants OR'ed together. Valid values are SWT.LEFT and SWT.RIGHT (mutually exclusive).
        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
      • getLinePosition

        public int getLinePosition()
        Returns the line position. The line position is a combination of integer constants OR'ed together.
        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
      • setLinePosition

        public void setLinePosition​(int linePosition)
        Sets the line position. The line position is a combination of integer constants OR'ed together. Valid values are SWT.BOTTOM and SWT.CENTER (mutually exclusive).
        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
      • computeTrim

        public org.eclipse.swt.graphics.Rectangle computeTrim​(int x,
                                                              int y,
                                                              int width,
                                                              int height)
        Overrides:
        computeTrim in class org.eclipse.swt.widgets.Scrollable
      • getClientArea

        public org.eclipse.swt.graphics.Rectangle getClientArea()
        Overrides:
        getClientArea in class org.eclipse.swt.widgets.Scrollable