| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| |
| <html> |
| <link href="../../book.css" rel="stylesheet" type="text/css" /> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| <title>Extensibility</title> |
| </head> |
| |
| <body> |
| <h1>Extensibility</h1> |
| <p>The following topic relate to extensibility in XWT. There are two |
| types of extensibility: Support of new kind of user-defined UI element |
| and Support register IMetaclass factory via API or EP.</p> |
| |
| <ul> |
| <li><b>User-defined UI Element</b>: The user-defined UI element |
| can be used directly in XWT when the customer respects the SWT standard |
| signature with two arguments: Composite/Widget parent and Style.</li> |
| <li><b>IMetaclass factory</b>: The IMetaclass factory is used to |
| create some special IMetaclass, which takes care of the UI creation.</li> |
| </ul> |
| |
| <h3>User-defined UI Element</h3> |
| <p>XWT support user-defined UI element which is extends from |
| Composite class or other SWT class. The following is a user defined |
| button.</p> |
| <p>XWT XML:</p> |
| <pre> |
| <span class="XMLElementTag"><j:UserControl</span> <span |
| class="XMLAttrTag">xmlns</span>=<span class="XMLAttrValue">"http://www.eclipse.org/xwt/presentation"</span> |
| <span class="XMLAttrTag">xmlns:x</span>=<span |
| class="XMLAttrValue">"http://www.eclipse.org/xwt"</span> |
| <span class="XMLAttrTag">xmlns:j</span>=<span |
| class="XMLAttrValue">"clr-namespace:org.eclipse.xwt.tests.usercontrol"</span> |
| <span class="XMLAttrTag">x:Class</span>=<span |
| class="XMLAttrValue">"org.eclipse.xwt.tests.usercontrol.UserControl"</span><span |
| class="XMLElementTag">></span> |
| ... |
| <span class="XMLElementTag"><Button</span> text="Hello, world" <span |
| class="XMLElementTag">/></span> |
| <span class="XMLElementTag"></j:UserControl></span> |
| </pre> |
| |
| <p>java:</p> |
| |
| <pre> |
| <span class="JavaKeyword">public class</span> UserControl extends Composite { |
| |
| <span class="JavaKeyword">public</span> UserControl(Composite parent, <span |
| class="JavaKeyword">int</span> style) { |
| <span |
| class="JavaKeyword">super</span>(parent, style); |
| } |
| } |
| </pre> |
| |
| <p>The defined element can be used directly in XWT. In XWT XML, only |
| need to declare the application class path and name in the place where |
| you want like the following code.</p> |
| |
| <!-- |
| <p>Please see the example below to show you the User-defined UI |
| element. The customized UI "UserControl" contains a Button |
| with a selection event.</p> |
| |
| <p><img src="images/mac-feature_20.png" /></p> |
| |
| <p>Now integrate the above example into a new XWT component |
| directly. See the screenshot below.</p> |
| <p><img src="images/mac-feature_10.png" /></p> |
| --> |
| |
| <pre> |
| <span class="XMLElementTag"><Composite</span> <span |
| class="XMLAttrTag">xmlns</span>=<span class="XMLAttrValue">"http://www.eclipse.org/xwt/presentation"</span> |
| <span class="XMLAttrTag">xmlns:x</span>=<span |
| class="XMLAttrValue">"http://www.eclipse.org/xwt"</span> |
| <span class="XMLAttrTag">xmlns:y</span>=<span |
| class="XMLAttrValue">"clr-namespace:org.eclipse.xwt.tests.usercontrol"</span><span |
| class="XMLElementTag">></span> |
| <span class="XMLElementTag"><Composite.layout></span> |
| <span |
| class="XMLElementTag"><GridLayout</span> <span class="XMLAttrTag">numColumns</span>=<span |
| class="XMLAttrValue">"2"</span><span class="XMLElementTag">/></span> |
| <span class="XMLElementTag"></Composite.layout></span> |
| <span class="XMLElementTag"><y:UserControl/></span> |
| <span class="XMLElementTag"></Composite></span> |
| </pre> |
| |
| <h3>IMetaclass factory</h3> |
| <p>XWT provide another way to registrate user defined component: |
| IMetaclass Factory. The IMetaclass factory is used to create some |
| special IMetaclass, Metaclass class implement IMetaclass interface. User |
| can define component by a special Metaclass. Compared with User-defined |
| UI Element, these component no need to extends from any SWT class.</p> |
| |
| |
| ******************** Sample ******************** |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| </body> |
| <p><img src="../../cpy.png" /></p> |
| </html> |