RSE
Release 3.2

org.eclipse.rse.ui.widgets
Class SystemHistoryCombo

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 org.eclipse.rse.ui.widgets.SystemHistoryCombo
All Implemented Interfaces:
EventListener, ISystemCombo, KeyListener, TraverseListener, Drawable, org.eclipse.swt.internal.SWTEventListener

public class SystemHistoryCombo
extends Composite
implements ISystemCombo, TraverseListener, KeyListener

This re-usable widget is for a combox box that persists its history and allows the user to manipulate that history.

The composite is layed as follows:


   ______________v...
 

See Also:
updateHistory()

Field Summary
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
SystemHistoryCombo(Composite parent, int style, String key, boolean readonly)
          Constructor for SystemHistoryCombo
SystemHistoryCombo(Composite parent, int style, String key, int maxComboEntries, boolean readonly)
          Constructor for SystemHistoryCombo
 
Method Summary
 void addModifyListener(ModifyListener listener)
          Register a listener interested in entry field modify events
protected  void addOurButtonSelectionListener()
           
 void addSelectionListener(SelectionListener listener)
          Register a listener interested in an item is selected in the combo box
 void clearSelection()
          Clear the selection of the text in the entry field part of the combo.
 void clearTextSelection()
          Clear the selection of the text in the entry field part of the combo.
static Combo createCombo(Composite parent, boolean readonly)
          Creates a new combobox instance and sets the default layout data.
protected  Button createHistoryButton()
           
 Combo getCombo()
          Return the combo box widget
 String[] getHistory()
          Return the current history for the directory combo box
 Button getHistoryButton()
          Return the history button widget
 String[] getItems()
          Get the items in the combo field
 int getSelectionIndex()
          Get the index number of the currently selected item.
 String getText()
          Query the history combo field's current contents
protected  void historyButtonPressed()
           
 void keyPressed(KeyEvent e)
           
 void keyReleased(KeyEvent e)
           
 void keyTraversed(TraverseEvent e)
           
protected  Composite prepareComposite(int numColumns)
          Prepares this composite control and sets the default layout data.
 void removeModifyListener(ModifyListener listener)
          Remove a previously set entry field listener.
 void removeSelectionListener(SelectionListener listener)
          Remove a previously set combo box selection listener.
 void select(int selIdx)
          Select the combo dropdown list entry at the given index
 int select(String itemText)
          Select the given text.
 void setAutoUpperCase(boolean enable)
          Set auto-uppercase.
 void setButtonToolTipText(String tip)
          Same as #setHistoryButtonToolTipText(String)
 void setDefaultHistory(String[] items)
          Set the items to default the history to, IF the history is currently empty.
 void setEnabled(boolean enabled)
          Disable/Enable all the child controls.
 boolean setFocus()
          Set the focus to the combo field
 void setHistory(String[] newHistory)
          Set the history to the given array of strings.
 void setHistoryButtonHeight(int height)
           
 void setHistoryButtonToolTipText(String tip)
          Set the tooltip text for the history button
 void setHistoryKey(String key)
          Reset the history key.
 void setItems(String[] items)
          Set the items in the combo field
 void setSelectionIndex(int selIdx)
          Same as select(int)
 void setText(String text)
          Set the combo field's current contents
 void setTextLimit(int limit)
          Set the combo field's text limit
 void setToolTipText(String tip)
          Set the tooltip text for the combo field
 void setWidthHint(int widthHint)
          Set the width hint for the combo box widget (in pixels).
 void updateHistory()
          Update the history with current entry field setting, but don't refresh contents.
 void updateHistory(boolean refresh)
          Update the history with current entry field setting, and optionally refresh the list from the new history This is called automatically for you when setText is called.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, drawBackground, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, 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, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SystemHistoryCombo

public SystemHistoryCombo(Composite parent,
                          int style,
                          String key,
                          boolean readonly)
Constructor for SystemHistoryCombo

Parameters:
parent - The owning composite
style - The swt style to apply to the overall composite. Typically it is just SWT.NULL
key - The unique string used as a preferences key to persist the history for this widget
readonly - Set to true for a readonly combo vs user-editable combo box

SystemHistoryCombo

public SystemHistoryCombo(Composite parent,
                          int style,
                          String key,
                          int maxComboEntries,
                          boolean readonly)
Constructor for SystemHistoryCombo

Parameters:
parent - The owning composite
style - The swt style to apply to the overall composite. Typically it is just SWT.NULL
key - The unique string used as a preferences key to persist the history for this widget
maxComboEntries - The number of history entries to show in the combo box. This only restricts the combo box not the full history list
readonly - Set to true for a readonly combo vs user-editable combo box
Method Detail

getCombo

public Combo getCombo()
Return the combo box widget

Specified by:
getCombo in interface ISystemCombo

setWidthHint

public void setWidthHint(int widthHint)
Set the width hint for the combo box widget (in pixels). Default is only 100, so you may want to set it. A rule of thumb is 10 pixels per character, but allow 15 for the litte button on the right. You must call this versus setting it yourself, else you may see truncation.

Specified by:
setWidthHint in interface ISystemCombo

setAutoUpperCase

