modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
| 17 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
| 80 +++++-----
2 files changed, 45 insertions(+), 52 deletions(-)
New commits:
commit c1ddd73fa51dbbdd185558a78b97314b2efa33cf
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Aug 29 17:44:34 2011 -0400
[BZ 34054 - Throws 'Globally uncaught exception' while adding 'Platform
Utilization' on dashboard]
More restructuring of this portlet and its datasource to get it to work
both in the report view and in the portlet view.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
index 84786cf..3d5e107 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformMetricDataSource.java
@@ -18,22 +18,19 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform;
+import java.util.ArrayList;
import java.util.List;
import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
/**
* @author Greg Hinkle
*/
public class PlatformMetricDataSource extends ResourceDatasource {
- private static final Messages MSG = CoreGUI.getMessages();
PlatformSummaryPortlet view;
@@ -47,17 +44,7 @@ public class PlatformMetricDataSource extends ResourceDatasource {
@Override
protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceTextField cpuField = new DataSourceTextField("cpu",
MSG.dataSource_platforms_field_cpu());
- fields.add(cpuField);
- DataSourceTextField memoryField = new DataSourceTextField("memory",
MSG.dataSource_platforms_field_memory());
- fields.add(memoryField);
-
- DataSourceTextField swapField = new DataSourceTextField("swap",
MSG.dataSource_platforms_field_swap());
- fields.add(swapField);
-
- return fields;
+ return new ArrayList<DataSourceField>();
}
@Override
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
index 5bd705e..69ed9f5 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
@@ -84,43 +85,18 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
setWidth100();
setHeight100();
- prefetch();
-
setShowRecordComponents(true);
setShowRecordComponentsByCell(true);
- setUseAllDataSourceFields(true);
setAutoFitData(Autofit.VERTICAL);
setOverflow(Overflow.AUTO);
setAutoFetchData(false);
setDataSource(new PlatformMetricDataSource(this));
- setInitialCriteria(new Criteria(ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.PLATFORM
- .name()));
- }
-
- private void prefetch() {
-
- ResourceTypeCriteria typeCriteria = new ResourceTypeCriteria();
- typeCriteria.addFilterCategory(ResourceCategory.PLATFORM);
- typeCriteria.fetchMetricDefinitions(true);
- typeCriteria.fetchOperationDefinitions(true);
-
- // TODO GH: Find a way to pass resource type criteria lookups through the type
cache
- typeService.findResourceTypesByCriteria(typeCriteria, new
AsyncCallback<PageList<ResourceType>>() {
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_portlet_platform_type_error_1(), caught);
- }
-
- public void onSuccess(PageList<ResourceType> result) {
- setTypes(result);
- fetchData(new Criteria(ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.PLATFORM
- .name()));
- }
- });
}
protected void onDraw() {
+ ArrayList<ListGridField> fields = new ArrayList<ListGridField>(5);
ListGridField nameField = new
ListGridField(ResourceDataSourceField.NAME.propertyName(), MSG
.common_title_name());
@@ -130,13 +106,21 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
+ "</a>";
}
});
- nameField.setWidth("20%");
- setFields(nameField);
+ fields.add(nameField);
+
+ ListGridField versionField = new
ListGridField(ResourceDataSourceField.VERSION.propertyName(), MSG
+ .common_title_version());
+ fields.add(versionField);
- ListGridField cpuField = getField(FIELD_CPU);
- ListGridField memoryField = getField(FIELD_MEMORY);
- ListGridField swapField = getField(FIELD_SWAP);
+ ListGridField cpuField = new ListGridField("cpu",
MSG.dataSource_platforms_field_cpu());
+ fields.add(cpuField);
+ ListGridField memoryField = new ListGridField("memory",
MSG.dataSource_platforms_field_memory());
+ fields.add(memoryField);
+ ListGridField swapField = new ListGridField("swap",
MSG.dataSource_platforms_field_swap());
+ fields.add(swapField);
+ nameField.setWidth("20%");
+ versionField.setWidth("20%");
cpuField.setWidth("20%");
memoryField.setWidth("20%");
swapField.setWidth("20%");
@@ -146,12 +130,30 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
memoryField.setCanSort(false);
swapField.setCanSort(false);
- hideField("id");
- hideField(ResourceDataSourceField.TYPE.propertyName()); // we could show this, do
we want to indicate the kind of platform?
- hideField(ResourceDataSourceField.DESCRIPTION.propertyName()); // we could show
this, but it makes the table wider
- hideField(ResourceDataSourceField.PLUGIN.propertyName()); // its always the
platform plugin, no need to show this
- hideField(ResourceDataSourceField.CATEGORY.propertyName()); // we only ever show
platforms, no need to show this
- hideField(ResourceDataSourceField.AVAILABILITY.propertyName()); // the icon
badging will indicate availability
+ setFields(fields.toArray(new ListGridField[fields.size()]));
+
+ initialFetch();
+ }
+
+ private void initialFetch() {
+
+ ResourceTypeCriteria typeCriteria = new ResourceTypeCriteria();
+ typeCriteria.addFilterCategory(ResourceCategory.PLATFORM);
+ typeCriteria.fetchMetricDefinitions(true);
+ typeCriteria.fetchOperationDefinitions(true);
+
+ // TODO GH: Find a way to pass resource type criteria lookups through the type
cache
+ typeService.findResourceTypesByCriteria(typeCriteria, new
AsyncCallback<PageList<ResourceType>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_portlet_platform_type_error_1(), caught);
+ }
+
+ public void onSuccess(PageList<ResourceType> result) {
+ setTypes(result);
+ fetchData(new Criteria(ResourceDataSourceField.CATEGORY.propertyName(),
ResourceCategory.PLATFORM
+ .name()));
+ }
+ });
}
protected void loadMetricsForResource(Resource resource, final Record record) {
@@ -330,6 +332,7 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
this.property = property;
}
+ @SuppressWarnings("unused")
public String getProperty() {
return property;
}
@@ -344,6 +347,7 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
this.property = property;
}
+ @SuppressWarnings("unused")
public String getProperty() {
return property;
}
@@ -358,6 +362,7 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
this.property = property;
}
+ @SuppressWarnings("unused")
public String getProperty() {
return property;
}
@@ -369,6 +374,7 @@ public class PlatformSummaryPortlet extends LocatableListGrid
implements Portlet
MeasurementDefinition freeSwap, usedSwap, totalSwap;
MeasurementDefinition idleCpu, systemCpu, userCpu, waitCpu;
+ @SuppressWarnings("unused")
MeasurementDefinition[] definitions = new MeasurementDefinition[] { freeMemory,
usedMemory, totalMemory,
freeSwap, usedSwap, totalSwap, idleCpu, systemCpu, userCpu, waitCpu };