Class CommonViewer
- All Implemented Interfaces:
- IInputProvider,- IInputSelectionProvider,- IPostSelectionProvider,- ISelectionProvider
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.
- Since:
- 3.2
- 
Nested Class SummaryNested classes/interfaces inherited from class org.eclipse.jface.viewers.StructuredViewerStructuredViewer.ColorAndFontCollector, StructuredViewer.ColorAndFontCollectorWithProviders
- 
Field SummaryFields inherited from class org.eclipse.jface.viewers.AbstractTreeViewerALL_LEVELS, NO_EXPANDFields inherited from class org.eclipse.jface.viewers.ViewerWIDGET_DATA_KEY
- 
Constructor SummaryConstructorsConstructorDescriptionCommonViewer(String aViewerId, Composite aParent, int aStyle) Constructs the Tree Viewer for the Common Navigator and the corresponding NavigatorContentService.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds the given child elements to this viewer as children of the given parent element.protected CommonDragAdapterCreates theCommonDragAdapter, this is used to provide a subclass if desired.protected CommonDropAdapterCreates theCommonDropAdapter, this is used to provide a subclass if desired.voidvoiddispose()Disposes of the NavigatorContentService, which will dispose the Content and Label providers.voiddoUpdateItem(Widget item) Update an item in the tree.org.eclipse.ui.internal.navigator.framelist.FrameListGets theICommonViewerMapperassigned to this viewer.TheINavigatorContentServiceprovides the hook into the framework to provide content from the various extensions.Returns the current selection.protected voidhandleDispose(DisposeEvent event) Handles a dispose event on this viewer's control.protected voidhandleDoubleSelect(SelectionEvent event) Handles a double-click select event from the widget.protected voidTheStructuredViewerimplementation of thisContentViewermethod callsupdateif the event specifies that the label of a given element has changed, otherwise it calls super.protected voidhandleOpen(SelectionEvent event) Handles an open event from the OpenStrategy.protected voidHandles a post select event from the widget.protected voidhandleSelect(SelectionEvent event) Handles a select event from the widget.protected voidhookControl(Control control) Adds event listener hooks to the given control.protected voidinit()Initializes the content provider, label provider, and drag and drop support.protected voidAdds DND support to the Navigator.protected voidinternalRefresh(Object element, boolean updateLabels) Refreshes this viewer starting at the given element.protected voidmapElement(Object element, Widget item) Adds the element item pair to the element map.voidRefreshes this viewer starting with the given element.voidRefreshes this viewer starting with the given element.voidRemovals are handled by refreshing the parents of each of the given elements.protected voidremoveWithoutRefresh(Object[] elements) voidsetComparator(ViewerComparator comparator) Sets this viewer's sorter and triggers refiltering and resorting of this viewer's element.voidsetMapper(ICommonViewerMapper mapper) Sets theICommonViewerMapperto work with this viewer.voidsetSelection(ISelection selection, boolean reveal) Sets a new selection for this viewer and optionally makes it visible.protected voidsetSelectionToWidget(List v, boolean reveal) This implementation of setSelectionToWidget accepts a list of elements or a list of tree paths.voidsetSorter(ViewerSorter sorter) Deprecated, for removal: This API element is subject to removal in a future version.toString()protected voidRemoves all elements from the map.protected voidunmapElement(Object element, Widget item) Removes the given association from the internal element to widget map.voidUpdates the given element's presentation when one or more of its properties changes.Methods inherited from class org.eclipse.jface.viewers.TreeVieweraddTreeListener, 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, updatePlusMethods inherited from class org.eclipse.jface.viewers.AbstractTreeVieweradd, addSelectionListener, addTreeListener, associate, buildLabel, collapseAll, collapseToLevel, contains, createChildren, createTreeItem, doFindInputItem, doFindItem, doUpdateItem, doUpdateItem, expandAll, expandAll, expandToLevel, expandToLevel, expandToLevel, expandToLevel, fireTreeCollapsed, fireTreeExpanded, getAutoExpandLevel, getAutoExpandOnSingleChildLevels, 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, setAutoExpandOnSingleChildLevels, setExpandedElements, setExpandedState, setExpandedStateWithAutoExpandOnSingleChild, setExpandedTreePaths, setExpandPreCheckFilters, setSelectionToWidget, updateChildrenMethods inherited from class org.eclipse.jface.viewers.ColumnViewerapplyEditorValue, cancelEditing, checkBusy, firePostSelectionChanged, getCell, getCellEditors, getCellModifier, getColumnProperties, getColumnViewerEditor, getItem, getLabelProvider, getViewerRow, hookEditingSupport, isBusy, isCellEditorActive, isExpandableNode, setBusy, setCellEditors, setCellModifier, setColumnProperties, setColumnViewerEditor, setDisplayIncrementally, setLabelProvider, triggerEditorActivationEvent, updateSelectionMethods inherited from class org.eclipse.jface.viewers.StructuredVieweraddDoubleClickListener, addDragSupport, addDropSupport, addFilter, addOpenListener, addPostSelectionChangedListener, assertElementsNotNull, equals, filter, findItem, findItems, fireDoubleClick, fireOpen, getColorAndFontCollector, getComparator, getComparer, getFilteredChildren, getFilters, getRoot, getSorter, handleInvalidSelection, hasFilters, internalUpdate, needsRefilter, preservingSelection, refresh, refresh, refreshItem, removeDoubleClickListener, removeFilter, removeOpenListener, removePostSelectionChangedListener, resetFilters, setComparer, setFilters, setInput, setUseHashlookup, testFindItem, testFindItems, unmapElement, update, updateItem, usingElementMapMethods inherited from class org.eclipse.jface.viewers.ContentViewergetContentProvider, getInputMethods inherited from class org.eclipse.jface.viewers.VieweraddHelpListener, addSelectionChangedListener, fireHelpRequested, fireSelectionChanged, getData, handleHelpRequest, removeHelpListener, removeSelectionChangedListener, setData, setSelectionMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jface.viewers.ISelectionProvideraddSelectionChangedListener, removeSelectionChangedListener, setSelection
- 
Constructor Details- 
CommonViewerConstructs 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.- Parameters:
- aViewerId- An id tied to the extensions that is used to focus specific content to a particular instance of the Common Navigator
- aParent- A Composite parent to contain the actual SWT widget
- aStyle- A style mask that will be used to create the TreeViewer Composite.
 
 
- 
- 
Method Details- 
initprotected 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. 
- 
getMapperGets theICommonViewerMapperassigned to this viewer.- Returns:
- the mapper
- Since:
- 3.4
 
