|
Re: Wizard with xwt [message #637172 is a reply to message #636960] |
Thu, 04 November 2010 13:12 |
Missing name Missing name Messages: 57 Registered: September 2009 |
Member |
|
|
Hello,
I reply to me because I found a solution. I added a class XWTWizardPage which load XWT file.
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 ActionWizard class is the wizard which add pages:
public class ActionWizard extends Wizard {
private PropagationData m_data;
public ActionWizard() {
super();
}
public void addPages() {
addPage(new OnePage(FirstPage.class, data)); // data is used for binding in FirstPage.xwt
addPage(new TwoPage(SecondPage.class, data));// data is used for binding in SecondPage.xwt
}
}
OnePage.java and TwoPage.java extend XWTWizardPage.java.
Then, you have to define FirstPage.xwt which contains a Composite, and FirstPage.java which extends Composite.
The same for SecondPage.
|
|
|
Re: Wizard with xwt [message #637615 is a reply to message #637172] |
Sun, 07 November 2010 21:42 |
Yves YANG Messages: 688 Registered: July 2009 |
Senior Member |
|
|
Can you fill a bug in bugzilla and add your code in it? It helps the
integration in XWT.
Best regards
Yves YANG
"Valoueee" <val.dupin@free.fr> wrote in message
news:iaub9b$o9j$1@news.eclipse.org...
> Hello,
>
> I reply to me because I found a solution. I added a class XWTWizardPage
> which load XWT file.
>
> 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 ActionWizard class is the wizard which add pages:
>
> public class ActionWizard extends Wizard {
> private PropagationData m_data;
> public ActionWizard() {
> super();
> }
>
> public void addPages() { addPage(new OnePage(FirstPage.class,
> data)); // data is used for binding in FirstPage.xwt
> addPage(new TwoPage(SecondPage.class, data));// data is used for
> binding in SecondPage.xwt
> }
> }
>
>
> OnePage.java and TwoPage.java extend XWTWizardPage.java.
>
> Then, you have to define FirstPage.xwt which contains a Composite, and
> FirstPage.java which extends Composite.
> The same for SecondPage.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03870 seconds