/** * Validates the input. * <p> * The default implementation of this framework method delegates the request * to the supplied input validator object; if it finds the input invalid, * the error message is displayed in the dialog's message line. This hook * method is called whenever the text changes in the input field. * </p> */ protected void validateInput() { String errorMessage = null; if (validator != null) { errorMessage = validator.isValid(text.getText()); } // Bug 16256: important not to treat "" (blank error) the same as null // (no error) setErrorMessage(errorMessage); }
/** * Validates the input. * <p> * The default implementation of this framework method delegates the request * to the supplied input validator object; if it finds the input invalid, * the error message is displayed in the dialog's message line. This hook * method is called whenever the text changes in the input field. * </p> */ protected void validateInput() { String errorMessage = null; if (validator != null) { errorMessage = validator.isValid(text.getText()); } // Bug 16256: important not to treat "" (blank error) the same as null // (no error) setErrorMessage(errorMessage); }
/** * Validates the input. * <p> * The default implementation of this framework method delegates the request * to the supplied input validator object; if it finds the input invalid, * the error message is displayed in the dialog's message line. This hook * method is called whenever the text changes in the input field. * </p> */ protected void validateInput() { String errorMessage = null; if (validator != null) { errorMessage = validator.isValid(text.getText()); } // Bug 16256: important not to treat "" (blank error) the same as null // (no error) setErrorMessage(errorMessage); }
setErrorMessage(errorMessage);
@Override protected Control createDialogArea(Composite parent) { // create composite Composite composite = (Composite) super.createDialogArea(parent); // create message if (message != null) { Label label = new Label(composite, SWT.WRAP); label.setText(message); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(data); label.setFont(parent.getFont()); } text = new Text(composite, getInputTextStyle()); text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); text.addModifyListener(e -> validateInput()); errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP); errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); errorMessageText.setBackground(errorMessageText.getDisplay() .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); // Set the error message text // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292 setErrorMessage(errorMessage); applyDialogFont(composite); return composite; }
@Override protected Control createDialogArea(Composite parent) { // create composite Composite composite = (Composite) super.createDialogArea(parent); // create message if (message != null) { Label label = new Label(composite, SWT.WRAP); label.setText(message); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); label.setLayoutData(data); label.setFont(parent.getFont()); } text = new Text(composite, getInputTextStyle()); text.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); text.addModifyListener(e -> validateInput()); errorMessageText = new Text(composite, SWT.READ_ONLY | SWT.WRAP); errorMessageText.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); errorMessageText.setBackground(errorMessageText.getDisplay() .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); // Set the error message text // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=66292 setErrorMessage(errorMessage); applyDialogFont(composite); return composite; }