public class CommonViewer extends TreeViewer
INavigatorContentService
which uses
the ID supplied in the constructor
CommonViewer(String, Composite, int)
or through
NavigatorContentServiceFactory.createContentService(String, org.eclipse.jface.viewers.StructuredViewer)
.
Clients may extend this class.
Note that as of 3.2.1 and 3.3, the common viewer caches its selection. Clients must not set the selection of the viewer's tree control directly.
StructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders
ALL_LEVELS
WIDGET_DATA_KEY
Constructor and Description |
---|
CommonViewer(String aViewerId,
Composite aParent,
int aStyle)
Constructs the Tree Viewer for the Common Navigator and the corresponding
NavigatorContentService.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Object parentElement,
Object[] childElements)
Adds the given child elements to this viewer as children of the given
parent element.
|
protected CommonDragAdapter |
createDragAdapter()
Creates the
CommonDragAdapter , this is used to provide a subclass
if desired. |
protected CommonDropAdapter |
createDropAdapter()
Creates the
CommonDropAdapter , this is used to provide a subclass
if desired. |
void |
createFrameList() |
void |
dispose()
Disposes of the NavigatorContentService, which will dispose the Content
and Label providers.
|
void |
doUpdateItem(Widget item)
Update an item in the tree.
|
CommonNavigator |
getCommonNavigator() |
org.eclipse.ui.internal.navigator.framelist.FrameList |
getFrameList() |
ICommonViewerMapper |
getMapper()
Gets the
ICommonViewerMapper assigned to this viewer. |
INavigatorContentService |
getNavigatorContentService()
The
INavigatorContentService provides the hook into the framework
to provide content from the various extensions. |
ISelection |
getSelection()
Returns the current selection.
|
protected void |
handleDispose(DisposeEvent event)
Handles a dispose event on this viewer's control.
|
protected void |
handleDoubleSelect(SelectionEvent event)
Handles a double-click select event from the widget.
|
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(SelectionEvent event)
Handles an open event from the OpenStrategy.
|
protected void |
handlePostSelect(SelectionEvent e)
Handles a post select event from the widget.
|
protected void |
handleSelect(SelectionEvent event)
Handles a select event from the widget.
|
protected void |
hookControl(Control control)
Adds event listener hooks to the given control.
|
protected void |
init()
Initializes the content provider, label provider, and drag and drop
support.
|
protected void |
initDragAndDrop()
Adds DND support to the Navigator.
|
protected void |
internalRefresh(Object element,
boolean updateLabels)
Refreshes this viewer starting at the given element.
|
protected void |
mapElement(Object element,
Widget item)
Adds the element item pair to the element map.
|
void |
refresh(Object element)
Refreshes this viewer starting with the given element.
|
void |
refresh(Object element,
boolean updateLabels)
Refreshes this viewer starting with the given element.
|
void |
remove(Object[] elements)
Removals are handled by refreshing the parents of each of the given
elements.
|
protected void |
removeWithoutRefresh(Object[] elements) |
void |
setMapper(ICommonViewerMapper mapper)
Sets the
ICommonViewerMapper to work with this viewer. |
void |
setSelection(ISelection selection,
boolean reveal)
Sets a new selection for this viewer and optionally makes it visible.
|
protected void |
setSelectionToWidget(List v,
boolean reveal)
This implementation of setSelectionToWidget accepts a list of elements or
a list of tree paths.
|
void |
setSorter(ViewerSorter sorter)
Sets this viewer's sorter and triggers refiltering and resorting of this
viewer's element.
|
String |
toString() |
protected void |
unmapAllElements()
Removes all elements from the map.
|
protected void |
unmapElement(Object element,
Widget item)
Removes the given association from the internal element to widget map.
|
void |
update(Object element,
String[] properties)
Updates the given element's presentation when one or more of its
properties changes.
|
addTreeListener, assertContentProviderType, createViewerEditor, disassociate, doGetColumnCount, editElement, getChild, getChildren, getColumnViewerOwner, getControl, getExpanded, getItemAt, getItemCount, getItemCount, getItems, getLabelProvider, getParentElement, getParentItem, getRawChildren, getSelection, getTree, getViewerRowFromItem, handleTreeCollapse, handleTreeExpand, internalAdd, internalInitializeTree, internalRefreshStruct, isExpandable, newItem, remove, removeAll, replace, setChildCount, setContentProvider, setExpanded, setHasChildren, setSelection, showItem, updatePlus
add, addSelectionListener, addTreeListener, associate, buildLabel, collapseAll, collapseToLevel, createChildren, createTreeItem, doFindInputItem, doFindItem, doUpdateItem, doUpdateItem, expandAll, expandAll, expandToLevel, expandToLevel, expandToLevel, expandToLevel, fireTreeCollapsed, fireTreeExpanded, getAutoExpandLevel, getChildren, getExpandedElements, getExpandedState, getExpandedTreePaths, getNextItem, getPreviousItem, getSelectionFromWidget, getSortedChildren, getStructuredSelection, getTreePathFromItem, getVisibleExpandedElements, indexForElement, inputChanged, insert, internalCollapseToLevel, internalExpand, internalExpandToLevel, internalFindItems, internalGetWidgetToSelect, internalIsInputOrEmptyPath, internalRefresh, internalRefresh, internalRemove, internalRemove, isSameSelection, labelProviderChanged, remove, remove, removeTreeListener, reveal, scrollDown, scrollUp, setAutoExpandLevel, setExpandedElements, setExpandedState, setExpandedTreePaths, setExpandPreCheckFilters, setSelectionToWidget, updateChildren
applyEditorValue, cancelEditing, checkBusy, getCell, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getLabelProvider, getViewerRow, hookEditingSupport, isBusy, isCellEditorActive, setBusy, setCellEditors, setCellModifier, setColumnProperties, setColumnViewerEditor, setLabelProvider, triggerEditorActivationEvent
addDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, firePostSelectionChanged, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getRoot, getSorter, handleInvalidSelection, hasFilters, internalUpdate, needsRefilter, preservingSelection, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparator, setComparer, setFilters, setInput, setUseHashlookup, testFindItem, testFindItems, unmapElement, update, updateItem, updateSelection, usingElementMap
getContentProvider, getInput
addHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelection
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addSelectionChangedListener, removeSelectionChangedListener, setSelection
public CommonViewer(String aViewerId, Composite aParent, int aStyle)
Constructs the Tree Viewer for the Common Navigator and the corresponding NavigatorContentService. The NavigatorContentService will provide the Content Provider and Label Provider -- these need not be supplied by clients.
For the valid bits to supply in the style mask (aStyle), see
documentation provided by TreeViewer
.
aViewerId
- An id tied to the extensions that is used to focus specific
content to a particular instance of the Common NavigatoraParent
- A Composite parent to contain the actual SWT widgetaStyle
- A style mask that will be used to create the TreeViewer
Composite.protected void init()
Initializes the content provider, label provider, and drag and drop support. Should not be called by clients -- this method is invoked when the constructor is invoked.
public void setMapper(ICommonViewerMapper mapper)
ICommonViewerMapper
to work with this viewer.mapper
- public ICommonViewerMapper getMapper()
ICommonViewerMapper
assigned to this viewer.public CommonNavigator getCommonNavigator()
protected void removeWithoutRefresh(Object[] elements)
protected void initDragAndDrop()
Adds DND support to the Navigator. Uses hooks into the extensible framework for DND.
By default, the following Transfer types are supported:
CommonDragAdapter
,
CommonDropAdapter
protected CommonDragAdapter createDragAdapter()
CommonDragAdapter
, this is used to provide a subclass
if desired.protected CommonDropAdapter createDropAdapter()
CommonDropAdapter
, this is used to provide a subclass
if desired.protected void handleLabelProviderChanged(LabelProviderChangedEvent event)
StructuredViewer
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. Subclasses may reimplement or extend.
handleLabelProviderChanged
in class StructuredViewer
event
- the event that generated this updateprotected void handleDispose(DisposeEvent event)
ContentViewer
The ContentViewer
implementation of this method disposes of this
viewer's label provider and content provider (if it has one).
Subclasses should override this method to perform any additional
cleanup of resources; however, overriding methods must invoke
super.handleDispose
.
handleDispose
in class ColumnViewer
event
- a dispose eventpublic void dispose()
Disposes of the NavigatorContentService, which will dispose the Content and Label providers.
public void setSorter(ViewerSorter sorter)
null
turns sorting off.setSorter
in class StructuredViewer
sorter
- a viewer sorter, or null
if nonepublic INavigatorContentService getNavigatorContentService()
The INavigatorContentService
provides the hook into the framework
to provide content from the various extensions.
INavigatorContentService
that was created when the
viewer was created.public void add(Object parentElement, Object[] childElements)
AbstractTreeViewer
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.
add
in class AbstractTreeViewer
parentElement
- the parent elementchildElements
- the child elements to addpublic void remove(Object[] elements)
Removals are handled by refreshing the parents of each of the given elements. The parents are determined via calls ot the contentProvider.
remove
in class AbstractTreeViewer
elements
- the elements to removeAbstractTreeViewer.remove(java.lang.Object[])
public void refresh(Object element, boolean updateLabels)
StructuredViewer
refresh(boolean updateLabels)
.
Unlike the update
methods, 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 the
update
methods.
refresh
in class ColumnViewer
element
- the elementupdateLabels
- true
to update labels for existing elements,
false
to only update labels as needed, assuming
that labels for existing elements are unchanged.public void setSelection(ISelection selection, boolean reveal)
TreeViewer
Currently the reveal
parameter is not honored because
Tree
does not provide an API to only select an item without
scrolling it into view
setSelection
in class TreeViewer
selection
- the new selectionreveal
- true
if the selection is to be made visible,
and false
otherwiseprotected void hookControl(Control control)
ContentViewer
All subclasses must call this method when their control is first established.
The ContentViewer
implementation of this method hooks
dispose events for the given control.
Subclasses may override if they need to add other control hooks;
however, super.hookControl
must be invoked.
hookControl
in class TreeViewer
control
- the controlpublic void doUpdateItem(Widget item)
item
- the item in the tree to updateprotected void mapElement(Object element, Widget item)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
mapElement
in class TreeViewer
element
- the elementitem
- the corresponding widgetprotected void unmapElement(Object element, Widget item)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
unmapElement
in class StructuredViewer
element
- the elementitem
- the item to unmapprotected void unmapAllElements()
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
unmapAllElements
in class StructuredViewer
protected void setSelectionToWidget(List v, boolean reveal)
AbstractTreeViewer
setSelectionToWidget
in class AbstractTreeViewer
v
- list of selected elements (element type: Object
)
or null
if the selection is to be clearedreveal
- true
if the selection is to be made visible,
and false
otherwiseprotected void handleDoubleSelect(SelectionEvent event)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
handleDoubleSelect
in class AbstractTreeViewer
event
- the SWT selection eventprotected void handleOpen(SelectionEvent event)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
handleOpen
in class StructuredViewer
event
- the SWT selection eventprotected void handlePostSelect(SelectionEvent e)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
handlePostSelect
in class StructuredViewer
e
- the SWT selection eventprotected void handleSelect(SelectionEvent event)
StructuredViewer
This method is internal to the framework; subclassers should not call this method.
handleSelect
in class StructuredViewer
event
- the SWT selection eventpublic ISelection getSelection()
Note that as of 3.2.1 and 3.3, the common viewer caches its selection. Clients must not set the selection of the viewer's tree control directly.
getSelection
in interface ISelectionProvider
getSelection
in class AbstractTreeViewer
AbstractTreeViewer.getSelection()
public void refresh(Object element)
StructuredViewer
Unlike the update
methods, 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 the
update
methods.
refresh
in class ColumnViewer
element
- the elementpublic void update(Object element, String[] properties)
StructuredViewer
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 refresh
methods 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.
Specifying properties
as null
forces 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.
Note that resorting may not happen if properties
is
null
.
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. Note that filtering may not
happen if properties
is null
.
update
in class ColumnViewer
element
- the elementproperties
- the properties that have changed, or null
to
indicate unknownprotected void internalRefresh(Object element, boolean updateLabels)
StructuredViewer
refresh(boolean updateLabels)
.
The default implementation simply calls
internalRefresh(element)
, ignoring
updateLabels
.
If this method is overridden to do the actual refresh, then
internalRefresh(Object element)
should simply call
internalRefresh(element, true)
.
internalRefresh
in class AbstractTreeViewer
element
- the elementupdateLabels
- true
to update labels for existing elements,
false
to only update labels as needed, assuming
that labels for existing elements are unchanged.public void createFrameList()
public org.eclipse.ui.internal.navigator.framelist.FrameList getFrameList()
Copyright (c) 2000, 2018 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.