| Summary: | Integration of XWT Form in Wizard | ||
|---|---|---|---|
| Product: | [Technology] XWT | Reporter: | Yves YANG <yves.yang> |
| Component: | Core | Assignee: | Project Inbox <e4.xwt-inbox> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | Flags: | yves.yang:
iplog+
|
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Yves YANG
The code is posted by the author (Valoueee) in e4 newsgroup:
package myproject.ui;
public class XWTWizardPage extends WizardPage {
private Object dataContext;
private BindingContext bindingContext;
private AggregateValidationStatus validationStatus;
private Class<?> contentCLS;
/**
* @param _pageName
*/
protected XWTWizardPage(String _pageName, Class<?> contentCLS,
Object dataContext) {
super(_pageName);
this.contentCLS = contentCLS;
this.dataContext = dataContext;
this.bindingContext = null;
}
protected XWTWizardPage(String pageName, String title,
ImageDescriptor titleImage, Class<?> contentCLS,
Object dataContext) {
super(pageName, title, null);
this.contentCLS = contentCLS;
this.dataContext = dataContext;
this.bindingContext = null;
}
@Override
public void createControl(Composite _parent) {
if (bindingContext == null) {
bindingContext = new BindingContext(_parent);
}
validationStatus = bindingContext.getStatus();
validationStatus.addChangeListener(new IChangeListener() {
public void handleChange(ChangeEvent event) {
IStatus status = (IStatus) validationStatus.getValue();
setMessage(status.getMessage(), status.getSeverity());
}
});
ClassLoader classLoader = Thread.currentThread()
.getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(
contentCLS.getClassLoader());
HashMap<String, Object> newOptions = new HashMap<String, Object>();
newOptions.put(XWTLoader.CONTAINER_PROPERTY, _parent);
Object dataContext = getDataContext();
if (dataContext != null) {
newOptions.put(XWTLoader.DATACONTEXT_PROPERTY, dataContext);
}
BindingContext bindingContext = getBindingContext();
if (bindingContext != null) {
newOptions.put(XWTLoader.BINDING_CONTEXT_PROPERTY,
bindingContext);
}
newOptions.put(XWTLoader.CLASS_PROPERTY, contentCLS);
Control control = XWT.loadWithOptions(getContentURL(), newOptions);
control.setParent(_parent);
setPageComplete(true);
setControl(control);
} catch (Exception e) {
e.printStackTrace();
} finally {
Thread.currentThread().setContextClassLoader(classLoader);
_parent.setVisible(true);
}
}
public URL getContentURL() {
if (contentCLS != null) {
return contentCLS.getResource(contentCLS.getSimpleName()
+ IConstants.XWT_EXTENSION_SUFFIX);
}
return null;
}
public Object getDataContext() {
return dataContext;
}
public BindingContext getBindingContext() {
return bindingContext;
}
}
The contribution code has implemented the data binding such as dataContext and the connection of data binding validation with the Wizard message. I think there are some limitations:
1. It is limited to load the UI through the class.
It is not possible to load a UI Resource with a different name to class or without CLR class
2. The completePage status is not handled automatically.
The XWT UIResource concept should be supported as well to avoid the XML loading and parsing each time. |