Package com._1c.g5.lwt.interop
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 Summary
Constructors Constructor Description SwtLightControl(org.eclipse.swt.widgets.Control swtControl)
Instantiates a new SWT light control.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addControlListener(ILightControlListener listener)
Adds the control listener.org.eclipse.swt.graphics.Point
computeSize(org.eclipse.swt.graphics.GC gc, int width, int height, boolean flushCache)
Computes the size of this control.static boolean
containsWidget(ILightControl control, org.eclipse.swt.widgets.Widget widget)
Checks whether a light control contains an SWT widget.void
dispose()
Disposes this control.protected void
disposed()
Invoked when the control is disposed from the SWT side.org.eclipse.swt.graphics.Rectangle
getBounds()
Gets the bounds of this control.org.eclipse.swt.graphics.Cursor
getCursor()
Gets the cursor of this control.Object
getData(String key)
Gets the user defined data associated with this control.static org.eclipse.swt.widgets.Display
getHostDisplay(ILightControl control)
Obtains the hostingDisplay
for the given control.static SwtLightControl
getHostSwtLightControl(org.eclipse.swt.widgets.Widget widget)
Obtains the hostingSwtLightComposite
for the given SWT widget.ILightLayoutData
getLayoutData()
Gets the layout data of this control.ILightControl
getOverlaySource()
Gets the overlay source if this control is an overlay.ILightComposite
getParent()
Gets the parent of this control.org.eclipse.swt.widgets.Control
getSwtControl()
Gets the associated native SWT control.static SwtLightControl
getSwtLightControl(org.eclipse.swt.widgets.Widget widget)
Obtains theSwtLightControl
for a given widget.String
getTooltip()
Gets the tooltip of this control.org.eclipse.swt.graphics.Rectangle
getVisibleBounds()
void
handleEvent(org.eclipse.swt.widgets.Event event)
Handles the SWT event, SWT events are pumped to this method if this control is active.void
invalidate()
Invalidates the bounds of this control.void
invalidate(org.eclipse.swt.graphics.Rectangle rectangle)
Invalidates the given rectangle of this control.boolean
isDisposed()
Checks if control this is disposed.boolean
isEnabled()
Checks if this is enabled.boolean
isFocused()
Checks if this control is focused.boolean
isVisible()
Checks if this control is visible.void
paint(org.eclipse.swt.graphics.GC gc, org.eclipse.swt.graphics.Rectangle rectangle)
Paints the given rectangle of this control.void
removeControlListener(ILightControlListener listener)
Removes the control listener.void
setBounds(org.eclipse.swt.graphics.Rectangle bounds)
Sets the bounds of this control.void
setCursor(org.eclipse.swt.graphics.Cursor cursor)
Sets the cursor of this control.void
setData(String key, Object data)
Sets the user-defined data associated with this control.void
setEnabled(boolean enabled)
Sets this control enablement.boolean
setFocus(FocusSource focusSource)
Sets the focus to this control.void
setLayoutData(ILightLayoutData layoutData)
Sets the layout data of this control.void
setOverlaySource(ILightControl control)
Sets the overlay source.void
setParent(ILightComposite parent)
Sets the parent of this control.void
setTooltip(String tooltip)
Sets the tooltip of this control.void
setVisible(boolean value)
Sets this control visibility.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com._1c.g5.lwt.ILightControl
initialize
-
-
-
-
Method Detail
-
getSwtLightControl
public static SwtLightControl getSwtLightControl(org.eclipse.swt.widgets.Widget widget)
Obtains theSwtLightControl
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 hostingSwtLightComposite
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 widgetwidget
- the SWT widget tested for being contained in a given light control- Returns:
true
ifcontrol
contains the givenwidget
-
getHostDisplay
public static org.eclipse.swt.widgets.Display getHostDisplay(ILightControl control)
Obtains the hostingDisplay
for the given control.- Parameters:
control
- the control to obtain the display for, should not benull
.- 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 theSwtLightControl
s, 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 theLightText
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:
getOverlaySource()
-
getParent
public ILightComposite getParent()
Description copied from interface:ILightControl
Gets the parent of this control.- Specified by:
getParent
in interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- Parameters:
bounds
- the new bounds.
-
getVisibleBounds
public org.eclipse.swt.graphics.Rectangle getVisibleBounds()
- Specified by:
getVisibleBounds
in interfaceILightControl
-
invalidate
public void invalidate()
Description copied from interface:ILightControl
Invalidates the bounds of this control.- Specified by:
invalidate
in interfaceILightControl
-
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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- Parameters:
event
- the event to handle.- See Also:
ILightComposite.setActiveControl(ILightControl)
-
isDisposed
public boolean isDisposed()
Description copied from interface:ILightControl
Checks if control this is disposed.- Specified by:
isDisposed
in interfaceILightControl
- 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 interfaceILightControl
-
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 interfaceILightControl
- Parameters:
gc
- theGC
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 interfaceILightControl
- 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 interfaceILightControl
- Parameters:
value
- the new visibility value.
-
isEnabled
public boolean isEnabled()
Description copied from interface:ILightControl
Checks if this is enabled.- Specified by:
isEnabled
in interfaceILightControl
- 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 interfaceILightControl
-
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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- 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 interfaceILightControl
- Parameters:
cursor
- the new cursor ornull
to reset to default cursor.
-
getTooltip
public String getTooltip()
Description copied from interface:ILightControl
Gets the tooltip of this control.- Specified by:
getTooltip
in interfaceILightControl
- 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 interfaceILightControl
- Parameters:
tooltip
- the new tooltip ornull
to clear the tooltip.
-
addControlListener
public void addControlListener(ILightControlListener listener)
Description copied from interface:ILightControl
Adds the control listener.- Specified by:
addControlListener
in interfaceILightControl
- Parameters:
listener
- the listener.
-
removeControlListener
public void removeControlListener(ILightControlListener listener)
Description copied from interface:ILightControl
Removes the control listener.- Specified by:
removeControlListener
in interfaceILightControl
- 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.
-
-