Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

XWT/SWT2XWT

< XWT
Revision as of 08:15, 16 December 2009 by Unnamed Poltroon (Talk)

XWT is a model-based UI solution. It provides a dynamic 1:1 mapping from UI element classes to XML tags It relies on Java refection to capture UI element model. If you're familiar with eclipse UI framework such as SWT, JFace, Nebula, eclipse forms etc, you only need to learn few rules. And the you can edit your XML file straightforward.

  • Standard UI elements are defined by XML elmeent in a specific namespace, which is in generak a default namespace. The definition of the name is http://www.eclipse.org/xwt/presentation.
  • Another namespace maps XWT with programming language. The definition of the name si http://www.eclipse.org/xwt. And by convention, it is prefixed by "x".
  • Every UI Element class is represented by a XML tag. So you have <Button/>, <Text/>, <Label/> and so on:
<?xml version="1.0" encoding="utf-8"?>
<Composite xmlns="http://www.eclipse.org/xwt/presentation">
   <Button/>
</Composite>
  • Composite tags can have children, these are added as child elements in XML to the containing composite:
<Composite>
   <Label/>
   <Text/>
</Composite>
  • Every writable property of the widget class corrresponds to an attribute for the tag. For example: button.setText("sometext") is <Button text="sometext"/>:
<Button text="hello" enabled="false"/>
  • Style constants are specified with the style attribute in the Language namespace, the value can be multiple and they are separated by a comma:
<Button text="hello" x:style="TOGGLE,FLAT"/>
  • Colors are specified by name, by the colors defined in SWT (as defined in SWT.COLOR_*) or by a hex triplet:
<Label foreground="red" background="#EE0000"/>
  • Images can be specified using either a relative or absolutely path to the .xwt file. You can refer to the root of the containing plugin using the scheme prefix "bundle:":
<Label image="someimage.png"/>
<Label image="platform:/plugins/org.eclipse.e4.xwt.example/icons/someicon.png"/>

Back to the top