- 
removeWithoutRefresh
- 
initDragAndDropprotected void initDragAndDrop()Adds DND support to the Navigator. Uses hooks into the extensible framework for DND. By default, the following Transfer types are supported: - LocalSelectionTransfer.getInstance(),
- PluginTransfer.getInstance()
 - See Also:
 
- 
createDragAdapterCreates theCommonDragAdapter, this is used to provide a subclass if desired.- Returns:
- the CommonDragAdapter
- Since:
- 3.4
 
- 
createDropAdapterCreates theCommonDropAdapter, this is used to provide a subclass if desired.- Returns:
- the CommonDropAdapter
- Since:
- 3.4
 
- 
handleLabelProviderChangedDescription copied from class:StructuredViewerTheStructuredViewerimplementation 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 class- StructuredViewer
- Parameters:
- event- the event that generated this update
 
- 
handleDisposeDescription copied from class:ContentViewerHandles a dispose event on this viewer's control.The ContentViewerimplementation 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 invokesuper.handleDispose.- Overrides:
- handleDisposein class- ColumnViewer
- Parameters:
- event- a dispose event
 
- 
disposepublic void dispose()Disposes of the NavigatorContentService, which will dispose the Content and Label providers. 
- 
setSorterDeprecated, for removal: This API element is subject to removal in a future version.UsesetComparator(ViewerComparator)instead.Sets this viewer's sorter and triggers refiltering and resorting of this viewer's element. Passingnullturns sorting off.- Overrides:
- setSorterin class- StructuredViewer
- Parameters:
- sorter- a viewer sorter, or- nullif none
 
- 
setComparatorSets this viewer's sorter and triggers refiltering and resorting of this viewer's element. Passingnullturns sorting off.- Overrides:
- setComparatorin class- StructuredViewer
- Parameters:
- comparator- a viewer sorter, or- nullif none
 
- 
addDescription copied from class:AbstractTreeViewerAdds the given child elements to this viewer as children of the given parent element. If this viewer does not have a sorter, the elements are added at the end of the parent's list of children in the order given; otherwise, the elements are inserted at the appropriate positions. If a child already exists under the given parent, the child gets refreshed and not added twice.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. - Overrides:
- addin class- AbstractTreeViewer
- Parameters:
- parentElement- the parent element
- childElements- the child elements to add
 
- 
removeRemovals are handled by refreshing the parents of each of the given elements. The parents are determined via calls ot the contentProvider. - Overrides:
- removein class- AbstractTreeViewer
- Parameters:
- elements- the elements to remove
- See Also:
 
