Java Doc for StructuredViewer.java in  » IDE-Eclipse » jface » org » eclipse » jface » viewers » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Eclipse » jface » org.eclipse.jface.viewers 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.eclipse.jface.viewers.Viewer
      org.eclipse.jface.viewers.ContentViewer
         org.eclipse.jface.viewers.StructuredViewer

All known Subclasses:   org.eclipse.jface.viewers.ColumnViewer,  org.eclipse.jface.viewers.AbstractListViewer,
StructuredViewer
abstract public class StructuredViewer extends ContentViewer implements IPostSelectionProvider(Code)
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.


See Also:   ViewerFilter
See Also:   ViewerComparator

Inner Class :protected class ColorAndFontCollectorWithProviders extends ColorAndFontCollector
Inner Class :protected class ColorAndFontCollector
Inner Class :class UpdateItemSafeRunnable extends SafeRunnable


Constructor Summary
protected  StructuredViewer()
     Creates a structured element viewer.

Method Summary
public  voidaddDoubleClickListener(IDoubleClickListener listener)
     Adds a listener for double-clicks in this viewer.
public  voidaddDragSupport(int operations, Transfer[] transferTypes, DragSourceListener listener)
     Adds support for dragging items out of this viewer via a user drag-and-drop operation.
public  voidaddDropSupport(int operations, Transfer[] transferTypes, DropTargetListener listener)
     Adds support for dropping items into this viewer via a user drag-and-drop operation.
public  voidaddFilter(ViewerFilter filter)
     Adds the given filter to this viewer, and triggers refiltering and resorting of the elements.
public  voidaddOpenListener(IOpenListener listener)
     Adds a listener for selection-open in this viewer.
public  voidaddPostSelectionChangedListener(ISelectionChangedListener listener)
    
protected  voidassertContentProviderType(IContentProvider provider)
     Assert that the content provider is of one of the supported types.
protected  voidassertElementsNotNull(Object[] elements)
     Asserts that the given array of elements is itself non- null and contains no null elements.
protected  voidassociate(Object element, Item item)
     Associates the given element with the given widget.
protected  voidbuildLabel(ViewerLabel updateLabel, Object element)
     Build a label up for the element using the supplied label provider.
 voidbuildLabel(ViewerLabel updateLabel, Object element, IViewerLabelProvider labelProvider)
     Build a label up for the element using the supplied label provider.
 voidbuildLabel(ViewerLabel updateLabel, TreePath elementPath, ITreePathLabelProvider labelProvider)
     Build a label up for the element using the supplied label provider.
 voidbuildLabel(ViewerLabel updateLabel, Object element, ILabelProvider labelProvider)
     Build a label up for the element using the supplied label provider.
protected  voiddisassociate(Item item)
     Disassociates the given SWT item from its corresponding element.
abstract protected  WidgetdoFindInputItem(Object element)
     Returns the widget in this viewer's control which represents the given element if it is the viewer's input.
abstract protected  WidgetdoFindItem(Object element)
     Returns the widget in this viewer's control which represent the given element.
abstract protected  voiddoUpdateItem(Widget item, Object element, boolean fullMap)
     Copies the attributes of the given element into the given SWT item.
protected  booleanequals(Object elementA, Object elementB)
     Compares two elements for equality.
protected  Object[]filter(Object[] elements)
     Returns the result of running the given elements through the filters.
