Class SwtLightControl

java.lang.Object
com._1c.g5.lwt.interop.SwtLightControl
All Implemented Interfaces:
ILightControl
Direct Known Subclasses:
SwtLightComposite

public class SwtLightControl extends Object implements ILightControl
Wraps the native SWT controls to abstract the difference between the native and light controls.
  • Constructor Details

    • SwtLightControl

      public SwtLightControl(org.eclipse.swt.widgets.Control swtControl)
      Instantiates a new SWT light control.
      Parameters:
      swtControl - the native SWT control to create a wrapper for.
  • Method Details

    • getSwtLightControl

      public static SwtLightControl getSwtLightControl(org.eclipse.swt.widgets.Widget widget)
      Obtains the SwtLightControl for a given widget.
      Parameters:
      widget - the widget to obtain the light wrapper of.
      Returns:
      obtained SwtLightControl if the given widget has an associated SWT light wrapper, null otherwise.
    • getHostSwtLightControl

      public static SwtLightControl getHostSwtLightControl(org.eclipse.swt.widgets.Widget widget)
      Obtains the hosting SwtLightComposite for the given SWT widget.
      Parameters:
      widget - SWT widget to obtain the hosting composite of.
      Returns:
      SwtLightComposite if widget is hosted inside one, null otherwise.
    • containsWidget

      public static boolean containsWidget(ILightControl control, org.eclipse.swt.widgets.Widget widget)
      Checks whether a light control contains an SWT widget.
      Parameters:
      control - the light control tested for containing a given SWT widget
      widget - the SWT widget tested for being contained in a given light control
      Returns:
      true if control contains the given widget
    • getHostDisplay

      public static org.eclipse.swt.widgets.Display getHostDisplay(ILightControl control)
      Obtains the hosting Display for the given control.
      Parameters:
      control - the control to obtain the display for, should not be null.
      Returns:
      the hosting display, never null.
    • getSwtControl

      public org.eclipse.swt.widgets.Control getSwtControl()
      Gets the associated native SWT control.
      Returns:
      the SWT control.
    • getOverlaySource

      public ILightControl getOverlaySource()
      Gets the overlay source if this control is an overlay. Overlay is a special kind of the SwtLightControls, overlays do not participate in layouting process. Overlays used to provide the native SWT controls for the needs of the light controls. For example, the editing support of the LightText is implemented via the overlays.
      Returns:
      the source control of this overlay, null if this control is not an overlay.
    • setOverlaySource

      public void setOverlaySource(ILightControl control)
      Sets the overlay source.
      Parameters:
      control - the new overlay source.
      See Also:
    • getParent

      public ILightComposite getParent()
      Description copied from interface: ILightControl
      Gets the parent of this control.
      Specified by:
      getParent in interface ILightControl
      Returns:
      the parent composite control or null if this control is not contained in any composite.
    • setParent

      public void setParent(ILightComposite parent)
      Description copied from interface: ILightControl
      Sets the parent of this control.
      Specified by:
      setParent in interface ILightControl
      Parameters:
      parent - the new parent.
    • getBounds

      public org.eclipse.swt.graphics.Rectangle getBounds()
      Description copied from interface: ILightControl
      Gets the bounds of this control.
      Specified by:
      getBounds in interface ILightControl
      Returns:
      the bounds.
    • setBounds

      public void setBounds(org.eclipse.swt.graphics.Rectangle bounds)
      Description copied from interface: ILightControl
      Sets the bounds of this control.
      Specified by:
      setBounds in interface ILightControl
      Parameters:
      bounds - the new bounds.
    • getVisibleBounds

      public org.eclipse.swt.graphics.Rectangle getVisibleBounds()
      Specified by:
      getVisibleBounds in interface ILightControl
    • invalidate

      public void invalidate()
      Description copied from interface: ILightControl
      Invalidates the bounds of this control.
      Specified by:
      invalidate in interface ILightControl
    • invalidate

      public void invalidate(org.eclipse.swt.graphics.Rectangle rectangle)
      Description copied from interface: ILightControl
      Invalidates the given rectangle of this control.
      Specified by:
      invalidate in interface ILightControl
      Parameters:
      rectangle - the rectangle to invalidate.
    • setFocus

      public boolean setFocus(FocusSource focusSource)
      Description copied from interface: ILightControl
      Sets the focus to this control.
      Specified by:
      setFocus in interface ILightControl
      Parameters:
      focusSource - the focus request source.
      Returns:
      true if focus was set, false otherwise.
    • isFocused

      public boolean isFocused()
      Description copied from interface: ILightControl
      Checks if this control is focused.
      Specified by:
      isFocused in interface ILightControl
      Returns:
      true if this control is focused, false otherwise.
    • handleEvent

      public void handleEvent(org.eclipse.swt.widgets.Event event)
      Description copied from interface: ILightControl
      Handles the SWT event, SWT events are pumped to this method if this control is active.
      Specified by:
      handleEvent in interface ILightControl
      Parameters:
      event - the event to handle.
      See Also:
    • isDisposed

      public boolean isDisposed()
      Description copied from interface: ILightControl
      Checks if control this is disposed.
      Specified by:
      isDisposed in interface ILightControl
      Returns:
      true if this control is disposed, false otherwise.
    • dispose

      public void dispose()
      Description copied from interface: ILightControl
      Disposes this control.
      Specified by:
      dispose in interface ILightControl
    • paint

      public void paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle)
      Description copied from interface: ILightControl
      Paints the given rectangle of this control.
      Specified by:
      paint in interface ILightControl
      Parameters:
      gc - the GC to paint on.
      rectangle - the rectangle to paint.
    • isVisible

      public boolean isVisible()
      Description copied from interface: ILightControl
      Checks if this control is visible.
      Specified by:
      isVisible in interface ILightControl
      Returns:
      true if this control is visible, false if not.
    • setVisible

      public void setVisible(boolean value)
      Description copied from interface: ILightControl
      Sets this control visibility.
      Specified by:
      setVisible in interface ILightControl
      Parameters:
      value - the new visibility value.
    • isEnabled

      public boolean isEnabled()
      Description copied from interface: ILightControl
      Checks if this is enabled.
      Specified by:
      isEnabled in interface ILightControl
      Returns:
      true if this control is enabled, false if not.
    • setEnabled

      public void setEnabled(boolean enabled)
      Description copied from interface: ILightControl
      Sets this control enablement.
      Specified by:
      setEnabled in interface ILightControl
    • computeSize

      public org.eclipse.swt.graphics.Point computeSize(org.eclipse.swt.graphics.GC gc, int width, int height, boolean flushCache)
      Description copied from interface: ILightControl
      Computes the size of this control.
      Specified by:
      computeSize in interface ILightControl
      Parameters:
      gc - the GC to do measurements with.
      width - the width hint, SWT.DEFAULT to compute the preferred width.
      height - the height hint, SWT.DEFAULT to compute the preferred height.
      flushCache - the flush cache flag, instructs the associated layout to reset all its caches, if any.
      Returns:
      the computed size.
    • getLayoutData

      public ILightLayoutData getLayoutData()
      Description copied from interface: ILightControl
      Gets the layout data of this control.
      Specified by:
      getLayoutData in interface ILightControl
      Returns:
      the layout data.
    • setLayoutData

      public void setLayoutData(ILightLayoutData layoutData)
      Description copied from interface: ILightControl
      Sets the layout data of this control.
      Specified by:
      setLayoutData in interface ILightControl
      Parameters:
      layoutData - the new layout data.
    • getData

      public Object getData(String key)
      Description copied from interface: ILightControl
      Gets the user defined data associated with this control.
      Specified by:
      getData in interface ILightControl
      Parameters:
      key - the key.
      Returns:
      the data or null if no data was set for the given key.
    • setData

      public void setData(String key, Object data)
      Description copied from interface: ILightControl
      Sets the user-defined data associated with this control.
      Specified by:
      setData in interface ILightControl
      Parameters:
      key - the key.
      data - the data.
    • getCursor

      public org.eclipse.swt.graphics.Cursor getCursor()
      Description copied from interface: ILightControl
      Gets the cursor of this control.
      Specified by:
      getCursor in interface ILightControl
      Returns:
      the cursor or null if no cursor was set.
    • setCursor

      public void setCursor(org.eclipse.swt.graphics.Cursor cursor)
      Description copied from interface: ILightControl
      Sets the cursor of this control.
      Specified by:
      setCursor in interface ILightControl
      Parameters:
      cursor - the new cursor or null to reset to default cursor.
    • getTooltip

      public String getTooltip()
      Description copied from interface: ILightControl
      Gets the tooltip of this control.
      Specified by:
      getTooltip in interface ILightControl
      Returns:
      the tooltip or null if no tooltip was set.
    • setTooltip

      public void setTooltip(String tooltip)
      Description copied from interface: ILightControl
      Sets the tooltip of this control.
      Specified by:
      setTooltip in interface ILightControl
      Parameters:
      tooltip - the new tooltip or null to clear the tooltip.
    • addControlListener

      public void addControlListener(ILightControlListener listener)
      Description copied from interface: ILightControl
      Adds the control listener.
      Specified by:
      addControlListener in interface ILightControl
      Parameters:
      listener - the listener.
    • removeControlListener

      public void removeControlListener(ILightControlListener listener)
      Description copied from interface: ILightControl
      Removes the control listener.
      Specified by:
      removeControlListener in interface ILightControl
      Parameters:
      listener - the listener.
    • disposed

      protected void disposed()
      Invoked when the control is disposed from the SWT side. In other words, the native SWT control is disposed at this point and we do not need to dispose it again. Override this method to customize the detaching logic, it is a good place to remove listeners from the native SWT control and stuff like that.