Community
Participate
Working Groups
A request on the integration of XWT in wizard is submitted in e4 newsgroup: http://www.eclipse.org/forums/index.php?t=msg&th=199619&start=0&S=eeee2217897168580b83685b5756bc21
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.