final protected  WidgetfindItem(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.

final protected  Widget[]findItems(Object element)
     Finds the widgets which represent the given element.
protected  voidfireDoubleClick(DoubleClickEvent event)
     Notifies any double-click listeners that a double-click has been received.
protected  voidfireOpen(OpenEvent event)
     Notifies any open event listeners that a open event has been received.
protected  voidfirePostSelectionChanged(SelectionChangedEvent event)
     Notifies any post selection listeners that a post selection event has been received.
protected  ColorAndFontCollectorgetColorAndFontCollector()
     Get the ColorAndFontCollector for the receiver.
public  ViewerComparatorgetComparator()
     Return this viewer's comparator used to sort elements.
public  IElementComparergetComparer()
     Returns the comparer to use for comparing elements, or null if none has been set.
protected  Object[]getFilteredChildren(Object parent)
     Returns the filtered array of children of the given element.
public  ViewerFilter[]getFilters()
     Returns this viewer's filters.
protected  ItemgetItem(int x, int y)
     Returns the item at the given display-relative coordinates, or null if there is no item at that location or the underlying SWT-Control is not made up of Item (e.g ListViewer )

The default implementation of this method returns null.

protected  Object[]getRawChildren(Object parent)
     Returns the children of the given parent without sorting and filtering them.
protected  ObjectgetRoot()
     Returns the root element.

The default implementation of this framework method forwards to getInput.

public  ISelectiongetSelection()
     The StructuredViewer implementation of this method returns the result as an IStructuredSelection.
abstract protected  ListgetSelectionFromWidget()
     Retrieves the selection, as a List, from the underlying widget.
protected  Object[]getSortedChildren(Object parent)
     Returns the sorted and filtered set of children of the given element.
public  ViewerSortergetSorter()
     Returns this viewer's sorter, or null if it does not have one.
protected  voidhandleDispose(DisposeEvent event)
    
protected  voidhandleDoubleSelect(SelectionEvent event)
     Handles a double-click select event from the widget.
protected  voidhandleInvalidSelection(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.

protected  voidhandleLabelProviderChanged(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  voidhandleOpen(SelectionEvent event)
     Handles an open event from the OpenStrategy.
protected  voidhandlePostSelect(SelectionEvent e)
     Handles a post select event from the widget.
protected  voidhandleSelect(SelectionEvent event)
     Handles a select event from the widget.
protected  booleanhasFilters()
     Returns whether this viewer has any filters.
protected  voidhookControl(Control control)
    
abstract protected  voidinternalRefresh(Object element)
     Refreshes this viewer starting at the given element.
protected  voidinternalRefresh(Object element, boolean updateLabels)
     Refreshes this viewer starting at the given element.
protected  voidinternalUpdate(Widget widget, Object element, String[] properties)
     Updates the given element's presentation when one or more of its properties changes.
protected  voidmapElement(Object element, Widget item)
     Adds the element item pair to the element map.
protected  booleanneedsRefilter(Object element, String property)
     Determines whether a change to the given property of the given element would require refiltering and/or resorting.
 CustomHashtablenewHashtable(int capacity)
     Returns a new hashtable using the given capacity and this viewer's element comparer.
protected  voidpreservingSelection(Runnable updateCode)
     Attempts to preserves the current selection across a run of the given code.
 voidpreservingSelection(Runnable updateCode, boolean reveal)
     Attempts to preserves the current selection across a run of the given code, with a best effort to avoid scrolling if reveal is false, or to reveal the selection if reveal is true.
public  voidrefresh()
    
public  voidrefresh(boolean updateLabels)
     Refreshes this viewer with information freshly obtained from this viewer's model.
public  voidrefresh(Object element)
     Refreshes this viewer starting with the given element.

Unlike the update methods, this handles structural changes to the given element (e.g.

public  voidrefresh(Object element, boolean updateLabels)
     Refreshes this viewer starting with the given element.
final protected  voidrefreshItem(Widget widget, Object element)
     Refreshes the given item with the given element.
public  voidremoveDoubleClickListener(IDoubleClickListener listener)
     Removes the given double-click listener from this viewer.
public  voidremoveFilter(ViewerFilter filter)
     Removes the given filter from this viewer, and triggers refiltering and resorting of the elements if required.
public  voidremoveOpenListener(IOpenListener listener)
     Removes the given open listener from this viewer.
public  voidremovePostSelectionChangedListener(ISelectionChangedListener listener)
    
public  voidresetFilters()
     Discards this viewer's filters and triggers refiltering and resorting of the elements.
abstract public  voidreveal(Object element)
     Ensures that the given element is visible, scrolling the viewer if necessary.
public  voidsetComparator(ViewerComparator comparator)
     Sets this viewer's comparator to be used for sorting elements, and triggers refiltering and resorting of this viewer's element.
public  voidsetComparer(IElementComparer comparer)
     Sets the comparer to use for comparing elements, or null to use the default equals and hashCode methods on the elements themselves.
public  voidsetContentProvider(IContentProvider provider)
    
public  voidsetFilters(ViewerFilter[] filters)
     Sets the filters, replacing any previous filters, and triggers refiltering and resorting of the elements.
final public  voidsetInput(Object input)
    
public  voidsetLabelProvider(IBaseLabelProvider labelProvider)
    
public  voidsetSelection(ISelection selection, boolean reveal)
    
abstract protected  voidsetSelectionToWidget(List l, boolean reveal)
     Parlays the given list of selected elements into selections on this viewer's control.
protected  voidsetSelectionToWidget(ISelection selection, boolean reveal)
     Converts the selection to a List and calls setSelectionToWidget(List, boolean).
public  voidsetSorter(ViewerSorter sorter)
     Sets this viewer's sorter and triggers refiltering and resorting of this viewer's element.
public  voidsetUseHashlookup(boolean enable)
     Configures whether this structured viewer uses an internal hash table to speeds up the mapping between elements and SWT items.
public  WidgettestFindItem(Object element)
     Hook for testing.
public  Widget[]testFindItems(Object element)
     Hook for testing.
protected  voidunmapAllElements()
     Removes all elements from the map.
protected  voidunmapElement(Object element)
     Removes the given element from the internal element to widget map.
protected  voidunmapElement(Object element, Widget item)
     Removes the given association from the internal element to widget map.
public  voidupdate(Object[] elements, String[] properties)
     Updates the given elements' presentation when one or more of their properties change.
public  voidupdate(Object element, String[] properties)
     Updates the given element's presentation when one or more of its properties changes.
final protected  voidupdateItem(Widget widget, 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.

protected  voidupdateSelection(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.

protected  booleanusingElementMap()
     Returns whether this structured viewer is configured to use an internal map to speed up the mapping between elements and SWT items.


Constructor Detail
StructuredViewer
protected StructuredViewer()(Code)
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)(Code)
Adds a listener for double-clicks in this viewer. Has no effect if an identical listener is already registered.
Parameters:
  listener - a double-click listener



addDragSupport
public void addDragSupport(int operations, Transfer[] transferTypes, DragSourceListener listener)(Code)
Adds support for dragging items out of this viewer via a user drag-and-drop operation.
Parameters:
  operations - a bitwise OR of the supported drag and drop operation types (DROP_COPY,DROP_LINK, andDROP_MOVE)
Parameters:
  transferTypes - the transfer types that are supported by the drag operation
Parameters:
  listener - the callback that will be invoked to set the drag data and tocleanup after the drag and drop operation finishes
See Also:   org.eclipse.swt.dnd.DND



addDropSupport
public void addDropSupport(int operations, Transfer[] transferTypes, DropTargetListener listener)(Code)
Adds support for dropping items into this viewer via a user drag-and-drop operation.
Parameters:
  operations - a bitwise OR of the supported drag and drop operation types (DROP_COPY,DROP_LINK, andDROP_MOVE)
Parameters:
  transferTypes - the transfer types that are supported by the drop operation
Parameters:
  listener - the callback that will be invoked after the drag and dropoperation finishes
See Also:   org.eclipse.swt.dnd.DND



addFilter
public void addFilter(ViewerFilter filter)(Code)
Adds the given filter to this viewer, and triggers refiltering and resorting of the elements. If you want to add more than one filter consider using StructuredViewer.setFilters(ViewerFilter[]) .
Parameters:
  filter - a viewer filter
See Also:   StructuredViewer.setFilters(ViewerFilter[])



addOpenListener
public void addOpenListener(IOpenListener listener)(Code)
Adds a listener for selection-open in this viewer. Has no effect if an identical listener is already registered.
Parameters:
  listener - a double-click listener



addPostSelectionChangedListener
public void addPostSelectionChangedListener(ISelectionChangedListener listener)(Code)



assertContentProviderType
protected void assertContentProviderType(IContentProvider provider)(Code)
Assert that the content provider is of one of the supported types.
Parameters:
  provider -



assertElementsNotNull
protected void assertElementsNotNull(Object[] elements)(Code)
Asserts that the given array of elements is itself non- null and contains no null elements.
Parameters:
  elements - the array to check



associate
protected void associate(Object element, Item item)(Code)
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).
Parameters:
  element - the element
Parameters:
  item - the widget



buildLabel
protected void buildLabel(ViewerLabel updateLabel, Object element)(Code)
Build a label up for the element using the supplied label provider.
Parameters:
  updateLabel - The ViewerLabel to collect the result in
Parameters:
  element - The element being decorated.



buildLabel
void buildLabel(ViewerLabel updateLabel, Object element, IViewerLabelProvider labelProvider)(Code)
Build a label up for the element using the supplied label provider.
Parameters:
  updateLabel - The ViewerLabel to collect the result in
Parameters:
  element - The element being decorated.
Parameters:
  labelProvider - ILabelProvider the labelProvider for the receiver.



buildLabel
void buildLabel(ViewerLabel updateLabel, TreePath elementPath, ITreePathLabelProvider labelProvider)(Code)
Build a label up for the element using the supplied label provider.
Parameters:
  updateLabel - The ViewerLabel to collect the result in
Parameters:
  elementPath - The path of the element being decorated.
Parameters:
  labelProvider - ILabelProvider the labelProvider for the receiver.



buildLabel
void buildLabel(ViewerLabel updateLabel, Object element, ILabelProvider labelProvider)(Code)
Build a label up for the element using the supplied label provider.
Parameters:
  updateLabel - The ViewerLabel to collect the result in
Parameters:
  element - The element being decorated.
Parameters:
  labelProvider - ILabelProvider the labelProvider for the receiver.



disassociate
protected void disassociate(Item item)(Code)
Disassociates the given SWT item from its corresponding element. Sets the item's data to null and removes the element from the element map (if enabled).
Parameters:
  item - the widget



doFindInputItem
abstract protected Widget doFindInputItem(Object element)(Code)
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.


Parameters:
  element - the corresponding widget, or null if none



doFindItem
abstract protected Widget doFindItem(Object element)(Code)
Returns 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.


Parameters:
  element - the corresponding widget, or null if none



doUpdateItem
abstract protected void doUpdateItem(Widget item, Object element, boolean fullMap)(Code)
Copies the attributes of the given element into the given SWT item. The element map is updated according to the value of fullMap. If fullMap is true then the current mapping from element to widgets is removed and the new mapping is added. If full map is false then 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.


Parameters:
  item -
Parameters:
  element - element
Parameters:
  fullMap - true if mappings are added and removed, andfalse if only the new map gets installed



equals
protected boolean equals(Object elementA, Object elementB)(Code)
Compares two elements for equality. Uses the element comparer if one has been set, otherwise uses the default equals method on the elements themselves.
Parameters:
  elementA - the first element
Parameters:
  elementB - the second element whether elementA is equal to elementB



filter
protected Object[] filter(Object[] elements)(Code)
Returns the result of running the given elements through the filters.
Parameters:
  elements - the elements to filter only the elements which all filters accept



findItem
final protected Widget findItem(Object element)(Code)
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 via doFindInputItem.


Parameters:
  element - the element the corresponding widget, or null if none



findItems
final protected Widget[] findItems(Object element)(Code)
Finds the widgets which represent the given element. The returned array must not be changed by clients; it might change upon calling other methods on this viewer.

This method was introduced to support multiple equal elements in a viewer (@see AbstractTreeViewer ). Multiple equal elements are only supported if the element map is enabled by calling StructuredViewer.setUseHashlookup(boolean) and passing true.

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, the widgets are looked up in the internal element map provided that this feature has been enabled. If the element map is disabled, the widget is found via doFindInputItem.


Parameters:
  element - the element the corresponding widgets
since:
   3.2



fireDoubleClick
protected void fireDoubleClick(DoubleClickEvent event)(Code)
Notifies any double-click listeners that a double-click has been received. Only listeners registered at the time this method is called are notified.
Parameters:
  event - a double-click event
See Also:   IDoubleClickListener.doubleClick



fireOpen
protected void fireOpen(OpenEvent event)(Code)
Notifies any open event listeners that a open event has been received. Only listeners registered at the time this method is called are notified.
Parameters:
  event - a double-click event
See Also:   IOpenListener.open(OpenEvent)



firePostSelectionChanged
protected void firePostSelectionChanged(SelectionChangedEvent event)(Code)
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.
Parameters:
  event - a selection changed event
See Also:   StructuredViewer.addPostSelectionChangedListener(ISelectionChangedListener)



getColorAndFontCollector
protected ColorAndFontCollector getColorAndFontCollector()(Code)
Get the ColorAndFontCollector for the receiver. ColorAndFontCollector
since:
   3.1



getComparator
public ViewerComparator getComparator()(Code)
Return this viewer's comparator used to sort elements. This method should be used instead of getSorter(). a viewer comparator, or null if none
since:
   3.2



getComparer
public IElementComparer getComparer()(Code)
Returns the comparer to use for comparing elements, or null if none has been set. If specified, the viewer uses this to compare and hash elements rather than the elements' own equals and hashCode methods. the comparer to use for comparing elements ornull



getFilteredChildren
protected Object[] getFilteredChildren(Object parent)(Code)
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.
Parameters:
  parent - the parent element a filtered array of child elements



getFilters
public ViewerFilter[] getFilters()(Code)
Returns this viewer's filters. an array of viewer filters
See Also:   StructuredViewer.setFilters(ViewerFilter[])



getItem
protected Item getItem(int x, int y)(Code)
Returns the item at the given display-relative coordinates, or null if there is no item at that location or the underlying SWT-Control is not made up of Item (e.g ListViewer )

The default implementation of this method returns null.


Parameters:
  x - horizontal coordinate
Parameters:
  y - vertical coordinate the item, or null if there is no item at the givencoordinatesColumnViewer.getItemAt(org.eclipse.swt.graphics.Point)ColumnViewerColumnViewer.getItemAt(org.eclipse.swt.graphics.Point)



getRawChildren
protected Object[] getRawChildren(Object parent)(Code)
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.


Parameters:
  parent - the parent element the child elements



getRoot
protected Object getRoot()(Code)
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.

the root element, or null if none



getSelection
public ISelection getSelection()(Code)
The StructuredViewer implementation of this method returns the result as an IStructuredSelection.

Subclasses do not typically override this method, but implement getSelectionFromWidget(List) instead.

ISelection




getSelectionFromWidget
abstract protected List getSelectionFromWidget()(Code)
Retrieves the selection, as a List, from the underlying widget. the list of selected elements



getSortedChildren
protected Object[] getSortedChildren(Object parent)(Code)
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.
Parameters:
  parent - the parent element a sorted and filtered array of child elements



getSorter
public ViewerSorter getSorter()(Code)
Returns this viewer's sorter, or null if it does not have one. If this viewer has a comparator that was set via setComparator(ViewerComparator) then this method will return null if the comparator is not an instance of ViewerSorter.

It is recommended to use getComparator() instead.

a viewer sorter, or null if none or if the comparator is not an instance of ViewerSorter



handleDispose
protected void handleDispose(DisposeEvent event)(Code)



handleDoubleSelect
protected void handleDoubleSelect(SelectionEvent event)(Code)
Handles a double-click select event from the widget.

This method is internal to the framework; subclassers should not call this method.


Parameters:
  event - the SWT selection event



handleInvalidSelection
protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection)(Code)
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.


Parameters:
  invalidSelection - the selection before the viewer was updated
Parameters:
  newSelection - the selection after the update, or null if none



handleLabelProviderChanged
protected void handleLabelProviderChanged(LabelProviderChangedEvent event)(Code)
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. Subclasses may reimplement or extend.


Parameters:
  event - the event that generated this update



handleOpen
protected void handleOpen(SelectionEvent event)(Code)
Handles an open event from the OpenStrategy.

This method is internal to the framework; subclassers should not call this method.


Parameters:
  event - the SWT selection event



handlePostSelect
protected void handlePostSelect(SelectionEvent e)(Code)
Handles a post select event from the widget.

This method is internal to the framework; subclassers should not call this method.


Parameters:
  e - the SWT selection event



handleSelect
protected void handleSelect(SelectionEvent event)(Code)
Handles a select event from the widget.

This method is internal to the framework; subclassers should not call this method.


Parameters:
  event - the SWT selection event



hasFilters
protected boolean hasFilters()(Code)
Returns whether this viewer has any filters. boolean



hookControl
protected void hookControl(Control control)(Code)



internalRefresh
abstract protected void internalRefresh(Object element)(Code)
Refreshes this viewer starting at the given element.
Parameters:
  element - the element



internalRefresh
protected void internalRefresh(Object element, boolean updateLabels)(Code)
Refreshes this viewer starting at the given element. Labels are updated as described in 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).
Parameters:
  element - the element
Parameters:
  updateLabels - true to update labels for existing elements,false to only update labels as needed, assumingthat labels for existing elements are unchanged.
since:
   2.0




internalUpdate
protected void internalUpdate(Widget widget, Object element, String[] properties)(Code)
Updates the given element's presentation when one or more of its properties changes. Only the given element is updated.

EXPERIMENTAL. Not to be used except by JDT. This method was added to support JDT's explorations into grouping by working sets, which requires viewers to support multiple equal elements. See bug 76482 for more details. This support will likely be removed in Eclipse 3.3 in favor of proper support for multiple equal elements (which was implemented for AbtractTreeViewer in 3.2).


Parameters:
  widget - the widget for the element
Parameters:
  element - the element
Parameters:
  properties - the properties that have changed, or null toindicate unknown



mapElement
protected void mapElement(Object element, Widget item)(Code)
Adds the element item pair to the element map.

This method is internal to the framework; subclassers should not call this method.


Parameters:
  element - the element
Parameters:
  item - the corresponding widget



needsRefilter
protected boolean needsRefilter(Object element, String property)(Code)
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.


Parameters:
  element - the element
Parameters:
  property - the property true if refiltering is required, andfalse otherwise



newHashtable
CustomHashtable newHashtable(int capacity)(Code)
Returns a new hashtable using the given capacity and this viewer's element comparer.
Parameters:
  capacity - the initial capacity of the hashtable a new hashtable
since:
   3.0



preservingSelection
protected void preservingSelection(Runnable updateCode)(Code)
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 handleInvalidSelection if the resulting selection is different from the old selection


Parameters:
  updateCode - the code to run



preservingSelection
void preservingSelection(Runnable updateCode, boolean reveal)(Code)
Attempts to preserves the current selection across a run of the given code, with a best effort to avoid scrolling if reveal is false, or to reveal the selection if reveal is true.

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 handleInvalidSelection if the selection did not take
  • calls postUpdateHook


Parameters:
  updateCode - the code to run
Parameters:
  reveal - true if the selection should be made visible,false if scrolling should be avoided
since:
   3.3



refresh
public void refresh()(Code)



refresh
public void refresh(boolean updateLabels)(Code)
Refreshes this viewer with information freshly obtained from this viewer's model. If updateLabels is true then 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 as refresh().

Note that the implementation may still obtain labels for existing elements even if updateLabels is false. The intent is simply to allow optimization where possible.
Parameters:
  updateLabels - true to update labels for existing elements,false to only update labels as needed, assumingthat labels for existing elements are unchanged.
since:
   2.0




refresh
public void refresh(Object element)(Code)
Refreshes this viewer starting with the given element.

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.


Parameters:
  element - the element



refresh
public void refresh(Object element, boolean updateLabels)(Code)
Refreshes this viewer starting with the given element. Labels are updated as described in 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.


Parameters:
  element - the element
Parameters:
  updateLabels - true to update labels for existing elements,false to only update labels as needed, assumingthat labels for existing elements are unchanged.
since:
   2.0



refreshItem
final protected void refreshItem(Widget widget, Object element)(Code)
Refreshes the given item with the given element. Calls doUpdateItem(..., false).

This method is internal to the framework; subclassers should not call this method.


Parameters:
  widget - the widget
Parameters:
  element - the element



removeDoubleClickListener
public void removeDoubleClickListener(IDoubleClickListener listener)(Code)
Removes the given double-click listener from this viewer. Has no affect if an identical listener is not registered.
Parameters:
  listener - a double-click listener



removeFilter
public void removeFilter(ViewerFilter filter)(Code)
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. If you want to remove more than one filter consider using StructuredViewer.setFilters(ViewerFilter[]) .
Parameters:
  filter - a viewer filter
See Also:   StructuredViewer.setFilters(ViewerFilter[])



removeOpenListener
public void removeOpenListener(IOpenListener listener)(Code)
Removes the given open listener from this viewer. Has no affect if an identical listener is not registered.
Parameters:
  listener - a double-click listener



removePostSelectionChangedListener
public void removePostSelectionChangedListener(ISelectionChangedListener listener)(Code)



resetFilters
public void resetFilters()(Code)
Discards this viewer's filters and triggers refiltering and resorting of the elements.



reveal
abstract public void reveal(Object element)(Code)
Ensures that the given element is visible, scrolling the viewer if necessary. The selection is unchanged.
Parameters:
  element - the element to reveal



setComparator
public void setComparator(ViewerComparator comparator)(Code)
Sets this viewer's comparator to be used for sorting elements, and triggers refiltering and resorting of this viewer's element. null turns sorting off. To get the viewer's comparator, call getComparator().

IMPORTANT: This method was introduced in 3.2. If a reference to this viewer object is passed to clients who call getSorter(), null may be returned from from that method even though the viewer is sorting its elements using the viewer's comparator.


Parameters:
  comparator - a viewer comparator, or null if none
since:
   3.2



setComparer
public void setComparer(IElementComparer comparer)(Code)
Sets the comparer to use for comparing elements, or null to use the default equals and hashCode methods on the elements themselves.
Parameters:
  comparer - the comparer to use for comparing elements ornull



setContentProvider
public void setContentProvider(IContentProvider provider)(Code)



setFilters
public void setFilters(ViewerFilter[] filters)(Code)
Sets the filters, replacing any previous filters, and triggers refiltering and resorting of the elements.
Parameters:
  filters - an array of viewer filters
since:
   3.3



setInput
final public void setInput(Object input)(Code)



setLabelProvider
public void setLabelProvider(IBaseLabelProvider labelProvider)(Code)



setSelection
public void setSelection(ISelection selection, boolean reveal)(Code)



setSelectionToWidget
abstract protected void setSelectionToWidget(List l, boolean reveal)(Code)
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.


Parameters:
  l - list of selected elements (element type: Object)or null if the selection is to be cleared
Parameters:
  reveal - true if the selection is to be made visible,and false otherwise



setSelectionToWidget
protected void setSelectionToWidget(ISelection selection, boolean reveal)(Code)
Converts the selection to a List and calls setSelectionToWidget(List, boolean). The selection is expected to be an IStructuredSelection of elements. If not, the selection is cleared.

Subclasses do not typically override this method, but implement setSelectionToWidget(List, boolean) instead.
Parameters:
  selection - an IStructuredSelection of elements
Parameters:
  reveal - true to reveal the first element in theselection, or false otherwise




setSorter
public void setSorter(ViewerSorter sorter)(Code)
Sets this viewer's sorter and triggers refiltering and resorting of this viewer's element. Passing null turns sorting off.

It is recommended to use setComparator() instead.


Parameters:
  sorter - a viewer sorter, or null if none



setUseHashlookup
public void setUseHashlookup(boolean enable)(Code)
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).
Parameters:
  enable - true to enable hash lookup, andfalse to disable it



testFindItem
public Widget testFindItem(Object element)(Code)
Hook for testing.
Parameters:
  element - Widget



testFindItems
public Widget[] testFindItems(Object element)(Code)
Hook for testing.
Parameters:
  element - Widget[]
since:
   3.2



unmapAllElements
protected void unmapAllElements()(Code)
Removes all elements from the map.

This method is internal to the framework; subclassers should not call this method.




unmapElement
protected void unmapElement(Object element)(Code)
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.


Parameters:
  element - the element



unmapElement
protected void unmapElement(Object element, Widget item)(Code)
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.


Parameters:
  element - the element
Parameters:
  item - the item to unmap
since:
   2.0



update
public void update(Object[] elements, String[] properties)(Code)
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 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 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. Note that resorting does not happen if properties is null.

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.


Parameters:
  elements - the elements
Parameters:
  properties - the properties that have changed, or null toindicate unknown



update
public void update(Object element, String[] properties)(Code)
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 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 does 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.


Parameters:
  element - the element
Parameters:
  properties - the properties that have changed, or null toindicate unknown



updateItem
final protected void updateItem(Widget widget, Object element)(Code)
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).


