Difference between revisions of "FAQ What kinds of viewers does JFace provide?"

From Eclipsepedia

Jump to: navigation, search
 
m
Line 1: Line 1:
 
JFace includes the following basic types of viewers:
 
JFace includes the following basic types of viewers:
  
 
+
* <tt>TreeViewer</tt> connects to an SWT <tt>Tree</tt> widget.
* <tt>TreeViewer</tt> connects to an SWT <tt>Tree</tt> widget.</li>
+
* <tt>TableViewer</tt> connects to an SWT <tt>Table</tt> widget.
 
+
* <tt>ListViewer</tt> connects to an SWT <tt>List</tt> widget. Note that because the native <tt>List</tt> widget cannot display icons, most applications use a <tt>TableViewer</tt> with a single column instead.
 
+
 
+
 
+
* <tt>TableViewer</tt> connects to an SWT <tt>Table</tt> widget.</li>
+
 
+
 
+
 
+
 
+
* <tt>ListViewer</tt> connects to an SWT <tt>List</tt> widget. Note
+
that because the native <tt>List</tt> widget cannot display icons, most applications
+
use a <tt>TableViewer</tt> with a single column instead.</li>
+
 
+
 
+
 
+
 
+
 
* <tt>TableTreeViewer</tt> connects to an SWT <tt>TableTree</tt> widget.
 
* <tt>TableTreeViewer</tt> connects to an SWT <tt>TableTree</tt> widget.
A <tt>TableTree</tt> is a table whose first column can contain a tree, and each row
+
A <tt>TableTree</tt> is a table whose first column can contain a tree, and each row of the table corresponds to a single item in the tree. The Properties view by default uses a <tt>TableTree</tt>.
of the table corresponds to a single item in the tree. The Properties view by default
+
* <tt>TextViewer</tt> connects to an SWT <tt>StyledText</tt> widget.
uses a <tt>TableTree</tt>.</li>
+
* <tt>CheckboxTreeViewer</tt> and <tt>CheckboxTableViewer</tt> are just like their namesakes, but have a check box next to each tree and table entry.
 
+
 
+
 
+
 
+
* <tt>TextViewer</tt> connects to an SWT <tt>StyledText</tt> widget.</li>
+
 
+
 
+
 
+
 
+
* <tt>CheckboxTreeViewer</tt> and <tt>CheckboxTableViewer</tt> are just
+
like their namesakes, but have a check box next to each tree and table entry.
+
 
+
 
+
 
+
 
+
  
 
In addition to these basic viewer types, you are free to implement your own
 
In addition to these basic viewer types, you are free to implement your own
Line 44: Line 14:
 
subclass.  
 
subclass.  
  
 
+
As a historical footnote, an earlier version of JFace used viewer subclassing as the mechanism for customization.  This led to a profusion of "monolithic" subclasses that were specialized for a particular purpose.  The problem with subclassing is that it provides only one dimension of reuse.  If you wanted to create a new viewer that filtered its contents like viewer <i>X</i> but displayed its contents like viewer <i>Y</i>, you were stuck with subclassing the viewer with the most contents in common and using copy and paste or other ad-hoc forms of reuse to get what you needed.  With the current JFace viewer architecture, each pluggable component provides a new dimension of reuse.  You can still subclass a viewer for very specialized situations, but you can generally get away with instantiating one of the standard viewers and installing the necessary pieces to get the behavior you want.
 
+
As a historical footnote, an earlier version of JFace used
+
viewer subclassing as the mechanism for customization.  This led to a
+
profusion of &#147;monolithic&#148; subclasses that were specialized
+
for a particular purpose.  The problem with subclassing is that it provides only  
+
one dimension of reuse.  If you wanted to create a new viewer that filtered
+
its contents like viewer <i>X</i> but displayed its contents like viewer
+
<i>Y</i>, you were stuck with subclassing the viewer with the most contents
+
in common and using copy and paste or other ad-hoc forms of reuse
+
to get what you needed.  With the current JFace viewer architecture, each
+
pluggable component provides a new dimension of reuse.  You can still
+
subclass a viewer for very specialized situations, but  
+
you can generally get away with instantiating one of the standard viewers and  
+
installing the necessary pieces to get the behavior you want.
+
 
+
 
+
 
+
 
+
 
+
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ What is a viewer?]]
 +
*[[FAQ Why should I use a viewer?]]
  
 
+
{{Template:FAQ_Tagline}}
[[FAQ_What_is_a_viewer%3F]]
+
 
+
 
+
[[FAQ_Why_should_I_use_a_viewer%3F]]
+
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Revision as of 21:42, 29 May 2006

JFace includes the following basic types of viewers:

  • TreeViewer connects to an SWT Tree widget.
  • TableViewer connects to an SWT Table widget.
  • ListViewer connects to an SWT List widget. Note that because the native List widget cannot display icons, most applications use a TableViewer with a single column instead.
  • TableTreeViewer connects to an SWT TableTree widget.

A TableTree is a table whose first column can contain a tree, and each row of the table corresponds to a single item in the tree. The Properties view by default uses a TableTree.

  • TextViewer connects to an SWT StyledText widget.
  • CheckboxTreeViewer and CheckboxTableViewer are just like their namesakes, but have a check box next to each tree and table entry.

In addition to these basic viewer types, you are free to implement your own or to subclass an existing viewer to obtain specialized functionality. Viewers, however, are designed to be extremely customizable without the need to create a subclass.

As a historical footnote, an earlier version of JFace used viewer subclassing as the mechanism for customization. This led to a profusion of "monolithic" subclasses that were specialized for a particular purpose. The problem with subclassing is that it provides only one dimension of reuse. If you wanted to create a new viewer that filtered its contents like viewer X but displayed its contents like viewer Y, you were stuck with subclassing the viewer with the most contents in common and using copy and paste or other ad-hoc forms of reuse to get what you needed. With the current JFace viewer architecture, each pluggable component provides a new dimension of reuse. You can still subclass a viewer for very specialized situations, but you can generally get away with instantiating one of the standard viewers and installing the necessary pieces to get the behavior you want.

See Also:


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.