Bug 66292 [Dialogs] InputDialog NPE when invoking setErrorMessage(...) too early
06081200 build Setting the error message this early is probably not anticipated, but it shouldn't throw an exception... public class Main { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); InputDialog dialog = new InputDialog (shell, "TEST", "value", "test", null); dialog.setErrorMessage("error"); dialog.open(); shell.open(); } }
bundles/org.eclipse.jface/src/org/eclipse/jface/dialogs/InputDialog.java
*/
    protected void validateInput() {
        String errorMessage = null;
        if (validator != null) {
            errorMessage = validator.isValid(text.getText());
        }
        
        
        setErrorMessage(errorMessage);
    }
    /**
     * Sets or clears the error message.
     * If not <code>null</code>, the OK button is disabled.
     * 
     * @param errorMessage
     *            the error message, or <code>null</code> to clear
     * @since 3.0
     */
    public void setErrorMessage(String errorMessage) {
        errorMessageText.setText(errorMessage == null ? "" : errorMessage); 
        errorMessageText.getParent().update();
        
        
        Control button = getButton(IDialogConstants.OK_ID);
        if (button != null) {
			button.setEnabled(errorMessage == null);
		}
    }
}