I'm new to eclipse plugin - SWT development. I'm trying to create wizard page having number of text fields and combo boxes. For better look n feel I'm trying to use FormToolkit for creating components and add them in ScrolledForm. But with this nothing is rendered on wizard page at runtime and there is no error also.
Questions:
- Is it possible to have scrolled container inside wizard page?
Can we mix JFace and forms api? (removed unwanted code) Here is wizard page code:
public class ContactWizardPage extends WizardPage { private static int counter; private Form form;
public ContactWizardPage() { super("New Contact Wizard" + ++counter, "New Contact Wizard" + counter, null); setMessage("Please enter contact info." + counter); } public void createControl(final Composite parent) { createControlWithoutToolkit(parent); // commenting out toolkit code// createControlWithToolkit(parent); }
public void createControlWithoutToolkit(final Composite parent) { Composite composite = new Composite(parent, SWT.DEFAULT); composite.setLayout(new GridLayout(2, true)); Label lblFirstName = new Label(composite, SWT.FLAT); lblFirstName.setText("First Name"); Label lblLastName = new Label(composite, SWT.FLAT); lblLastName.setText("Last Name"); Text txtFirstName = new Text(composite, SWT.FLAT); Text txtLastName = new Text(composite, SWT.FLAT); Label lblEmail = new Label(composite, SWT.FLAT); lblEmail.setText("Email"); GridDataFactory.swtDefaults().span(2, 1).align( SWT.FILL, SWT.BEGINNING).applyTo(lblEmail); Text txtEmail = new Text(composite, SWT.FLAT); GridDataFactory.swtDefaults().span(2, 1).align( SWT.FILL, SWT.BEGINNING).applyTo(txtEmail); setControl(composite); } public void createControlWithToolkit(final Composite parent) { FormToolkit toolkit = new FormToolkit(Display.getCurrent()); ScrolledForm form = toolkit.createScrolledForm(parent); Composite composite = form.getBody(); composite.setLayout(new GridLayout(2, true)); Label lblFirstName = toolkit.createLabel(composite, "First Name"); Label lblLastName = toolkit.createLabel(composite, "Last Name"); Text txtFirstName = toolkit.createText(composite, ""); Text txtLastName = toolkit.createText(composite, ""); Label lblEmail = toolkit.createLabel(composite, "Email"); GridDataFactory.swtDefaults().span(2, 1).align( SWT.FILL, SWT.BEGINNING).applyTo(lblEmail); Text txtEmail = toolkit.createText(composite, ""); GridDataFactory.swtDefaults().span(2, 1).align( SWT.FILL, SWT.BEGINNING).applyTo(txtEmail); setControl(composite); }}
Here is Wizard code:
public class SampleNewWizard extends Wizard implements INewWizard {
public SampleNewWizard() {
super();
setNeedsProgressMonitor(true);
}
@Override
public IWizardPage getNextPage(IWizardPage page) {
return super.getNextPage(page);
}
public void addPages() {
addPage(new ContactWizardPage());
addPage(new ContactWizardPage());
addPage(new ContactWizardPage());
addPage(new ContactWizardPage());
}
public boolean performFinish() {
return true;
}
public void init(IWorkbench workbench, IStructuredSelection selection) {
}
}
With this code first page of wizard shows fine but second page is never rendered properly. :( here are screenshots: first page:

second page:

FormToolkitin wizard pages in the Eclipse code.FormToolkitjust uses jface internally so there should not be a problem in mixing them. If you add some of your code we may be able to see what is wrong. - greg-449