Parameters:
  widget - the widget
Parameters:
  element - the element



updateSelection
protected void updateSelection(ISelection selection)(Code)
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.updateSelection must be invoked.


Parameters:
  selection - the selection, or null if none



usingElementMap
protected boolean usingElementMap()(Code)
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.

true if the element map is enabled, andfalse if disabled



Methods inherited from org.eclipse.jface.viewers.ContentViewer
public IContentProvider getContentProvider()(Code)(Java Doc)
public Object getInput()(Code)(Java Doc)
public IBaseLabelProvider getLabelProvider()(Code)(Java Doc)
protected void handleDispose(DisposeEvent event)(Code)(Java Doc)
protected void handleLabelProviderChanged(LabelProviderChangedEvent event)(Code)(Java Doc)
protected void hookControl(Control control)(Code)(Java Doc)
protected void labelProviderChanged()(Code)(Java Doc)
public void setContentProvider(IContentProvider contentProvider)(Code)(Java Doc)
public void setInput(Object input)(Code)(Java Doc)
public void setLabelProvider(IBaseLabelProvider labelProvider)(Code)(Java Doc)

Fields inherited from org.eclipse.jface.viewers.Viewer
final protected static String WIDGET_DATA_KEY(Code)(Java Doc)

Methods inherited from org.eclipse.jface.viewers.Viewer
public void addHelpListener(HelpListener listener)(Code)(Java Doc)
public void addSelectionChangedListener(ISelectionChangedListener listener)(Code)(Java Doc)
protected void fireHelpRequested(HelpEvent event)(Code)(Java Doc)
protected void fireSelectionChanged(SelectionChangedEvent event)(Code)(Java Doc)
abstract public Control getControl()(Code)(Java Doc)
public Object getData(String key)(Code)(Java Doc)
abstract public Object getInput()(Code)(Java Doc)
abstract public ISelection getSelection()(Code)(Java Doc)
protected void handleHelpRequest(HelpEvent event)(Code)(Java Doc)
protected void inputChanged(Object input, Object oldInput)(Code)(Java Doc)
abstract public void refresh()(Code)(Java Doc)
public void removeHelpListener(HelpListener listener)(Code)(Java Doc)
public void removeSelectionChangedListener(ISelectionChangedListener listener)(Code)(Java Doc)
public Item scrollDown(int x, int y)(Code)(Java Doc)
public Item scrollUp(int x, int y)(Code)(Java Doc)
public void setData(String key, Object value)(Code)(Java Doc)
abstract public void setInput(Object input)(Code)(Java Doc)
public void setSelection(ISelection selection)(Code)(Java Doc)
abstract public void setSelection(ISelection selection, boolean reveal)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.