modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
| 92 ++++------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 3
3 files changed, 47 insertions(+), 50 deletions(-)
New commits:
commit 5e00d3c76b16f5e2f1e8c26467c3c1599add8e1c
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Fri Mar 25 17:16:06 2011 -0400
make sure config editor renders everything appropriately when in read-only mode
(
https://bugzilla.redhat.com/show_bug.cgi?id=680233)
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 9765188..449e9c3 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
@@ -344,10 +344,6 @@ public class ConfigurationEditor extends LocatableVLayout {
}
public void reload() {
- /*if (this.loaded && !this.reloadable) {
- return;
- }*/
-
if (this.configurationDefinition == null || this.configuration == null) {
// Wait for both to load.
return;
@@ -364,13 +360,7 @@ public class ConfigurationEditor extends LocatableVLayout {
if (configurationDefinition.getConfigurationFormat() ==
ConfigurationFormat.STRUCTURED
|| configurationDefinition.getConfigurationFormat() ==
ConfigurationFormat.STRUCTURED_AND_RAW) {
Log.info("Building structured configuration editor...");
- LocatableVLayout structuredConfigLayout = null;
- try {
- structuredConfigLayout = buildStructuredPane();
- } catch (RuntimeException e) {
- e.printStackTrace();
- throw e;
- }
+ LocatableVLayout structuredConfigLayout = buildStructuredPane();
addMember(structuredConfigLayout);
} else {
Label label = new Label("Structured configuration is not
supported.");
@@ -1267,7 +1257,9 @@ public class ConfigurationEditor extends LocatableVLayout {
FormItem valueItem = null;
boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple,
propertySimple);
- if (propertyIsReadOnly) {
+ // TODO (ips, 03/25/11): We eventually want to use StaticTextItems for read-only
PASSWORD props too, but we have
+ // to wait until we implement masking/unmasking of PASSWORD
props at the SLSB layer first.
+ if (propertyIsReadOnly && propertyDefinitionSimple.getType() !=
PropertySimpleType.PASSWORD) {
valueItem = new StaticTextItem();
} else {
List<PropertyDefinitionEnumeration> enumeratedValues =
propertyDefinitionSimple.getEnumeratedValues();
@@ -1319,7 +1311,7 @@ public class ConfigurationEditor extends LocatableVLayout {
}
}
- valueItem.setDisabled(isUnset(propertyDefinitionSimple, propertySimple));
+ valueItem.setDisabled(propertyIsReadOnly || isUnset(propertyDefinitionSimple,
propertySimple));
List<Validator> validators = buildValidators(propertyDefinitionSimple,
propertySimple);
valueItem.setValidators(validators.toArray(new
Validator[validators.size()]));
@@ -1348,7 +1340,7 @@ public class ConfigurationEditor extends LocatableVLayout {
valueItem.setWidth(220);
/*
- Click handlers seem to be turned off for disabled fields... need an
alternative
+ TODO: Click handlers seem to be turned off for disabled fields... need to
find an alternative.
valueItem.addClickHandler(new
com.smartgwt.client.widgets.form.fields.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
com.allen_sauer.gwt.log.client.Log.info("Click in value
field");
@@ -1532,7 +1524,7 @@ public class ConfigurationEditor extends LocatableVLayout {
private void displayMapEditor(final ListGrid summaryTable, final
PropertyMapListGridRecord existingRecord,
PropertyDefinitionMap definition, final PropertyList
list, final PropertyMap map,
- boolean mapReadOnly) {
+ final boolean mapReadOnly) {
final List<PropertyDefinition> memberDefinitions = new
ArrayList<PropertyDefinition>(definition
.getPropertyDefinitions().values());
@@ -1542,7 +1534,8 @@ public class ConfigurationEditor extends LocatableVLayout {
final PropertyMap workingMap = (newRow) ? new PropertyMap(definition.getName()) :
map.deepCopy(true);
final LocatableWindow popup = new
LocatableWindow(extendLocatorId("MapEditor"));
- popup.setTitle(MSG.view_configEdit_editRow());
+ String title = (mapReadOnly) ? MSG.view_configEdit_viewRow() :
MSG.view_configEdit_editRow();
+ popup.setTitle(title);
popup.setWidth(800);
popup.setHeight(600);
popup.setIsModal(true);
@@ -1568,31 +1561,33 @@ public class ConfigurationEditor extends LocatableVLayout {
}
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- if (!childForm.validate()) {
- okButton.disable();
- return;
- }
- if (newRow) {
- try {
- list.add(workingMap);
- int index = list.getList().size() - 1;
- PropertyMapListGridRecord record = new
PropertyMapListGridRecord(workingMap, index,
- memberDefinitions);
- summaryTable.addData(record);
- } catch (Exception e) {
- e.printStackTrace();
+ if (!mapReadOnly) {
+ if (!childForm.validate()) {
+ okButton.disable();
+ return;
}
- } else {
- try {
- mergePropertyMap(workingMap, map, memberDefinitions);
- existingRecord.refresh();
- summaryTable.updateData(existingRecord);
- } catch (Exception e) {
- e.printStackTrace();
+ if (newRow) {
+ try {
+ list.add(workingMap);
+ int index = list.getList().size() - 1;
+ PropertyMapListGridRecord record = new
PropertyMapListGridRecord(workingMap, index,
+ memberDefinitions);
+ summaryTable.addData(record);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ mergePropertyMap(workingMap, map, memberDefinitions);
+ existingRecord.refresh();
+ summaryTable.updateData(existingRecord);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
+ firePropertyChangedEvent(list, null, true);
+ summaryTable.redraw();
}
- firePropertyChangedEvent(list, null, true);
- summaryTable.redraw();
layout.destroy();
popup.destroy();
@@ -1608,20 +1603,21 @@ public class ConfigurationEditor extends LocatableVLayout {
okButton.setDisabled(false);
}
});
+ buttonBar.addMember(okButton);
- final IButton cancelButton = new
LocatableIButton(buttonBar.extendLocatorId("Cancel"),
MSG.common_button_cancel());
- cancelButton.addClickHandler(new
com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- layout.destroy();
- popup.destroy();
- }
- });
+ if (!mapReadOnly) {
+ final IButton cancelButton = new
LocatableIButton(buttonBar.extendLocatorId("Cancel"),
MSG.common_button_cancel());
+ cancelButton.addClickHandler(new
com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ layout.destroy();
+ popup.destroy();
+ }
+ });
+ buttonBar.addMember(cancelButton);
+ }
- buttonBar.setMembers(okButton, cancelButton);
layout.addMember(buttonBar);
-
popup.addItem(layout);
-
popup.show();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
index 08c94d7..a080f13 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/configuration/TestConfigurationFactory.java
@@ -226,7 +226,7 @@ public abstract class TestConfigurationFactory {
string2Prop.setErrorMessage("illegal value!");
configuration.put(string2Prop);
configuration.put(new PropertySimple("LongString", "blah blah
blah\nblah blah blah"));
- configuration.put(new PropertySimple("Password", null));
+ configuration.put(new PropertySimple("Password", "ou812"));
configuration.put(new PropertySimple("Boolean", false));
configuration.put(new PropertySimple("Integer", 666));
configuration.put(new PropertySimple("Float", Math.PI));
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index df17ca8..8317263 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1332,7 +1332,8 @@ view_configEdit_addItem = Add Item to List
view_configEdit_confirm_1 = Are you sure you want to delete the selected properties from
the set?
view_configEdit_confirm_2 = Are you sure you want to delete this row?
view_configEdit_confirm_3 = Are you sure you want to delete the [{0}] selected [{1}]?
-view_configEdit_editRow = Edit Configuration Row
+view_configEdit_viewRow = View Row
+view_configEdit_editRow = Edit Row
view_configEdit_enterPropName = Enter the name of the property to be added.
view_configEdit_error_1 = Configuration is not supported by this Resource.
view_configEdit_error_2 = Connection settings are not supported by this Resource.