public void setAutoUpperCase(boolean enable)
Set auto-uppercase. When enabled, all non-quoted values are uppercases when added to the history.

Specified by:
setAutoUpperCase in interface ISystemCombo

getHistoryButton

public Button getHistoryButton()
Return the history button widget


setText

public void setText(String text)
Set the combo field's current contents


getText

public String getText()
Query the history combo field's current contents

Specified by:
getText in interface ISystemCombo

setEnabled

public void setEnabled(boolean enabled)
Disable/Enable all the child controls.

Specified by:
setEnabled in interface ISystemCombo
Overrides:
setEnabled in class Control

setToolTipText

public void setToolTipText(String tip)
Set the tooltip text for the combo field

Specified by:
setToolTipText in interface ISystemCombo
Overrides:
setToolTipText in class Control

setHistoryButtonToolTipText

public void setHistoryButtonToolTipText(String tip)
Set the tooltip text for the history button


setButtonToolTipText

public void setButtonToolTipText(String tip)
Same as #setHistoryButtonToolTipText(String)

Specified by:
setButtonToolTipText in interface ISystemCombo

setTextLimit

public void setTextLimit(int limit)
Set the combo field's text limit


setFocus

public boolean setFocus()
Set the focus to the combo field

Specified by:
setFocus in interface ISystemCombo
Overrides:
setFocus in class Composite

setItems

public void setItems(String[] items)
Set the items in the combo field


setDefaultHistory

public void setDefaultHistory(String[] items)
Set the items to default the history to, IF the history is currently empty.


setHistoryKey

public void setHistoryKey(String key)
Reset the history key. This changes the contents! You should re-call setDefaultHistory() as well after this, if you had called it before


getItems

public String[] getItems()
Get the items in the combo field


select

public void select(int selIdx)
Select the combo dropdown list entry at the given index

Specified by:
select in interface ISystemCombo

select

public int select(String itemText)
Select the given text. This finds the given string in the list, determines its zero-based offset, and calls select for that index. If the item is not found it does nothing. Returns the index number of the found string, or -1 if not found.


setSelectionIndex

public void setSelectionIndex(int selIdx)
Same as select(int)

Specified by:
setSelectionIndex in interface ISystemCombo

clearSelection

public void clearSelection()
Clear the selection of the text in the entry field part of the combo. Also deselects the list part.

Specified by:
clearSelection in interface ISystemCombo

clearTextSelection

public void clearTextSelection()
Clear the selection of the text in the entry field part of the combo. Does not deselect the list part.

Specified by:
clearTextSelection in interface ISystemCombo

getSelectionIndex

public int getSelectionIndex()
Get the index number of the currently selected item. Only really reliable in readonly mode.

Specified by:
getSelectionIndex in interface ISystemCombo

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Register a listener interested in an item is selected in the combo box

Specified by:
addSelectionListener in interface ISystemCombo
See Also:
removeSelectionListener(SelectionListener)

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Remove a previously set combo box selection listener.

Specified by:
removeSelectionListener in interface ISystemCombo
See Also:
addSelectionListener(SelectionListener)

addModifyListener

public void addModifyListener(ModifyListener listener)
Register a listener interested in entry field modify events

See Also:
removeModifyListener(ModifyListener)

removeModifyListener

public void removeModifyListener(ModifyListener listener)
Remove a previously set entry field listener.

See Also:
addModifyListener(ModifyListener)

getHistory

public String[] getHistory()
Return the current history for the directory combo box


updateHistory

public void updateHistory()
Update the history with current entry field setting, but don't refresh contents.

This is called automatically for you when setText is called. However, for non-readonly versions, you should still call this yourself when OK is successfully pressed on the dialog box.


updateHistory

public void updateHistory(boolean refresh)
Update the history with current entry field setting, and optionally refresh the list from the new history

This is called automatically for you when setText is called. However, for non-readonly versions, you should still call this yourself when OK is successfully pressed on the dialog box.


setHistory

public void setHistory(String[] newHistory)
Set the history to the given array of strings. Replaces what is there.


prepareComposite

protected Composite prepareComposite(int numColumns)
Prepares this composite control and sets the default layout data.

Parameters:
numColumns - Number of columns the new group will contain.

createCombo

public static Combo createCombo(Composite parent,
                                boolean readonly)
Creates a new combobox instance and sets the default layout data.

Does NOT set the widthHint as that causes problems. Instead the combo will consume what space is available within this composite.

Parameters:
parent - composite to put the button into.

addOurButtonSelectionListener

protected void addOurButtonSelectionListener()

historyButtonPressed

protected void historyButtonPressed()

createHistoryButton

protected Button createHistoryButton()

setHistoryButtonHeight

public void setHistoryButtonHeight(int height)

keyTraversed

public void keyTraversed(TraverseEvent e)
Specified by:
keyTraversed in interface TraverseListener

keyPressed

public void keyPressed(KeyEvent e)
Specified by:
keyPressed in interface KeyListener

keyReleased

public void keyReleased(KeyEvent e)
Specified by:
keyReleased in interface KeyListener

RSE
Release 3.2

Copyright (c) IBM Corporation and others 2000, 2010. All Rights Reserved.