Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout gl = new GridLayout(3, false);
composite.setLayout(gl);
GridData gd;
mUseExistingKeystore = new Button(composite, SWT.RADIO);
mUseExistingKeystore.setText("Use existing keystore");
mUseExistingKeystore.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
gd.horizontalSpan = 3;
mUseExistingKeystore.setSelection(true);
mCreateKeystore = new Button(composite, SWT.RADIO);
mCreateKeystore.setText("Create new keystore");
mCreateKeystore.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
gd.horizontalSpan = 3;
new Label(composite, SWT.NONE).setText("Location:");
mKeystore = new Text(composite, SWT.BORDER);
mKeystore.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
final Button browseButton = new Button(composite, SWT.PUSH);
browseButton.setText("Browse...");
browseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
FileDialog fileDialog;
if (mUseExistingKeystore.getSelection()) {
fileDialog = new FileDialog(browseButton.getShell(),SWT.OPEN);
fileDialog.setText("Load Keystore");
} else {
fileDialog = new FileDialog(browseButton.getShell(),SWT.SAVE);
fileDialog.setText("Select Keystore Name");
}
String fileName = fileDialog.open();
if (fileName != null) {
mKeystore.setText(fileName);
}
}
});
new Label(composite, SWT.NONE).setText("Password:");
mKeystorePassword = new Text(composite, SWT.BORDER | SWT.PASSWORD);
mKeystorePassword.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
mKeystorePassword.addVerifyListener(sPasswordVerifier);
new Composite(composite, SWT.NONE).setLayoutData(gd = new GridData());
gd.heightHint = gd.widthHint = 0;
mConfirmLabel = new Label(composite, SWT.NONE);
mConfirmLabel.setText("Confirm:");
mKeystorePassword2 = new Text(composite, SWT.BORDER | SWT.PASSWORD);
mKeystorePassword2.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
mKeystorePassword2.addVerifyListener(sPasswordVerifier);
new Composite(composite, SWT.NONE).setLayoutData(gd = new GridData());
gd.heightHint = gd.widthHint = 0;
mKeystorePassword2.setEnabled(false);
// Show description the first time
setErrorMessage(null);
setMessage(null);
setControl(composite);
mUseExistingKeystore.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean createStore = !mUseExistingKeystore.getSelection();
mKeystorePassword2.setEnabled(createStore);
mConfirmLabel.setEnabled(createStore);
mWizard.setKeystoreCreationMode(createStore);
onChange();
}
});
mKeystore.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
mWizard.setKeystore(mKeystore.getText().trim());
onChange();
}
});
mKeystorePassword.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
mWizard.setKeystorePassword(mKeystorePassword.getText());
onChange();
}
});
mKeystorePassword2.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
onChange();
}
});