com.ibm.commons.swt.data.viewers
Class DCComboBoxDeferredViewer

java.lang.Object
  extended by org.eclipse.jface.viewers.Viewer
      extended by com.ibm.commons.swt.viewers.AbstractDeferredViewer
          extended by com.ibm.commons.swt.data.viewers.DCComboBoxDeferredViewer
All Implemented Interfaces:
com.ibm.commons.swt.viewers.JobCompletedCallback, org.eclipse.jface.viewers.IInputProvider, org.eclipse.jface.viewers.IInputSelectionProvider, org.eclipse.jface.viewers.ISelectionProvider

public class DCComboBoxDeferredViewer
extends AbstractDeferredViewer

Class to fetch data for a DCCombo in the background. This class is not an eclipse viewer but uses content providers and label providers to maximize reuse. To use, create the viewer by passing an existing DCComboBox. Next set the content provider and the label provider. If a label provider is not available then, it is assume the values returned from the content provider are both the lables and the codes. Next set the Input. This will set the lookup values for the DCComboBox. Initially the combo box will display "Working..." when dropped down until the real data is ready.


Field Summary
 
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY
 
Constructor Summary
DCComboBoxDeferredViewer(DCComboBox combo, java.lang.String title)
          Creates a new instance of this class.
DCComboBoxDeferredViewer(DCCompositeCombo combo, java.lang.String title)
          Creates a new instance of this class.
 
Method Summary
 void dispose()
           
protected  void doUpdateControl(java.lang.Object results)
          Update the control with the results of the deferred data.
 org.eclipse.swt.widgets.Control getControl()
          Return the control associated with this viewer.
protected  void hookControl()
          Adds listeners to the control.
 boolean isRefreshing()
           
 void refresh()
          Refresh the contents of the combo box.
 void setInput(java.lang.Object input)
          Set the input for the viewer.
 void setRefreshOnFocus(boolean refreshOnFocus)
           
 
Methods inherited from class com.ibm.commons.swt.viewers.AbstractDeferredViewer
getContentProvider, getErrorDialogTitle, getInput, getLabelProvider, getSelection, getStackTraceAsMultiStatus, getStatus, getUpdateCallback, jobCompleted, setContentProvider, setInputOnly, setLabelProvider, setSelection, setStatus, setUpdateCallback, updateStatus
 
Methods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, inputChanged, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DCComboBoxDeferredViewer

public DCComboBoxDeferredViewer(DCComboBox combo,
                                java.lang.String title)
Creates a new instance of this class.

Parameters:
combo - an existing DCComboBox whose content is determined by a long running operation
title - a dialog title for any error messages

DCComboBoxDeferredViewer

public DCComboBoxDeferredViewer(DCCompositeCombo combo,
                                java.lang.String title)
Creates a new instance of this class.

Parameters:
combo - an existing DCCompositeCombo whose content is determined by a long running operation
title - a dialog title for any error messages
Method Detail

hookControl

protected void hookControl()
Adds listeners to the control. Subclasses may add additional listeners here, however all listeners must be removed when the widget is disposed.

Overrides:
hookControl in class AbstractDeferredViewer

setInput

public void setInput(java.lang.Object input)
Set the input for the viewer. This triggers the data retrieval operation. Once that operation completes the viewer's contents are updated.

Overrides:
setInput in class AbstractDeferredViewer

refresh

public void refresh()
Refresh the contents of the combo box. Be careful when calling this method. The operation to retrieve the contents of the viewer may be a long one.

Specified by:
refresh in class AbstractDeferredViewer

doUpdateControl

protected void doUpdateControl(java.lang.Object results)
Description copied from class: AbstractDeferredViewer
Update the control with the results of the deferred data. This method is called when the content provider completes and sends its data to the viewer.

Specified by:
doUpdateControl in class AbstractDeferredViewer

getControl

public org.eclipse.swt.widgets.Control getControl()
Return the control associated with this viewer.

Specified by:
getControl in class AbstractDeferredViewer

setRefreshOnFocus

public void setRefreshOnFocus(boolean refreshOnFocus)
Parameters:
refreshOnFocus - - if true refresh the combo box if needed only when the combobox gets focus. If false refresh the combo box when ever set input is called.

dispose

public void dispose()
Overrides:
dispose in class AbstractDeferredViewer

isRefreshing

public boolean isRefreshing()