Package org.eclipse.ui.forms.widgets
Class AbstractHyperlink
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.ui.forms.widgets.AbstractHyperlink
- All Implemented Interfaces:
Drawable
- Direct Known Subclasses:
Hyperlink
,ToggleHyperlink
This is the base class for custom hyperlink widget. It is responsible for
processing mouse and keyboard events, and converting them into unified
hyperlink events. Subclasses are responsible for rendering the hyperlink in
the client area.
- Styles:
- None
- Since:
- 3.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
Amount of the margin height around the hyperlink (default is 1).protected int
Amount of the margin width around the hyperlink (default is 1). -
Constructor Summary
ConstructorsConstructorDescriptionAbstractHyperlink
(Composite parent, int style) Creates a new hyperlink in the provided parent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHyperlinkListener
(IHyperlinkListener listener) Adds the event listener to this hyperlink.getHref()
Returns the object associated with this hyperlink.boolean
Returns the selection state of the control.getText()
Returns the textual representation of this hyperlink suitable for showing in tool tips or on the status line.protected void
Called when hyperlink has been activated.protected void
handleEnter
(Event e) Called when hyperlink is entered.protected void
handleExit
(Event e) Called when hyperlink is exited.protected void
paint
(PaintEvent e) Paints the control as a reaction to the provided paint event.protected abstract void
paintHyperlink
(GC gc) Paints the hyperlink as a reaction to the provided paint event.void
removeHyperlinkListener
(IHyperlinkListener listener) Removes the event listener from this hyperlink.void
setEnabled
(boolean enabled) Enables the receiver if the argument istrue
, and disables it otherwise.void
Sets the object associated with this hyperlink.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, 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, 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, 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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.swt.graphics.Drawable
isAutoScalable
-
Field Details
-
marginWidth
protected int marginWidthAmount of the margin width around the hyperlink (default is 1). -
marginHeight
protected int marginHeightAmount of the margin height around the hyperlink (default is 1).
-
-
Constructor Details
-
AbstractHyperlink
Creates a new hyperlink in the provided parent.- Parameters:
parent
- the control parentstyle
- the widget style
-
-
Method Details
-
addHyperlinkListener
Adds the event listener to this hyperlink.- Parameters:
listener
- the event listener to add
-
removeHyperlinkListener
Removes the event listener from this hyperlink.- Parameters:
listener
- the event listener to remove
-
getSelection
public boolean getSelection()Returns the selection state of the control. When focus is gained, the state will be true ; it will switch to false when the control looses focus.- Returns:
true
if the widget has focus,false
otherwise.
-
handleEnter
Called when hyperlink is entered. Subclasses that override this method must call 'super'. -
handleExit
Called when hyperlink is exited. Subclasses that override this method must call 'super'. -
handleActivate
Called when hyperlink has been activated. Subclasses that override this method must call 'super'. -
setHref
Sets the object associated with this hyperlink. Concrete implementation of this class can use if to store text, URLs or model objects that need to be processed on hyperlink events.- Parameters:
href
- the hyperlink object reference
-
getHref
Returns the object associated with this hyperlink.- Returns:
- the hyperlink object reference
- See Also:
-
getText
Returns the textual representation of this hyperlink suitable for showing in tool tips or on the status line.- Returns:
- the hyperlink text
-
paintHyperlink
Paints the hyperlink as a reaction to the provided paint event.- Parameters:
gc
- graphic context
-
paint
Paints the control as a reaction to the provided paint event.- Parameters:
e
- the paint event
-
setEnabled
public void setEnabled(boolean enabled) Description copied from class:Control
Enables the receiver if the argument istrue
, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.- Overrides:
setEnabled
in classControl
- Parameters:
enabled
- the new enabled state
-