net.sf.ecl.datepicker
Class AbstractCombo

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by net.sf.ecl.datepicker.AbstractCombo
All Implemented Interfaces:
Drawable
Direct Known Subclasses:
DatePicker

public abstract class AbstractCombo
extends Composite

is an abstract implementation of a custom SWT combo. The class groups together an editor and drop-down control and manages their common lifecycle. The control was maid as native as possible. Unfortunately, it is not possible to make it look like native OS X drop-down combos yet.

Styles:
NONE
Events:
SelectionListener

Author:
Alexey Afanasyev, Alexey Kharlamov

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
protected AbstractCombo(Composite parent, int style)
          creates an instance of the combo with the given parent widget and style.
 
Method Summary
 void addSelectionListener(SelectionListener listener)
          adds a selection listener to the control.
 Point computeSize(int wHint, int hHint, boolean changed)
           
protected abstract  Control createInput(Composite parent, int style)
          creates an input widget.
protected abstract  Control createPopup(Composite parent, int style)
          creates a control placed into combo's drop-down.
 void dispose()
           
protected abstract  void handlePopupHiding()
          notification of popup hiding.
protected abstract  void handlePopupShowing()
          notification of popup appearance.
protected  void hidePopup()
          hides the combo's popup.
 void layout(boolean changed)
           
 void removeSelectionListener(SelectionListener listener)
          removes selection listener to the control.
 void setBackground(Color color)
           
 void setEnabled(boolean enabled)
           
 void setFont(Font font)
           
 void setForeground(Color color)
           
 void setToolTipText(String toolTip)
           
protected  void showPopup()
          shows the combo's drop-down popup.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, setBackgroundMode, 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, getBackgroundImage, 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, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, 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
 

Constructor Detail

AbstractCombo

protected AbstractCombo(Composite parent,
                        int style)
creates an instance of the combo with the given parent widget and style.

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

addSelectionListener

public final void addSelectionListener(SelectionListener listener)
adds a selection listener to the control.

Parameters:
listener - the listener.

computeSize

public final Point computeSize(int wHint,
                               int hHint,
                               boolean changed)
Overrides:
computeSize in class Composite

dispose

public final void dispose()
Overrides:
dispose in class Widget

layout

public final void layout(boolean changed)
Overrides:
layout in class Composite

removeSelectionListener

public final void removeSelectionListener(SelectionListener listener)
removes selection listener to the control.

Parameters:
listener - the listener.

setBackground

public final void setBackground(Color color)
Overrides:
setBackground in class Control

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class Control

setFont

public final void setFont(Font font)
Overrides:
setFont in class Control

setForeground

public final void setForeground(Color color)
Overrides:
setForeground in class Control

setToolTipText

public final void setToolTipText(String toolTip)
Overrides:
setToolTipText in class Control

createInput

protected abstract Control createInput(Composite parent,
                                       int style)
creates an input widget. The widget is used by the composite to edit textual representation of the date.

Parameters:
parent - the input widget's parent.
style - the style for input widget. The style is derived from the composite's style.
Returns:
the input widget.

createPopup

protected abstract Control createPopup(Composite parent,
                                       int style)
creates a control placed into combo's drop-down. The method is called each time the drop-down is shown.

Parameters:
parent - the parent control.
style - the style derived from the style of the combo.
Returns:
the control.

handlePopupHiding

protected abstract void handlePopupHiding()
notification of popup hiding. It is called _before_ the actual hiding.


handlePopupShowing

protected abstract void handlePopupShowing()
notification of popup appearance. The method is called after popup construction but before it becomes visible.


hidePopup

protected final void hidePopup()
hides the combo's popup.


showPopup

protected final void showPopup()
shows the combo's drop-down popup.