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

Difference between revisions of "XWT/SWT2XWT"

< XWT
Line 1: Line 1:
XWT is a model-based UI solution. It mapps directly with the existing UI libraries using Java refection. Here are some rules to help SWT developer to find XWT UI model and edit directly XWT resource file.
+
XWT is a model-based UI solution.&nbsp;It provides a dynamic 1:1 mapping from UI element classes to XML tags It&nbsp;relies on&nbsp;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&nbsp;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 &lt;Button/&gt;, &lt;Text/&gt;, &lt;Label/&gt; and so on:
 +
<pre>&lt;?xml version="1.0" encoding="utf-8"?&gt;
 +
&lt;Composite xmlns="http://www.eclipse.org/xwt/presentation"&gt;
 +
  &lt;Button/&gt;
 +
&lt;/Composite&gt;</pre>
 +
*Composite tags can have children, these are added as child elements in XML to the containing composite:
 +
<pre>&lt;Composite&gt;
 +
  &lt;Label/&gt;
 +
  &lt;Text/&gt;
 +
&lt;/Composite&gt;</pre>
 +
*Every writable property of the widget class corrresponds to an attribute for the tag. For example: button.setText("sometext") is &lt;Button text="sometext"/&gt;:
 +
<pre>&lt;Button text="hello" enabled="false"/&gt;</pre>
 +
*Style constants are specified with the style attribute in the Language namespace, the value can be multiple and they are separated by a comma:
 +
<pre>&lt;Button text="hello" x:style="TOGGLE,FLAT"/&gt;</pre>
 +
*Colors are specified by name, by the colors defined in SWT (as defined in SWT.COLOR_*) or by a hex triplet:
 +
<pre>&lt;Label foreground="red" background="#EE0000"/&gt;</pre>
 +
*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:":
 +
<pre>&lt;Label image="someimage.png"/&gt;
 +
&lt;Label image="platform:/plugins/org.eclipse.e4.xwt.example/icons/someicon.png"/&gt;</pre>

Revision as of 08:15, 16 December 2009

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