|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ viewers overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.jface.viewers
Class StructuredViewer

java.lang.Objectorg.eclipse.jface.viewers.Viewer
org.eclipse.jface.viewers.ContentViewer
org.eclipse.jface.viewers.StructuredViewer
- All Implemented Interfaces:
- IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider
- Direct Known Subclasses:
- AbstractListViewer, AbstractTreeViewer, TableViewer
- public abstract class StructuredViewer
- extends ContentViewer
- implements IPostSelectionProvider
- extends ContentViewer
Abstract base implementation for structure-oriented viewers (trees, lists, tables). Supports custom sorting, filtering, and rendering.
Any number of viewer filters can be added to this viewer (using
addFilter). When the viewer receives an update, it asks each
of its filters if it is out of date, and refilters elements as required.
| Nested Class Summary | |
(package private) class |
StructuredViewer.UpdateItemSafeRunnable
The safe runnable used to update an item. |
| Field Summary | |
private IElementComparer |
comparer
The comparer to use for comparing elements, or null to use
the default equals and hashCode methods on
the element itself. |
private org.eclipse.jface.util.ListenerList |
doubleClickListeners
List of double-click state listeners (element type: IDoubleClickListener). |
private CustomHashtable |
elementMap
A map from the viewer's model elements to SWT widgets. |
private java.util.List |
filters
This viewer's filters (element type: ViewerFilter). |
private boolean |
inChange
Indicates whether a selection change is in progress on this viewer. |
private org.eclipse.jface.util.ListenerList |
openListeners
List of open listeners (element type: ISelectionActivateListener). |
private org.eclipse.jface.util.ListenerList |
postSelectionChangedListeners
List of post selection listeners (element type: ISelectionActivateListener). |
private boolean |
restoreSelection
Used while a selection change is in progress on this viewer to indicates whether the selection should be restored. |
private ViewerSorter |
sorter
This viewer's sorter. |
| Fields inherited from class org.eclipse.jface.viewers.ContentViewer |
|
| Fields inherited from class org.eclipse.jface.viewers.Viewer |
WIDGET_DATA_KEY |
| Constructor Summary | |
protected |
StructuredViewer()
Creates a structured element viewer. |
| Method Summary | |
void |
addDoubleClickListener(IDoubleClickListener listener)
Adds a listener for double-clicks in this viewer. |
void |
addDragSupport(int operations,
org.eclipse.swt.dnd.Transfer[] transferTypes,
org.eclipse.swt.dnd.DragSourceListener listener)
Adds support for dragging items out of this viewer via a user drag-and-drop operation. |
void |
addDropSupport(int operations,
org.eclipse.swt.dnd.Transfer[] transferTypes,
org.eclipse.swt.dnd.DropTargetListener listener)
Adds support for dropping items into this viewer via a user drag-and-drop operation. |
void |
addFilter(ViewerFilter filter)
Adds the given filter to this viewer, and triggers refiltering and resorting of the elements. |
void |
addOpenListener(IOpenListener listener)
Adds a listener for selection-open in this viewer. |
void |
addPostSelectionChangedListener(ISelectionChangedListener listener)
Adds a listener for post selection changes in this selection provider. |
protected void |
assertElementsNotNull(java.lang.Object[] elements)
Asserts that the given array of elements is itself non- null
and contains no null elements. |
protected void |
associate(java.lang.Object element,
org.eclipse.swt.widgets.Item item)
Associates the given element with the given widget. |
protected void |
disassociate(org.eclipse.swt.widgets.Item item)
Disassociates the given SWT item from its corresponding element. |
protected abstract org.eclipse.swt.widgets.Widget |
doFindInputItem(java.lang.Object element)
Returns the widget in this viewer's control which represents the given element if it is the viewer's input. |
protected abstract org.eclipse.swt.widgets.Widget |
doFindItem(java.lang.Object element)
Returns the widget in this viewer's control which represent the given element. |
protected abstract void |
doUpdateItem(org.eclipse.swt.widgets.Widget item,
java.lang.Object element,
boolean fullMap)
Copies the attributes of the given element into the given SWT item. |
protected boolean |
equals(java.lang.Object elementA,
java.lang.Object elementB)
Compares two elements for equality. |
protected java.lang.Object[] |
filter(java.lang.Object[] elements)
Returns the result of running the given elements through the filters. |
protected org.eclipse.swt.widgets.Widget |
findItem(java.lang.Object element)
Finds the widget which represents the given element. |
protected void |
fireDoubleClick(DoubleClickEvent event)
Notifies any double-click listeners that a double-click has been received. |
protected void |
fireOpen(OpenEvent event)
Notifies any open event listeners that a open event has been received. |
protected void |
firePostSelectionChanged(SelectionChangedEvent event)
Notifies any post selection listeners that a post selection event has been received. |
IElementComparer |
getComparer()
Returns the comparator to use for comparing elements, or null if none has been set. |
protected java.lang.Object[] |
getFilteredChildren(java.lang.Object parent)
Returns the filtered array of children of the given element. |
ViewerFilter[] |
getFilters()
Returns this viewer's filters. |
protected org.eclipse.swt.widgets.Item |
getItem(int x,
int y)
Returns the item at the given display-relative coordinates, or null if there is no item at that location. |
protected java.lang.Object[] |
getRawChildren(java.lang.Object parent)
Returns the children of the given parent without sorting and filtering them. |
protected java.lang.Object |
getRoot()
Returns the root element. |
ISelection |
getSelection()
The StructuredViewer implementation of this method returns
the result as an IStructuredSelection. |
protected abstract java.util.List |
getSelectionFromWidget()
Retrieves the selection, as a List, from the underlying
widget. |
protected java.lang.Object[] |
getSortedChildren(java.lang.Object parent)
Returns the sorted and filtered set of children of the given element. |
ViewerSorter |
getSorter()
Returns this viewer's sorter, or null if it does not have
one. |
protected void |
handleDoubleSelect(org.eclipse.swt.events.SelectionEvent event)
Handles a double-click select event from the widget. |
protected void |
handleInvalidSelection(ISelection invalidSelection,
ISelection newSelection)
Handles an invalid selection. |
protected void |
handleLabelProviderChanged(LabelProviderChangedEvent event)
The StructuredViewer implementation of this
ContentViewer method calls update if the
event specifies that the label of a given element has changed, otherwise
it calls super. |
protected void |
handleOpen(org.eclipse.swt.events.SelectionEvent event)
Handles an open event from the OpenStrategy. |
protected void |
handlePostSelect(org.eclipse.swt.events.SelectionEvent e)
Handles a post select event from the widget. |
protected void |
handleSelect(org.eclipse.swt.events.SelectionEvent event)
Handles a select event from the widget. |
protected boolean |
hasFilters()
Returns whether this viewer has any filters. |
protected void |
hookControl(org.eclipse.swt.widgets.Control control)
Adds event listener hooks to the given control. |
protected abstract void |
internalRefresh(java.lang.Object element)
Refreshes this viewer starting at the given element. |
protected void |
internalRefresh(java.lang.Object element,
boolean updateLabels)
Refreshes this viewer starting at the given element. |
protected void |
mapElement(java.lang.Object element,
org.eclipse.swt.widgets.Widget item)
Adds the element item pair to the element map. |
protected boolean |
needsRefilter(java.lang.Object element,
java.lang.String property)
Determines whether a change to the given property of the given element would require refiltering and/or resorting. |
(package private) CustomHashtable |
newHashtable(int capacity)
Returns a new hashtable using the given capacity and this viewer's element comparer. |
protected void |
preservingSelection(java.lang.Runnable updateCode)
Attempts to preserves the current selection across a run of the given code. |
void |
refresh()
Refreshes this viewer completely with information freshly obtained from this viewer's model. |
void |
refresh(boolean updateLabels)
Refreshes this viewer with information freshly obtained from this viewer's model. |
void |
refresh(java.lang.Object element)
Refreshes this viewer starting with the given element. |
void |
refresh(java.lang.Object element,
boolean updateLabels)
Refreshes this viewer starting with the given element. |
protected void |
refreshItem(org.eclipse.swt.widgets.Widget widget,
java.lang.Object element)
Refreshes the given TableItem with the given element. |
void |
removeDoubleClickListener(IDoubleClickListener listener)
Removes the given double-click listener from this viewer. |
void |
removeFilter(ViewerFilter filter)
Removes the given filter from this viewer, and triggers refiltering and resorting of the elements if required. |
void |
removeOpenListener(IOpenListener listener)
Removes the given open listener from this viewer. |
void |
removePostSelectionChangedListener(ISelectionChangedListener listener)
Removes the given listener for post selection changes from this selection provider. |
void |
resetFilters()
Discards this viewer's filters and triggers refiltering and resorting of the elements. |
abstract void |
reveal(java.lang.Object element)
Ensures that the given element is visible, scrolling the viewer if necessary. |
void |
setComparer(IElementComparer comparer)
Sets the comparator to use for comparing elements, or null
to use the default equals and hashCode
methods on the elements themselves. |
void |
setContentProvider(IContentProvider provider)
Sets the content provider used by this viewer. |
void |
setInput(java.lang.Object input)
The ContentViewer implementation of this Viewer
method invokes inputChanged on the content provider and then the
inputChanged hook method. |
void |
setSelection(ISelection selection,
boolean reveal)
Sets a new selection for this viewer and optionally makes it visible. |
protected void |
setSelectionToWidget(ISelection selection,
boolean reveal)
Converts the selection to a List and calls
setSelectionToWidget(List, boolean). |
protected abstract void |
setSelectionToWidget(java.util.List l,
boolean reveal)
Parlays the given list of selected elements into selections on this viewer's control. |
void |
setSorter(ViewerSorter sorter)
Sets this viewer's sorter and triggers refiltering and resorting of this viewer's element. |
void |
setUseHashlookup(boolean enable)
Configures whether this structured viewer uses an internal hash table to speeds up the mapping between elements and SWT items. |
org.eclipse.swt.widgets.Widget |
testFindItem(java.lang.Object element)
Hook for testing. |
protected void |
unmapAllElements()
Removes all elements from the map. |
protected void |
unmapElement(java.lang.Object element)
Removes the given element from the internal element to widget map. |
protected void |
unmapElement(java.lang.Object element,
org.eclipse.swt.widgets.Widget item)
Removes the given association from the internal element to widget map. |
void |
update(java.lang.Object[] elements,
java.lang.String[] properties)
Updates the given elements' presentation when one or more of their properties change. |
void |
update(java.lang.Object element,
java.lang.String[] properties)
Updates the given element's presentation when one or more of its properties changes. |
protected void |
updateItem(org.eclipse.swt.widgets.Widget widget,
java.lang.Object element)
Copies attributes of the given element into the given widget. |
protected void |
updateSelection(ISelection selection)
Updates the selection of this viewer. |
protected boolean |
usingElementMap()
Returns whether this structured viewer is configured to use an internal map to speed up the mapping between elements and SWT items. |
| Methods inherited from class org.eclipse.jface.viewers.ContentViewer |
getContentProvider, getInput, getLabelProvider, handleDispose, labelProviderChanged, setLabelProvider |
| Methods inherited from class org.eclipse.jface.viewers.Viewer |
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getControl, 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 |
| Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvider |
addSelectionChangedListener, removeSelectionChangedListener, setSelection |
| Field Detail |
elementMap
private CustomHashtable elementMap
- A map from the viewer's model elements to SWT widgets. (key type:
Object, value type:Widget).nullmeans that the element map is disabled.
comparer
private IElementComparer comparer
- The comparer to use for comparing elements, or
nullto use the defaultequalsandhashCodemethods on the element itself.
sorter
private ViewerSorter sorter
- This viewer's sorter.
nullmeans there is no sorter.
filters
private java.util.List filters
- This viewer's filters (element type:
ViewerFilter).nullmeans there are no filters.
inChange
private boolean inChange
- Indicates whether a selection change is in progress on this viewer.
- See Also:
setSelection(ISelection, boolean)55
restoreSelection
private boolean restoreSelection
- Used while a selection change is in progress on this viewer to indicates
whether the selection should be restored.
- See Also:
setSelection(ISelection, boolean)55
doubleClickListeners
private org.eclipse.jface.util.ListenerList doubleClickListeners
- List of double-click state listeners (element type:
IDoubleClickListener).
openListeners
private org.eclipse.jface.util.ListenerList openListeners
- List of open listeners (element type:
ISelectionActivateListener).- See Also:
fireOpen(org.eclipse.jface.viewers.OpenEvent)55
postSelectionChangedListeners
private org.eclipse.jface.util.ListenerList postSelectionChangedListeners
- List of post selection listeners (element type:
ISelectionActivateListener).
| Constructor Detail |
StructuredViewer
protected StructuredViewer()
- Creates a structured element viewer. The viewer has no input, no content
provider, a default label provider, no sorter, and no filters.
| Method Detail |
addDoubleClickListener
public void addDoubleClickListener(IDoubleClickListener listener)
- Adds a listener for double-clicks in this viewer. Has no effect if an
identical listener is already registered.
addOpenListener
public void addOpenListener(IOpenListener listener)
- Adds a listener for selection-open in this viewer. Has no effect if an
identical listener is already registered.
addPostSelectionChangedListener
public void addPostSelectionChangedListener(ISelectionChangedListener listener)
- Description copied from interface:
IPostSelectionProvider - Adds a listener for post selection changes in this selection provider.
Has no effect if an identical listener is already registered.
- Specified by:
addPostSelectionChangedListenerin interfaceIPostSelectionProvider
addDragSupport
public void addDragSupport(int operations,
org.eclipse.swt.dnd.Transfer[] transferTypes,
org.eclipse.swt.dnd.DragSourceListener listener)
- Adds support for dragging items out of this viewer via a user
drag-and-drop operation.
addDropSupport
public void addDropSupport(int operations,
org.eclipse.swt.dnd.Transfer[] transferTypes,
org.eclipse.swt.dnd.DropTargetListener listener)
- Adds support for dropping items into this viewer via a user drag-and-drop
operation.
addFilter
public void addFilter(ViewerFilter filter)
- Adds the given filter to this viewer, and triggers refiltering and
resorting of the elements.
assertElementsNotNull
protected void assertElementsNotNull(java.lang.Object[] elements)
- Asserts that the given array of elements is itself non-
nulland contains nonullelements.
associate
protected void associate(java.lang.Object element, org.eclipse.swt.widgets.Item item)
- Associates the given element with the given widget. Sets the given item's
data to be the element, and maps the element to the item in the element
map (if enabled).
disassociate
protected void disassociate(org.eclipse.swt.widgets.Item item)
- Disassociates the given SWT item from its corresponding element. Sets the
item's data to
nulland removes the element from the element map (if enabled).
doFindInputItem
protected abstract org.eclipse.swt.widgets.Widget doFindInputItem(java.lang.Object element)
- Returns 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.
doFindItem
protected abstract org.eclipse.swt.widgets.Widget doFindItem(java.lang.Object element)
- Returns the widget in this viewer's control which represent the given
element. This method searchs all the children of the input element.
This method is internal to the framework; subclassers should not call this method.
doUpdateItem
protected abstract void doUpdateItem(org.eclipse.swt.widgets.Widget item, java.lang.Object element, boolean fullMap)
- Copies the attributes of the given element into the given SWT item. The
element map is updated according to the value of
fullMap. IffullMapistruethen the current mapping from element to widgets is removed and the new mapping is added. If fullmap 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.
equals
protected boolean equals(java.lang.Object elementA, java.lang.Object elementB)
- Compares two elements for equality. Uses the element comparer if one has
been set, otherwise uses the default
equalsmethod on the elements themselves.
filter
protected java.lang.Object[] filter(java.lang.Object[] elements)
- Returns the result of running the given elements through the filters.
findItem
protected final org.eclipse.swt.widgets.Widget findItem(java.lang.Object element)
- Finds the widget which represents the given element.
The default implementation of this method tries first to find the widget for the given element assuming that it is the viewer's input; this is done by calling
doFindInputItem. If it is not found there, it is looked up in the internal element map provided that this feature has been enabled. If the element map is disabled, the widget is found viadoFindInputItem.
fireDoubleClick
protected void fireDoubleClick(DoubleClickEvent event)
- Notifies any double-click listeners that a double-click has been
received. Only listeners registered at the time this method is called are
notified.
fireOpen
protected void fireOpen(OpenEvent event)
- Notifies any open event listeners that a open event has been received.
Only listeners registered at the time this method is called are notified.
firePostSelectionChanged
protected void firePostSelectionChanged(SelectionChangedEvent event)
- Notifies any post selection listeners that a post selection event has
been received. Only listeners registered at the time this method is
called are notified.
getComparer
public IElementComparer getComparer()
- Returns the comparator to use for comparing elements, or
nullif none has been set.
getFilteredChildren
protected java.lang.Object[] getFilteredChildren(java.lang.Object parent)
- Returns the filtered array of children of the given element. The
resulting array must not be modified, as it may come directly from the
model's internal state.
getFilters
public ViewerFilter[] getFilters()
- Returns this viewer's filters.
getItem
protected org.eclipse.swt.widgets.Item getItem(int x, int y)
- Returns the item at the given display-relative coordinates, or
nullif there is no item at that location.The default implementation of this method returns
null.
getRawChildren
protected java.lang.Object[] getRawChildren(java.lang.Object parent)
- Returns the children of the given parent without sorting and filtering
them. The resulting array must not be modified, as it may come directly
from the model's internal state.
Returns an empty array if the given parent is
null.
getRoot
protected java.lang.Object getRoot()
- Returns the root element.
The default implementation of this framework method forwards to
getInput. Override if the root element is different from the viewer's input element.
getSelection
public ISelection getSelection()
- The
StructuredViewerimplementation of this method returns the result as anIStructuredSelection.Subclasses do not typically override this method, but implement
getSelectionFromWidget(List)instead.- Specified by:
getSelectionin interfaceISelectionProvider- Specified by:
getSelectionin classViewer
getSelectionFromWidget
protected abstract java.util.List getSelectionFromWidget()
- Retrieves the selection, as a
List, from the underlying widget.
getSortedChildren
protected java.lang.Object[] getSortedChildren(java.lang.Object parent)
- Returns the sorted and filtered set of children of the given element. The
resulting array must not be modified, as it may come directly from the
model's internal state.
getSorter
public ViewerSorter getSorter()
- Returns this viewer's sorter, or
nullif it does not have one.
handleDoubleSelect
protected void handleDoubleSelect(org.eclipse.swt.events.SelectionEvent event)
- Handles a double-click select event from the widget.
This method is internal to the framework; subclassers should not call this method.
handleOpen
protected void handleOpen(org.eclipse.swt.events.SelectionEvent event)
- Handles an open event from the OpenStrategy.
This method is internal to the framework; subclassers should not call this method.
handleInvalidSelection
protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection)
- Handles an invalid selection.
This framework method is called if a model change picked up by a viewer results in an invalid selection. For instance if an element contained in the selection has been removed from the viewer, the viewer is free to either remove the element from the selection or to pick another element as its new selection. The default implementation of this method calls
updateSelection. Subclasses may override it to implement a different strategy for picking a new selection when the old selection becomes invalid.
handleLabelProviderChanged
protected void handleLabelProviderChanged(LabelProviderChangedEvent event)
- The
StructuredViewerimplementation of thisContentViewermethod callsupdateif the event specifies that the label of a given element has changed, otherwise it calls super. Subclasses may reimplement or extend.- Overrides:
handleLabelProviderChangedin classContentViewer
handleSelect
protected void handleSelect(org.eclipse.swt.events.SelectionEvent event)
- Handles a select event from the widget.
This method is internal to the framework; subclassers should not call this method.
handlePostSelect
protected void handlePostSelect(org.eclipse.swt.events.SelectionEvent e)
- Handles a post select event from the widget.
This method is internal to the framework; subclassers should not call this method.
hookControl
protected void hookControl(org.eclipse.swt.widgets.Control control)
- Description copied from class:
ContentViewer - Adds event listener hooks to the given control.
All subclasses must call this method when their control is first established.
The
ContentViewerimplementation of this method hooks dispose events for the given control. Subclasses may override if they need to add other control hooks; however,super.hookControlmust be invoked.- Overrides:
hookControlin classContentViewer
hasFilters
protected boolean hasFilters()
- Returns whether this viewer has any filters.
internalRefresh
protected abstract void internalRefresh(java.lang.Object element)
- Refreshes this viewer starting at the given element.
internalRefresh
protected void internalRefresh(java.lang.Object element, boolean updateLabels)
- Refreshes this viewer starting at the given element. Labels are updated
as described in
refresh(boolean updateLabels).The default implementation simply calls
internalRefresh(element), ignoringupdateLabels.If this method is overridden to do the actual refresh, then
internalRefresh(Object element)should simply callinternalRefresh(element, true).- Since:
- 2.0
mapElement
protected void mapElement(java.lang.Object element, org.eclipse.swt.widgets.Widget item)
- Adds the element item pair to the element map.
This method is internal to the framework; subclassers should not call this method.
needsRefilter
protected boolean needsRefilter(java.lang.Object element, java.lang.String property)
- Determines whether a change to the given property of the given element
would require refiltering and/or resorting.
This method is internal to the framework; subclassers should not call this method.
newHashtable
CustomHashtable newHashtable(int capacity)
- Returns a new hashtable using the given capacity and this viewer's element comparer.
- Since:
- 3.0
preservingSelection
protected void preservingSelection(java.lang.Runnable updateCode)
- Attempts to preserves the current selection across a run of the given
code.
The default implementation of this method:
- discovers the old selection (via
getSelection) - runs the given runnable
- attempts to restore the old selection (using
setSelectionToWidget - rediscovers the resulting selection (via
getSelection) - calls
handleInvalidSelectionif the selection did not take - calls
postUpdateHook
- discovers the old selection (via
refresh
public void refresh()
- Description copied from class:
Viewer - Refreshes this viewer completely with information freshly obtained from this
viewer's model.
refresh
public void refresh(boolean updateLabels)
- Refreshes this viewer with information freshly obtained from this
viewer's model. If
updateLabelsistruethen labels for otherwise unaffected elements are updated as well. Otherwise, it assumes labels for existing elements are unchanged, and labels are only obtained as needed (for example, for new elements).Calling
refresh(true)has the same effect asrefresh().Note that the implementation may still obtain labels for existing elements even if
updateLabelsis false. The intent is simply to allow optimization where possible.- Since:
- 2.0
refresh
public void refresh(java.lang.Object element)
- Refreshes this viewer starting with the given element.
Unlike the
updatemethods, this handles structural changes to the given element (e.g. addition or removal of children). If only the given element needs updating, it is more efficient to use theupdatemethods.
refresh
public void refresh(java.lang.Object element, boolean updateLabels)
- Refreshes this viewer starting with the given element. Labels are updated
as described in
refresh(boolean updateLabels).Unlike the
updatemethods, this handles structural changes to the given element (e.g. addition or removal of children). If only the given element needs updating, it is more efficient to use theupdatemethods.- Since:
- 2.0
refreshItem
protected final void refreshItem(org.eclipse.swt.widgets.Widget widget, java.lang.Object element)
- Refreshes the given TableItem with the given element. Calls
doUpdateItem(..., false).This method is internal to the framework; subclassers should not call this method.
removeOpenListener
public void removeOpenListener(IOpenListener listener)
- Removes the given open listener from this viewer. Has no affect if an
identical listener is not registered.
removePostSelectionChangedListener
public void removePostSelectionChangedListener(ISelectionChangedListener listener)
- Description copied from interface:
IPostSelectionProvider - Removes the given listener for post selection changes from this selection
provider.
Has no affect if an identical listener is not registered.
- Specified by:
removePostSelectionChangedListenerin interfaceIPostSelectionProvider
removeDoubleClickListener
public void removeDoubleClickListener(IDoubleClickListener listener)
- Removes the given double-click listener from this viewer. Has no affect
if an identical listener is not registered.
removeFilter
public void removeFilter(ViewerFilter filter)
- Removes the given filter from this viewer, and triggers refiltering and
resorting of the elements if required. Has no effect if the identical
filter is not registered.
resetFilters
public void resetFilters()
- Discards this viewer's filters and triggers refiltering and resorting of
the elements.
reveal
public abstract void reveal(java.lang.Object element)
- Ensures that the given element is visible, scrolling the viewer if
necessary. The selection is unchanged.
setContentProvider
public void setContentProvider(IContentProvider provider)
- Description copied from class:
ContentViewer - Sets the content provider used by this viewer.
The
ContentViewerimplementation of this method records the content provider in an internal state variable. Overriding this method is generally not required; however, if overriding in a subclass,super.setContentProvidermust be invoked.- Overrides:
setContentProviderin classContentViewer
setInput
public final void setInput(java.lang.Object input)
- Description copied from class:
ContentViewer - The
ContentViewerimplementation of thisViewermethod invokesinputChangedon the content provider and then theinputChangedhook method. This method fails if this viewer does not have a content provider. Subclassers are advised to overrideinputChangedrather than this method, but may extend this method if required.- Overrides:
setInputin classContentViewer
setSelection
public void setSelection(ISelection selection, boolean reveal)
- Description copied from class:
Viewer - Sets a new selection for this viewer and optionally makes it visible.
Subclasses must implement this method.
- Specified by:
setSelectionin classViewer
setSelectionToWidget
protected abstract void setSelectionToWidget(java.util.List l, boolean reveal)
- Parlays 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.
setSelectionToWidget
protected void setSelectionToWidget(ISelection selection, boolean reveal)
- Converts the selection to a
Listand callssetSelectionToWidget(List, boolean). The selection is expected to be anIStructuredSelectionof elements. If not, the selection is cleared.Subclasses do not typically override this method, but implement
setSelectionToWidget(List, boolean)instead.
setSorter
public void setSorter(ViewerSorter sorter)
- Sets this viewer's sorter and triggers refiltering and resorting of this
viewer's element. Passing
nullturns sorting off.
setUseHashlookup
public void setUseHashlookup(boolean enable)
- Configures whether this structured viewer uses an internal hash table to
speeds up the mapping between elements and SWT items. This must be called
before the viewer is given an input (via
setInput).
setComparer
public void setComparer(IElementComparer comparer)
- Sets the comparator to use for comparing elements, or
nullto use the defaultequalsandhashCodemethods on the elements themselves.
testFindItem
public org.eclipse.swt.widgets.Widget testFindItem(java.lang.Object element)
- Hook for testing.
unmapAllElements
protected void unmapAllElements()
- Removes all elements from the map.
This method is internal to the framework; subclassers should not call this method.
unmapElement
protected void unmapElement(java.lang.Object element)
- Removes the given element from the internal element to widget map. Does
nothing if mapping is disabled. If mapping is enabled, the given element
must be present.
This method is internal to the framework; subclassers should not call this method.
unmapElement
protected void unmapElement(java.lang.Object element, org.eclipse.swt.widgets.Widget item)
- Removes the given association from the internal element to widget map.
Does nothing if mapping is disabled, or if the given element does not map
to the given item.
This method is internal to the framework; subclassers should not call this method.
- Since:
- 2.0
update
public void update(java.lang.Object[] elements, java.lang.String[] properties)
- Updates the given elements' presentation when one or more of their
properties change. Only the given elements are updated.
This does not handle structural changes (e.g. addition or removal of elements), and does not update any other related elements (e.g. child elements). To handle structural changes, use the
refreshmethods instead.This should be called when an element has changed in the model, in order to have the viewer accurately reflect the model. This method only affects the viewer, not the model.
Specifying which properties are affected may allow the viewer to optimize the update. For example, if the label provider is not affected by changes to any of these properties, an update may not actually be required. Specifing
propertiesasnullforces a full update of the given elements.If the viewer has a sorter which is affected by a change to one of the properties, the elements' positions are updated to maintain the sort order.
If the viewer has a filter which is affected by a change to one of the properties, elements may appear or disappear if the change affects whether or not they are filtered out.
update
public void update(java.lang.Object element, java.lang.String[] properties)
- Updates the given element's presentation when one or more of its
properties changes. Only the given element is updated.
This does not handle structural changes (e.g. addition or removal of elements), and does not update any other related elements (e.g. child elements). To handle structural changes, use the
refreshmethods instead.This should be called when an element has changed in the model, in order to have the viewer accurately reflect the model. This method only affects the viewer, not the model.
Specifying which properties are affected may allow the viewer to optimize the update. For example, if the label provider is not affected by changes to any of these properties, an update may not actually be required. Specifing
propertiesasnullforces a full update of the element.If the viewer has a sorter which is affected by a change to one of the properties, the element's position is updated to maintain the sort order.
If the viewer has a filter which is affected by a change to one of the properties, the element may appear or disappear if the change affects whether or not the element is filtered out.
updateItem
protected final void updateItem(org.eclipse.swt.widgets.Widget widget, java.lang.Object element)
- Copies attributes of the given element into the given widget.
This method is internal to the framework; subclassers should not call this method. Calls
doUpdateItem(widget, element, true).
updateSelection
protected void updateSelection(ISelection selection)
- Updates the selection of this viewer.
This framework method should be called when the selection in the viewer widget changes.
The default implementation of this method notifies all selection change listeners recorded in an internal state variable. Overriding this method is generally not required; however, if overriding in a subclass,
super.updateSelectionmust be invoked.
usingElementMap
protected boolean usingElementMap()
- Returns whether this structured viewer is configured to use an internal
map to speed up the mapping between elements and SWT items.
The default implementation of this framework method checks whether the internal map has been initialized.
|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ viewers overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC