Class AbstractListViewer
- All Implemented Interfaces:
IInputProvider,IInputSelectionProvider,IPostSelectionProvider,ISelectionProvider
- Direct Known Subclasses:
ComboViewer,ListViewer
- Since:
- 3.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jface.viewers.StructuredViewer
StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders -
Field Summary
Fields inherited from class org.eclipse.jface.viewers.Viewer
WIDGET_DATA_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given element to this list viewer.voidAdds the given elements to this list viewer.protected WidgetdoFindInputItem(Object element) Returns the widget in this viewer's control which represents the given element if it is the viewer's input.protected WidgetdoFindItem(Object element) Returns the widget in this viewer's control which represent the given element.protected voiddoUpdateItem(Widget data, Object element, boolean fullMap) Copies the attributes of the given element into the given SWT item.getElementAt(int index) Returns the element with the given index from this list viewer.The list viewer implementation of thisViewerframework method returns the label provider, which in the case of list viewers will be an instance ofILabelProvider.protected ListRetrieves the selection, as aList, from the underlying widget.protected intindexForElement(Object element) protected voidinputChanged(Object input, Object oldInput) Internal hook method called when the input to this viewer is initially set or subsequently changed.voidInserts the given element into this list viewer at the given position.protected voidinternalRefresh(Object element) Refreshes this viewer starting at the given element.protected abstract voidAdds the given string to the underlying widget at the given indexprotected abstract voidDeselects all selected items in the underlying widget.protected abstract intReturns the number of items contained in the underlying widget.protected abstract int[]Returns the zero-relative indices of the items which are currently selected in the underlying widget.protected intReturns the index of the item currently at the top of the viewable area.protected abstract voidlistRemove(int index) Removes the item from the underlying widget at the given zero-relative index.protected abstract voidRemoves all of the items from the underlying widget.protected abstract voidlistSetItem(int index, String string) Sets the text of the item at the given index in the underlying widget.protected abstract voidlistSetItems(String[] labels) Sets the underlying widget's items to be the given array of items.protected abstract voidlistSetSelection(int[] ixs) Selects the items at the given zero-relative indices in the underlying widget.protected voidlistSetTopIndex(int index) Sets the index of the item to be at the top of the viewable area.protected abstract voidShows the selection.voidRemoves the given element from this list viewer.voidRemoves the given elements from this list viewer.voidsetLabelProvider(IBaseLabelProvider labelProvider) The list viewer implementation of thisViewerframework method ensures that the given label provider is an instance ofILabelProvider.protected voidsetSelectionToWidget(List in, boolean reveal) Parlays the given list of selected elements into selections on this viewer's control.Methods inherited from class org.eclipse.jface.viewers.StructuredViewer
addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertContentProviderType, assertElementsNotNull, associate, buildLabel, disassociate, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getItem, getRawChildren, getRoot, getSelection, getSortedChildren, getSorter, getStructuredSelection, handleDispose, handleDoubleSelect, handleInvalidSelection, handleLabelProviderChanged, handleOpen, handlePostSelect, handleSelect, hasFilters, hookControl, internalRefresh, internalUpdate, mapElement, needsRefilter, preservingSelection, refresh, refresh, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, reveal, setComparator, setComparer, setContentProvider, setFilters, setInput, setSelection, setSelectionToWidget, setSorter, setUseHashlookup, testFindItem, testFindItems, unmapAllElements, unmapElement, unmapElement, update, update, updateItem, updateSelection, usingElementMapMethods inherited from class org.eclipse.jface.viewers.ContentViewer
getContentProvider, getInput, labelProviderChangedMethods inherited from class org.eclipse.jface.viewers.Viewer
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getControl, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, scrollDown, scrollUp, setData, setSelectionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.jface.viewers.ISelectionProvider
addSelectionChangedListener, removeSelectionChangedListener, setSelection
-
Constructor Details
-
AbstractListViewer
public AbstractListViewer()
-
-
Method Details
-
listAdd
Adds the given string to the underlying widget at the given index- Parameters:
string- the string to addindex- position to insert the string into
-
listSetItem
Sets the text of the item at the given index in the underlying widget.- Parameters:
index- index to modifystring- new text
-
listGetSelectionIndices
protected abstract int[] listGetSelectionIndices()Returns the zero-relative indices of the items which are currently selected in the underlying widget. The array is empty if no items are selected.Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
- Returns:
- the array of indices of the selected items
-
listGetItemCount
protected abstract int listGetItemCount()Returns the number of items contained in the underlying widget.- Returns:
- the number of items
-
listSetItems
Sets the underlying widget's items to be the given array of items.- Parameters:
labels- the array of label text
-
listRemoveAll
protected abstract void listRemoveAll()Removes all of the items from the underlying widget. -
listRemove
protected abstract void listRemove(int index) Removes the item from the underlying widget at the given zero-relative index.- Parameters:
index- the index for the item
-
listSetSelection
protected abstract void listSetSelection(int[] ixs) Selects the items at the given zero-relative indices in the underlying widget. The current selection is cleared before the new items are selected.Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
- Parameters:
ixs- the indices of the items to select
-
listShowSelection
protected abstract void listShowSelection()Shows the selection. If the selection is already showing in the receiver, this method simply returns. Otherwise, the items are scrolled until the selection is visible. -
listDeselectAll
protected abstract void listDeselectAll()Deselects all selected items in the underlying widget. -
add
Adds the given elements to this list viewer. If this viewer does not have a sorter, the elements are added at the end in the order given; otherwise the elements are inserted at appropriate positions.This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.
- Parameters:
elements- the elements to add
-
insert
Inserts the given element into this list viewer at the given position. If this viewer has a sorter, the position is ignored and the element is inserted at the correct position in the sort order.This method should be called (by the content provider) when elements have been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.
- Parameters:
element- the elementposition- a 0-based position relative to the model, or -1 to indicate the last position- Since:
- 3.3
-
add
Adds the given element to this list viewer. If this viewer does not have a sorter, the element is added at the end; otherwise the element is inserted at the appropriate position.This method should be called (by the content provider) when a single element has been added to the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous addition of multiple elements.
- Parameters:
element- the element
-
doFindInputItem
Description copied from class:StructuredViewerReturns the widget in this viewer's control which represents the given element if it is the viewer's input.This method is internal to the framework; subclassers should not call this method.
- Specified by:
doFindInputItemin classStructuredViewer- Parameters:
element- the element to find the representing widget for- Returns:
- the corresponding widget, or
nullif none
-
doFindItem
Description copied from class:StructuredViewerReturns the widget in this viewer's control which represent the given element. This method searches all the children of the input element.This method is internal to the framework; subclassers should not call this method.
- Specified by:
doFindItemin classStructuredViewer- Parameters:
element- the element to find the representing widget for- Returns:
- the corresponding widget, or
nullif none
-
doUpdateItem
Description copied from class:StructuredViewerCopies the attributes of the given element into the given SWT item. The element map is updated according to the value offullMap. IffullMapistruethen the current mapping from element to widgets is removed and the new mapping is added. If full map isfalsethen only the new map gets installed. Installing only the new map is necessary in cases where only the order of elements changes but not the set of elements.This method is internal to the framework; subclassers should not call this method.
- Specified by:
doUpdateItemin classStructuredViewer- Parameters:
data- widget item to updateelement- the element to representfullMap-trueif mappings are added and removed, andfalseif only the new map gets installed
-
getElementAt
Returns the element with the given index from this list viewer. Returnsnullif the index is out of range.- Parameters:
index- the zero-based index- Returns:
- the element at the given index, or
nullif the index is out of range
-
getLabelProvider
The list viewer implementation of thisViewerframework method returns the label provider, which in the case of list viewers will be an instance ofILabelProvider.- Overrides:
getLabelProviderin classContentViewer- Returns:
- a label provider
-
getSelectionFromWidget
Description copied from class:StructuredViewerRetrieves the selection, as aList, from the underlying widget.- Specified by:
getSelectionFromWidgetin classStructuredViewer- Returns:
- the list of selected elements
-
indexForElement
- Parameters:
element- the element to insert- Returns:
- the index where the item should be inserted.
-
inputChanged
Description copied from class:ViewerInternal hook method called when the input to this viewer is initially set or subsequently changed.The default implementation does nothing. Subclassers may override this method to do something when a viewer's input is set. A typical use is populate the viewer.
- Overrides:
inputChangedin classViewer- Parameters:
input- the new input of this viewer, ornullif noneoldInput- the old input element ornullif there was previously no input
-
internalRefresh
Description copied from class:StructuredViewerRefreshes this viewer starting at the given element.- Specified by:
internalRefreshin classStructuredViewer- Parameters:
element- the element
-
listGetTopIndex
protected int listGetTopIndex()Returns the index of the item currently at the top of the viewable area.Default implementation returns -1.
- Returns:
- index, -1 for none
- Since:
- 3.3
-
listSetTopIndex
protected void listSetTopIndex(int index) Sets the index of the item to be at the top of the viewable area.Default implementation does nothing.
- Parameters:
index- the given index. -1 for none. index will always refer to a valid index.- Since:
- 3.3
-
remove
Removes the given elements from this list viewer. The selection is updated if required.This method should be called (by the content provider) when elements have been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model.
- Parameters:
elements- the elements to remove
-
remove
Removes the given element from this list viewer. The selection is updated if necessary.This method should be called (by the content provider) when a single element has been removed from the model, in order to cause the viewer to accurately reflect the model. This method only affects the viewer, not the model. Note that there is another method for efficiently processing the simultaneous removal of multiple elements.
- Parameters:
element- the element
-
setLabelProvider
The list viewer implementation of thisViewerframework method ensures that the given label provider is an instance ofILabelProvider. The optional interfacesIColorProviderandIFontProviderhave no effect for this type of viewer- Overrides:
setLabelProviderin classStructuredViewer- Parameters:
labelProvider- the label provider, ornullif none
-
setSelectionToWidget
Description copied from class:StructuredViewerParlays the given list of selected elements into selections on this viewer's control.Subclasses should override to set their selection based on the given list of elements.
- Specified by:
setSelectionToWidgetin classStructuredViewer- Parameters:
in- list of selected elements (element type:Object) ornullif the selection is to be clearedreveal-trueif the selection is to be made visible, andfalseotherwise
-