Package gda.rcp.views

Class NudgePositionerComposite

java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
gda.rcp.views.AbstractPositionerComposite
gda.rcp.views.NudgePositionerComposite
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
SlimPositionerComposite

public class NudgePositionerComposite extends AbstractPositionerComposite
A class which provides a GUI composite to allow easy control of a scannable

It provides the current position which can be edited and moved (unless READ_ONLY is specified) and buttons to allow incremental moves.
A stop button to abort moves is provided by the base class AbstractPositionerComposite.
Tapping the up and down arrows while in the position box will nudge the position by the increment.

The format of the displayed number will be specified by the scannable output format.

Example of vertical invalid input: '&' horizontal format:

  • Field Summary

    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
    NudgePositionerComposite(org.eclipse.swt.widgets.Composite parent, int style)
    Constructor for a NudgePositionerComposite only requires the specification of minimal parameters.
    NudgePositionerComposite(org.eclipse.swt.widgets.Composite parent, int style, boolean unitDisplayOutsideTextBox)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Creates the control(s) (drawn between the label and the stop button) to display and/or control the scannable's position.
    protected void
     
    protected void
     
    protected org.eclipse.swt.widgets.Button
     
    protected org.eclipse.swt.widgets.Button
     
    protected org.eclipse.swt.widgets.Text
     
    protected org.eclipse.swt.widgets.Text
     
    void
    hides the increment control composite
    boolean
    check if the Increment Control composite is visible
    protected boolean
     
    protected boolean
    moveAllowed(Object newPosition)
    Subclasses can override to check whether the requested position lies within limits, for instance.
    protected void
    setDecrementButton(org.eclipse.swt.widgets.Button decrementButton)
     
    void
    Sets a different name to be used in the GUI instead of the default which is the scannable name
    void
    setEnabled(boolean enabled)
     
    void
     
    void
    setIncrement(double increment)
    Change the increment programmatically or from Spring bean definition
    protected void
    setIncrement(String incrementText)
    Change the increment from a view's text box
    protected void
    setIncrementButton(org.eclipse.swt.widgets.Button incrementButton)
     
    protected void
    setIncrementText(org.eclipse.swt.widgets.Text incrementText)
     
    void
    setIncrementTextWidth(int incrementTextWidth)
     
    void
    Sets the description label for the composite to a bold font
    void
    setLimits(double lowerLimit, double upperLimit)
    Sets the limits which will be used to check if a new position is valid.
    protected void
    setPositionText(org.eclipse.swt.widgets.Text positionText)
     
    void
    This sets the scannable which will be controlled and will automatically configure the control.
    void
    setUserUnits(String userUnits)
     
    void
    shows the increment control composite
    protected void
    updatePositionerControl(Object currentPosition, boolean moving)
    This is used to update the GUI.

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

    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, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setFont, 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, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • NudgePositionerComposite

      public NudgePositionerComposite(org.eclipse.swt.widgets.Composite parent, int style)
      Constructor for a NudgePositionerComposite only requires the specification of minimal parameters.
      Parameters:
      parent - The parent composite
      style - SWT style parameter. This is typically SWT.NONE, but you can specify:
      • SWT.VERTICAL or SWT.HORIZONTAL to lay the controls out vertically or horizontally respectively (default is vertical)
      • SWT.READ_ONLY to make the position text box read-only. Note that the increment/decrement text box will always be writable
    • NudgePositionerComposite

      public NudgePositionerComposite(org.eclipse.swt.widgets.Composite parent, int style, boolean unitDisplayOutsideTextBox)
  • Method Details

    • createPositionerControl

      protected void createPositionerControl()
      Description copied from class: AbstractPositionerComposite
      Creates the control(s) (drawn between the label and the stop button) to display and/or control the scannable's position.

      For consistent results, implementors are advised to create widgets directly on top of this Composite.

      Specified by:
      createPositionerControl in class AbstractPositionerComposite
    • setDisplayUnit

      public void setDisplayUnit(String userUnits)
      Sets a different name to be used in the GUI instead of the default which is the scannable name

      After calling this method the control will be automatically redrawn.

      Parameters:
      userUnits - The name to be used in the GUI
    • setScannable

      public void setScannable(Scannable scannable)
      Description copied from class: AbstractPositionerComposite
      This sets the scannable which will be controlled and will automatically configure the control.

      This can also be called to change the scannable controlled at any time which will reconfigure the control.

      Overrides:
      setScannable in class AbstractPositionerComposite
      Parameters:
      scannable - The scannable to control
    • moveAllowed

      protected boolean moveAllowed(Object newPosition)
      Description copied from class: AbstractPositionerComposite
      Subclasses can override to check whether the requested position lies within limits, for instance.

      If a move is disallowed, it is advised that a reason be set via AbstractPositionerComposite.setReasonForDisallowingMove(String) so that it can be presented to the user.

      Overrides:
      moveAllowed in class AbstractPositionerComposite
    • updatePositionerControl

      protected void updatePositionerControl(Object currentPosition, boolean moving)
      This is used to update the GUI. Only this method should be used to update the GUI to ensure display is consistent. The position is updated and the controls enabled/disabled as appropriate.
      Specified by:
      updatePositionerControl in class AbstractPositionerComposite
      Parameters:
      currentPosition - The newest position to display
      moving - Flag showing if the scannable is moving
    • setIncrement

      public void setIncrement(double increment)
      Change the increment programmatically or from Spring bean definition
      Parameters:
      increment - The new increment value
    • setIncrement

      protected void setIncrement(String incrementText)
      Change the increment from a view's text box
      Parameters:
      incrementText - The new increment value
    • setFixedIncrementInput

      public void setFixedIncrementInput()
    • setUserUnits

      public void setUserUnits(String userUnits)
    • setLabelToBold

      public void setLabelToBold()
      Sets the description label for the composite to a bold font
    • setLimits

      public void setLimits(double lowerLimit, double upperLimit)
      Sets the limits which will be used to check if a new position is valid.
      Parameters:
      lowerLimit - the desired lower limit
      upperLimit - the desired upper limit
      Throws:
      IllegalArgumentException - if the lowerLimit > upperLimit
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class AbstractPositionerComposite
    • setIncrementTextWidth

      public void setIncrementTextWidth(int incrementTextWidth)
    • hideIncrementControl

      public void hideIncrementControl()
      hides the increment control composite

      This is useful if users don't use increment control and want more screen estate to display other live control elements

      See Also:
    • showIncrementControl

      public void showIncrementControl()
      shows the increment control composite
      See Also:
    • isIncrementControlVisible

      public boolean isIncrementControlVisible()
      check if the Increment Control composite is visible
      Returns:
      true if the increment control composite is visible
      See Also:
    • getPositionText

      protected org.eclipse.swt.widgets.Text getPositionText()
    • setPositionText

      protected void setPositionText(org.eclipse.swt.widgets.Text positionText)
    • getIncrementText

      protected org.eclipse.swt.widgets.Text getIncrementText()
    • setIncrementText

      protected void setIncrementText(org.eclipse.swt.widgets.Text incrementText)
    • getDecrementButton

      protected org.eclipse.swt.widgets.Button getDecrementButton()
    • setDecrementButton

      protected void setDecrementButton(org.eclipse.swt.widgets.Button decrementButton)
    • getIncrementButton

      protected org.eclipse.swt.widgets.Button getIncrementButton()
    • setIncrementButton

      protected void setIncrementButton(org.eclipse.swt.widgets.Button incrementButton)
    • isReadOnlyPosition

      protected boolean isReadOnlyPosition()
    • doIncrementValue

      protected void doIncrementValue()
    • doDecrementValue

      protected void doDecrementValue()