Eclipse Platform
Release 3.1

org.eclipse.ui.forms.widgets
Class AbstractHyperlink

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended byorg.eclipse.swt.widgets.Canvas
                      extended byorg.eclipse.ui.forms.widgets.AbstractHyperlink
All Implemented Interfaces:
Drawable
Direct Known Subclasses:
Hyperlink, ToggleHyperlink

public abstract class AbstractHyperlink
extends Canvas

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.

Since:
3.0

Field Summary
protected  int marginHeight
          Amount of the margin height around the hyperlink (default is 1).
protected  int marginWidth
          Amount of the margin width around the hyperlink (default is 1).
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
AbstractHyperlink(Composite parent, int style)
          Creates a new hyperlink in the provided parent.
 
Method Summary
 void addHyperlinkListener(IHyperlinkListener listener)
          Adds the event listener to this hyperlink.
 Object getHref()
          Returns the object associated with this hyperlink.
 boolean getSelection()
          Returns the selection state of the control.
 String getText()
          Returns the textual representation of this hyperlink suitable for showing in tool tips or on the status line.
protected  void handleActivate(Event e)
          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 setHref(Object href)
          Sets the object associated with this hyperlink.
 
Methods inherited from class org.eclipse.swt.widgets.Canvas
getCaret, scroll, setCaret, setFont
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setFocus, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

marginWidth

protected int marginWidth
Amount of the margin width around the hyperlink (default is 1).


marginHeight

protected int marginHeight
Amount of the margin height around the hyperlink (default is 1).

Constructor Detail

AbstractHyperlink

public AbstractHyperlink(Composite parent,
                         int style)
Creates a new hyperlink in the provided parent.

Parameters:
parent - the control parent
style - the widget style
Method Detail

addHyperlinkListener

public void addHyperlinkListener(IHyperlinkListener listener)
Adds the event listener to this hyperlink.

Parameters:
listener - the event listener to add

removeHyperlinkListener

public void removeHyperlinkListener(IHyperlinkListener listener)
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

protected void handleEnter(Event e)
Called when hyperlink is entered. Subclasses that override this method must call 'super'.


handleExit

protected void handleExit(Event e)
Called when hyperlink is exited. Subclasses that override this method must call 'super'.


handleActivate

protected void handleActivate(Event e)
Called when hyperlink has been activated. Subclasses that override this method must call 'super'.


setHref

public void setHref(Object href)
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

public Object getHref()
Returns the object associated with this hyperlink.

Returns:
the hyperlink object reference
See Also:
setHref(java.lang.Object)

getText

public String getText()
Returns the textual representation of this hyperlink suitable for showing in tool tips or on the status line.

Returns:
the hyperlink text

paintHyperlink

protected abstract void paintHyperlink(GC gc)
Paints the hyperlink as a reaction to the provided paint event.

Parameters:
gc - graphic context

paint

protected void paint(PaintEvent e)
Paints the control as a reaction to the provided paint event.

Parameters:
e - the paint event

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.