How to implement a custom *Info class

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

How to implement a custom *Info class

Postby Marcel Mager » Tue Jun 02, 2009 8:17 am

Hi,

At the moment we are examining the SWT Designer and encountered a problem when extending the Palette.

We would like to do something similar you did with ContolDecorations as they have a visual representation in the

SWT designer although they are apart from the Control hierarchy of SWT. In our case we have a class (e.g.

TextControlDecoration) that wraps two ControlDecorations and a Handler that manages these decorations depending

on a text control’s content.

We registered the class TextControlDecoration to com.instantiations.designer.rcp.wbp-palette.xml and tried to add

it to the Palette using a TextControlDecoration.wbp-component.xml:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">
   <description>TextControlDecoration</description>
   <!-- CREATION -->
   <creation>
      <source><![CDATA[new path.to.package.TextControlDecoration (%parent%)]]></source>
   </creation>
   <!-- CONSTRUCTORS -->
   <constructors>
      <constructor>
         <parameter type="org.eclipse.swt.widgets.Control" parent="true"/>
      </constructor>
   </constructors>
</component>


As a result, the class appears in the Palette but is not dropable to any Control on the Panel.

Then, we followed your ControlDecoration.wbp-component.xml definition as an example and reused your ControlDecoration_Info:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://www.instantiations.com/D2/WBPComponent">
   <model class="com.instantiations.designer.rcp.model.jface.ControlDecoration_Info"/>
   <description>TextControlDecoration</description>
   <!-- CREATION -->
   <creation>
      <source><![CDATA[new path.to.package.TextControlDecoration (%parent%)]]></source>
   </creation>
   <!-- CONSTRUCTORS -->
   <constructors>
      <constructor>
         <parameter type="org.eclipse.swt.widgets.Control" parent="true"/>
      </constructor>
   </constructors>
</component>


As a result, the designer throws an exception

Code: Select all
com.instantiations.designer.core.utils.check.AssertionFailedException: null argument: Can not find method

getImage() in class *



as our TextControlDecoration is neither derived from ControlDecoration nor does it have a

similar API (e.g. a getImage()) method.

Ok, we need a custom implementation for a 'TextControlDecoration_Info' class.

In your documentation we found the hint to subclass CompositeInfo/ControlInfo. However, we do not think that

this is the way to go as TextControlDecoration is apart from the Control hierarchy. A look at

ControlDecoration_Info shows that it directly derives from AbstractComponentInfo.

Unfortunately, there is no example code available that demonstrates how to implement such a *Info class.

At this point we depend on your help as this problem will potentially prevent us from using the SWT designer in the way

it was planed.
Marcel Mager
 
Posts: 2
Joined: Tue Jun 02, 2009 6:26 am

Re: How to implement a custom *Info class

Postby Eric Clayberg » Wed Jun 03, 2009 8:44 am

We'll need to think about this one. Our docs and tutorial on extending he palette are focused on adding new widgets. ContolDecorations are very specialzed components that are visual but are not widgets. Adding them to the palette took quite a bit of speciaized work on our end, and you would need access to quite a bit of source to replicate that.

As it would be good for us to make it easier for folks like yourselves to do this, we would like to use your component as a test case. If you don't mind sending it to us, we can work up the entire implementation and send it back to you.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: Google [Bot] and 2 guests