modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java
| 219 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java
| 354 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
| 201 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
| 51 +
11 files changed, 670 insertions(+), 177 deletions(-)
New commits:
commit f92d8d94501b260b1ee96fedf429518886ef5800
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Mar 6 12:39:40 2013 -0800
Charting - Add back in the old dashboard charts to compare with the new d3 dashboard
charts.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index aab866a..a02d074 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -38,9 +38,11 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetr
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOobsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupPkgHistoryPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupD3GraphPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupGraphPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.queue.AutodiscoveryPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.FavoriteResourcesPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceGraphPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
@@ -99,7 +101,9 @@ public class PortletFactory {
globalPortletFactoryMap.put(AutodiscoveryPortlet.KEY,
AutodiscoveryPortlet.Factory.INSTANCE);
globalPortletFactoryMap.put(RecentAlertsPortlet.KEY,
RecentAlertsPortlet.Factory.INSTANCE);
globalPortletFactoryMap.put(ResourceGraphPortlet.KEY,
ResourceGraphPortlet.Factory.INSTANCE);
+ globalPortletFactoryMap.put(ResourceD3GraphPortlet.KEY,
ResourceD3GraphPortlet.Factory.INSTANCE);
globalPortletFactoryMap.put(ResourceGroupGraphPortlet.KEY,
ResourceGroupGraphPortlet.Factory.INSTANCE);
+ globalPortletFactoryMap.put(ResourceGroupD3GraphPortlet.KEY,
ResourceGroupD3GraphPortlet.Factory.INSTANCE);
//conditionally add tags. Defaults to true, not available in JON builds.
if (CoreGUI.isTagsEnabledForUI()) {
globalPortletFactoryMap.put(TagCloudPortlet.KEY,
TagCloudPortlet.Factory.INSTANCE);
@@ -120,7 +124,9 @@ public class PortletFactory {
globalPortletNameMap.put(AutodiscoveryPortlet.NAME, AutodiscoveryPortlet.KEY);
globalPortletNameMap.put(RecentAlertsPortlet.NAME, RecentAlertsPortlet.KEY);
globalPortletNameMap.put(ResourceGraphPortlet.NAME, ResourceGraphPortlet.KEY);
+ globalPortletNameMap.put(ResourceD3GraphPortlet.NAME,
ResourceD3GraphPortlet.KEY);
globalPortletNameMap.put(ResourceGroupGraphPortlet.NAME,
ResourceGroupGraphPortlet.KEY);
+ globalPortletNameMap.put(ResourceGroupD3GraphPortlet.NAME,
ResourceGroupD3GraphPortlet.KEY);
//conditionally add tags. Defaults to true, not available in JON builds.
if (CoreGUI.isTagsEnabledForUI()) {
globalPortletNameMap.put(TagCloudPortlet.NAME, TagCloudPortlet.KEY);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java
new file mode 100644
index 0000000..70aa2ef
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupD3GraphPortlet.java
@@ -0,0 +1,219 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * 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.dashboard.portlets.inventory.groups.graph;
+
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.ResourceGroupMetricGraphView;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
+import
org.rhq.enterprise.gui.coregui.client.components.selector.AssignedItemsChangedEvent;
+import
org.rhq.enterprise.gui.coregui.client.components.selector.AssignedItemsChangedHandler;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.ResourceGroupMetricGraphView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.SingleResourceGroupSelector;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ * @author Mike Thompson
+ */
+public class ResourceGroupD3GraphPortlet extends ResourceGroupMetricGraphView implements
CustomSettingsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceGroupMetricD3";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_groupMetric();
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ public static final String CFG_RESOURCE_GROUP_ID = "resourceGroupId";
+ public static final String CFG_DEFINITION_ID = "definitionId";
+
+ public ResourceGroupD3GraphPortlet(String locatorId) {
+ super(locatorId);
+ setOverflow(Overflow.HIDDEN);
+ }
+
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ Integer integerValue =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID).getIntegerValue();
+ if (integerValue!=null)
+ setEntityId(integerValue);
+
+ PropertySimple propertySimple =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
+ if (propertySimple!=null && propertySimple.getIntegerValue()!=null)
+ setDefinitionId(propertySimple.getIntegerValue());
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_graph());
+ }
+
+ @Override
+ protected void onDraw() {
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ PropertySimple simple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID);
+ if (simple == null || simple.getIntegerValue()==null) {
+ removeMembers(getMembers());
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ } else {
+ super.onDraw();
+ }
+ }
+
+ public DynamicForm getCustomSettingsForm() {
+ final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("Config"));
+ form.setWidth(750);
+ form.setNumCols(1);
+
+ final CanvasItem selectorItem = new CanvasItem();
+ selectorItem.setTitleOrientation(TitleOrientation.TOP);
+ selectorItem.setShowTitle(false);
+
+ final SingleResourceGroupSelector resourceGroupSelector = new
SingleResourceGroupSelector(form
+ .extendLocatorId("Selector"), GroupCategory.COMPATIBLE,
false);
+ resourceGroupSelector.setWidth(700);
+ resourceGroupSelector.setHeight(300);
+ //TODO, would probaby be nice to find a way to seed assigned with the current
group
+ //ListGridRecord rec = new ListGridRecord();
+ //rec.setAttribute("id", getEntityId());
+ //rec.setAttribute("name", "current");
+ //resourceGroupSelector.setAssigned(new ListGridRecord[] { rec });
+
+ final SelectItem metric = new SortedSelectItem(CFG_DEFINITION_ID,
MSG.common_title_metric()) {
+ @Override
+ protected Criteria getPickListFilterCriteria() {
+ Criteria criteria = new Criteria();
+
+ if (resourceGroupSelector.getSelectedItems().size() == 1) {
+ int groupId =
resourceGroupSelector.getSelectedItems().iterator().next().getId();
+ criteria.addCriteria(CFG_RESOURCE_GROUP_ID, groupId);
+ form.setValue(CFG_RESOURCE_GROUP_ID, groupId);
+ }
+ return criteria;
+ }
+ };
+ metric.setWidth(300);
+ metric.setTitleOrientation(TitleOrientation.TOP);
+ metric.setValueField("id");
+ metric.setDisplayField("displayName");
+ metric.setOptionDataSource(new ResourceScheduledMetricDatasource());
+
+ resourceGroupSelector.addAssignedItemsChangedHandler(new
AssignedItemsChangedHandler() {
+
+ public void onSelectionChanged(AssignedItemsChangedEvent event) {
+
+ if (resourceGroupSelector.getSelectedItems().size() == 1) {
+ metric.fetchData();
+ form.clearValue(CFG_DEFINITION_ID);
+ }
+ }
+ });
+
+ final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ Integer integerValue =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID)
+ .getIntegerValue();
+ if (integerValue!=null)
+ form.setValue(CFG_RESOURCE_GROUP_ID, integerValue);
+
+ PropertySimple propertySimple =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
+ if (propertySimple!=null && propertySimple.getIntegerValue()!=null)
+ form.setValue(CFG_DEFINITION_ID, propertySimple.getIntegerValue());
+ }
+
+ selectorItem.setCanvas(resourceGroupSelector);
+ form.setFields(selectorItem, metric, new SpacerItem());
+
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_RESOURCE_GROUP_ID,
form.getValue(CFG_RESOURCE_GROUP_ID)));
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_DEFINITION_ID,
form.getValue(CFG_DEFINITION_ID)));
+
+ configure(portletWindow, storedPortlet);
+
+ redraw();
+ }
+ });
+
+ return form;
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+
+ removeMembers(getMembers());
+
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+ PropertySimple simple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID);
+ if (simple == null | simple.getIntegerValue()==null) {
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ } else {
+ renderGraph();
+ }
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId, EntityContext context) {
+
+ return new ResourceGroupGraphPortlet(locatorId);
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
index 7e75fae..b797372 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
@@ -50,7 +50,9 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
/**
* @author Greg Hinkle
* @author Jay Shaughnessy
+ * @deprecated see ResourceGroupD3GraphPortlet
*/
+@Deprecated
public class ResourceGroupGraphPortlet extends ResourceGroupMetricGraphView implements
CustomSettingsPortlet {
// A non-displayed, persisted identifier for the portlet
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java
new file mode 100644
index 0000000..4e1f9d9
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceD3GraphPortlet.java
@@ -0,0 +1,354 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * 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.dashboard.portlets.inventory.resource.graph;
+
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ */
+
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import
org.rhq.enterprise.gui.coregui.client.components.lookup.ResourceLookupComboBoxItem;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricStackedBarGraph;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3Graph;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.Log;
+import org.rhq.enterprise.gui.coregui.client.util.async.Command;
+import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
+import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ * @author Mike Thompson
+ */
+public class ResourceD3GraphPortlet extends ResourceMetricD3Graph implements
CustomSettingsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceMetricD3";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME =
"d3-"+MSG.view_portlet_defaultName_resourceMetric();
+ public static final String CFG_RESOURCE_ID = "resourceId";
+ public static final String CFG_DEFINITION_ID = "definitionId";
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ public ResourceD3GraphPortlet(String locatorId) {
+ super(locatorId);
+ isPortalGraph = true;
+ setOverflow(Overflow.HIDDEN);
+ setGraph(new MetricStackedBarGraph(new MetricGraphData()));
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ Log.debug("\nResourceD3GraphPortlet Configure !!");
+
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ PropertySimple resourceIdProperty =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
+ PropertySimple measurementDefIdProperty =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
+ if (resourceIdProperty != null && measurementDefIdProperty != null)
{
+ final Integer entityId = resourceIdProperty.getIntegerValue();
+ final Integer measurementDefId =
measurementDefIdProperty.getIntegerValue();
+ if (entityId != null && measurementDefId != null) {
+ graph.setDefinitionId(measurementDefId);
+ graph.setEntityId(entityId);
+ queryResource(entityId, measurementDefId);
+ }
+
+ }
+ }
+ }
+
+ private void queryResource(Integer entityId, final Integer measurementDefId) {
+ ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
+ resourceCriteria.addFilterId(entityId);
+ resourceService.findResourcesByCriteria(resourceCriteria, new
AsyncCallback<PageList<Resource>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(),
caught);
+ }
+
+ @Override
+ public void onSuccess(PageList<Resource> result) {
+ if (result.isEmpty()) {
+ return;
+ }
+ // only concerned with first resource since this is a query by id
+ final Resource resource = result.get(0);
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ typesSet.add(resource.getResourceType().getId());
+ HashSet<String> ancestries = new HashSet<String>();
+ ancestries.add(resource.getAncestry());
+ // In addition to the types of the result resources, get the types of
their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(
+ typesSet.toArray(new Integer[typesSet.size()]),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypesLoadedCallback() {
+
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType>
types) {
+ ResourceType type =
types.get(resource.getResourceType().getId());
+ for (final MeasurementDefinition def :
type.getMetricDefinitions()) {
+ if (def.getId() == measurementDefId) {
+ Log.debug("Found portlet measurement
definition !" + def);
+
+ getJsniChart().setEntityId(resource.getId());
+
getJsniChart().setEntityName(resource.getName());
+ getJsniChart().setDefinition(def);
+
queryMetricsDataForDashboardGraphs(resource.getId(), def);
+ break;
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+
+ private void queryMetricsDataForDashboardGraphs(final Integer entityId, final
MeasurementDefinition def) {
+ final long startTime = System.currentTimeMillis();
+
+ // setting up a deferred Command to execute after all resource queries have
completed (successfully or unsuccessfully)
+ // we know there are exactly 1 resources
+ final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() {
+ @Override
+ /**
+ * Satisfied only after ALL of the metric queries AND availability have
completed
+ */
+ public void execute() {
+ Log.debug("Dashboard chart query total time for entity: " +
entityId + ", MeasurementDef: "
+ + def.getId() + " in " + (System.currentTimeMillis() -
startTime) + " ms");
+ drawGraph();
+ }
+ });
+
+ queryMeasurementsAndMetricData(entityId, def.getId(), countDownLatch);
+ // now the countDown latch will run sometime asynchronously after BOTH the
previous 2 queries have executed
+ }
+
+ private void queryMeasurementsAndMetricData(final Integer entityId, final Integer
definitionId,
+ final CountDownLatch countDownLatch) {
+ final long startTime = System.currentTimeMillis();
+ //
+ GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(entityId,
new int[] { definitionId },
+ 8, MeasurementUtils.UNIT_HOURS, 60,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(),
caught);
+ if(countDownLatch != null){
+ countDownLatch.countDown();
+ }
+ }
+
+ @Override
+ public void onSuccess(final
List<List<MeasurementDataNumericHighLowComposite>> measurementData) {
+ Log.debug("Dashboard Metric data in: " +
(System.currentTimeMillis() - startTime) + " ms.");
+
graph.getMetricGraphData().setMetricData(measurementData.get(0));
+ if(countDownLatch != null){
+ countDownLatch.countDown();
+ }
+ }
+ });
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_graph());
+ }
+
+ @Override
+ protected void onDraw() {
+ Log.debug("ResourceD3GraphPortlet.onDraw()");
+
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ PropertySimple simple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
+ if (simple == null || simple.getIntegerValue() == null) {
+ removeMembers(getMembers());
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ } else {
+ super.onDraw();
+ }
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ final DynamicForm form = new DynamicForm();
+
+ final ResourceLookupComboBoxItem resourceLookupComboBoxItem = new
ResourceLookupComboBoxItem(CFG_RESOURCE_ID,
+ MSG.common_title_resource());
+ resourceLookupComboBoxItem.setWidth(300);
+
+ final SelectItem metric = new SelectItem(CFG_DEFINITION_ID,
MSG.common_title_metric()) {
+ @Override
+ protected Criteria getPickListFilterCriteria() {
+ Criteria criteria = new Criteria();
+
+ if (resourceLookupComboBoxItem.getValue() != null) {
+ int resourceId = (Integer) resourceLookupComboBoxItem.getValue();
+ criteria.addCriteria(CFG_RESOURCE_ID, resourceId);
+ }
+ return criteria;
+ }
+ };
+
+ final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ metric.setWidth(300);
+ metric.setValueField("id");
+ metric.setDisplayField("displayName");
+ metric.setOptionDataSource(new ResourceScheduledMetricDatasource());
+
+ resourceLookupComboBoxItem
+ .addChangedHandler(new
com.smartgwt.client.widgets.form.fields.events.ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+
+ if (form.getValue(CFG_RESOURCE_ID) instanceof Integer) {
+ metric.fetchData();
+ form.clearValue(CFG_DEFINITION_ID);
+ }
+ }
+ });
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ Integer integerValue =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue();
+ if (integerValue != null) {
+ form.setValue(CFG_RESOURCE_ID, integerValue);
+ }
+
+ PropertySimple propertySimple =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
+ if (propertySimple != null && propertySimple.getIntegerValue() !=
null) {
+ form.setValue(CFG_DEFINITION_ID, propertySimple.getIntegerValue());
+ }
+ }
+
+ form.setFields(resourceLookupComboBoxItem, metric);
+
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_RESOURCE_ID,
form.getValue(CFG_RESOURCE_ID)));
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(CFG_DEFINITION_ID,
form.getValue(CFG_DEFINITION_ID)));
+
+ configure(portletWindow, storedPortlet);
+
+ redraw();
+ }
+ });
+
+ return form;
+ }
+
+ @Override
+ public void redraw() {
+ Log.debug("Redraw Portlet Graph and set data");
+ super.redraw();
+
+ removeMembers(getMembers());
+
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+ PropertySimple simple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
+
+ if (simple == null || simple.getIntegerValue() == null) {
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ } else {
+ graph.getMetricGraphData().setEntityId(simple.getIntegerValue());
+ PropertySimple simpleDefId =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
+ graph.getMetricGraphData().setDefinitionId(simpleDefId.getIntegerValue());
+ Log.debug(" *** Redraw Portlet");
+ drawJsniChart();
+ markForRedraw();
+ }
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ @Override
+ public final Portlet getInstance(String locatorId, EntityContext context) {
+
+ return new ResourceD3GraphPortlet(locatorId);
+ }
+ }
+}
+
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
index 482c650..da59f47 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
@@ -18,12 +18,6 @@
*/
package
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
@@ -37,58 +31,40 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import
org.rhq.enterprise.gui.coregui.client.components.lookup.ResourceLookupComboBoxItem;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricStackedBarGraph;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3Graph;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricGraphView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.Log;
-import org.rhq.enterprise.gui.coregui.client.util.async.Command;
-import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch;
-import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
/**
* @author Greg Hinkle
* @author Jay Shaughnessy
+ * @deprecated see ResourceD3GraphPortlet
*/
-public class ResourceGraphPortlet extends ResourceMetricD3Graph implements
CustomSettingsPortlet {
+@Deprecated
+public class ResourceGraphPortlet extends ResourceMetricGraphView implements
CustomSettingsPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceMetric";
// A default displayed, persisted name for the portlet
public static final String NAME = MSG.view_portlet_defaultName_resourceMetric();
- public static final String CFG_RESOURCE_ID = "resourceId";
- public static final String CFG_DEFINITION_ID = "definitionId";
+
// set on initial configuration, the window for this portlet view.
private PortletWindow portletWindow;
+ public static final String CFG_RESOURCE_ID = "resourceId";
+ public static final String CFG_DEFINITION_ID = "definitionId";
+
public ResourceGraphPortlet(String locatorId) {
super(locatorId);
- isPortalGraph = true;
- //setChartHeight("100%");
setOverflow(Overflow.HIDDEN);
- setGraph(new MetricStackedBarGraph(new MetricGraphData()));
}
- @Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- Log.debug("\nPortlet Configure !!");
if (null == this.portletWindow && null != portletWindow) {
this.portletWindow = portletWindow;
@@ -99,133 +75,32 @@ public class ResourceGraphPortlet extends ResourceMetricD3Graph
implements Custo
}
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- PropertySimple resourceIdProperty =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
- PropertySimple measurementDefIdProperty =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
- if (resourceIdProperty != null && measurementDefIdProperty != null)
{
- final Integer entityId = resourceIdProperty.getIntegerValue();
- final Integer measurementDefId =
measurementDefIdProperty.getIntegerValue();
- if (entityId != null && measurementDefId != null) {
- graph.setDefinitionId(measurementDefId);
- graph.setEntityId(entityId);
- Log.debug("Metric Graph Data: " +
graph.getMetricGraphData());
-
- queryResource(entityId, measurementDefId);
- }
-
- }
- }
- }
-
- private void queryResource(Integer entityId, final Integer measurementDefId) {
- ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
-
- ResourceCriteria resourceCriteria = new ResourceCriteria();
- resourceCriteria.addFilterId(entityId);
- resourceService.findResourcesByCriteria(resourceCriteria, new
AsyncCallback<PageList<Resource>>() {
- @Override
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(),
caught);
+ PropertySimple propertySimple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
+ if (propertySimple!=null) {
+ Integer integerValue = propertySimple.getIntegerValue();
+ if (integerValue!=null)
+ setEntityId(integerValue);
}
+ propertySimple =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
+ if (propertySimple!=null) {
- @Override
- public void onSuccess(PageList<Resource> result) {
- if (result.isEmpty()) {
- return;
- }
- // only concerned with first resource since this is a query by id
- final Resource resource = result.get(0);
- HashSet<Integer> typesSet = new HashSet<Integer>();
- typesSet.add(resource.getResourceType().getId());
- HashSet<String> ancestries = new HashSet<String>();
- ancestries.add(resource.getAncestry());
- // In addition to the types of the result resources, get the types of
their ancestry
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- typesSet.toArray(new Integer[typesSet.size()]),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypesLoadedCallback() {
-
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types)
{
- ResourceType type =
types.get(resource.getResourceType().getId());
- for (final MeasurementDefinition def :
type.getMetricDefinitions()) {
- if (def.getId() == measurementDefId) {
- Log.debug("Found portlet measurement definition
!" + def);
-
- getJsniChart().setEntityId(resource.getId());
- getJsniChart().setEntityName(resource.getName());
- getJsniChart().setDefinition(def);
- queryMetricsDataForDashboardGraphs(resource.getId(),
def);
- break;
- }
- }
- }
- });
+ Integer integerValue = propertySimple.getIntegerValue();
+ if (integerValue!=null)
+ setDefinitionId(integerValue);
}
- });
- }
-
- private void queryMetricsDataForDashboardGraphs(final Integer entityId, final
MeasurementDefinition def) {
- final long startTime = System.currentTimeMillis();
-
- // setting up a deferred Command to execute after all resource queries have
completed (successfully or unsuccessfully)
- // we know there are exactly 1 resources
- final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() {
- @Override
- /**
- * Satisfied only after ALL of the metric queries AND availability have
completed
- */
- public void execute() {
- Log.debug("Dashboard chart query total time for entity: " +
entityId + ", MeasurementDef: "
- + def.getId() + " in " + (System.currentTimeMillis() -
startTime) + " ms");
- drawGraph();
- }
- });
-
- queryMeasurementsAndMetricData(entityId, def.getId(), countDownLatch);
- // now the countDown latch will run sometime asynchronously after BOTH the
previous 2 queries have executed
- }
-
- private void queryMeasurementsAndMetricData(final Integer entityId, final Integer
definitionId,
- final CountDownLatch countDownLatch) {
- final long startTime = System.currentTimeMillis();
- //
- GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(entityId,
new int[] { definitionId },
- 8, MeasurementUtils.UNIT_HOURS, 60,
- new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(),
caught);
- if(countDownLatch != null){
- countDownLatch.countDown();
- }
- }
-
- @Override
- public void onSuccess(final
List<List<MeasurementDataNumericHighLowComposite>> measurementData) {
- Log.debug("Dashboard Metric data in: " +
(System.currentTimeMillis() - startTime) + " ms.");
- graph.getMetricGraphData().setMetricData(measurementData.get(0));
- if(countDownLatch != null){
- countDownLatch.countDown();
- }
- }
- });
+ }
}
- @Override
public Canvas getHelpCanvas() {
return new HTMLFlow(MSG.view_portlet_help_graph());
}
@Override
protected void onDraw() {
- Log.debug("ResourceGraphPortlet.onDraw()");
-
DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
PropertySimple simple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
- if (simple == null || simple.getIntegerValue() == null) {
+ if (simple == null || simple.getIntegerValue()==null) {
removeMembers(getMembers());
addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
} else {
@@ -233,12 +108,11 @@ public class ResourceGraphPortlet extends ResourceMetricD3Graph
implements Custo
}
}
- @Override
public DynamicForm getCustomSettingsForm() {
final DynamicForm form = new DynamicForm();
final ResourceLookupComboBoxItem resourceLookupComboBoxItem = new
ResourceLookupComboBoxItem(CFG_RESOURCE_ID,
- MSG.common_title_resource());
+ MSG.common_title_resource());
resourceLookupComboBoxItem.setWidth(300);
final SelectItem metric = new SelectItem(CFG_DEFINITION_ID,
MSG.common_title_metric()) {
@@ -262,24 +136,24 @@ public class ResourceGraphPortlet extends ResourceMetricD3Graph
implements Custo
metric.setOptionDataSource(new ResourceScheduledMetricDatasource());
resourceLookupComboBoxItem
- .addChangedHandler(new
com.smartgwt.client.widgets.form.fields.events.ChangedHandler() {
- public void onChanged(ChangedEvent event) {
+ .addChangedHandler(new
com.smartgwt.client.widgets.form.fields.events.ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
- if (form.getValue(CFG_RESOURCE_ID) instanceof Integer) {
- metric.fetchData();
- form.clearValue(CFG_DEFINITION_ID);
+ if (form.getValue(CFG_RESOURCE_ID) instanceof Integer) {
+ metric.fetchData();
+ form.clearValue(CFG_DEFINITION_ID);
+ }
}
- }
- });
+ });
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
Integer integerValue =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue();
- if (integerValue != null) {
+ if (integerValue!=null) {
form.setValue(CFG_RESOURCE_ID, integerValue);
}
PropertySimple propertySimple =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
- if (propertySimple != null && propertySimple.getIntegerValue() !=
null) {
+ if (propertySimple!=null && propertySimple.getIntegerValue()!=null)
{
form.setValue(CFG_DEFINITION_ID, propertySimple.getIntegerValue());
}
}
@@ -289,9 +163,9 @@ public class ResourceGraphPortlet extends ResourceMetricD3Graph
implements Custo
form.addSubmitValuesHandler(new SubmitValuesHandler() {
public void onSubmitValues(SubmitValuesEvent submitValuesEvent) {
storedPortlet.getConfiguration().put(
- new PropertySimple(CFG_RESOURCE_ID,
form.getValue(CFG_RESOURCE_ID)));
+ new PropertySimple(CFG_RESOURCE_ID,
form.getValue(CFG_RESOURCE_ID)));
storedPortlet.getConfiguration().put(
- new PropertySimple(CFG_DEFINITION_ID,
form.getValue(CFG_DEFINITION_ID)));
+ new PropertySimple(CFG_DEFINITION_ID,
form.getValue(CFG_DEFINITION_ID)));
configure(portletWindow, storedPortlet);
@@ -304,29 +178,22 @@ public class ResourceGraphPortlet extends ResourceMetricD3Graph
implements Custo
@Override
public void redraw() {
- Log.debug("Redraw Portlet Graph and set data");
super.redraw();
removeMembers(getMembers());
DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
PropertySimple simple =
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
-
- if (simple == null || simple.getIntegerValue() == null) {
+ if (simple == null || simple.getIntegerValue()==null) {
addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
} else {
- graph.getMetricGraphData().setEntityId(simple.getIntegerValue());
- PropertySimple simpleDefId =
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID);
- graph.getMetricGraphData().setDefinitionId(simpleDefId.getIntegerValue());
- drawJsniChart();
- markForRedraw();
+ renderGraph();
}
}
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
- @Override
public final Portlet getInstance(String locatorId, EntityContext context) {
return new ResourceGraphPortlet(locatorId);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
index 9dc6fa3..3ad6734 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceMetricsPortlet.java
@@ -55,10 +55,8 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AvailabilityLineGraphType;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView.ChartViewWindow;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.avail.AvailabilityD3Graph;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.D3GraphListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
index 797088b8..d3a8940 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
@@ -62,6 +62,7 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWidgetCanvas
/**
* @author Greg Hinkle
* @author Jay Shaughnessy
+ * @deprecated see AbstractMetricD3GraphView
*/
@Deprecated
public abstract class AbstractMetricGraphView extends LocatableVLayout {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
index 396e259..5b684bb 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java
@@ -43,7 +43,6 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTyp
import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
-@Deprecated
public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView {
/**
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
index 4232284..facafd8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
@@ -43,7 +43,9 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* @author Greg Hinkle
* @author Jay Shaughnessy
+ * @deprecated see ResourceGroupD3MetricGraphView
*/
+@Deprecated
public class ResourceGroupMetricGraphView extends AbstractMetricGraphView {
private HTMLFlow resourceGroupTitle;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index b4be93c..77238c6 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -86,6 +86,7 @@ import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceD3GraphPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.ResourceGraphPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
@@ -756,7 +757,7 @@ public class ResourceTreeView extends LocatableVLayout {
defItem.setSubmenu(defSubItem);
for (final Dashboard d : result) {
- MenuItem addToDBItem = new MenuItem(MSG
+ MenuItem addToDBItem = new MenuItem("d3-"+MSG
.view_tree_common_contextMenu_addChartToDashboard(d.getName()));
defSubItem.addItem(addToDBItem);
@@ -764,12 +765,12 @@ public class ResourceTreeView extends LocatableVLayout {
public void onClick(MenuItemClickEvent
menuItemClickEvent) {
DashboardPortlet p = new DashboardPortlet(MSG
-
.view_tree_common_contextMenu_resourceGraph(), ResourceGraphPortlet.KEY,
+
.view_tree_common_contextMenu_resourceGraph(), ResourceD3GraphPortlet.KEY,
250);
p.getConfiguration().put(
- new
PropertySimple(ResourceGraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ new
PropertySimple(ResourceD3GraphPortlet.CFG_RESOURCE_ID, resource.getId()));
p.getConfiguration().put(
- new
PropertySimple(ResourceGraphPortlet.CFG_DEFINITION_ID, def.getId()));
+ new
PropertySimple(ResourceD3GraphPortlet.CFG_DEFINITION_ID, def.getId()));
d.addPortlet(p);
@@ -793,7 +794,49 @@ public class ResourceTreeView extends LocatableVLayout {
});
}
+
});
+ //@todo: Remove once we have verified the charts
+ // now add the old menu items
+ MenuItem addOldItemToDBItem = new MenuItem(MSG
+
.view_tree_common_contextMenu_addChartToDashboard(d.getName()));
+ defSubItem.addItem(addOldItemToDBItem);
+
+ addOldItemToDBItem.addClickHandler(new ClickHandler() {
+
+ public void onClick(MenuItemClickEvent
menuItemClickEvent) {
+ DashboardPortlet p = new DashboardPortlet(MSG
+
.view_tree_common_contextMenu_resourceGraph(), ResourceGraphPortlet.KEY,
+ 250);
+ p.getConfiguration().put(
+ new
PropertySimple(ResourceGraphPortlet.CFG_RESOURCE_ID, resource.getId()));
+ p.getConfiguration().put(
+ new
PropertySimple(ResourceGraphPortlet.CFG_DEFINITION_ID, def.getId()));
+
+ d.addPortlet(p);
+
+
GWTServiceLookup.getDashboardService().storeDashboard(d,
+ new AsyncCallback<Dashboard>() {
+
+ public void onFailure(Throwable
caught) {
+
CoreGUI.getErrorHandler().handleError(
+
MSG.view_tree_common_contextMenu_saveChartToDashboardFailure(),
+ caught);
+ }
+
+ public void onSuccess(Dashboard
result) {
+ CoreGUI
+ .getMessageCenter()
+ .notify(
+ new Message(
+
MSG.view_tree_common_contextMenu_saveChartToDashboardSuccessful(result
+
.getName()), Message.Severity.Info));
+ }
+ });
+
+ }
+ });
+
}//end dashboard iteration
//add new menu item for adding current graphable element to
view if on Monitor/Graphs tab
commit 3e2c83d71ce45a3fd5f40c596a9db5244a258df1
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Wed Mar 6 09:34:54 2013 -0800
Charting - Fix issues with graphing NaN javascript values.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
index bc90a9b..7da01a9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java
@@ -214,7 +214,7 @@ public class MetricGraphData implements JsonMetricProducer {
public String getChartTitle() {
- return entityName + " - "+definition.getDisplayName();
+ return (entityName == null) ? definition.getDisplayName() : entityName + " -
"+definition.getDisplayName();
}
@@ -279,6 +279,10 @@ public class MetricGraphData implements JsonMetricProducer {
sb.append(" \"low\":" + newLow.getValue() +
",");
sb.append(" \"y\":" + newValue.getValue() +
"},");
} else {
+ // give it some values so that we dont have NaN
+ sb.append(" \"high\":0,");
+ sb.append(" \"low\":0,");
+ sb.append(" \"y\":0,");
sb.append(" \"nodata\":true },");
}
if (!sb.toString().endsWith("},")) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
index f8c5dad..4232284 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
@@ -67,8 +67,6 @@ public class ResourceGroupMetricGraphView extends
AbstractMetricGraphView {
@Override
protected void renderGraph() {
if (null == getDefinition()) {
- Log.debug(" **** Mike Group Metric Graph");
-
ResourceGroupGWTServiceAsync groupService =
GWTServiceLookup.getResourceGroupService();
ResourceGroupCriteria criteria = new ResourceGroupCriteria();