This class can be extended from the class WizardPage. An abstract base implementation of a wizard page. We can use the following methods to configure the wizard page:
- setDescription
- setErrorMessage
- setImageDescriptor
- setMessage
- setPageComplete
- setPreviousPage
- setTitle
You can get more information about these methods from here.
This is my page template let see what each of these code segmants do.
class RS_wizard_page1 extends WizardPage {
private Text host;
private Text port;
private Text path;
public String server_url;
private Composite container;
private Object user_select_value;
String[][] Value_ecg_providers;
public RS_wizard_page1(Object user_select_value ) {
super("Hello Remote Service Host");
this.user_select_value = user_select_value;
setTitle("Hello Remote Service Host");
setDescription("Enter data for your server");
}
@Override
public void createControl(Composite parent) {
container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
container.setLayout(new GridLayout(1,false));
layout.numColumns = 1;
Label example = new Label(container, SWT.NONE);
example.setText("Example ecftcp://localhost:3282/server");
Label Host = new Label(container, SWT.NONE);
Host.setText("Host");
host = new Text(container, SWT.BORDER | SWT.SINGLE);
host.setText("");
Label Port = new Label(container, SWT.NONE);
Port.setText("Port");
port = new Text(container, SWT.BORDER| SWT.SINGLE);
port.setText("");
Label Path = new Label(container, SWT.NONE);
Path.setText("Path");
path = new Text(container, SWT.BORDER| SWT.SINGLE);
path.setText("");
host.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
if (!host.getText().isEmpty()) {
setPageComplete(true);
}
}
});
port.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (!port.getText().isEmpty()) {
setPageComplete(true);
}
}
});
path.addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (!path.getText().isEmpty()) {
setPageComplete(true);
}
}
});
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
host.setLayoutData(gd);
port.setLayoutData(gd);
path.setLayoutData(gd);
// Required to avoid an error in the system
setControl(container);
setPageComplete(false);
}
public String getText1() {
return host.getText();
}
public String getText2() {
return port.getText();
}
public String getText3() {
return path.getText();
}
//to get the full server url
public String getServer_url() {
return server_url;
}
public void setServer_url(String server_url) {
this.server_url = server_url;
server_url= getText1()+getText2()+getText3();
}
@Override
public IWizardPage getNextPage() {
// TODO Auto-generated method stub
return super.getNextPage();
}
}
From the following part we set the page title,description of the page
super("Hello Remote Service Host");
this.user_select_value = user_select_value;
setTitle("Hello Remote Service Host");
setDescription("Enter data for your server");
Then we need to configure the layout of the page.I have done it in the following way.
container = new Composite(parent, SWT.NONE);
GridLayout layout = new GridLayout();
container.setLayout(new GridLayout(1,false));
layout.numColumns = 1;
Frist I have create a new container. This new instance of this class given its parent and a style value describing its behavior and appearance.
Then I have created a new layout. which controls children of a Composite in a grid. GridLayout has a number of configuration fields, and the controls it lays out can have an associated layout data object, called GridData.
Because I need only one column i have set the numColumns to one.
How to put a label in the page
We can create a new label and have include the parent a composite control which will be the parent of the new instance(in our case it is container ) and this cannot be null and the style we need for the labe control to construct. In here I have put it has none
Label Host = new Label(container, SWT.NONE);
Then we can say what does the label need have say by simpley invoking the method setText.
Host.setText("Host");
Then we create a new instance of this class given with the parent and a style value describing its behavior and appearance.
host = new Text(container, SWT.BORDER | SWT.SINGLE);