Package gda.rcp.views

Class AbstractPositionerComposite

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
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
Direct Known Subclasses:
EnumPositionerComposite, NudgePositionerComposite, ScannableFieldsComposite

public abstract class AbstractPositionerComposite extends org.eclipse.swt.widgets.Composite
This GUI elements of this class are a label for a Scannable and a 'stop' button. Between these, concrete subclasses will createPositionerControl() suitable for a particular scannable.

This base class registers a listener which calls updatePositionerControl(Object, boolean) while the scannable is moving.

Should subclasses wish to manually trigger the update job, they can call scheduleUpdateReadbackJob().

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected final org.eclipse.swt.custom.CLabel
     
    protected String
     
    protected boolean
     

    Fields inherited from class org.eclipse.swt.widgets.Composite

    embeddedHandle

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

    handle
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractPositionerComposite(org.eclipse.swt.widgets.Composite parent, int style)
     
    protected
    AbstractPositionerComposite(org.eclipse.swt.widgets.Composite parent, int style, boolean unitDisplayOutsideTextBox)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
     
    protected abstract void
    Creates the control(s) (drawn between the label and the stop button) to display and/or control the scannable's position.
    void
     
    protected Object
     
    protected String
     
    protected Scannable
     
    protected String
     
    void
    Hides the stop button.
    boolean
     
    boolean
    Check if the stop button is visible
    protected void
    move(Object position)
    Moves the scannable to a new position.
    Checks whether the scannable is busy before moving
    protected boolean
    moveAllowed(Object newPosition)
    Subclasses can override to check whether the requested position lies within limits, for instance.
    protected void
    Manually schedule the update readback job.
    void
    setCheckHoldingBaton(boolean checkHoldingBaton)
     
    void
    setDisplayName(String displayName)
    Sets a different name to be used in the GUI instead of the default which is the scannable name
    void
     
    void
    setEnabled(boolean enabled)
     
    protected void
    Specify why the the last call to moveAllowed(Object) returned false.
    void
    This sets the scannable which will be controlled and will automatically configure the control.
    void
    Shows the stop button.
    protected abstract void
    updatePositionerControl(Object newPosition, boolean moving)
    Updates the control(s) created at createPositionerControl() to reflect the given scannable position and whether it is currently moving.

    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
  • Field Details

    • displayNameLabel

      protected final org.eclipse.swt.custom.CLabel displayNameLabel
    • reasonForDisallowingMove

      protected String reasonForDisallowingMove
    • unitDisplayOutsideTextBox

      protected boolean unitDisplayOutsideTextBox
    • checkHoldingBaton

      protected boolean checkHoldingBaton
  • Constructor Details

    • AbstractPositionerComposite

      protected AbstractPositionerComposite(org.eclipse.swt.widgets.Composite parent, int style)
      Parameters:
      parent - the parent composite on which to draw this one
      style - SWT.HORIZONTAL or SWT.VERTICAL will define a horizontal or vertical (default) layout
    • AbstractPositionerComposite

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

    • dispose

      public void dispose()
      Overrides:
      dispose in class org.eclipse.swt.widgets.Widget
    • createPositionerControl

      protected abstract void createPositionerControl()
      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.

    • updatePositionerControl

      protected abstract void updatePositionerControl(Object newPosition, boolean moving)
      Updates the control(s) created at createPositionerControl() to reflect the given scannable position and whether it is currently moving.

      This method is called as soon as the scannable is set, so implementors may use it to initialise their controls.

    • moveAllowed

      protected boolean moveAllowed(Object newPosition)
      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 setReasonForDisallowingMove(String) so that it can be presented to the user.

    • setReasonForDisallowingMove

      protected void setReasonForDisallowingMove(String reason)
      Specify why the the last call to moveAllowed(Object) returned false. This will be shown to the user in an error dialog, and then cleared.
    • checkBatonHeld

      protected boolean checkBatonHeld()
    • move

      protected void move(Object position)
      Moves the scannable to a new position.
      Checks whether the scannable is busy before moving
      Parameters:
      position - The demanded position
    • setEnabled

      public void setEnabled(boolean enabled)
      Overrides:
      setEnabled in class org.eclipse.swt.widgets.Control
    • getCurrentPosition

      protected Object getCurrentPosition()
    • setScannable

      public void setScannable(Scannable scannable)
      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.

      Parameters:
      scannable - The scannable to control
    • getScannable

      protected Scannable getScannable()
    • setDisplayNameWidth

      public void setDisplayNameWidth(int width)
    • setDisplayName

      public void setDisplayName(String displayName)
      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:
      displayName - The name to be used in the GUI
    • getDisplayName

      protected String getDisplayName()
    • getScannableOutputFormat

      protected String getScannableOutputFormat()
    • scheduleUpdateReadbackJob

      protected void scheduleUpdateReadbackJob()
      Manually schedule the update readback job.
    • hideStopButton

      public void hideStopButton()
      Hides the stop button.

      This is useful for scannables which can't be stopped (move instantly) i.e. setting a voltage.

      See Also:
    • showStopButton

      public void showStopButton()
      Shows the stop button.
      See Also:
    • isStopButtonVisible

      public boolean isStopButtonVisible()
      Check if the stop button is visible
      Returns:
      true if stop button is visible
      See Also:
    • isCheckHoldingBaton

      public boolean isCheckHoldingBaton()
    • setCheckHoldingBaton

      public void setCheckHoldingBaton(boolean checkHoldingBaton)