Sometimes you need to customize the widgets. To use the drag-drop facility with these custom widgets, they need to be added to the Eclipse palette.

To do this, two files are needed to be changed in Eclipse:

  • eclipse\plugins\org.eclipse.ve.swt_1.1.0.1\palette\palette.properties:

First of all make a Category of the Controls like in-built “SWT Controls, SWT Containers”. E.g. if you want to make the category of MyControl then add the following line in the palette.properties file:

Palette.Category.MyControls = MyControls

  • eclipse\plugins\org.eclipse.ve.swt_1.1.0.1\palette\ swtpalette.xmi:

Now Custom Control can be added to the Category that you have made with the help of the swtpalette.xmi file. E.g. you can add “TextWithLabel” Widget to MyControl category by adding the following lines in the swtpalette.xmi file:

 <org.eclipse.ve.internal.cde.palette:Drawer>

  <entryLabel xsi:type="org.eclipse.ve.internal.cde.utility:TranslatableString" 
    key="Palette.Category.MyControls" bundle="#bundle"/>
  
  <children xsi:type="org.eclipse.ve.internal.cde.palette:EMFCreationToolEntry" 
  icon16Name="platform:/plugin/org.eclipse.ve.swt/icons/full/clcl16/text_obj.gif" 
  creationClassURI="java:/CustomWidgets#TextWithLabel">

  <entryLabel xsi:type="org.eclipse.ve.internal.cde.utility:ConstantString" 
    string="TextWithLabel"/>

  <keyedValues xsi:type="ecore:EStringToStringMapEntry" 
    key="org.eclipse.ve.internal.cde.core.nameincomposition" 
    value="TextWithLabel"/>

  </children>

</org.eclipse.ve.internal.cde.palette:Drawer>