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.