modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 22 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 33 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java | 59 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java | 30 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java | 27 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java | 13 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 61 ++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java | 63 ++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java | 14 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java | 64 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java | 21 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java | 15 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 21 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java | 48 -------
14 files changed, 288 insertions(+), 203 deletions(-)
New commits:
commit 3f5cc3fd0018b723b4082e9f31b20d94bed328c8
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Thu Sep 30 21:55:29 2010 -0400
implement v2 of the new MessageCenter API; fix a few bugs in resource and plugin config relating to authz checking and to Save button
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 5e66764..9aaa0e9 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.MetadataType;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
@@ -129,13 +129,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("[" + result + "] alert definitions enabled", Severity.Info));
+ new Message("[" + result + "] alert definitions enabled.", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to enable alert definitions", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to enable alert definitions", caught);
}
});
}
@@ -156,13 +156,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("[" + result + "] alert definitions disabled", Severity.Info));
+ new Message("[" + result + "] alert definitions disabled.", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to disable alert definitions", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to disable alert definitions.", caught);
}
});
}
@@ -183,13 +183,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("[" + result + "] alert definitions deleted", Severity.Info));
+ new Message("[" + result + "] alert definitions deleted.", Severity.Info));
ResourceAlertDefinitionsView.this.refresh();
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to delete alert definitions", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to delete alert definitions.", caught);
}
});
}
@@ -202,13 +202,13 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(Integer result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("Alert definition is created", Severity.Info));
+ new Message("Alert definition is created", Severity.Info));
alertDefinition.setId(result.intValue());
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to create alert definition", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to create alert definition.", caught);
}
});
} else {
@@ -217,12 +217,12 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
@Override
public void onSuccess(AlertDefinition result) {
CoreGUI.getMessageCenter().notify(
- new TransientMessage("Alert definition is updated", Severity.Info));
+ new Message("Alert definition is updated.", Severity.Info));
}
@Override
public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleTransientError("Failed to update alert definition", caught);
+ CoreGUI.getErrorHandler().handleError("Failed to update alert definition.", caught);
}
});
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index 544ded9..eb1e2d2 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -159,8 +159,8 @@ public class ConfigurationEditor extends LocatableVLayout {
private boolean readOnly = false;
private Set<String> invalidPropertyNames = new HashSet<String>();
- private Set<ValidationStateChangeListener> validationStateChangeListeners =
- new HashSet<ValidationStateChangeListener>();
+ private Set<PropertyValueChangeListener> validationStateChangeListeners =
+ new HashSet<PropertyValueChangeListener>();
public static enum ConfigType {
plugin, resource
@@ -218,7 +218,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return this.valuesManager.hasErrors();
}
- public void addValidationStateChangeListener(ValidationStateChangeListener validationStateChangeListener) {
+ public void addValidationStateChangeListener(PropertyValueChangeListener validationStateChangeListener) {
this.validationStateChangeListeners.add(validationStateChangeListener);
}
@@ -250,11 +250,11 @@ public class ConfigurationEditor extends LocatableVLayout {
EnumSet.of(ResourceTypeRepository.MetadataType.resourceConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
+ //System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
definition = types.get(resourceTypeId).getResourceConfigurationDefinition();
if (definition == null) {
loadingLabel.hide();
- showError("No configuration supported for this resource");
+ showError("Configuration is not supported by this Resource.");
}
reload();
}
@@ -276,10 +276,10 @@ public class ConfigurationEditor extends LocatableVLayout {
EnumSet.of(ResourceTypeRepository.MetadataType.pluginConfigurationDefinition),
new ResourceTypeRepository.TypesLoadedCallback() {
public void onTypesLoaded(Map<Integer, ResourceType> types) {
- System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
+ //System.out.println("ConfigDef retreived in: " + (System.currentTimeMillis() - start));
definition = types.get(resourceTypeId).getPluginConfigurationDefinition();
if (definition == null) {
- showError("No configuration supported for this resource");
+ showError("Connection settings are not supported by this Resource.");
}
reload();
}
@@ -556,6 +556,10 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
+ public Set<String> getInvalidPropertyNames() {
+ return this.invalidPropertyNames;
+ }
+
private void buildMapsField(ArrayList<FormItem> fields, PropertyDefinitionMap propertyDefinitionMap,
PropertyMap propertyMap) {
// create the property grid
@@ -564,7 +568,7 @@ public class ConfigurationEditor extends LocatableVLayout {
propertyGrid.getValuesField().setName("Value");
// create the editors
- HashMap<String, FormItem> editorsMap = new HashMap<String, FormItem>();
+ Map<String, FormItem> editorsMap = new HashMap<String, FormItem>();
TextItem textEditor = new TextItem();
editorsMap.put("simpleText", textEditor);
@@ -768,8 +772,8 @@ public class ConfigurationEditor extends LocatableVLayout {
return record;
}
- private FormItem buildSimpleField(ArrayList<FormItem> fields, PropertyDefinitionSimple propertyDefinition,
- boolean oddRow, Property property) {
+ private FormItem buildSimpleField(ArrayList<FormItem> fields, final PropertyDefinitionSimple propertyDefinition,
+ boolean oddRow, final Property property) {
final PropertySimple propertySimple = (PropertySimple) property;
FormItem valueItem = null;
@@ -887,10 +891,11 @@ public class ConfigurationEditor extends LocatableVLayout {
ConfigurationEditor.this.invalidPropertyNames.add(propertySimple.getName());
}
boolean isValidNow = ConfigurationEditor.this.invalidPropertyNames.isEmpty();
- if (isValidNow != wasValidBefore) {
- for (ValidationStateChangeListener validationStateChangeListener : ConfigurationEditor.this.validationStateChangeListeners) {
- validationStateChangeListener.validationStateChanged(isValidNow);
- }
+ boolean validationStateChanged = (isValidNow != wasValidBefore);
+ for (PropertyValueChangeListener validationStateChangeListener : ConfigurationEditor.this.validationStateChangeListeners) {
+ PropertyValueChangeEvent event = new PropertyValueChangeEvent(property, propertyDefinition,
+ validationStateChanged, ConfigurationEditor.this.invalidPropertyNames);
+ validationStateChangeListener.propertyValueChanged(event);
}
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
new file mode 100644
index 0000000..2ba852d
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeEvent.java
@@ -0,0 +1,59 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.configuration;
+
+import java.util.Set;
+
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+
+/**
+ * @author Ian Springer
+ */
+public class PropertyValueChangeEvent {
+ private Property property;
+ private PropertyDefinition propertyDefinition;
+ private boolean validationStateChanged;
+ private Set<String> invalidPropertyNames;
+
+ public PropertyValueChangeEvent(Property property, PropertyDefinition propertyDefinition, boolean validationStatechanged,
+ Set<String> invalidPropertyNames) {
+ this.property = property;
+ this.propertyDefinition = propertyDefinition;
+ this.validationStateChanged = validationStatechanged;
+ this.invalidPropertyNames = invalidPropertyNames;
+ }
+
+ public Property getProperty() {
+ return property;
+ }
+
+ public PropertyDefinition getPropertyDefinition() {
+ return propertyDefinition;
+ }
+
+ public boolean isValidationStateChanged() {
+ return validationStateChanged;
+ }
+
+ public Set<String> getInvalidPropertyNames() {
+ return invalidPropertyNames;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java
new file mode 100644
index 0000000..0ed46f4
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/PropertyValueChangeListener.java
@@ -0,0 +1,30 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.components.configuration;
+
+/**
+ * A listener that can register to be notified by a {@link ConfigurationEditor} when a configuration property's value
+ * changes.
+ *
+ * @author Ian Springer
+ */
+public interface PropertyValueChangeListener {
+ void propertyValueChanged(PropertyValueChangeEvent event);
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
deleted file mode 100644
index 154c731..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ValidationStateChangeListener.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.components.configuration;
-
-/**
- * @author Ian Springer
- */
-public interface ValidationStateChangeListener {
- void validationStateChanged(boolean isValid);
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
index 1008b83..4e66027 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/wizard/GroupCreateWizard.java
@@ -37,7 +37,6 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupListView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
/**
* A wizard for creating a new Resource group.
@@ -92,13 +91,11 @@ public class GroupCreateWizard extends AbstractWizard {
public void onSuccess(ResourceGroup result) {
String groupUrl = LinkManager.getResourceGroupLink(result.getId());
- CoreGUI.getMessageCenter().notify(
- new TransientMessage("Resource group created. [<a href='" + groupUrl + "'>View Group</a>]",
- Message.Severity.Info));
- CoreGUI.getMessageCenter().notify(
- new Message("Created new " + result.getGroupCategory().name().toLowerCase() + " Resource group '"
- + result.getName() + "' with " + memberStep.getSelectedResourceIds().length + " members.",
- Message.Severity.Info));
+ String conciseMessage = "Resource group created. [<a href='" + groupUrl + "'>View Group</a>]";
+ String detailedMessage =
+ "Created new " + result.getGroupCategory().name().toLowerCase() + " Resource group '"
+ + result.getName() + "' with " + memberStep.getSelectedResourceIds().length + " members.";
+ CoreGUI.getMessageCenter().notify(new Message(conciseMessage, detailedMessage));
resourceGroupListView.refresh();
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index b002f0b..f5afb2c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration;
+import java.util.EnumSet;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.IButton;
@@ -33,19 +35,21 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ValidationStateChangeListener;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
+ * A view for editing a Resource's configuration.
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
-public class ResourceConfigurationEditView extends LocatableVLayout implements ValidationStateChangeListener {
+public class ResourceConfigurationEditView extends LocatableVLayout implements PropertyValueChangeListener {
private Resource resource;
private ResourcePermission resourcePermission;
private ConfigurationEditor editor;
@@ -76,20 +80,30 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
save();
}
});
- this.saveButton.disable();
toolStrip.addMember(saveButton);
+
+ addMember(toolStrip);
+ reloadConfiguration();
- editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(), resource.getResourceType().getId());
+ if (!this.resourcePermission.isConfigureWrite()) {
+ Message message = new Message("You do not have permission to edit this Resource's configuration.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+ }
+
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+ editor = new ConfigurationEditor(this.extendLocatorId("Editor"), resource.getId(),
+ resource.getResourceType().getId());
editor.setOverflow(Overflow.AUTO);
editor.addValidationStateChangeListener(this);
editor.setReadOnly(!this.resourcePermission.isConfigureWrite());
-
- addMember(toolStrip);
addMember(editor);
-
- Message message = new TransientMessage("You do not have permission to edit this Resource's configuration.",
- Message.Severity.Info, true);
- CoreGUI.getMessageCenter().notify(message);
}
private void save() {
@@ -103,24 +117,31 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements V
public void onSuccess(ResourceConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
- new Message("Configuration updated for Resource [" + resource.getName() + "].",
+ new Message("Configuration updated.",
+ "Configuration updated for Resource [" + resource.getName() + "].",
Message.Severity.Info));
-
+ reloadConfiguration();
}
});
}
@Override
- public void validationStateChanged(boolean isValid) {
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (isValid) {
- this.saveButton.enable();
- message = new TransientMessage("All configuration properties now have valid values, so the configuration can now be saved.", Message.Severity.Info);
+ if (event.isValidationStateChanged()) {
+ if (event.getInvalidPropertyNames().isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All configuration properties now have valid values, so the configuration can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ } else {
+ this.saveButton.disable();
+ message = new Message("One or more configuration properties have invalid values. The values must be corrected before the configuration can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
} else {
- this.saveButton.disable();
- message = new TransientMessage("One or more configuration properties have invalid values. The values must be corrected before the configuration can be saved.", Message.Severity.Error, true);
+ this.saveButton.enable();
}
- messageCenter.notify(message);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
index 1483cfa..4556da0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/inventory/PluginConfigurationEditView.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory;
+import java.util.EnumSet;
+
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.events.ClickEvent;
@@ -32,19 +34,21 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ValidationStateChangeListener;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.message.MessageCenter;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
+ * A view for editing a Resource's plugin configuration (aka connection settings).
+ *
* @author Greg Hinkle
* @author Ian Springer
*/
-public class PluginConfigurationEditView extends LocatableVLayout implements ValidationStateChangeListener {
+public class PluginConfigurationEditView extends LocatableVLayout implements PropertyValueChangeListener {
private Resource resource;
private ResourcePermission resourcePermission;
private ConfigurationEditor editor;
@@ -76,20 +80,30 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
}
});
this.saveButton.disable();
- toolStrip.addMember(saveButton);
+ toolStrip.addMember(this.saveButton);
+
+ addMember(toolStrip);
+ reloadConfiguration();
+
+ if (!this.resourcePermission.isInventory()) {
+ Message message = new Message("You do not have permission to edit this Resource's connection settings.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ CoreGUI.getMessageCenter().notify(message);
+ }
+ }
- editor = new ConfigurationEditor(this.getLocatorId(), resource.getId(), resource.getResourceType().getId(),
- ConfigurationEditor.ConfigType.plugin);
+ private void reloadConfiguration() {
+ this.saveButton.disable();
+ if (editor != null) {
+ editor.destroy();
+ removeMember(editor);
+ }
+ editor = new ConfigurationEditor(extendLocatorId("Editor"), resource.getId(),
+ resource.getResourceType().getId(), ConfigurationEditor.ConfigType.plugin);
editor.setOverflow(Overflow.AUTO);
editor.addValidationStateChangeListener(this);
editor.setReadOnly(!this.resourcePermission.isInventory());
-
- addMember(toolStrip);
addMember(editor);
-
- Message message = new TransientMessage("You do not have permission to edit this Resource's connection properties.",
- Message.Severity.Info, true);
- CoreGUI.getMessageCenter().notify(message);
}
private void save() {
@@ -103,24 +117,31 @@ public class PluginConfigurationEditView extends LocatableVLayout implements Val
public void onSuccess(PluginConfigurationUpdate result) {
CoreGUI.getMessageCenter().notify(
- new Message("Connection settings updated for Resource [" + resource.getName() + "].",
+ new Message("Connection settings updated.",
+ "Connection settings updated for Resource [" + resource.getName() + "].",
Message.Severity.Info));
-
+ reloadConfiguration();
}
});
}
@Override
- public void validationStateChanged(boolean isValid) {
+ public void propertyValueChanged(PropertyValueChangeEvent event) {
MessageCenter messageCenter = CoreGUI.getMessageCenter();
Message message;
- if (isValid) {
- this.saveButton.enable();
- message = new TransientMessage("All connection properties now have valid values, so the configuration can now be saved.", Message.Severity.Info);
+ if (event.isValidationStateChanged()) {
+ if (event.getInvalidPropertyNames().isEmpty()) {
+ this.saveButton.enable();
+ message = new Message("All connection settings now have valid values, so the settings can now be saved.",
+ Message.Severity.Info, EnumSet.of(Message.Option.Transient));
+ } else {
+ this.saveButton.disable();
+ message = new Message("One or more connection settings have invalid values. The values must be corrected before the settings can be saved.",
+ Message.Severity.Error, EnumSet.of(Message.Option.Transient, Message.Option.Sticky));
+ }
+ messageCenter.notify(message);
} else {
- this.saveButton.disable();
- message = new TransientMessage("One or more connection properties have invalid values. The values must be corrected before the configuration can be saved.", Message.Severity.Error, true);
+ this.saveButton.enable();
}
- messageCenter.notify(message);
}
}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
index 6e5f80b..49bb67e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/ErrorHandler.java
@@ -20,31 +20,21 @@ package org.rhq.enterprise.gui.coregui.client.util;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.TransientMessage;
/**
* @author Greg Hinkle
*/
public class ErrorHandler {
-
public void handleError(String message) {
handleError(message, null);
}
public void handleError(String message, Throwable t) {
- Message errorMessage = new Message(message, (t == null) ? null : t.toString(), Message.Severity.Error);
- CoreGUI.getMessageCenter().notify(errorMessage);
-
- if (t != null) {
- t.printStackTrace();
- }
- }
-
- public void handleTransientError(String message, Throwable t) {
- Message errorMessage = new TransientMessage(message, (t == null) ? null : t.toString(), Message.Severity.Error);
+ Message errorMessage = new Message(message, (t == null) ? null : t.toString(), Message.Severity.Fatal);
CoreGUI.getMessageCenter().notify(errorMessage);
if (t != null) {
+ System.err.println(message);
t.printStackTrace();
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
index 97cc7ab..429ef36 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/Message.java
@@ -19,36 +19,55 @@
package org.rhq.enterprise.gui.coregui.client.util.message;
import java.util.Date;
+import java.util.EnumSet;
/**
+ * A message to be displayed to the user in one or more places.
+ *
* @author Greg Hinkle
+ * @author Ian Springer
*/
@SuppressWarnings({"UnnecessarySemicolon"})
public class Message {
- protected String title;
- protected String detail;
+ protected String conciseMessage;
+ protected String detailedMessage;
protected Date fired = new Date();
protected Severity severity;
+ protected EnumSet<Option> options;
// TODO: Add Debug severity?
- public enum Severity { Info, Warning, Error };
+ public enum Severity { Info, Warning, Error, Fatal };
+ public enum Option { Transient, Sticky, BackgroundJobResult };
+
+ public Message(String conciseMessage, Severity severity) {
+ this(conciseMessage, null, severity);
+ }
+
+ public Message(String conciseMessage, String detailedMessage) {
+ this(conciseMessage, detailedMessage, null);
+ }
+
+ public Message(String conciseMessage, String detailedMessage, Severity severity) {
+ this(conciseMessage, detailedMessage, severity, null);
+ }
- public Message(String title, Severity severity) {
- this(title, null, severity);
+ public Message(String conciseMessage, Severity severity, EnumSet<Option> options) {
+ this(conciseMessage, null, severity, options);
}
- public Message(String title, String detail, Severity severity) {
- this.title = title;
- this.detail = detail;
+ public Message(String conciseMessage, String detailedMessage, Severity severity, EnumSet<Option> options) {
+ this.conciseMessage = conciseMessage;
+ this.detailedMessage = detailedMessage;
this.severity = (severity != null) ? severity : Severity.Info;
+ this.options = (options != null) ? options : EnumSet.noneOf(Option.class);
}
- public String getTitle() {
- return title;
+ public String getConciseMessage() {
+ return conciseMessage;
}
- public String getDetail() {
- return detail;
+ public String getDetailedMessage() {
+ return detailedMessage;
}
public Date getFired() {
@@ -59,13 +78,26 @@ public class Message {
return severity;
}
+ public boolean isTransient() {
+ return options.contains(Option.Transient);
+ }
+
+ public boolean isSticky() {
+ return options.contains(Option.Sticky);
+ }
+
+ public boolean isBackgroundJobResult() {
+ return options.contains(Option.BackgroundJobResult);
+ }
+
@Override
public String toString() {
return "Message{" +
- "title='" + title + '\'' +
- ", detail='" + detail + '\'' +
- ", fired=" + fired +
- ", severity=" + severity +
+ "conciseMessage='" + this.conciseMessage + '\'' +
+ ", detailedMessage='" + this.detailedMessage + '\'' +
+ ", fired=" + this.fired +
+ ", severity=" + this.severity +
+ ", options=" + this.options +
'}';
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
index b03499f..02d3e33 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageBar.java
@@ -46,6 +46,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Info, "InfoBlock");
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Warning, "WarnBlock");
SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Error, "ErrorBlock");
+ SEVERITY_TO_STYLE_NAME_MAP.put(Message.Severity.Fatal, "FatalBlock");
}
private static final Map<Message.Severity, String> SEVERITY_TO_ICON_MAP =
@@ -70,7 +71,7 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
setWidth100();
setAutoHeight();
- setHeight(40);
+ setHeight(35);
setAlign(Alignment.CENTER);
@@ -79,18 +80,16 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
@Override
public void onMessage(Message message) {
- if (message instanceof TransientMessage) {
- TransientMessage transientMessage = (TransientMessage)message;
-
+ if (!message.isBackgroundJobResult()) {
// First clear any previous message.
clearMessage();
- this.label = createLabel(transientMessage);
- addMember(this.label);
+ this.label = createLabel(message);
+ addMember(this.label);
markForRedraw();
// Auto-clear the message after 30 seconds unless it's been designated as sticky.
- if (!transientMessage.isSticky()) {
+ if (!message.isSticky()) {
Timer hideTimer = new Timer() {
@Override
public void run() {
@@ -113,17 +112,15 @@ public class MessageBar extends LocatableHLayout implements MessageCenter.Messag
private Label createLabel(Message message) {
Label label = new Label();
- String contents = message.getTitle();
- if (message.getDetail() != null) {
- contents += ": " + message.getDetail();
- }
+ String contents = (message.getConciseMessage() != null) ?
+ message.getConciseMessage() : message.getDetailedMessage();
label.setContents(contents);
String styleName = (contents != null) ? SEVERITY_TO_STYLE_NAME_MAP.get(message.getSeverity()) : null;
label.setStyleName(styleName);
label.setAutoHeight();
- label.setHeight(35);
+ label.setHeight(30);
label.setAutoWidth();
label.setWidth("75%");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
index a3c29dd..a9070b1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenter.java
@@ -29,12 +29,14 @@ public class MessageCenter {
private LinkedList<Message> messages = new LinkedList<Message>();
private List<MessageListener> listeners = new ArrayList<MessageListener>();
- private static final int MAX_MESSAGES = 100;
+ private static final int MAX_MESSAGES = 50;
public void notify(Message message) {
- this.messages.add(message);
- if (messages.size() > MAX_MESSAGES) {
- messages.removeFirst();
+ if (!message.isTransient()) {
+ this.messages.add(message);
+ if (messages.size() > MAX_MESSAGES) {
+ messages.removeFirst();
+ }
}
for (MessageListener listener : listeners) {
listener.onMessage(message);
@@ -45,6 +47,11 @@ public class MessageCenter {
this.listeners.add(listener);
}
+ /**
+ * Returns a list of recently published non-transient messages.
+ *
+ * @return a list of recently published non-transient messages
+ */
public List<Message> getMessages() {
return messages;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index 5d81646..d51bc47 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -86,7 +86,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
MenuItem[] items = new MenuItem[messages.size()];
for (int i = 0, messagesSize = messages.size(); i < messagesSize; i++) {
final Message message = messages.get(i);
- MenuItem messageItem = new MenuItem(message.title, getSeverityIcon(message.severity));
+ MenuItem messageItem = new MenuItem(message.conciseMessage, getSeverityIcon(message.severity));
items[i] = messageItem;
@@ -116,7 +116,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
form.setWrapItemTitles(false);
StaticTextItem title = new StaticTextItem("title", "Title");
- title.setValue(message.title);
+ title.setValue(message.conciseMessage);
StaticTextItem severity = new StaticTextItem("severity", "Severity");
FormItemIcon severityIcon = new FormItemIcon();
@@ -129,7 +129,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
StaticTextItem detail = new StaticTextItem("detail", "Detail");
detail.setTitleOrientation(TitleOrientation.TOP);
- detail.setValue(message.detail);
+ detail.setValue(message.detailedMessage);
detail.setColSpan(2);
ButtonItem okButton = new ButtonItem("Ok", "Ok");
@@ -139,7 +139,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
form.setItems(title, severity, date, detail, okButton);
final Window window = new LocatableWindow(this.extendLocatorId("Message"));
- window.setTitle(message.title);
+ window.setTitle(message.conciseMessage);
window.setWidth(600);
window.setHeight(400);
window.setIsModal(true);
@@ -157,8 +157,8 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
}
public void onMessage(final Message message) {
- if (!(message instanceof TransientMessage)) {
- final Label label = new Label(message.title);
+ if (!message.isTransient()) {
+ final Label label = new Label(message.conciseMessage);
label.setMargin(5);
label.setAutoFit(true);
label.setHeight(25);
@@ -168,7 +168,7 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
label.setIcon(iconSrc);
- label.setTooltip(message.detail);
+ label.setTooltip(message.detailedMessage);
label.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
@@ -196,13 +196,14 @@ public class MessageCenterView extends LocatableHLayout implements MessageCenter
private String getSeverityIcon(Message.Severity severity) {
String iconSrc = null;
switch (severity) {
- case Info:
+ case Info:
iconSrc = "info/icn_info_blue.png";
break;
- case Warning:
+ case Warning:
iconSrc = "info/icn_info_orange.png";
break;
- case Error:
+ case Error:
+ case Fatal:
iconSrc = "info/icn_info_red.png";
break;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java
deleted file mode 100644
index 318c4a5..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/TransientMessage.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.util.message;
-
-/**
- * @author Ian Springer
- */
-public class TransientMessage extends Message {
- private boolean sticky;
-
- public TransientMessage(String title, Severity severity) {
- super(title, severity);
- }
-
- public TransientMessage(String title, String detail, Severity severity) {
- super(title, detail, severity);
- }
-
- public TransientMessage(String title, Severity severity, boolean sticky) {
- this(title, null, severity, sticky);
- }
-
- public TransientMessage(String title, String detail, Severity severity, boolean sticky) {
- super(title, detail, severity);
- this.sticky = sticky;
- }
-
- public boolean isSticky() {
- return this.sticky;
- }
-}