modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
| 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
| 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
| 201 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
| 181 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
| 181 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
| 351 +++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
| 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
| 134 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
| 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
| 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
| 156 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
| 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
| 380 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
| 42 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java
| 65 +
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 6
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
| 3
18 files changed, 1201 insertions(+), 596 deletions(-)
New commits:
commit 41b30a2488ec12255afacb9a293b99a7b2553df5
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 21 17:54:27 2011 -0400
Metric Graph Portlet Work
Fix issues with adding metric portlets from the resource and group
trees. In particular, add missing support for the group tree, and group
metric graphs in general.
- refactor and rename to use an AbstractMetricGraphView supporting resource
and resource group views and portlets.
- add relevant resource or group name info to the portlets so you can see
what it is the metric data actually comes from.
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 98220d7..fa76473 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
@@ -33,9 +33,10 @@ 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.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.GraphPortlet;
+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;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedResourcesPortlet;
@@ -71,8 +72,8 @@ public class PortletFactory {
private static HashMap<String, String> registeredPortletIconMap;
static {
- //############## Default Dashboard ############################
- //defines portlet factory mappings for landing page Dashboard
+ // ############# Global Dashboard ############################
+ // defines portlet factory mappings for global Dashboard
registeredPortletFactoryMap = new HashMap<String, PortletViewFactory>();
registeredPortletFactoryMap.put(InventorySummaryPortlet.KEY,
InventorySummaryPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(RecentlyAddedResourcesPortlet.KEY,
@@ -80,7 +81,8 @@ public class PortletFactory {
registeredPortletFactoryMap.put(PlatformSummaryPortlet.KEY,
PlatformSummaryPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(AutodiscoveryPortlet.KEY,
AutodiscoveryPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(RecentAlertsPortlet.KEY,
RecentAlertsPortlet.Factory.INSTANCE);
- registeredPortletFactoryMap.put(GraphPortlet.KEY,
GraphPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(ResourceGraphPortlet.KEY,
ResourceGraphPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(ResourceGroupGraphPortlet.KEY,
ResourceGroupGraphPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(TagCloudPortlet.KEY,
TagCloudPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(FavoriteResourcesPortlet.KEY,
FavoriteResourcesPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(MashupPortlet.KEY,
MashupPortlet.Factory.INSTANCE);
@@ -88,14 +90,15 @@ public class PortletFactory {
registeredPortletFactoryMap.put(ProblemResourcesPortlet.KEY,
ProblemResourcesPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(OperationsPortlet.KEY,
OperationsPortlet.Factory.INSTANCE);
- //defines portlet name mappings for landing page Dashboard
+ // defines portlet name mappings for global Dashboard
registeredPortletNameMap = new HashMap<String,
String>(registeredPortletFactoryMap.size());
registeredPortletNameMap.put(InventorySummaryPortlet.KEY,
InventorySummaryPortlet.NAME);
registeredPortletNameMap.put(RecentlyAddedResourcesPortlet.KEY,
RecentlyAddedResourcesPortlet.NAME);
registeredPortletNameMap.put(PlatformSummaryPortlet.KEY,
PlatformSummaryPortlet.NAME);
registeredPortletNameMap.put(AutodiscoveryPortlet.KEY,
AutodiscoveryPortlet.NAME);
registeredPortletNameMap.put(RecentAlertsPortlet.KEY, RecentAlertsPortlet.NAME);
- registeredPortletNameMap.put(GraphPortlet.KEY, GraphPortlet.NAME);
+ registeredPortletNameMap.put(ResourceGraphPortlet.KEY,
ResourceGraphPortlet.NAME);
+ registeredPortletNameMap.put(ResourceGroupGraphPortlet.KEY,
ResourceGroupGraphPortlet.NAME);
registeredPortletNameMap.put(TagCloudPortlet.KEY, TagCloudPortlet.NAME);
registeredPortletNameMap.put(FavoriteResourcesPortlet.KEY,
FavoriteResourcesPortlet.NAME);
registeredPortletNameMap.put(MashupPortlet.KEY, MashupPortlet.NAME);
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
new file mode 100644
index 0000000..9ac2534
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/groups/graph/ResourceGroupGraphPortlet.java
@@ -0,0 +1,201 @@
+/*
+ * 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.
+ */
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.groups.graph;
+
+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.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.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
+ */
+public class ResourceGroupGraphPortlet extends ResourceGroupMetricGraphView implements
CustomSettingsPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "ResourceGroupMetric";
+ // 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 ResourceGroupGraphPortlet(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) {
+
setEntityId(storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID).getIntegerValue());
+
setDefinitionId(storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID).getIntegerValue());
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_graph());
+ }
+
+ @Override
+ protected void onDraw() {
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ super.onDraw();
+ } else {
+ removeMembers(getMembers());
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ 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 SelectItem(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) {
+ form.setValue(CFG_RESOURCE_GROUP_ID,
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID)
+ .getIntegerValue());
+ form.setValue(CFG_DEFINITION_ID,
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID)
+ .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();
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_GROUP_ID) != null) {
+ renderGraph();
+ } else {
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new ResourceGroupGraphPortlet(locatorId);
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
deleted file mode 100644
index 821fe56..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/GraphPortlet.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.
- */
-package
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph;
-
-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.configuration.PropertySimple;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-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.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.SmallGraphView;
-
-/**
- * @author Greg Hinkle
- */
-public class GraphPortlet extends SmallGraphView implements CustomSettingsPortlet {
-
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "Graph";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_graph();
-
- // 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 static final String CFG_RESOURCE_GROUP_ID = "resourceGroupId";
-
- public GraphPortlet(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_ID) != null) {
-
setResourceId(storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue());
-
setDefinitionId(storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID).getIntegerValue());
- }
- }
-
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_graph());
- }
-
- @Override
- protected void onDraw() {
- DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
-
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- super.onDraw();
- } else {
- removeMembers(getMembers());
- addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
- }
- }
-
- 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("defininitionId");
- }
- }
- });
-
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- form.setValue(CFG_RESOURCE_ID,
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID)
- .getIntegerValue());
- form.setValue(CFG_DEFINITION_ID,
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID)
- .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() {
- super.redraw();
-
- removeMembers(getMembers());
-
- DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
- if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
- renderGraph();
- } else {
- addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
- }
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance(String locatorId) {
-
- return new GraphPortlet(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
new file mode 100644
index 0000000..820cf4f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java
@@ -0,0 +1,181 @@
+/*
+ * 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.
+ */
+package
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph;
+
+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.configuration.PropertySimple;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+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.inventory.resource.detail.monitoring.ResourceMetricGraphView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+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();
+
+ // 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);
+ 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_ID) != null) {
+
setEntityId(storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue());
+
setDefinitionId(storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID).getIntegerValue());
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_graph());
+ }
+
+ @Override
+ protected void onDraw() {
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ super.onDraw();
+ } else {
+ removeMembers(getMembers());
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ 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) {
+ form.setValue(CFG_RESOURCE_ID,
storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID)
+ .getIntegerValue());
+ form.setValue(CFG_DEFINITION_ID,
storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID)
+ .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() {
+ super.redraw();
+
+ removeMembers(getMembers());
+
+ DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+ if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) {
+ renderGraph();
+ } else {
+ addMember(new Label("<i>" +
MSG.view_portlet_configure_needed() + "</i>"));
+ }
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new ResourceGraphPortlet(locatorId);
+ }
+ }
+}
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
new file mode 100644
index 0000000..6c9b167
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricGraphView.java
@@ -0,0 +1,351 @@
+/*
+ * 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.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common;
+
+import java.util.Date;
+import java.util.List;
+
+import ca.nanometrics.gflot.client.Axis;
+import ca.nanometrics.gflot.client.DataPoint;
+import ca.nanometrics.gflot.client.PlotItem;
+import ca.nanometrics.gflot.client.PlotModel;
+import ca.nanometrics.gflot.client.PlotPosition;
+import ca.nanometrics.gflot.client.SeriesHandler;
+import ca.nanometrics.gflot.client.SimplePlot;
+import ca.nanometrics.gflot.client.event.PlotHoverListener;
+import ca.nanometrics.gflot.client.jsni.Plot;
+import ca.nanometrics.gflot.client.options.AxisOptions;
+import ca.nanometrics.gflot.client.options.GridOptions;
+import ca.nanometrics.gflot.client.options.LineSeriesOptions;
+import ca.nanometrics.gflot.client.options.PlotOptions;
+import ca.nanometrics.gflot.client.options.PointsSeriesOptions;
+import ca.nanometrics.gflot.client.options.TickFormatter;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.smartgwt.client.types.AnimationEffect;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.Img;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.events.MouseOutEvent;
+import com.smartgwt.client.widgets.events.MouseOutHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWidgetCanvas;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public abstract class AbstractMetricGraphView extends LocatableVLayout {
+
+ private static final String INSTRUCTIONS =
MSG.view_resource_monitor_graph_instructions();
+
+ /*
+ private static final String[] MONTH_NAMES = { MSG.common_calendar_january_short(),
+ MSG.common_calendar_february_short(), MSG.common_calendar_march_short(),
MSG.common_calendar_april_short(),
+ MSG.common_calendar_may_short(), MSG.common_calendar_june_short(),
MSG.common_calendar_july_short(),
+ MSG.common_calendar_august_short(), MSG.common_calendar_september_short(),
MSG.common_calendar_october_short(),
+ MSG.common_calendar_november_short(), MSG.common_calendar_december_short() };
+ */
+
+ private final Label selectedPointLabel = new Label(INSTRUCTIONS);
+ private final Label positionLabel = new Label();
+ private final Label hoverLabel = new Label();
+
+ private int entityId;
+ private int definitionId;
+
+ private MeasurementDefinition definition;
+ private List<MeasurementDataNumericHighLowComposite> data;
+
+ public AbstractMetricGraphView(String locatorId) {
+ super(locatorId);
+ }
+
+ public AbstractMetricGraphView(String locatorId, int entityId, int definitionId) {
+ this(locatorId);
+
+ this.entityId = entityId;
+ this.definitionId = definitionId;
+ }
+
+ public AbstractMetricGraphView(String locatorId, int entityId, MeasurementDefinition
def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+ this(locatorId);
+
+ this.entityId = entityId;
+ this.definition = def;
+ this.data = data;
+ setHeight100();
+ setWidth100();
+ }
+
+ public abstract AbstractMetricGraphView getInstance(String locatorId, int entityId,
MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data);
+
+ protected abstract void renderGraph();
+
+ protected abstract HTMLFlow getEntityTitle();
+
+ public int getEntityId() {
+ return this.entityId;
+ }
+
+ public void setEntityId(int entityId) {
+ this.entityId = entityId;
+ this.definition = null;
+ }
+
+ public int getDefinitionId() {
+ return definitionId;
+ }
+
+ public void setDefinitionId(int definitionId) {
+ this.definitionId = definitionId;
+ this.definition = null;
+ }
+
+ public MeasurementDefinition getDefinition() {
+ return definition;
+ }
+
+ public void setDefinition(MeasurementDefinition definition) {
+ this.definition = definition;
+ }
+
+ public List<MeasurementDataNumericHighLowComposite> getData() {
+ return data;
+ }
+
+ public void setData(List<MeasurementDataNumericHighLowComposite> data) {
+ this.data = data;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ removeMembers(getMembers());
+ renderGraph();
+ }
+
+ @Override
+ public void parentResized() {
+ super.parentResized();
+ removeMembers(getMembers());
+ renderGraph();
+ }
+
+ protected void drawGraph() {
+
+ HLayout titleHLayout = new
LocatableHLayout(extendLocatorId("HTitle"));
+
+ if (definition != null) {
+ titleHLayout.setAutoHeight();
+ titleHLayout.setWidth100();
+
+ HTMLFlow entityTitle = getEntityTitle();
+ if (null != entityTitle) {
+ entityTitle.setWidth("*");
+ titleHLayout.addMember(entityTitle);
+ }
+
+ if (supportsLiveGraphViewDialog()) {
+ Img liveGraph = new LocatableImg(extendLocatorId("Live"),
"subsystems/monitor/Monitor_16.png", 16, 16);
+ liveGraph.setTooltip(MSG.view_resource_monitor_graph_live_tooltip());
+
+ liveGraph.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ displayLiveGraphViewDialog();
+ }
+ });
+ titleHLayout.addMember(liveGraph);
+ }
+
+ addMember(titleHLayout);
+
+ HTMLFlow title = new HTMLFlow("<b>" +
definition.getDisplayName() + "</b> " + definition.getDescription());
+ title.setWidth100();
+ title.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ displayAsDialog(extendLocatorId("Dialog"));
+ }
+ });
+ addMember(title);
+ }
+
+ PlotModel model = new PlotModel();
+ PlotOptions plotOptions = new PlotOptions();
+ plotOptions.setDefaultLineSeriesOptions(new
LineSeriesOptions().setLineWidth(1).setShow(true));
+ plotOptions.setDefaultPointsOptions(new
PointsSeriesOptions().setRadius(2).setShow(true));
+ plotOptions.setDefaultShadowSize(0);
+
+ // You need make the grid hoverable <<<<<<<<<
+ plotOptions
+ .setGridOptions(new
GridOptions().setHoverable(true).setMouseActiveRadius(10).setAutoHighlight(true));
+
+ // create a series
+ if (definition != null && data != null) {
+ loadData(model, plotOptions);
+ }
+
+ // create the plot
+ SimplePlot plot = new SimplePlot(model, plotOptions);
+ plot.setSize(String.valueOf(getInnerContentWidth()),
String.valueOf(getInnerContentHeight()
+ - titleHLayout.getHeight() - 50));
+ // "80%","80%");
+
+ // add hover listener
+ plot.addHoverListener(new PlotHoverListener() {
+ public void onPlotHover(Plot plot, PlotPosition position, PlotItem item) {
+ if (position != null) {
+ positionLabel.setContents("position: (" + position.getX() +
"," + position.getY() + ")");
+ }
+ if (item != null) {
+ hoverLabel.setContents(getHover(item));
+
+ hoverLabel.animateShow(AnimationEffect.FADE);
+ if (hoverLabel.getLeft() > 0 || hoverLabel.getTop() > 0) {
+ hoverLabel.animateMove(item.getPageX() + 10, item.getPageY() -
35);
+ } else {
+ hoverLabel.moveTo(item.getPageX() + 10, item.getPageY() - 35);
+ }
+ hoverLabel.redraw();
+
+ selectedPointLabel.setContents("x: " +
item.getDataPoint().getX() + ", y: "
+ + item.getDataPoint().getY());
+ } else {
+ hoverLabel.animateHide(AnimationEffect.FADE);
+ selectedPointLabel.setContents(INSTRUCTIONS);
+ }
+ }
+ }, false);
+
+ addMouseOutHandler(new MouseOutHandler() {
+ public void onMouseOut(MouseOutEvent mouseOutEvent) {
+ hoverLabel.animateHide(AnimationEffect.FADE);
+ }
+ });
+
+ hoverLabel.setOpacity(80);
+ hoverLabel.setWrap(false);
+ hoverLabel.setHeight(25);
+ hoverLabel.setBackgroundColor("yellow");
+ hoverLabel.setBorder("1px solid orange");
+ hoverLabel.hide();
+
+ if (hoverLabel.isDrawn())
+ hoverLabel.redraw();
+ else
+ hoverLabel.draw();
+
+ // put it on a panel
+
+ addMember(new LocatableWidgetCanvas(extendLocatorId("Plot"), plot));
+
+ plot.setSize(String.valueOf(getInnerContentWidth()),
String.valueOf(getInnerContentHeight()
+ - titleHLayout.getHeight() - 50));
+
+ }
+
+ protected boolean supportsLiveGraphViewDialog() {
+ return false;
+ }
+
+ protected void displayLiveGraphViewDialog() {
+ return;
+ }
+
+ @Override
+ public void destroy() {
+ hoverLabel.destroy();
+ super.destroy();
+ }
+
+ @Override
+ public void hide() {
+ super.hide();
+ hoverLabel.hide();
+ }
+
+ protected String getHover(PlotItem item) {
+ if (definition != null) {
+ com.google.gwt.i18n.client.DateTimeFormat df =
DateTimeFormat.getMediumDateTimeFormat();
+ return definition.getDisplayName() + ": "
+ + MeasurementConverterClient.format(item.getDataPoint().getY(),
definition.getUnits(), true) + "<br/>"
+ + df.format(new Date((long) item.getDataPoint().getX()));
+ } else {
+ return "x: " + item.getDataPoint().getX() + ", y: " +
item.getDataPoint().getY();
+ }
+ }
+
+ protected void loadData(PlotModel model, PlotOptions plotOptions) {
+ SeriesHandler handler = model.addSeries(definition.getDisplayName(),
"#007f00");
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ handler.add(new DataPoint(d.getTimestamp(), d.getValue()));
+ }
+
+ plotOptions.setYAxisOptions(new
AxisOptions().setTicks(5).setLabelWidth(70).setTickFormatter(
+ new TickFormatter() {
+ public String formatTickValue(double v, Axis axis) {
+ return MeasurementConverterClient.format(v, definition.getUnits(),
true);
+ }
+ }));
+
+ long max = System.currentTimeMillis();
+ long min = max - (1000L * 60 * 60 * 8);
+
+ int xTicks = getWidth() / 140;
+
+ plotOptions.setXAxisOptions(new
AxisOptions().setTicks(xTicks).setMinimum(min).setMaximum(max)
+ .setTickFormatter(new TickFormatter() {
+ public String formatTickValue(double tickValue, Axis axis) {
+ com.google.gwt.i18n.client.DateTimeFormat dateFormat =
DateTimeFormat.getShortDateTimeFormat();
+ return dateFormat.format(new Date((long) tickValue));
+ // return String.valueOf(new Date((long) tickValue));
+ // return MONTH_NAMES[(int) (tickValue - 1)];
+ }
+ }));
+
+ }
+
+ private void displayAsDialog(String locatorId) {
+ AbstractMetricGraphView graph = getInstance(locatorId, entityId, definition,
data);
+ Window graphPopup = new Window();
+ graphPopup.setTitle(MSG.view_resource_monitor_detailed_graph_label());
+ graphPopup.setWidth(800);
+ graphPopup.setHeight(400);
+ graphPopup.setIsModal(true);
+ graphPopup.setShowModalMask(true);
+ graphPopup.setCanDragResize(true);
+ graphPopup.centerInPage();
+ graphPopup.addItem(graph);
+ graphPopup.show();
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
index 65d4c88..43b3700 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupContextMenu.java
@@ -44,7 +44,7 @@ import
org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.groups.graph.ResourceGroupGraphPortlet;
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.util.message.Message;
@@ -291,12 +291,16 @@ public class ResourceGroupContextMenu extends LocatableMenu {
addToDBItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent
menuItemClickEvent) {
- DashboardPortlet p = new
DashboardPortlet(def.getDisplayName() + " "
- + MSG.view_tree_common_contextMenu_chart(),
GraphPortlet.KEY, 250);
+ DashboardPortlet p = new DashboardPortlet(MSG
+ .view_tree_common_contextMenu_groupGraph(),
ResourceGroupGraphPortlet.KEY,
+ 250);
p.getConfiguration().put(
- new
PropertySimple(GraphPortlet.CFG_RESOURCE_GROUP_ID, group.getId()));
- p.getConfiguration().put(
- new
PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+ new
PropertySimple(ResourceGroupGraphPortlet.CFG_RESOURCE_GROUP_ID, group
+ .getId()));
+ p.getConfiguration()
+ .put(
+ new
PropertySimple(ResourceGroupGraphPortlet.CFG_DEFINITION_ID, def
+ .getId()));
d.addPortlet(p);
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
new file mode 100644
index 0000000..61a30ce
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricGraphView.java
@@ -0,0 +1,134 @@
+/*
+ * 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.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring;
+
+import java.util.EnumSet;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+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.common.AbstractMetricGraphView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public class ResourceGroupMetricGraphView extends AbstractMetricGraphView {
+
+ private HTMLFlow resourceGroupTitle;
+
+ public ResourceGroupMetricGraphView(String locatorId) {
+ super(locatorId);
+ }
+
+ public ResourceGroupMetricGraphView(String locatorId, int groupId, int definitionId)
{
+ super(locatorId, groupId, definitionId);
+ }
+
+ public ResourceGroupMetricGraphView(String locatorId, int groupId,
MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ super(locatorId, groupId, def, data);
+ }
+
+ protected HTMLFlow getEntityTitle() {
+ return resourceGroupTitle;
+ }
+
+ protected void renderGraph() {
+ if (null == getDefinition()) {
+
+ ResourceGroupGWTServiceAsync groupService =
GWTServiceLookup.getResourceGroupService();
+
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(getEntityId());
+ criteria.fetchResourceType(true);
+ groupService.findResourceGroupsByCriteria(criteria, new
AsyncCallback<PageList<ResourceGroup>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(),
caught);
+ }
+
+ public void onSuccess(PageList<ResourceGroup> result) {
+ if (result.isEmpty()) {
+ return;
+ }
+
+ final ResourceGroup group = result.get(0);
+ String url = LinkManager.getResourceGroupLink(group.getId());
+ resourceGroupTitle = new
HTMLFlow(SeleniumUtility.getLocatableHref(url, group.getName(), null));
+
+
ResourceTypeRepository.Cache.getInstance().getResourceTypes(group.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(final ResourceType type) {
+
+ for (MeasurementDefinition def :
type.getMetricDefinitions()) {
+ if (def.getId() == getDefinitionId()) {
+ setDefinition(def);
+
+
GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(
+ getEntityId(), new int[] { getDefinitionId()
},
+ System.currentTimeMillis() - (1000L * 60 * 60
* 8),
+ System.currentTimeMillis(), 60,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ public void onFailure(Throwable caught)
{
+
CoreGUI.getErrorHandler().handleError(
+
MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ }
+
+ public void onSuccess(
+
List<List<MeasurementDataNumericHighLowComposite>> result) {
+ setData(result.get(0));
+
+ drawGraph();
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ });
+
+ } else {
+
+ drawGraph();
+ }
+ }
+
+ @Override
+ public AbstractMetricGraphView getInstance(String locatorId, int entityId,
MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ return new ResourceGroupMetricGraphView(locatorId, entityId, def, data);
+ }
+}
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 cf34caf..9870a42 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
@@ -71,7 +71,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.ViewId;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph.GraphPortlet;
+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;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
@@ -421,8 +421,9 @@ public class ResourceTreeView extends LocatableVLayout {
MenuItem operationItem = new
MenuItem(operationDefinition.getDisplayName());
operationItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent event) {
- CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(),
ResourceDetailView.Tab.OPERATIONS,
- ResourceDetailView.OperationsSubTab.SCHEDULES) +
"/0/" + operationDefinition.getId());
+
CoreGUI.goToView(LinkManager.getResourceTabLink(resource.getId(),
+ ResourceDetailView.Tab.OPERATIONS,
ResourceDetailView.OperationsSubTab.SCHEDULES)
+ + "/0/" + operationDefinition.getId());
}
});
opSubMenu.addItem(operationItem);
@@ -547,12 +548,12 @@ public class ResourceTreeView extends LocatableVLayout {
addToDBItem.addClickHandler(new ClickHandler() {
public void onClick(MenuItemClickEvent
menuItemClickEvent) {
- DashboardPortlet p = new
DashboardPortlet(def.getDisplayName() + " Chart",
- GraphPortlet.KEY, 250);
+ DashboardPortlet p = new DashboardPortlet(MSG
+ .view_tree_common_contextMenu_resourceGraph(),
ResourceGraphPortlet.KEY, 250);
p.getConfiguration().put(
- new PropertySimple(GraphPortlet.CFG_RESOURCE_ID,
resource.getId()));
+ new
PropertySimple(ResourceGraphPortlet.CFG_RESOURCE_ID, resource.getId()));
p.getConfiguration().put(
- new
PropertySimple(GraphPortlet.CFG_DEFINITION_ID, def.getId()));
+ new
PropertySimple(ResourceGraphPortlet.CFG_DEFINITION_ID, def.getId()));
d.addPortlet(p);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
index dcd89d0..11ed7a5 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/GraphListView.java
@@ -127,7 +127,7 @@ public class GraphListView extends LocatableVLayout implements
ResourceSelectLis
}
private void buildGraph(MeasurementDefinition def,
List<MeasurementDataNumericHighLowComposite> data) {
- SmallGraphView graph = new SmallGraphView(extendLocatorId(def.getName()),
resource.getId(), def, data);
+ ResourceMetricGraphView graph = new
ResourceMetricGraphView(extendLocatorId(def.getName()), resource.getId(), def, data);
graph.setWidth("95%");
graph.setHeight(220);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
new file mode 100644
index 0000000..d051b92
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricGraphView.java
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
+
+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.widgets.HTMLFlow;
+
+import org.rhq.core.domain.criteria.ResourceCriteria;
+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.LinkManager;
+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.AbstractMetricGraphView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Greg Hinkle
+ * @author Jay Shaughnessy
+ */
+public class ResourceMetricGraphView extends AbstractMetricGraphView {
+
+ private HTMLFlow resourceTitle;
+
+ public ResourceMetricGraphView(String locatorId) {
+ super(locatorId);
+ }
+
+ public ResourceMetricGraphView(String locatorId, int resourceId, int definitionId) {
+ super(locatorId, resourceId, definitionId);
+ }
+
+ public ResourceMetricGraphView(String locatorId, int resourceId,
MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ super(locatorId, resourceId, def, data);
+ }
+
+ protected HTMLFlow getEntityTitle() {
+ return resourceTitle;
+ }
+
+ protected void renderGraph() {
+ if (null == getDefinition()) {
+
+ ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
+
+ ResourceCriteria resourceCriteria = new ResourceCriteria();
+ resourceCriteria.addFilterId(getEntityId());
+ resourceService.findResourcesByCriteria(resourceCriteria, new
AsyncCallback<PageList<Resource>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(),
caught);
+ }
+
+ public void onSuccess(PageList<Resource> result) {
+ if (result.isEmpty()) {
+ return;
+ }
+
+ 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() {
+
+ public void onTypesLoaded(Map<Integer, ResourceType>
types) {
+ String url =
LinkManager.getResourceLink(resource.getId());
+ resourceTitle = new
HTMLFlow(SeleniumUtility.getLocatableHref(url, resource.getName(),
+ null));
+
resourceTitle.setTooltip(AncestryUtil.getAncestryHoverHTMLForResource(resource, types,
+ 0));
+
+ ResourceType type =
types.get(resource.getResourceType().getId());
+ for (MeasurementDefinition def :
type.getMetricDefinitions()) {
+ if (def.getId() == getDefinitionId()) {
+ setDefinition(def);
+
+
GWTServiceLookup.getMeasurementDataService().findDataForResource(getEntityId(),
+ new int[] { getDefinitionId() },
+ System.currentTimeMillis() - (1000L * 60 * 60
* 8),
+ System.currentTimeMillis(), 60,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ public void onFailure(Throwable caught)
{
+
CoreGUI.getErrorHandler().handleError(
+
MSG.view_resource_monitor_graphs_loadFailed(), caught);
+ }
+
+ public void onSuccess(
+
List<List<MeasurementDataNumericHighLowComposite>> result) {
+ setData(result.get(0));
+
+ drawGraph();
+ }
+ });
+ }
+ }
+ }
+ });
+ }
+ });
+
+ } else {
+
+ drawGraph();
+ }
+ }
+
+ protected boolean supportsLiveGraphViewDialog() {
+ return true;
+ }
+
+ protected void displayLiveGraphViewDialog() {
+ LiveGraphView.displayAsDialog(getLocatorId(), getEntityId(), getDefinition());
+ }
+
+ @Override
+ public AbstractMetricGraphView getInstance(String locatorId, int entityId,
MeasurementDefinition def,
+ List<MeasurementDataNumericHighLowComposite> data) {
+
+ return new ResourceMetricGraphView(locatorId, entityId, def, data);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
index b255539..f2a92ce 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceScheduledMetricDatasource.java
@@ -118,6 +118,25 @@ public class ResourceScheduledMetricDatasource extends
RPCDataSource<Measurement
processResponse(request.getRequestId(), response);
}
});
+
+ } else if
(request.getCriteria().getValues().containsKey("resourceGroupId")) {
+ MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria();
+ criteria.fetchDefinition(true);
+
+
criteria.addFilterResourceGroupId(request.getCriteria().getAttributeAsInt("resourceGroupId"));
+
+
GWTServiceLookup.getMeasurementDataService().findMeasurementSchedulesByCriteria(criteria,
+ new AsyncCallback<PageList<MeasurementSchedule>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.dataSource_schedules_loadFailed(), caught);
+ }
+
+ public void onSuccess(PageList<MeasurementSchedule> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+
} else {
processResponse(request.getRequestId(), response);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
deleted file mode 100644
index a6d3fe9..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/SmallGraphView.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * 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.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring;
-
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.List;
-
-import ca.nanometrics.gflot.client.Axis;
-import ca.nanometrics.gflot.client.DataPoint;
-import ca.nanometrics.gflot.client.PlotItem;
-import ca.nanometrics.gflot.client.PlotModel;
-import ca.nanometrics.gflot.client.PlotPosition;
-import ca.nanometrics.gflot.client.SeriesHandler;
-import ca.nanometrics.gflot.client.SimplePlot;
-import ca.nanometrics.gflot.client.event.PlotHoverListener;
-import ca.nanometrics.gflot.client.jsni.Plot;
-import ca.nanometrics.gflot.client.options.AxisOptions;
-import ca.nanometrics.gflot.client.options.GridOptions;
-import ca.nanometrics.gflot.client.options.LineSeriesOptions;
-import ca.nanometrics.gflot.client.options.PlotOptions;
-import ca.nanometrics.gflot.client.options.PointsSeriesOptions;
-import ca.nanometrics.gflot.client.options.TickFormatter;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.AnimationEffect;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.Img;
-import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-import com.smartgwt.client.widgets.events.MouseOutEvent;
-import com.smartgwt.client.widgets.events.MouseOutHandler;
-import com.smartgwt.client.widgets.layout.HLayout;
-
-import org.rhq.core.domain.criteria.ResourceCriteria;
-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.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWidgetCanvas;
-
-/**
- * @author Greg Hinkle
- */
-public class SmallGraphView extends LocatableVLayout {
-
- private static final String INSTRUCTIONS =
MSG.view_resource_monitor_graph_instructions();
-
- private static final String[] MONTH_NAMES = { MSG.common_calendar_january_short(),
- MSG.common_calendar_february_short(), MSG.common_calendar_march_short(),
MSG.common_calendar_april_short(),
- MSG.common_calendar_may_short(), MSG.common_calendar_june_short(),
MSG.common_calendar_july_short(),
- MSG.common_calendar_august_short(), MSG.common_calendar_september_short(),
MSG.common_calendar_october_short(),
- MSG.common_calendar_november_short(), MSG.common_calendar_december_short() };
-
- private final Label selectedPointLabel = new Label(INSTRUCTIONS);
- private final Label positionLabel = new Label();
-
- private final Label hoverLabel = new Label();
-
- private int resourceId;
-
- private int definitionId;
-
- private MeasurementDefinition definition;
- private List<MeasurementDataNumericHighLowComposite> data;
-
- public SmallGraphView(String locatorId) {
- super(locatorId);
- }
-
- public SmallGraphView(String locatorId, int resourceId, int definitionId) {
- this(locatorId);
-
- this.resourceId = resourceId;
- this.definitionId = definitionId;
- }
-
- public SmallGraphView(String locatorId, int resourceId, MeasurementDefinition def,
- List<MeasurementDataNumericHighLowComposite> data) {
- this(locatorId);
-
- this.resourceId = resourceId;
- this.definition = def;
- this.data = data;
- setHeight100();
- setWidth100();
- }
-
- public String getName() {
- return "PlotHoverListener";
- }
-
- public int getResourceId() {
- return resourceId;
- }
-
- public void setResourceId(int resourceId) {
- this.resourceId = resourceId;
- this.definition = null;
- }
-
- public int getDefinitionId() {
- return definitionId;
- }
-
- public void setDefinitionId(int definitionId) {
- this.definitionId = definitionId;
- this.definition = null;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
- removeMembers(getMembers());
- renderGraph();
- }
-
- @Override
- public void parentResized() {
- super.parentResized();
- removeMembers(getMembers());
- renderGraph();
- }
-
- protected void renderGraph() {
- if (this.definition == null) {
-
- ResourceGWTServiceAsync resourceService =
GWTServiceLookup.getResourceService();
-
- ResourceCriteria resourceCriteria = new ResourceCriteria();
- resourceCriteria.addFilterId(resourceId);
- resourceService.findResourcesByCriteria(resourceCriteria, new
AsyncCallback<PageList<Resource>>() {
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(),
caught);
- }
-
- public void onSuccess(PageList<Resource> result) {
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(
- result.get(0).getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(final ResourceType type) {
-
- for (MeasurementDefinition def :
type.getMetricDefinitions()) {
- if (def.getId() == definitionId) {
- SmallGraphView.this.definition = def;
-
-
GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
- new int[] { definitionId },
- System.currentTimeMillis() - (1000L * 60 * 60
* 8),
- System.currentTimeMillis(), 60,
- new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- public void onFailure(Throwable caught)
{
-
CoreGUI.getErrorHandler().handleError(
-
MSG.view_resource_monitor_graphs_loadFailed(), caught);
- }
-
- public void onSuccess(
-
List<List<MeasurementDataNumericHighLowComposite>> result) {
- SmallGraphView.this.data =
result.get(0);
-
- drawGraph();
- }
- });
- }
- }
- }
- });
- }
- });
-
- } else {
-
- drawGraph();
-
- }
- }
-
- private void drawGraph() {
-
- HLayout titleLayout = new LocatableHLayout(getLocatorId());
-
- if (definition != null) {
- titleLayout.setAutoHeight();
-
- titleLayout.setWidth100();
-
- HTMLFlow title = new HTMLFlow("<b>" +
definition.getDisplayName() + "</b> " + definition.getDescription());
- title.setWidth("*");
- title.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- displayAsDialog(extendLocatorId("Dialog"));
- }
- });
- titleLayout.addMember(title);
-
- Img liveGraph = new LocatableImg(getLocatorId(),
"subsystems/monitor/Monitor_16.png", 16, 16);
- liveGraph.setTooltip(MSG.view_resource_monitor_graph_live_tooltip());
-
- liveGraph.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- LiveGraphView.displayAsDialog(getLocatorId(), resourceId,
definition);
- }
- });
- titleLayout.addMember(liveGraph);
-
- addMember(titleLayout);
- }
-
- PlotModel model = new PlotModel();
- PlotOptions plotOptions = new PlotOptions();
- plotOptions.setDefaultLineSeriesOptions(new
LineSeriesOptions().setLineWidth(1).setShow(true));
- plotOptions.setDefaultPointsOptions(new
PointsSeriesOptions().setRadius(2).setShow(true));
- plotOptions.setDefaultShadowSize(0);
-
- // You need make the grid hoverable <<<<<<<<<
- plotOptions
- .setGridOptions(new
GridOptions().setHoverable(true).setMouseActiveRadius(10).setAutoHighlight(true));
-
- // create a series
- if (definition != null && data != null) {
- loadData(model, plotOptions);
- }
-
- // create the plot
- SimplePlot plot = new SimplePlot(model, plotOptions);
- plot.setSize(String.valueOf(getInnerContentWidth()),
String.valueOf(getInnerContentHeight()
- - titleLayout.getHeight() - 50));
- // "80%","80%");
-
- // add hover listener
- plot.addHoverListener(new PlotHoverListener() {
- public void onPlotHover(Plot plot, PlotPosition position, PlotItem item) {
- if (position != null) {
- positionLabel.setContents("position: (" + position.getX() +
"," + position.getY() + ")");
- }
- if (item != null) {
- hoverLabel.setContents(getHover(item));
-
- hoverLabel.animateShow(AnimationEffect.FADE);
- if (hoverLabel.getLeft() > 0 || hoverLabel.getTop() > 0) {
- hoverLabel.animateMove(item.getPageX() + 10, item.getPageY() -
35);
- } else {
- hoverLabel.moveTo(item.getPageX() + 10, item.getPageY() - 35);
- }
- hoverLabel.redraw();
-
- selectedPointLabel.setContents("x: " +
item.getDataPoint().getX() + ", y: "
- + item.getDataPoint().getY());
- } else {
- hoverLabel.animateHide(AnimationEffect.FADE);
- selectedPointLabel.setContents(INSTRUCTIONS);
- }
- }
- }, false);
-
- addMouseOutHandler(new MouseOutHandler() {
- public void onMouseOut(MouseOutEvent mouseOutEvent) {
- hoverLabel.animateHide(AnimationEffect.FADE);
- }
- });
-
- hoverLabel.setOpacity(80);
- hoverLabel.setWrap(false);
- hoverLabel.setHeight(25);
- hoverLabel.setBackgroundColor("yellow");
- hoverLabel.setBorder("1px solid orange");
- hoverLabel.hide();
-
- if (hoverLabel.isDrawn())
- hoverLabel.redraw();
- else
- hoverLabel.draw();
-
- // put it on a panel
-
- addMember(new LocatableWidgetCanvas(this.getLocatorId(), plot));
-
- plot.setSize(String.valueOf(getInnerContentWidth()),
String.valueOf(getInnerContentHeight()
- - titleLayout.getHeight() - 50));
-
- }
-
- @Override
- public void destroy() {
- hoverLabel.destroy();
- super.destroy();
- }
-
- @Override
- public void hide() {
- super.hide();
- hoverLabel.hide();
- }
-
- private String getHover(PlotItem item) {
- if (definition != null) {
- com.google.gwt.i18n.client.DateTimeFormat df =
DateTimeFormat.getMediumDateTimeFormat();
- return definition.getDisplayName() + ": "
- + MeasurementConverterClient.format(item.getDataPoint().getY(),
definition.getUnits(), true) + "<br/>"
- + df.format(new Date((long) item.getDataPoint().getX()));
- } else {
- return "x: " + item.getDataPoint().getX() + ", y: " +
item.getDataPoint().getY();
- }
- }
-
- private void loadData(PlotModel model, PlotOptions plotOptions) {
- SeriesHandler handler = model.addSeries(definition.getDisplayName(),
"#007f00");
-
- for (MeasurementDataNumericHighLowComposite d : data) {
- handler.add(new DataPoint(d.getTimestamp(), d.getValue()));
- }
-
- plotOptions.setYAxisOptions(new
AxisOptions().setTicks(5).setLabelWidth(70).setTickFormatter(
- new TickFormatter() {
- public String formatTickValue(double v, Axis axis) {
- return MeasurementConverterClient.format(v, definition.getUnits(),
true);
- }
- }));
-
- long max = System.currentTimeMillis();
- long min = max - (1000L * 60 * 60 * 8);
-
- int xTicks = getWidth() / 140;
-
- plotOptions.setXAxisOptions(new
AxisOptions().setTicks(xTicks).setMinimum(min).setMaximum(max)
- .setTickFormatter(new TickFormatter() {
- public String formatTickValue(double tickValue, Axis axis) {
- com.google.gwt.i18n.client.DateTimeFormat dateFormat =
DateTimeFormat.getShortDateTimeFormat();
- return dateFormat.format(new Date((long) tickValue));
- // return String.valueOf(new Date((long) tickValue));
- // return MONTH_NAMES[(int) (tickValue - 1)];
- }
- }));
-
- }
-
- private void displayAsDialog(String locatorId) {
- SmallGraphView graph = new SmallGraphView(locatorId, resourceId, definition,
data);
- Window graphPopup = new Window();
- graphPopup.setTitle(MSG.view_resource_monitor_detailed_graph_label());
- graphPopup.setWidth(800);
- graphPopup.setHeight(400);
- graphPopup.setIsModal(true);
- graphPopup.setShowModalMask(true);
- graphPopup.setCanDragResize(true);
- graphPopup.centerInPage();
- graphPopup.addItem(graph);
- graphPopup.show();
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index 48cd8da..320e341 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -31,7 +31,6 @@ import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
@@ -42,17 +41,13 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
- private static final ViewName GROUP_COMPATIBLE = new
ViewName(GroupCategory.COMPATIBLE.getName(), MSG
- .view_group_summary_compatible());
- private static final ViewName GROUP_MIXED = new
ViewName(GroupCategory.MIXED.getName(), MSG
- .view_group_summary_mixed());
private static LinkedHashMap<String, String> CATEGORY_VALUE_MAP = new
LinkedHashMap<String, String>();
GroupCategory categoryFilter;
static {
- CATEGORY_VALUE_MAP.put(GroupCategory.COMPATIBLE.getName(),
MSG.view_group_summary_compatible() + "-!");
- CATEGORY_VALUE_MAP.put(GroupCategory.MIXED.getName(),
MSG.view_group_summary_mixed() + "-!");
+ CATEGORY_VALUE_MAP.put(GroupCategory.COMPATIBLE.getName(),
MSG.view_group_summary_compatible());
+ CATEGORY_VALUE_MAP.put(GroupCategory.MIXED.getName(),
MSG.view_group_summary_mixed());
}
@@ -78,7 +73,6 @@ public class ResourceGroupSelector extends
AbstractSelector<ResourceGroup> {
final TextItem search = new TextItem("search",
MSG.common_title_search());
SelectItem groupCategorySelect = new SelectItem("groupCategory",
MSG.widget_resourceSelector_groupCategory());
- //groupCategorySelect.setValueMap(GROUP_COMPATIBLE.getTitle(),
GROUP_MIXED.getTitle());
groupCategorySelect.setValueMap(CATEGORY_VALUE_MAP);
if (null == categoryFilter) {
groupCategorySelect.setAllowEmptyValue(true);
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 aebcd71..a07b4b6 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
@@ -1444,7 +1444,8 @@ view_dashboardsManager_message_title_details = <h1>Welcome to
RHQ</h1>\n<p>The R
view_portlet_defaultName_autodiscovery = Discovery Queue
view_portlet_defaultName_favoriteResources = Favorite Resources
-view_portlet_defaultName_graph = Resource Metric Graph
+view_portlet_defaultName_resourceMetric = Resource Metric Graph
+view_portlet_defaultName_groupMetric = Resource Group Metric Graph
view_portlet_defaultName_inventorySummary = Inventory Summary
view_portlet_defaultName_mashup = Mashup
view_portlet_defaultName_message = Message
@@ -1644,7 +1645,8 @@ view_tree_common_contextMenu_operations = Operations
view_tree_common_contextMenu_operations_loadFailed = Failure to start wizard for running
operations
view_tree_common_contextMenu_measurements = Measurements
view_tree_common_contextMenu_addChartToDashboard = Add chart to dashboard [{0}]
-view_tree_common_contextMenu_chart = Chart
+view_tree_common_contextMenu_resourceGraph = Resource Metric Graph
+view_tree_common_contextMenu_groupGraph = Group Metric Graph
view_tree_common_contextMenu_saveChartToDashboardSuccessful = You have saved dashboard
[{0}]
view_tree_common_contextMenu_saveChartToDashboardFailure = Failed to save the dashboard
view_tree_common_contextMenu_loadFailed_dashboard = Failed to load user dashboards
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 242a76b..805d4bf 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -1153,7 +1153,8 @@ view_tree_common_contextMenu_operations=Operations~
view_tree_common_contextMenu_operations_loadFailed=Failure to start wizard for running
operations~
view_tree_common_contextMenu_measurements=Measurements~
view_tree_common_contextMenu_addChartToDashboard=Diagramm zum Dashboard [{0}] hinzufügen
-view_tree_common_contextMenu_chart=Chart~
+view_tree_common_contextMenu_resourceGraph = Resource Metric Graph~
+view_tree_common_contextMenu_groupGraph = Group Metric Graph~
view_tree_common_contextMenu_saveChartToDashboardSuccessful=sie haben das Dashboard [{0}]
gesichert
view_tree_common_contextMenu_saveChartToDashboardFailure=Speichern des Dashboards
fehlgeschlagen
view_tree_common_contextMenu_loadFailed_dashboard=Failed to load user dashboards
commit 2d4b0e8ae833aee4d9ea57df914ca19ec50f6810
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 21 16:19:13 2011 -0400
Add AncestryUtil entry point for getting resource hover without using a
ListGridRecord, just the required entity info.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
index b7734c4..8a2cbe2 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/AncestryUtil.java
@@ -189,9 +189,24 @@ public abstract class AncestryUtil {
Map<Integer, ResourceType> types = ((MapWrapper)
listGridRecord.getAttributeAsObject(RESOURCE_ANCESTRY_TYPES))
.getMap();
Integer resourceTypeId = listGridRecord.getAttributeAsInt(RESOURCE_TYPE_ID);
+ String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
+
+ String result = getAncestryHoverHTMLString(resourceId, resourceName, ancestry,
resourceTypeId, types, width);
+
+ listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result);
+ return result;
+ }
+
+ public static String getAncestryHoverHTMLForResource(Resource resource,
Map<Integer, ResourceType> types, int width) {
+
+ return getAncestryHoverHTMLString(resource.getId(), resource.getName(),
resource.getAncestry(), resource
+ .getResourceType().getId(), types, width);
+ }
+
+ private static String getAncestryHoverHTMLString(int resourceId, String resourceName,
String ancestry,
+ int resourceTypeId, Map<Integer, ResourceType> types, int width) {
ResourceType type = types.get(resourceTypeId);
String resourceLongName = getResourceLongName(resourceName, type);
- String ancestry = listGridRecord.getAttributeAsString(RESOURCE_ANCESTRY);
width = (width <= 0) ? 500 : width;
@@ -231,9 +246,7 @@ public abstract class AncestryUtil {
sb.append("</p>");
- String result = sb.toString();
- listGridRecord.setAttribute(RESOURCE_ANCESTRY_HOVER, result);
- return result;
+ return sb.toString();
}
private static String getResourceLongName(String resourceName, ResourceType type) {
commit 1cd5508cf4d898bdc29c6f6b7a705a680e338ff3
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Mon Mar 21 16:16:38 2011 -0400
Fix and enhance various selectors
- don't ignore construction-time criteria, so the first fetch can be filtered
- allow localized categories in the resource group selector category filter
- allow preset category filter in group selector (this, for example, can force
only compatible groups).
- add SingleResourceGroupSelector when you only want one group
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
index c3ae654..457d13b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/selector/AbstractSelector.java
@@ -284,12 +284,13 @@ public abstract class AbstractSelector<T> extends
LocatableVLayout {
availableSectionStack.addSection(availableSection);
// Load data.
- this.datasource = getDataSource();
- populateAvailableGrid(new Criteria());
-
if (this.availableFilterForm != null) {
+ // this grabs any initial criteria prior to the first data fetch
+ latestCriteria = getLatestCriteria(availableFilterForm);
+
this.availableFilterForm.addItemChangedHandler(new ItemChangedHandler() {
public void onItemChanged(ItemChangedEvent itemChangedEvent) {
+
latestCriteria = getLatestCriteria(availableFilterForm);
Timer timer = new Timer() {
@@ -306,6 +307,8 @@ public abstract class AbstractSelector<T> extends
LocatableVLayout {
}
});
}
+ this.datasource = getDataSource();
+ populateAvailableGrid((null == latestCriteria) ? new Criteria() :
latestCriteria);
// Add event handlers.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
index 9424d59..48cd8da 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/ResourceGroupSelector.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
+import java.util.LinkedHashMap;
+
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -26,8 +28,11 @@ import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import org.rhq.core.domain.criteria.ResourceGroupCriteria;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.enterprise.gui.coregui.client.components.selector.AbstractSelector;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupDataSourceField;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.ResourceGroupsDataSource;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -37,12 +42,32 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
*/
public class ResourceGroupSelector extends AbstractSelector<ResourceGroup> {
+ private static final ViewName GROUP_COMPATIBLE = new
ViewName(GroupCategory.COMPATIBLE.getName(), MSG
+ .view_group_summary_compatible());
+ private static final ViewName GROUP_MIXED = new
ViewName(GroupCategory.MIXED.getName(), MSG
+ .view_group_summary_mixed());
+ private static LinkedHashMap<String, String> CATEGORY_VALUE_MAP = new
LinkedHashMap<String, String>();
+
+ GroupCategory categoryFilter;
+
+ static {
+ CATEGORY_VALUE_MAP.put(GroupCategory.COMPATIBLE.getName(),
MSG.view_group_summary_compatible() + "-!");
+ CATEGORY_VALUE_MAP.put(GroupCategory.MIXED.getName(),
MSG.view_group_summary_mixed() + "-!");
+
+ }
+
public ResourceGroupSelector(String locatorId) {
this(locatorId, false);
}
-
+
public ResourceGroupSelector(String locatorId, boolean isReadOnly) {
+ this(locatorId, null, isReadOnly);
+ }
+
+ public ResourceGroupSelector(String locatorId, GroupCategory categoryFilter, boolean
isReadOnly) {
super(locatorId, isReadOnly);
+
+ this.categoryFilter = categoryFilter;
}
protected DynamicForm getAvailableFilterForm() {
@@ -53,8 +78,21 @@ public class ResourceGroupSelector extends
AbstractSelector<ResourceGroup> {
final TextItem search = new TextItem("search",
MSG.common_title_search());
SelectItem groupCategorySelect = new SelectItem("groupCategory",
MSG.widget_resourceSelector_groupCategory());
- groupCategorySelect.setValueMap("Compatible", "Mixed"); // I
don't think we can i18n these, may need these literal values - need to double check
this
- groupCategorySelect.setAllowEmptyValue(true);
+ //groupCategorySelect.setValueMap(GROUP_COMPATIBLE.getTitle(),
GROUP_MIXED.getTitle());
+ groupCategorySelect.setValueMap(CATEGORY_VALUE_MAP);
+ if (null == categoryFilter) {
+ groupCategorySelect.setAllowEmptyValue(true);
+ } else {
+ switch (categoryFilter) {
+ case COMPATIBLE:
+ groupCategorySelect.setValue(GroupCategory.COMPATIBLE.getName());
+ break;
+ case MIXED:
+ groupCategorySelect.setValue(GroupCategory.MIXED.getName());
+ break;
+ }
+ groupCategorySelect.setDisabled(true);
+ }
availableFilterForm.setItems(search, groupCategorySelect, new SpacerItem());
return availableFilterForm;
@@ -72,10 +110,10 @@ public class ResourceGroupSelector extends
AbstractSelector<ResourceGroup> {
String category = (String)
availableFilterForm.getValue("groupCategory");
Criteria criteria = new Criteria();
if (null != search) {
- criteria.addCriteria("name", search);
+ criteria.addCriteria(ResourceGroupDataSourceField.NAME.propertyName(),
search);
}
if (null != category) {
- criteria.addCriteria("category", category);
+ criteria.addCriteria(ResourceGroupDataSourceField.CATEGORY.propertyName(),
category);
}
return criteria;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java
new file mode 100644
index 0000000..513419f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/selection/SingleResourceGroupSelector.java
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.selection;
+
+import com.smartgwt.client.types.SelectionStyle;
+
+import org.rhq.core.domain.resource.group.GroupCategory;
+
+/**
+ * This forces the user to only be able to select a single resource.
+ *
+ * @author Jay Shaughnessy
+ */
+public class SingleResourceGroupSelector extends ResourceGroupSelector {
+
+ public SingleResourceGroupSelector(String locatorId) {
+ super(locatorId);
+ }
+
+ public SingleResourceGroupSelector(String locatorId, GroupCategory categoryFilter,
boolean isReadOnly) {
+ super(locatorId, categoryFilter, isReadOnly);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ // we only allow a single resource to be selected
+ availableGrid.setSelectionType(SelectionStyle.SINGLE);
+ }
+
+ @Override
+ protected void updateButtonEnablement() {
+ addButton.setDisabled(!availableGrid.anySelected() ||
availableGrid.getTotalRows() == 0
+ || assignedGrid.getTotalRows() > 0);
+ removeButton.setDisabled(!assignedGrid.anySelected());
+ addAllButton.hide();
+ removeAllButton.hide();
+ }
+
+ @Override
+ public void addSelectedRows() {
+ // do not allow more than one row into the assigned grid
+ if (assignedGrid.getTotalRows() == 0) {
+ super.addSelectedRows();
+ }
+ }
+}