- 
refreshDescription copied from class:StructuredViewerRefreshes this viewer starting with the given element. Labels are updated as described inrefresh(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.- Overrides:
- refreshin class- ColumnViewer
- Parameters:
- element- the element
- updateLabels-- trueto update labels for existing elements,- falseto only update labels as needed, assuming that labels for existing elements are unchanged.
 
- 
setSelectionDescription copied from class:TreeViewerSets a new selection for this viewer and optionally makes it visible.Currently the revealparameter is not honored becauseTreedoes not provide an API to only select an item without scrolling it into view- Overrides:
- setSelectionin class- TreeViewer
- Parameters:
- selection- the new selection
- reveal-- trueif the selection is to be made visible, and- falseotherwise
 
- 
hookControlDescription copied from class:ContentViewerAdds 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 class- TreeViewer
- Parameters:
- control- the control
 
- 
doUpdateItemUpdate an item in the tree.- Parameters:
- item- the item in the tree to update
- Since:
- 3.4
 
- 
mapElementDescription copied from class:StructuredViewerAdds the element item pair to the element map.This method is internal to the framework; subclassers should not call this method. - Overrides:
- mapElementin class- TreeViewer
- Parameters:
- element- the element
- item- the corresponding widget
 
- 
unmapElementDescription copied from class:StructuredViewerRemoves 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. - Overrides:
- unmapElementin class- StructuredViewer
- Parameters:
- element- the element
- item- the item to unmap
 
- 
unmapAllElementsprotected void unmapAllElements()Description copied from class:StructuredViewerRemoves all elements from the map.This method is internal to the framework; subclassers should not call this method. - Overrides:
- unmapAllElementsin class- ColumnViewer
 
- 
setSelectionToWidgetDescription copied from class:AbstractTreeViewerThis implementation of setSelectionToWidget accepts a list of elements or a list of tree paths.- Overrides:
- setSelectionToWidgetin class- AbstractTreeViewer
- Parameters:
- v- list of selected elements (element type:- Object) or- nullif the selection is to be cleared
- reveal-- trueif the selection is to be made visible, and- falseotherwise
 
- 
handleDoubleSelectDescription copied from class:StructuredViewerHandles a double-click select event from the widget.This method is internal to the framework; subclassers should not call this method. - Overrides:
- handleDoubleSelectin class- AbstractTreeViewer
- Parameters:
- event- the SWT selection event
 
- 
handleOpenDescription copied from class:StructuredViewerHandles an open event from the OpenStrategy.This method is internal to the framework; subclassers should not call this method. - Overrides:
- handleOpenin class- StructuredViewer
- Parameters:
- event- the SWT selection event
 
- 
handlePostSelectDescription copied from class:StructuredViewerHandles a post select event from the widget.This method is internal to the framework; subclassers should not call this method. - Overrides:
- handlePostSelectin class- StructuredViewer
- Parameters:
- e- the SWT selection event
 
- 
handleSelectDescription copied from class:StructuredViewerHandles a select event from the widget.This method is internal to the framework; subclassers should not call this method. - Overrides:
- handleSelectin class- StructuredViewer
- Parameters:
- event- the SWT selection event
 
- 
getSelectionReturns the current selection.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. - Specified by:
- getSelectionin interface- ISelectionProvider
- Overrides:
- getSelectionin class- AbstractTreeViewer
- Returns:
- ISelection
- See Also:
 
- 
refreshDescription copied from class:StructuredViewerRefreshes 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.- Overrides:
- refreshin class- ColumnViewer
- Parameters:
- element- the element
 
- 
updateDescription copied from class:StructuredViewerUpdates 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. Specifying 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. Note that resorting may not happen if propertiesisnull.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 propertiesisnull.- Overrides:
- updatein class- ColumnViewer
- Parameters:
- element- the element
- properties- the properties that have changed, or- nullto indicate unknown
 
- 
toString
- 
internalRefreshDescription copied from class:StructuredViewerRefreshes this viewer starting at the given element. Labels are updated as described inrefresh(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).- Overrides:
- internalRefreshin class- AbstractTreeViewer
- Parameters:
- element- the element
- updateLabels-- trueto update labels for existing elements,- falseto only update labels as needed, assuming that labels for existing elements are unchanged.
 
- 
createFrameListpublic void createFrameList()- Since:
- 3.4
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
 
- 
getFrameListpublic org.eclipse.ui.internal.navigator.framelist.FrameList getFrameList()- Returns:
- a FrameList
- Since:
- 3.4
- Restriction:
- This method is not intended to be referenced by clients.
- Restriction:
- This method is not intended to be re-implemented or extended by clients.
 
 
- 
setComparator(ViewerComparator)instead.