modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java | 42 +++++++--- 1 file changed, 33 insertions(+), 9 deletions(-)
New commits: commit 618b064ab399d0b92dd827158234de4629cba403 Author: Jirka Kremser jkremser@redhat.com Date: Tue Nov 20 15:17:34 2012 +0100
[BZ 850818 - Globally uncaught exception on clicking OK button while adding CLI Script alert notification to the alert definition] Another possible scenario where NPE was thrown was fixed by this commit. (cherry picked from commit 2ae8bc1158dcae4457a738a7414e3c71fd898ed0)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java index cf66856..891875b 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/CliNotificationSenderForm.java @@ -139,8 +139,8 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm { protected List<FormItem> getOnDrawItems() { List<FormItem> items = super.getOnDrawItems();
- TextItem version = new TextItem("editableVersion", MSG - .view_alert_definition_notification_cliScript_editor_newScriptVersion()); + TextItem version = new TextItem("editableVersion", + MSG.view_alert_definition_notification_cliScript_editor_newScriptVersion()); version.setColSpan(getNumCols()); version.addChangedHandler(new ChangedHandler() { public void onChanged(ChangedEvent event) { @@ -178,8 +178,9 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm { } };
- private boolean formBuilt; + private static String FAILED_LAST_TIME = "failed";
+ private boolean formBuilt; private SelectItem repoSelector; private RadioGroupWithComponentsItem packageSelector; private SelectItem existingPackageSelector; @@ -226,8 +227,8 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm { SectionItem userSection = new SectionItem("userSection"); userSection.setDefaultValue(MSG.view_alert_definition_notification_cliScript_editor_whichUser());
- repoSelector = new SelectItem(extendLocatorId("repoSelector"), MSG - .view_alert_definition_notification_cliScript_editor_selectRepo()); + repoSelector = new SortedSelectItem(extendLocatorId("repoSelector"), + MSG.view_alert_definition_notification_cliScript_editor_selectRepo()); repoSelector.setDefaultToFirstOption(true); repoSelector.setWrapTitle(false); repoSelector.setWidth(400); @@ -403,10 +404,19 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm {
private void validatePackage(final AsyncCallback<Void> callback) { if (config.selectedRepo == null) { - repoSelector.setIcons(failureIcon); + setFailed(repoSelector); callback.onFailure(null); return; } + setOk(repoSelector); + if (!existingPackageSelector.isDisabled()) { + if (config.selectedPackage == null) { + setFailed(existingPackageSelector); + callback.onFailure(null); + return; + } + setOk(existingPackageSelector); + } getConfiguration().put(new PropertySimple(PROP_REPO_ID, config.selectedRepo.getId()));
if (packageSelector.getSelectedIndex() == 0) { @@ -417,7 +427,8 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm { if (cliScriptPackageType.getVersionFormat() != null) { String versionRegex = cliScriptPackageType.getVersionFormat().getFullFormatRegex(); if (versionRegex != null) { - if (!matches(uploadForm.getField("version").getValue().toString(), versionRegex)) { + Object version = uploadForm.getField("version").getValue(); + if (version == null ||!matches(version.toString(), versionRegex)) { uploadForm.getItem("editableVersion").setIcons(failureIcon); callback.onFailure(null); return; @@ -529,8 +540,8 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm { form.setTitleOrientation(TitleOrientation.TOP); anotherUserName = new TextItem("userName", MSG.dataSource_users_field_name()); anotherUserPassword = new PasswordItem("password", MSG.common_title_password()); - verifyUserButton = new ButtonItem("verify", MSG - .view_alert_definition_notification_cliScript_editor_verifyAuthentication()); + verifyUserButton = new ButtonItem("verify", + MSG.view_alert_definition_notification_cliScript_editor_verifyAuthentication());
successIcon = new FormItemIcon(); successIcon.setSrc(ImageManager.getAvailabilityIcon(Boolean.TRUE)); @@ -679,6 +690,19 @@ public class CliNotificationSenderForm extends AbstractNotificationSenderForm { GWTServiceLookup.getContentService().findPackageType(null, PACKAGE_TYPE_NAME, handler); }
+ private void setFailed(FormItem item) { + item.setIcons(failureIcon); + item.setAttribute(FAILED_LAST_TIME, true); + } + + private void setOk(FormItem item) { + Boolean lastTimeFail = item.getAttributeAsBoolean(FAILED_LAST_TIME); + if (lastTimeFail != null && lastTimeFail) { + item.setIcons(successIcon); + item.setAttribute(FAILED_LAST_TIME, false); + } + } + private void checkAuthenticationAndDo(final AsyncCallback<Void> action) { String username = anotherUserName.getEnteredValue(); String password = anotherUserPassword.getEnteredValue();
rhq-commits@lists.fedorahosted.org