Bug 67305 - Full support for all SWT controls
Summary: Full support for all SWT controls
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: VE (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: David J. Orme CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-15 13:20 EDT by David J. Orme CLA
Modified: 2011-06-13 11:37 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David J. Orme CLA 2004-06-15 13:20:19 EDT
What is an SWT control?

Traditionally, widget toolkits use inheritence to create new controls.  However,
SWT is an exception to this.  Indeed, most SWT controls specifically do not
allow subclassing.  The recommended way to create a new control is to subclass
Composite or Canvas.

However, observing SWT itself reveals that SWT does not always follow this rule.
 For example, some invisible SWT controls inherit from Widget.  And "controls"
that are contained by specific other controls inherit from Item.

Going beyond SWT, we find that Eclipse itself doesn't follow this rule.  For
example, JFace objects inherit from Object.

Extending this logically, one can see instances where a SWT control could
logically inherit from *anywhere* in the Java class hierarchy.

So what really logically constitutes an SWT control?  This bug report is
intended to be an essay and a discussion about this issue so we can discuss it
and make sure that we get this essential part of VE's SWT support right the
first time.  The discussion here will start with the technical requirements for
something to function as an SWT control and will derive the requirements for
something to be an SWT control from there.

Technically speaking, SWT controls have exactly one requirement:

- They must pass their containership parent to the constructor.

From a technical perspective, that's it.

By convention, SWT and JFace add a second requirement:

- SWT controls always use a 2-arg constructor (parent, int style).

Note that the type of the parent object is undefined.  Within SWT itself, you
can find objects that use Composite, Decorations, Control, Table, Widget, and
more as the type of the parent argument.

A second observation is that when one is extending SWT, it sometimes makes no
sense at all to support the "int style" parameter to the constructor.  There
simply are no style bits accepted because the contained control has a fixed set
of style bits that it *must* use.  An example of this case is the "View" class
in the open-source SWTworkbench RCPLite framework.

Lastly, as a practical matter, all of the standard SWT controls follow JavaBean
naming conventions for defining properties and events.  This appears to be the
only thing consistent about SWT's design.  It's also a good thing that this part
of the design is consistent, because otherwise VE support for SWT would be
nearly impossible.

All of this leads to the following definition of a SWT control.  An SWT control is:

- An arbitrary Java object

- That inherits from anything

- That contains either:
    a 1-arg constructor of the form Class(parent)
    a 2-arg constructor of the form Class(parent, int style)

- That follows JavaBean naming conventions for property accessors/setters and
event definition

- That can optionally supply BeanInfo in order to provide a builder with
additional information about properties, events, icons, etc.
Comment 1 David J. Orme CLA 2004-06-15 13:24:31 EDT
Gili,

Per our discussion yesterday, I've recorded my thoughts about the definition of
an SWT control here.  Please add anyone on your team who you think should be in
on this discussion to this bug report and we can hash this out here.


Dave
Comment 2 Gili Mendel CLA 2004-06-16 07:39:16 EDT
There are some complications with JFace like components like 
the TableViewer:
  It may take a parent on a constructor, or 
  It will wrap arround an existing Table (Taking a table on the constructor).

   In the first case, the viewer is the table, in the later case, the viewer is
a helper.   We could provide special handling for a TableViewer, but it becomes
more difficult to understant what Class(parent???) mean
Comment 3 David J. Orme CLA 2004-06-16 09:37:21 EDT
Yes.  In the XSWT SWT XML engine we handle this by looking for a getControl()
method on the object (via reflection).  If we find it, then we assume that we've
got a wrappered JFace-style object and use the getControl() method to find and
set properties.  Essential Data's VirtualTable control uses the same code
pattern as JFace here, so if we support JFace, we'll also support Essential Data.
Comment 4 David J. Orme CLA 2004-09-15 16:41:20 EDT
XSWT has been relaunched as its own open-source project on SourceForge.

http://xswt.sf.net

There's a file release and an update site with the latest code there.

- All the nastiness with namespaces has been fixed
- There's an XSWT-to-Java compiler
- JFace support has been added
- Control construction and property setting is abstracted--one step toward GUI
builder support.