Class Stepbar

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

    public class Stepbar
    extends org.eclipse.swt.widgets.Canvas
    Instances of this class represent a collection of steps, indicating progress/status in a linear order. Each step has a label. One can select the current step, and possibly set an error state.
    Styles:
    SWT.BORDER
    SWT.TOP or SWT.BOTTOM (vertical location of the text)
    Events:
    (none)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean bottom  
      private static int CIRCLE_DIAMETER  
      private int currentStep  
      private org.eclipse.swt.graphics.Color errorColor  
      private static int MINIMUM_LINE_WIDTH  
      private boolean onError  
      private static int SPACING  
      private java.util.List<java.lang.String> steps  
      private org.eclipse.swt.graphics.Color textColor  
      private org.eclipse.swt.graphics.Color unselectedColor  
      private static int VERTICAL_SPACE  
      • 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
      Stepbar​(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 addStep​(java.lang.String stepText)
      Append a step to the existing ones
      private static int checkStyle​(int style)  
      org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
      private java.util.List<org.eclipse.swt.graphics.Point> computeTextSizes()  
      private void drawSteps​(int y, org.eclipse.swt.graphics.GC gc)  
      private void drawTexts​(int y, org.eclipse.swt.graphics.GC gc)  
      int getCurrentStep()
      Returns the receiver's current step.
      java.util.List<java.lang.String> getSteps()
      Returns the receiver's list of steps
      org.eclipse.swt.graphics.Color getTextColor()
      Returns the receiver's color of the text
      org.eclipse.swt.graphics.Color getUnselectedColor()
      Returns the receiver's color used when the step is not reached
      void removeStep​(java.lang.String stepText)
      Remove a step from the list of the existing ones
      void setCurrentStep​(int currentStep)
      Remove a step from the list of the existing ones
      void setErrorState​(boolean errorState)
      Set the error state (on/off) of the selected step
      void setSteps​(java.lang.String[] steps)
      Set the steps
      void setSteps​(java.util.List<java.lang.String> steps)
      Set the steps
      void setTextColor​(org.eclipse.swt.graphics.Color textColor)
      Set the color of the text
      void setUnselectedColor​(org.eclipse.swt.graphics.Color unselectedColor)
      Set the color used to draw bars and circles for steps that have not been reached
      • Methods inherited from class org.eclipse.swt.widgets.Canvas

        drawBackground, getCaret, getIME, scroll, setCaret, setFont, 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

        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, 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, setBackground, 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

      • unselectedColor

        private org.eclipse.swt.graphics.Color unselectedColor
      • textColor

        private org.eclipse.swt.graphics.Color textColor
      • errorColor

        private final org.eclipse.swt.graphics.Color errorColor
      • steps

        private java.util.List<java.lang.String> steps
      • bottom

        private boolean bottom
      • currentStep

        private int currentStep
      • onError

        private boolean onError
    • Constructor Detail

      • Stepbar

        public Stepbar​(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 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
    • Method Detail

      • checkStyle

        private static int checkStyle​(int style)
      • drawSteps

        private void drawSteps​(int y,
                               org.eclipse.swt.graphics.GC gc)
      • drawTexts

        private void drawTexts​(int y,
                               org.eclipse.swt.graphics.GC gc)
      • addStep

        public void addStep​(java.lang.String stepText)
        Append a step to the existing ones
        Parameters:
        stepText - the text associated to the step the user wants to add
        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
        • ERROR_NULL_ARGUMENT - if the stepText is null or empty
      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(int wHint,
                                                          int hHint,
                                                          boolean changed)
        Overrides:
        computeSize in class org.eclipse.swt.widgets.Control
        See Also:
        Control.computeSize(int, int, boolean)
      • computeTextSizes

        private java.util.List<org.eclipse.swt.graphics.Point> computeTextSizes()
      • getCurrentStep

        public int getCurrentStep()
        Returns the receiver's current step.
        Returns:
        the current step (starting index is 0)
        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
      • getSteps

        public java.util.List<java.lang.String> getSteps()
        Returns the receiver's list of steps
        Returns:
        the color
        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
      • getTextColor

        public org.eclipse.swt.graphics.Color getTextColor()
        Returns the receiver's color of the text
        Returns:
        the color
        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
      • getUnselectedColor

        public org.eclipse.swt.graphics.Color getUnselectedColor()
        Returns the receiver's color used when the step is not reached
        Returns:
        the color
        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
      • removeStep

        public void removeStep​(java.lang.String stepText)
        Remove a step from the list of the existing ones
        Parameters:
        stepText - the text associated to the removed step
        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
        • ERROR_NULL_ARGUMENT - if the stepText is null or empty
      • setCurrentStep

        public void setCurrentStep​(int currentStep)
        Remove a step from the list of the existing ones
        Parameters:
        stepText - the text associated to the removed step
        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
        • ERROR_NULL_ARGUMENT - if the stepText is null or empty
      • setUnselectedColor

        public void setUnselectedColor​(org.eclipse.swt.graphics.Color unselectedColor)
        Set the color used to draw bars and circles for steps that have not been reached
        Parameters:
        unselectedColor - the new color
        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
      • setErrorState

        public void setErrorState​(boolean errorState)
        Set the error state (on/off) of the selected step
        Parameters:
        errorState - the new error 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
      • setSteps

        public void setSteps​(java.lang.String[] steps)
        Set the steps
        Parameters:
        steps - an array of steps
        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
        • ERROR_NULL_ARGUMENT - if the array of steps is null
      • setSteps

        public void setSteps​(java.util.List<java.lang.String> steps)
        Set the steps
        Parameters:
        steps - a list of steps
        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
        • ERROR_NULL_ARGUMENT - if the list of steps is null
      • setTextColor

        public void setTextColor​(org.eclipse.swt.graphics.Color textColor)
        Set the color of the text
        Parameters:
        textColor - the new color
        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