Methods Summary |
---|
protected org.eclipse.swt.widgets.Control | createContents(org.eclipse.swt.widgets.Composite parent)
Control control = super.createContents(parent);
mOkButton = getButton(IDialogConstants.OK_ID);
validateButtons();
return control;
|
protected org.eclipse.swt.widgets.Control | createDialogArea(org.eclipse.swt.widgets.Composite parent)
Composite composite = new Composite(parent, SWT.NONE);
GridLayout layout;
composite.setLayout(layout = new GridLayout(2, false));
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(
IDialogConstants.HORIZONTAL_SPACING);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Label l = new Label(composite, SWT.NONE);
l.setText("Name");
mNameField = new Text(composite, SWT.BORDER);
mNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
mNameField.addVerifyListener(this);
if (mName != null) {
mNameField.setText(mName);
}
mNameField.addModifyListener(this);
l = new Label(composite, SWT.NONE);
l.setText("Filter");
mFilterField = new Text(composite, SWT.BORDER);
mFilterField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
if (mFilter != null) {
mFilterField.setText(mFilter);
}
mFilterField.addVerifyListener(this);
mFilterField.addModifyListener(this);
applyDialogFont(composite);
return composite;
|
public java.lang.String | getFilter()Returns the filter for the config. This is only valid if the user clicked OK and
{@link #open()} returned {@link Window#OK}
return mFilter;
|
public java.lang.String | getName()Returns the name of the config. This is only valid if the user clicked OK and {@link #open()}
returned {@link Window#OK}
return mName;
|
public void | modifyText(org.eclipse.swt.events.ModifyEvent e)Callback for text modification in the 2 text fields.
validateButtons();
|
protected void | okPressed()
mName = mNameField.getText();
mFilter = mFilterField.getText().trim();
super.okPressed();
|
private void | validateButtons()Validates the OK button based on the content of the 2 text fields.
mOkButton.setEnabled(mNameField.getText().trim().length() > 0 &&
mFilterField.getText().trim().length() > 0);
|
public void | verifyText(org.eclipse.swt.events.VerifyEvent e)Callback to ensure the content of the text field are proper.
Text source = ((Text)e.getSource());
if (source == mNameField) {
// check for a-zA-Z0-9.
final String text = e.text;
final int len = text.length();
for (int i = 0 ; i < len; i++) {
char letter = text.charAt(i);
if (letter > 255 || Character.isLetterOrDigit(letter) == false) {
e.doit = false;
return;
}
}
} else if (source == mFilterField) {
// we can't validate the content as its typed, but we can at least ensure the characters
// are valid. Same as mNameFiled + the comma.
final String text = e.text;
final int len = text.length();
for (int i = 0 ; i < len; i++) {
char letter = text.charAt(i);
if (letter > 255 || (Character.isLetterOrDigit(letter) == false && letter != ',")) {
e.doit = false;
return;
}
}
}
|