modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
| 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
| 32
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
| 209 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
| 44
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
| 23
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
| 435 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
| 394 ----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
| 398 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
| 119 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
| 145 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
| 51
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
| 814 ++-------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
| 229 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java
| 702 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
| 205 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
| 825 ++--------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java
| 691 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
| 4
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 6
26 files changed, 2885 insertions(+), 2482 deletions(-)
New commits:
commit 33815da4e801a6ebce0f9be4e01b4c1da7d0a2df
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 12:46:05 2011 -0400
fix resourceOps link issue.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
index a1f9c3e..f2a0ab4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -245,6 +245,11 @@ class ResourceOperationsCriteriaHistoryListView extends
AbstractOperationHistory
MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()),
String.valueOf(count)));
}
}
+
+ @Override
+ protected String getBasePath() {
+ return "Resource/" + resourceComposite.getResource().getId() +
"/Operations/History";
+ }
}
/** Provide implementation of ResourceOperationHistoryDataSource that dynamically
commit 13336db776cbdf7f8133f9ff3ab6eb38035dccba
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 11:52:43 2011 -0400
fix/enforce unmodifiable PortletFactory mapping data.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 10610e4..e8ee80c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -20,6 +20,7 @@ package org.rhq.enterprise.gui.coregui.client.dashboard;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -194,7 +195,8 @@ public class DashboardView extends LocatableVLayout {
private DynamicForm buildEditForm() {
editForm = new LocatableDynamicForm(extendLocatorId("Editor"));
- final HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
+ final Map<String, String> groupKeyNameMap = new HashMap<String,
String>(PortletFactory
+ .getRegisteredGroupPortletNameMap());
//remove BundleDeployment and add back later if relevant.
groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
//if group, need to do asynch check for bundlePortlet to ensure only Platform
members
@@ -246,7 +248,7 @@ public class DashboardView extends LocatableVLayout {
*
* @param groupKeyNameMap
*/
- private void populateBuildEditForm(HashMap<String, String> groupKeyNameMap) {
+ private void populateBuildEditForm(Map<String, String> groupKeyNameMap) {
editForm.setMargin(5);
editForm.setAutoWidth();
editForm.setNumCols(canEditName() ? 12 : 10);
@@ -312,7 +314,7 @@ public class DashboardView extends LocatableVLayout {
});
final Menu addPortletMenu = new
LocatableMenu(editForm.extendLocatorId("PortletMenu"));
- HashMap<String, String> keyNameMap =
PortletFactory.getRegisteredPortletNameMap();
+ HashMap<String, String> keyNameMap = new HashMap<String,
String>(PortletFactory.getRegisteredPortletNameMap());
// the assumption here is that the portlet names are unique. we want a sorted
menu here, so create a
// sorted map from portlet name to portlet key and use that to generate the menu.
It would be nice if you
// could just call Menu.sort() but it's not supported (yet?).
@@ -333,7 +335,8 @@ public class DashboardView extends LocatableVLayout {
}
}
- HashMap<String, String> resourceKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
+ HashMap<String, String> resourceKeyNameMap = new HashMap<String,
String>(PortletFactory
+ .getRegisteredResourcePortletNameMap());
//if resource passed in then add additional portlets to list
if (this.resource != null) {
//trim out portlets that should not be visible
@@ -504,7 +507,7 @@ public class DashboardView extends LocatableVLayout {
/**Process the portletName map to exclude portlets that should not be visible for
this
* group. All except BundleDeployment visibility is handled here. Bundle requires
runtime check.
*/
- public static HashMap<String, String>
processPortletNameMapForGroup(HashMap<String, String> groupKeyNameMap,
+ public static Map<String, String> processPortletNameMapForGroup(Map<String,
String> groupKeyNameMap,
ResourceGroupComposite composite) {
if ((composite != null) && (composite.getResourceGroup() != null)
&& (groupKeyNameMap != null)
&& !groupKeyNameMap.isEmpty()) {
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 b42ffa5..98220d7 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
@@ -19,8 +19,10 @@
package org.rhq.enterprise.gui.coregui.client.dashboard;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
@@ -66,7 +68,7 @@ public class PortletFactory {
private static final HashMap<String, PortletViewFactory>
registeredResourcePortletFactoryMap;
private static final HashMap<String, String> registeredGroupPortletNameMap;
private static final HashMap<String, String> registeredResourcePortletNameMap;
- private static final HashMap<String, String> registeredPortletIconMap;
+ private static HashMap<String, String> registeredPortletIconMap;
static {
//############## Default Dashboard ############################
@@ -209,19 +211,24 @@ public class PortletFactory {
/**
* @return Unmodifiable Map of registered portlet keys to names
*/
- public static HashMap<String, String> getRegisteredPortletNameMap() {
-
- return registeredPortletNameMap;
+ public static Map<String, String> getRegisteredPortletNameMap() {
+ return Collections.unmodifiableMap(registeredPortletNameMap);
}
- public static HashMap<String, String> getRegisteredGroupPortletNameMap() {
+ /**
+ * @return Unmodifiable Map of registered portlet keys to names
+ */
+ public static Map<String, String> getRegisteredGroupPortletNameMap() {
- return registeredGroupPortletNameMap;
+ return Collections.unmodifiableMap(registeredGroupPortletNameMap);
}
- public static HashMap<String, String> getRegisteredResourcePortletNameMap() {
+ /**
+ * @return Unmodifiable Map of registered portlet keys to names
+ */
+ public static Map<String, String> getRegisteredResourcePortletNameMap() {
- return registeredResourcePortletNameMap;
+ return Collections.unmodifiableMap(registeredResourcePortletNameMap);
}
public static String getRegisteredPortletName(String key) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
index 106ac4b..7ff4f7d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -48,6 +49,7 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
@@ -189,8 +191,13 @@ public class ActivityView extends LocatableVLayout implements
DashboardContainer
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
//figure out which portlets to display and how
- HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
+ Map<String, String> groupKeyNameMap = new HashMap<String,
String>(PortletFactory
+ .getRegisteredGroupPortletNameMap());
+ //remove BundleDeployment and add back later if relevant.
+ groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap,
groupComposite);
+ //TODO: spinder 3/21/11 need asynch call to execute and then update the menu for
bundle
+
int colLeft = 0;
int colRight = 1;
int rowLeft = 0;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
index ee64837..4cec210 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
@@ -172,7 +172,8 @@ public class ActivityView extends LocatableVLayout implements
DashboardContainer
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
//figure out which portlets to display and how
- HashMap<String, String> resKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
+ HashMap<String, String> resKeyNameMap = new HashMap<String,
String>(PortletFactory
+ .getRegisteredResourcePortletNameMap());
resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap,
resourceComposite);
int colLeft = 0;
int colRight = 1;
commit 0fcd909efb4236646d9faaa1e1278ce4545ed678
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Mon Mar 21 09:15:00 2011 -0400
i)moved portlet dashboard to first activitytab. Still trailing dashboard reset issue
ii)disable sort results widget
iii)fix resourceOperationsPortlet init issue
iv)add NPE check to messageCenter execution.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index a1a1c98..10610e4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -474,22 +474,24 @@ public class DashboardView extends LocatableVLayout {
Resource resource = composite.getResource();
//filter out portlets not relevent for facets
Set<ResourceTypeFacet> facets =
composite.getResourceFacets().getFacets();
- //Operation related portlets
- if (!facets.contains(ResourceTypeFacet.OPERATION)) {
- resourceKeyNameMap.remove(ResourceOperationsPortlet.KEY);
- }
- //MEASUREMENT related portlets(METRICS)
- if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
- resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
- resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
- }
- //Content related portlets
- if (!facets.contains(ResourceTypeFacet.CONTENT)) {
- resourceKeyNameMap.remove(ResourcePkgHistoryPortlet.KEY);
- }
- //Event related portlets
- if (!facets.contains(ResourceTypeFacet.EVENT)) {
- resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
+ if (!facets.isEmpty()) {
+ //Operation related portlets
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ resourceKeyNameMap.remove(ResourceOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ }
+ //Content related portlets
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ resourceKeyNameMap.remove(ResourcePkgHistoryPortlet.KEY);
+ }
+ //Event related portlets
+ if (!facets.contains(ResourceTypeFacet.EVENT)) {
+ resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
+ }
}
//Bundle related portlet
if
(!resource.getResourceType().getCategory().equals(ResourceCategory.PLATFORM)) {
@@ -513,18 +515,20 @@ public class DashboardView extends LocatableVLayout {
// ResourceGroup group = composite.getResourceGroup();
//compatible if not a compatible group may need to do some pruning.
if (groupCategory != GroupCategory.COMPATIBLE) {
- //Operations related portlets(Config,PkgHistory)
- if (!facets.contains(ResourceTypeFacet.OPERATION)) {
- groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
- }
- //MEASUREMENT related portlets(METRICS)
- if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
- groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
- groupKeyNameMap.remove(GroupOobsPortlet.KEY);
- }
- //CONTENT related portlets(CONTENT)
- if (!facets.contains(ResourceTypeFacet.CONTENT)) {
- groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ if (!facets.isEmpty()) {
+ //Operations related portlets(Config,PkgHistory)
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ groupKeyNameMap.remove(GroupOobsPortlet.KEY);
+ }
+ //CONTENT related portlets(CONTENT)
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ }
}
// //EVENT related portlets
// if (!facets.contains(ResourceTypeFacet.EVENT)) {
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 b8d2ddc..b42ffa5 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
@@ -57,16 +57,16 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePort
*/
public class PortletFactory {
- private static HashMap<String, PortletViewFactory>
registeredPortletFactoryMap;
- private static HashMap<String, String> registeredPortletNameMap;
+ private static final HashMap<String, PortletViewFactory>
registeredPortletFactoryMap;
+ private static final HashMap<String, String> registeredPortletNameMap;
//Group portlet registrations, diff from default portlets as only applicable for
specific group
- private static HashMap<String, PortletViewFactory>
registeredGroupPortletFactoryMap;
+ private static final HashMap<String, PortletViewFactory>
registeredGroupPortletFactoryMap;
//Resource portlet registrations, diff from default portlets as only applicable for
specific resource
- private static HashMap<String, PortletViewFactory>
registeredResourcePortletFactoryMap;
- private static HashMap<String, String> registeredGroupPortletNameMap;
- private static HashMap<String, String> registeredResourcePortletNameMap;
- private static HashMap<String, String> registeredPortletIconMap;
+ private static final HashMap<String, PortletViewFactory>
registeredResourcePortletFactoryMap;
+ private static final HashMap<String, String> registeredGroupPortletNameMap;
+ private static final HashMap<String, String> registeredResourcePortletNameMap;
+ private static final HashMap<String, String> registeredPortletIconMap;
static {
//############## Default Dashboard ############################
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index e148b1e..f2322b0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -46,7 +46,6 @@ import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
@@ -93,8 +92,8 @@ public class GroupOperationsPortlet extends LocatableVLayout implements
CustomSe
CONFIG_INCLUDE.add(Constant.METRIC_RANGE_LASTN);
CONFIG_INCLUDE.add(Constant.METRIC_RANGE_UNIT);
CONFIG_INCLUDE.add(Constant.RESULT_COUNT);
- CONFIG_INCLUDE.add(Constant.RESULT_SORT_ORDER);
- CONFIG_INCLUDE.add(Constant.RESULT_SORT_PRIORITY);
+ // CONFIG_INCLUDE.add(Constant.RESULT_SORT_ORDER);
+ // CONFIG_INCLUDE.add(Constant.RESULT_SORT_PRIORITY);
CONFIG_INCLUDE.add(Constant.OPERATION_STATUS);
}
@@ -234,9 +233,9 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
//add filter operation status type selector
final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
.getOperationStatusEditor(portletConfig);
- //add sort priority selector
- final SelectItem resultSortSelector = PortletConfigurationEditorComponent
- .getResulSortOrderEditor(portletConfig);
+ // //add sort priority selector
+ // final SelectItem resultSortSelector =
PortletConfigurationEditorComponent
+ // .getResulSortOrderEditor(portletConfig);
//add result count selector
final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
@@ -244,7 +243,7 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
- form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+ form.setItems(operationStatusSelector, resultCountSelector);
//submit handler
customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
@@ -404,18 +403,18 @@ class GroupOperationsCriteriaDataSource extends
GroupOperationHistoryDataSource
//retrieve previous settings from portlet config
if (portletConfig != null) {
- //result sort order
- PropertySimple property =
portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
- criteria.addSortStatus(PageOrdering.DESC);
- } else {
- criteria.addSortStatus(PageOrdering.ASC);
- }
- }
+ // //result sort order
+ // PropertySimple property =
portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ // if (property != null) {
+ // String currentSetting = property.getStringValue();
+ // if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ // criteria.addSortStatus(PageOrdering.DESC);
+ // } else {
+ // criteria.addSortStatus(PageOrdering.ASC);
+ // }
+ // }
//result timeframe if enabled
- property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ PropertySimple property =
portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
boolean isAdvanced = false;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
index 30929c1..a1f9c3e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -41,7 +41,6 @@ import org.rhq.core.domain.operation.ResourceOperationHistory;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
@@ -87,7 +86,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet {
protected void onInit() {
// super.onInit();
initializeUi();
- // loadData();
+ loadData();
}
@Override
@@ -107,9 +106,9 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet
{
//add filter operation status type selector
final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
.getOperationStatusEditor(portletConfig);
- //add sort priority selector
- final SelectItem resultSortSelector = PortletConfigurationEditorComponent
- .getResulSortOrderEditor(portletConfig);
+ // //add sort priority selector
+ // final SelectItem resultSortSelector =
PortletConfigurationEditorComponent
+ // .getResulSortOrderEditor(portletConfig);
//add result count selector
final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
@@ -117,7 +116,7 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet
{
final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
- form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+ form.setItems(operationStatusSelector, resultCountSelector);
//submit handler
customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
@@ -279,18 +278,18 @@ class ResourceOperationsCriteriaDataSource extends
ResourceOperationHistoryDataS
//retrieve previous settings from portlet config
if (portletConfig != null) {
- //result sort order
- PropertySimple property =
portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
- criteria.addSortStatus(PageOrdering.DESC);
- } else {
- criteria.addSortStatus(PageOrdering.ASC);
- }
- }
+ // //result sort order
+ // PropertySimple property =
portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ // if (property != null) {
+ // String currentSetting = property.getStringValue();
+ // if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ // criteria.addSortStatus(PageOrdering.DESC);
+ // } else {
+ // criteria.addSortStatus(PageOrdering.ASC);
+ // }
+ // }
//result timeframe if enabled
- property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ PropertySimple property =
portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
boolean isAdvanced = false;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 9b89dff..86a7c1c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -64,7 +64,7 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView2;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView3;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
@@ -263,7 +263,7 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
updateSubTab(this.summaryTab, this.summaryActivity2, true, true, new
ViewFactory() {
@Override
public Canvas createView() {
- return new
ActivityView2(summaryActivity2.extendLocatorId("View2"), groupComposite);
+ return new
ActivityView3(summaryActivity2.extendLocatorId("View2"), groupComposite);
}
});
// TODO (ips): Add Timeline subtab?
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
index eb0f23c..106ac4b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView.java
@@ -18,685 +18,240 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.util.BooleanCallback;
+import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.LinkItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
-import org.rhq.core.domain.content.InstalledPackageHistory;
-import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.GroupBundleDeploymentCriteria;
-import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
-import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
-import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
-import org.rhq.core.domain.operation.GroupOperationHistory;
-import org.rhq.core.domain.resource.ResourceTypeFacet;
-import org.rhq.core.domain.resource.group.GroupCategory;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardCategory;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.InitializableView;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
-import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
-import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
-import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
-import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
- * The content pane for the group Summary>Activity subtab.
+ * The content pane for the group Summary>Dashboard subtab.
*
* @author Simeon Pinder
+ * @author Jay Shaughnessy
*/
-public class ActivityView extends AbstractActivityView {
- private ResourceGroupComposite groupComposite;
+public class ActivityView extends LocatableVLayout implements DashboardContainer,
InitializableView {
- public ActivityView(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId, groupComposite, null);
- this.groupComposite = groupComposite;
- }
+ private static final String DASHBOARD_NAME_PREFIX = "GroupDashboard_";
- @Override
- protected void onInit() {
- super.onInit();
- loadData();
- }
-
- /**Initiates data request.
- */
- protected void loadData() {
- ResourceGroup group = null;
- GroupCategory groupCategory = null;
- Set<ResourceTypeFacet> facets = null;
- if ((groupComposite != null) && (groupComposite.getResourceGroup() !=
null)) {
- group = groupComposite.getResourceGroup();
- groupCategory = groupComposite.getResourceGroup().getGroupCategory();
- //Load Facets to conditionally display relevant tabs
- facets = groupComposite.getResourceFacets().getFacets();
-
- getRecentAlerts();
- //events
- if (displayGroupEvents(groupCategory, facets)) {
- getRecentEventUpdates();
- }
- //operations
- if (displayGroupOperations(groupCategory, facets)) {
- getRecentOperations();
- }
- //Config updates
- if (displayGroupConfigurationUpdates(groupCategory, facets)) {
- getRecentConfigurationUpdates();
- }
- //recentMetrics,oobs,pkghistory
- if (groupCategory == GroupCategory.COMPATIBLE) {
- getRecentOobs();
- getRecentPkgHistory();
- getRecentMetrics();
- }
-
- //conditionally display Bundle deployments for groups of platforms only
- displayBundleDeploymentsForPlatformGroups(group);
- }
- }
-
- /** Fetches alerts and updates the DynamicForm instance with the latest
- * alert information.
- */
- private void getRecentAlerts() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- //fetches last five alerts for this resource
- AlertCriteria criteria = new AlertCriteria();
- PageControl pageControl = new PageControl(0, 5);
- pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceGroupIds(groupId);
- GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
- @Override
- public void onSuccess(PageList<Alert> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (Alert alert : result) {
- // alert history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
- .getPriority()),
alert.getAlertDefinition().getPriority().getDisplayName());
- LinkItem link = newLinkItem(alert.getAlertDefinition().getName()
+ ": ",
- ReportDecorator.GWT_GROUP_URL + groupId +
"/Alerts/History/" + alert.getId());
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Alerts/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
- RECENT_ALERTS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentAlertsContent.getChildren()) {
- child.destroy();
- }
- recentAlertsContent.addChild(column);
- recentAlertsContent.markForRedraw();
- }
+ private ResourceGroupComposite groupComposite;
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent alerts for group [" +
groupId + "]:" + caught.getMessage());
- }
- });
- }
+ private DashboardGWTServiceAsync dashboardService =
GWTServiceLookup.getDashboardService();
- /** Fetches operations and updates the DynamicForm instance with the latest
- * operation information.
- */
- private void getRecentOperations() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- //fetches five most recent operations.
- PageControl pageControl = new PageControl(0, 5);
-
- GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
- List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
- filterResourceGroupIds.add(groupId);
- criteria.addFilterResourceGroupIds(filterResourceGroupIds);
- criteria.setPageControl(pageControl);
- criteria.addSortStatus(PageOrdering.DESC);
-
-
GWTServiceLookup.getOperationService().findGroupOperationHistoriesByCriteria(criteria,
- new AsyncCallback<PageList<GroupOperationHistory>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent operations for group ["
+ groupId + "]:" + caught.getMessage());
- }
+ private DashboardView dashboardView;
- @Override
- public void onSuccess(PageList<GroupOperationHistory> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (GroupOperationHistory report : result) {
- // operation history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getOperationResultsIcon(report
- .getStatus()), report.getStatus().getDisplayName());
- LinkItem link =
newLinkItem(report.getOperationDefinition().getDisplayName() + ": ",
- ReportDecorator.GWT_GROUP_URL + groupId +
"/Operations/History/" + report.getId());
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(report
- .getStartedTime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //insert see more link
- LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Operations/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentOperationsContent
- .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(column);
- recentOperationsContent.markForRedraw();
- }
- });
- }
+ private LocatableToolStrip footer;
+ private IButton editButton;
+ private IButton resetButton;
- /** Fetches configuration updates and updates the DynamicForm instance with the
latest
- * config change information.
- */
- private void getRecentConfigurationUpdates() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
-
- PageControl lastFive = new PageControl(0, 5);
- GroupResourceConfigurationUpdateCriteria criteria = new
GroupResourceConfigurationUpdateCriteria();
- criteria.setPageControl(lastFive);
- criteria.addSortStatus(PageOrdering.DESC);
- List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
- filterResourceGroupIds.add(groupId);
- criteria.addFilterResourceGroupIds(filterResourceGroupIds);
-
-
GWTServiceLookup.getConfigurationService().findGroupResourceConfigurationUpdatesByCriteria(criteria,
- new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>()
{
-
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent configuration updates for
group [" + groupId + "]:"
- + caught.getMessage());
- }
+ // Capture the user's global permissions for use by any dashboard or portlet that
may need it for rendering.
+ private Set<Permission> globalPermissions;
- @Override
- public void onSuccess(PageList<GroupResourceConfigurationUpdate>
result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (GroupResourceConfigurationUpdate update : result) {
- // config update history records do not have a usable
locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
- .getStatus()), null);
- String linkTitle =
MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName() + ":";
- if ((update.getSubjectName() == null) ||
(update.getSubjectName().trim().isEmpty())) {
- linkTitle = MSG.common_msg_changeAutoDetected();
- }
- LinkItem link = newLinkItem(linkTitle,
ReportDecorator.GWT_GROUP_URL + groupId
- + "/Configuration/History/" + update.getId());
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(update
- .getCreatedTime()));
+ private boolean editMode = false;
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- //insert see more link
- LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Configuration/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentConfigurationContent
- .extendLocatorId("None"),
RECENT_CONFIGURATIONS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentConfigurationContent.getChildren()) {
- child.destroy();
- }
- recentConfigurationContent.addChild(column);
- recentConfigurationContent.markForRedraw();
+ private boolean isInitialized = false;
- }
- });
+ public ActivityView(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId);
+ this.groupComposite = groupComposite;
}
- /** Fetches recent events and updates the DynamicForm instance with the latest
- * event information over last 24hrs.
- */
- private void getRecentEventUpdates() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- long now = System.currentTimeMillis();
- long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
- GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(groupId,
nowMinus24Hours, now,
- new AsyncCallback<Map<EventSeverity, Integer>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log
- .debug("Error retrieving recent event counts for group
[" + groupId + "]:"
- + caught.getMessage());
- }
-
- @Override
- public void onSuccess(Map<EventSeverity, Integer> eventCounts) {
- //Now populated Tuples
- List<GwtTuple<EventSeverity, Integer>> results = new
ArrayList<GwtTuple<EventSeverity, Integer>>();
- for (EventSeverity severity : eventCounts.keySet()) {
- int count = eventCounts.get(severity);
- if (count > 0) {
- results.add(new GwtTuple<EventSeverity,
Integer>(severity, count));
- }
- }
- //build display
- VLayout column = new VLayout();
- column.setHeight(10);
-
- if (!results.isEmpty()) {
- int rowNum = 0;
- for (GwtTuple<EventSeverity, Integer> tuple : results) {
- // event history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(2);
- row.setWidth(10);//pack.
-
- //icon
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
- .getLefty()), tuple.getLefty().name());
- //count
- StaticTextItem count =
newTextItem(String.valueOf(tuple.righty));
- row.setItems(iconItem, count);
-
- column.addMember(row);
+ @Override
+ protected void onInit() {
+ if (!isInitialized()) {
+ super.onInit();
+
+ // first async call to get global permissions
+ new PermissionsLoader().loadExplicitGlobalPermissions(new
PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ globalPermissions = permissions;
+
+ // now make async call to look for customized dash for this user and
entity
+ DashboardCriteria criteria = new DashboardCriteria();
+ criteria.addFilterCategory(DashboardCategory.GROUP);
+
criteria.addFilterGroupId(groupComposite.getResourceGroup().getId());
+ dashboardService.findDashboardsByCriteria(criteria, new
AsyncCallback<PageList<Dashboard>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
}
- //insert see more link
- LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum)));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Events/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
- RECENT_EVENTS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentEventsContent.getChildren()) {
- child.destroy();
- }
- recentEventsContent.addChild(column);
- recentEventsContent.markForRedraw();
- }
- });
- }
- /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
- * oob change details.
- */
- private void getRecentOobs() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
-
- GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForGroup(groupId, 5,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent out of bound metrics for
group [" + groupId + "]:"
- + caught.getMessage());
- }
+ public void onSuccess(final PageList<Dashboard> result) {
+ Dashboard dashboard = result.isEmpty() ?
getDefaultDashboard() : result.get(0);
+ setDashboard(dashboard);
+
+ isInitialized = true;
- @Override
- public void onSuccess(PageList<MeasurementOOBComposite> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- for (MeasurementOOBComposite oob : result) {
- LocatableDynamicForm row = new
LocatableDynamicForm(recentOobContent.extendLocatorId(oob
- .getScheduleName()));
- row.setNumCols(2);
-
- String title = oob.getScheduleName() + ":";
- String destination =
"/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId()
- + "&id=" + groupId +
"&mode=chartSingleMetricSingleResource";
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
-
- row.setItems(link, time);
- column.addMember(row);
+ // draw() may be done since onInit finishes asynchronously,
if so redraw
+ if (isDrawn()) {
+ markForRedraw();
+ }
}
- //insert see more link spinder(2/24/11): no page that displays
all oobs... See More not possible.
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
- RECENT_OOB_NONE);
- column.addMember(row);
- }
- recentOobContent.setContents("");
- for (Canvas child : recentOobContent.getChildren()) {
- child.destroy();
- }
- recentOobContent.addChild(column);
- recentOobContent.markForRedraw();
+ });
}
});
+ }
}
- /** Fetches recent package history information and updates the DynamicForm instance
with details.
- */
- private void getRecentPkgHistory() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- InstalledPackageHistoryCriteria criteria = new
InstalledPackageHistoryCriteria();
- PageControl pageControl = new PageControl(0, 5);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceGroupIds(groupId);
- criteria.addSortStatus(PageOrdering.DESC);
-
-
GWTServiceLookup.getContentService().findInstalledPackageHistoryByCriteria(criteria,
-
- new AsyncCallback<PageList<InstalledPackageHistory>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving installed package history for group
[" + groupId + "]:"
- + caught.getMessage());
+ private void setDashboard(Dashboard dashboard) {
+ Canvas[] members = getMembers();
+ removeMembers(members);
+ //pass in the group information
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, groupComposite, null);
+ addMember(dashboardView);
+
+ footer = new LocatableToolStrip(extendLocatorId("Footer"));
+ footer.setPadding(5);
+ footer.setWidth100();
+ footer.setMembersMargin(15);
+
+ editButton = new LocatableIButton(footer.extendLocatorId("Mode"),
editMode ? MSG.common_title_view_mode() : MSG
+ .common_title_edit_mode());
+ editButton.setAutoFit(true);
+ editButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ editMode = !editMode;
+ editButton.setTitle(editMode ? MSG.common_title_view_mode() :
MSG.common_title_edit_mode());
+ dashboardView.setEditMode(editMode);
}
+ });
- @Override
- public void onSuccess(PageList<InstalledPackageHistory> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- for (InstalledPackageHistory history : result) {
- LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
- .extendLocatorId(history.getPackageVersion().getFileName()
- + history.getPackageVersion().getVersion()));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Package_16.png", null);
- String title = history.getPackageVersion().getFileName() +
":";
- String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId
- + "&selectedHistoryId=" + history.getId();
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(history.getTimestamp()));
-
- row.setItems(iconItem, link, time);
- column.addMember(row);
+ resetButton = new LocatableIButton(footer.extendLocatorId("Reset"),
MSG.common_button_reset());
+ resetButton.setAutoFit(true);
+ resetButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ String message = MSG.view_summaryDashboard_resetConfirm();
+
+ SC.ask(message, new BooleanCallback() {
+ public void execute(Boolean confirmed) {
+ if (confirmed) {
+ dashboardView.delete();
+ setDashboard(getDefaultDashboard());
+ markForRedraw();
+ }
}
- // //insert see more link
- // LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
- //
.extendLocatorId("PkgHistoryContentSeeMore"));
- // String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId;
- // addSeeMoreLink(row, destination, column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentPkgHistoryContent.extendLocatorId("None"),
- RECENT_PKG_HISTORY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentPkgHistoryContent.getChildren()) {
- child.destroy();
- }
- recentPkgHistoryContent.addChild(column);
- recentPkgHistoryContent.markForRedraw();
+ });
}
});
- }
- /** Fetches recent metric information and updates the DynamicForm instance with
i)sparkline information,
- * ii) link to recent metric graph for more details and iii) last metric value
formatted to show significant
- * digits.
- */
- private void getRecentMetrics() {
+ footer.addMember(editButton);
+ footer.addMember(resetButton);
- //display container
- final VLayout column = new VLayout();
- column.setHeight(10);//pack
- final int groupId = this.groupComposite.getResourceGroup().getId();
+ addMember(footer);
+ }
- //retrieve all relevant measurement definition ids.
- Set<MeasurementDefinition> definitions =
this.groupComposite.getResourceGroup().getResourceType()
- .getMetricDefinitions();
+ protected Dashboard getDefaultDashboard() {
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ ResourceGroup group = groupComposite.getResourceGroup();
+
+ Dashboard dashboard = new Dashboard();
+
+ dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_"
+ group.getId());
+ dashboard.setCategory(DashboardCategory.GROUP);
+ dashboard.setGroup(group);
+ dashboard.setColumns(2);
+
+ // set leftmost column and let the rest be equally divided
+ dashboard.setColumnWidths("40%");
+ dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
+
+ //figure out which portlets to display and how
+ HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
+ groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap,
groupComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left
if available
+ DashboardPortlet measurements = new
DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ }
- //build id mapping for measurementDefinition instances Ex. Free Memory ->
MeasurementDefinition[100071]
- final HashMap<String, MeasurementDefinition> measurementDefMap = new
HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition definition : definitions) {
- measurementDefMap.put(definition.getDisplayName(), definition);
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (groupKeyNameMap.containsKey(GroupAlertsPortlet.KEY)) {//alerts top right if
available
+ DashboardPortlet alerts = new DashboardPortlet(GroupAlertsPortlet.NAME,
GroupAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupAlertsPortlet.KEY);
}
- //bundle definition ids for asynch call.
- int[] definitionArrayIds = new int[definitions.size()];
- final String[] displayOrder = new String[definitions.size()];
- measurementDefMap.keySet().toArray(displayOrder);
- //sort the charting data ex. Free Memory, Free Swap Space,..System Load
- Arrays.sort(displayOrder);
-
- //organize definitionArrayIds for ordered request on server.
- int index = 0;
- for (String definitionToDisplay : displayOrder) {
- definitionArrayIds[index++] =
measurementDefMap.get(definitionToDisplay).getId();
+ if (groupKeyNameMap.containsKey(GroupOperationsPortlet.KEY)) {//operations if
available
+ DashboardPortlet ops = new DashboardPortlet(GroupOperationsPortlet.NAME,
GroupOperationsPortlet.KEY, 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
}
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(groupId,
definitionArrayIds,
- System.currentTimeMillis() - (1000L * 60 * 60 * 8),
System.currentTimeMillis(), 60,
- new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent metrics charting data for
group [" + groupId + "]:"
- + caught.getMessage());
+ //Fill out left column(typically smaller portlets) then alternate cols with
remaining
+ boolean displayLeft = false;
+ for (String key : groupKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key),
key, 100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
}
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
+ return dashboard;
+ }
- @Override
- public void
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
- if (!results.isEmpty()) {
- boolean someChartedData = false;
- //iterate over the retrieved charting data
- for (int index = 0; index < displayOrder.length; index++) {
- //retrieve the correct measurement definition
- MeasurementDefinition md =
measurementDefMap.get(displayOrder[index]);
-
- //load the data results for the given metric definition
- List<MeasurementDataNumericHighLowComposite> data =
results.get(index);
-
- //locate last and minimum values.
- double lastValue = -1;
- double minValue = Double.MAX_VALUE;//
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- if (d.getValue() < minValue) {
- minValue = d.getValue();
- }
- lastValue = d.getValue();
- }
- }
-
- //collapse the data into comma delimited list for consumption
by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
-
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- commaDelimitedList += d.getValue() + ",";
- }
- }
- LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
- .extendLocatorId(md.getName()));
- row.setNumCols(3);
- HTMLFlow graph = new HTMLFlow();
- // String contents = "<span
id='sparkline_" + index + "' class='dynamicsparkline'
width='0'>"
- // + commaDelimitedList +
"</span>";
- String contents = "<span id='sparkline_" +
index + "' class='dynamicsparkline' width='0' "
- + "values='" + commaDelimitedList +
"'>...</span>";
- graph.setContents(contents);
- graph.setContentsType(ContentsType.PAGE);
- //diable scrollbars on span
- graph.setScrollbarSize(0);
-
- CanvasItem graphContainer = new CanvasItem();
- graphContainer.setShowTitle(false);
- graphContainer.setHeight(16);
- graphContainer.setWidth(60);
- graphContainer.setCanvas(graph);
-
- //Link/title element
- //TODO: spinder, change link whenever portal.war/graphing is
removed.
- String title = md.getDisplayName() + ":";
- // String destination =
"/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- // + resourceId +
"&m=" + md.getId();
- String destination =
"/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
- + groupId + "&m=" + md.getId();
- LinkItem link = newLinkItem(title, destination);
-
- //Value
- String convertedValue = lastValue + " " +
md.getUnits();
- convertedValue = convertLastValueForDisplay(lastValue, md);
- StaticTextItem value = newTextItem(convertedValue);
-
- row.setItems(graphContainer, link, value);
- //if graph content returned
- if ((md.getName().trim().indexOf("Trait.") == -1)
&& (lastValue != -1)) {
- column.addMember(row);
- someChartedData = true;
- }
- }
- if (!someChartedData) {// when there are results but no chartable
entries.
- LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
-
.extendLocatorId("RecentMeasurementsContentSeeMore"));
- addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Monitoring/Graphs/", column);
- }
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- }
- }
- });
+ @Override
+ public boolean isInitialized() {
+ return isInitialized;
+ }
- //cleanup
- for (Canvas child : recentMeasurementsContent.getChildren()) {
- child.destroy();
- }
- recentMeasurementsContent.addChild(column);
- recentMeasurementsContent.markForRedraw();
+ public Set<Permission> getGlobalPermissions() {
+ return globalPermissions;
}
- /** Fetches recent bundle deployment information and updates the DynamicForm instance
with details.
+ /**
+ * name update not supported because the name is derived from the entity id.
+ * @return
*/
- protected void getRecentBundleDeployments() {
- final int groupId = this.groupComposite.getResourceGroup().getId();
- GroupBundleDeploymentCriteria criteria = new GroupBundleDeploymentCriteria();
- PageControl pageControl = new PageControl(0, 5);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceGroupIds(groupId);
- criteria.addSortStatus(PageOrdering.DESC);
- criteria.fetchDestination(true);
- criteria.fetchBundleVersion(true);
-
- GWTServiceLookup.getBundleService().findBundleDeploymentsByCriteria(criteria,
- new AsyncCallback<PageList<BundleDeployment>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving installed bundle deployments for
group [" + groupId + "]:"
- + caught.getMessage());
- }
+ public boolean supportsDashboardNameEdit() {
+ return false;
+ }
- @Override
- public void onSuccess(PageList<BundleDeployment> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- for (BundleDeployment deployment : result) {
- LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent
- .extendLocatorId(deployment.getBundleVersion().getName()
- + deployment.getBundleVersion().getVersion()));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Content_16.png", null);
- String title = deployment.getBundleVersion().getName() +
"["
- + deployment.getBundleVersion().getVersion() +
"]:";
- String destination = ReportDecorator.GWT_BUNDLE_URL
- + deployment.getBundleVersion().getBundle().getId() +
"/destinations/"
- + deployment.getDestination().getId();
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter
- .format(deployment.getCtime()));
-
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- //insert see more link
- //TODO: spinder:2/25/11 (add this later) no current view for
seeing all bundle deployments
- // LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent.extendLocatorId("RecentBundleContentSeeMore"));
- // addSeeMoreLink(row,
LinkManager.getResourceGroupLink(groupId) + "/Events/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentBundleDeployContent
- .extendLocatorId("None"),
RECENT_BUNDLE_DEPLOY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentBundleDeployContent.getChildren()) {
- child.destroy();
- }
- recentBundleDeployContent.addChild(column);
- recentBundleDeployContent.markForRedraw();
- }
- });
+ public void updateDashboardNames() {
+ return;
}
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
deleted file mode 100644
index af8d09c..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 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.summary;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.util.BooleanCallback;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DashboardCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardCategory;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-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.InitializableView;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * The content pane for the group Summary>Dashboard subtab.
- *
- * @author Simeon Pinder
- * @author Jay Shaughnessy
- */
-
-public class ActivityView2 extends LocatableVLayout implements DashboardContainer,
InitializableView {
-
- private static final String DASHBOARD_NAME_PREFIX = "GroupDashboard_";
-
- private ResourceGroupComposite groupComposite;
-
- private DashboardGWTServiceAsync dashboardService =
GWTServiceLookup.getDashboardService();
-
- private DashboardView dashboardView;
-
- private LocatableToolStrip footer;
- private IButton editButton;
- private IButton resetButton;
-
- // Capture the user's global permissions for use by any dashboard or portlet that
may need it for rendering.
- private Set<Permission> globalPermissions;
-
- private boolean editMode = false;
-
- private boolean isInitialized = false;
-
- public ActivityView2(String locatorId, ResourceGroupComposite groupComposite) {
- super(locatorId);
- this.groupComposite = groupComposite;
- }
-
- @Override
- protected void onInit() {
- if (!isInitialized()) {
- super.onInit();
-
- // first async call to get global permissions
- new PermissionsLoader().loadExplicitGlobalPermissions(new
PermissionsLoadedListener() {
-
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
-
- // now make async call to look for customized dash for this user and
entity
- DashboardCriteria criteria = new DashboardCriteria();
- criteria.addFilterCategory(DashboardCategory.GROUP);
-
criteria.addFilterGroupId(groupComposite.getResourceGroup().getId());
- dashboardService.findDashboardsByCriteria(criteria, new
AsyncCallback<PageList<Dashboard>>() {
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
- }
-
- public void onSuccess(final PageList<Dashboard> result) {
- Dashboard dashboard = result.isEmpty() ?
getDefaultDashboard() : result.get(0);
- setDashboard(dashboard);
-
- isInitialized = true;
-
- // draw() may be done since onInit finishes asynchronously,
if so redraw
- if (isDrawn()) {
- markForRedraw();
- }
- }
- });
- }
- });
- }
- }
-
- private void setDashboard(Dashboard dashboard) {
- Canvas[] members = getMembers();
- removeMembers(members);
- //pass in the group information
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, groupComposite, null);
- addMember(dashboardView);
-
- footer = new LocatableToolStrip(extendLocatorId("Footer"));
- footer.setPadding(5);
- footer.setWidth100();
- footer.setMembersMargin(15);
-
- editButton = new LocatableIButton(footer.extendLocatorId("Mode"),
editMode ? MSG.common_title_view_mode() : MSG
- .common_title_edit_mode());
- editButton.setAutoFit(true);
- editButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- editMode = !editMode;
- editButton.setTitle(editMode ? MSG.common_title_view_mode() :
MSG.common_title_edit_mode());
- dashboardView.setEditMode(editMode);
- }
- });
-
- resetButton = new LocatableIButton(footer.extendLocatorId("Reset"),
MSG.common_button_reset());
- resetButton.setAutoFit(true);
- resetButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- String message = MSG.view_summaryDashboard_resetConfirm();
-
- SC.ask(message, new BooleanCallback() {
- public void execute(Boolean confirmed) {
- if (confirmed) {
- dashboardView.delete();
- setDashboard(getDefaultDashboard());
- markForRedraw();
- }
- }
- });
- }
- });
-
- footer.addMember(editButton);
- footer.addMember(resetButton);
-
- addMember(footer);
- }
-
- protected Dashboard getDefaultDashboard() {
- Subject sessionSubject = UserSessionManager.getSessionSubject();
- ResourceGroup group = groupComposite.getResourceGroup();
-
- Dashboard dashboard = new Dashboard();
-
- dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_"
+ group.getId());
- dashboard.setCategory(DashboardCategory.GROUP);
- dashboard.setGroup(group);
- dashboard.setColumns(2);
-
- // set leftmost column and let the rest be equally divided
- dashboard.setColumnWidths("40%");
- dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
-
- //figure out which portlets to display and how
- HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
- groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap,
groupComposite);
- int colLeft = 0;
- int colRight = 1;
- int rowLeft = 0;
- int rowRight = 0;
- //Left Column
- if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left
if available
- DashboardPortlet measurements = new
DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
- dashboard.addPortlet(measurements, colLeft, rowLeft++);
- groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
- }
-
- // right Column(approx 60%. As larger more room to display table and N rows.)
- if (groupKeyNameMap.containsKey(GroupAlertsPortlet.KEY)) {//alerts top right if
available
- DashboardPortlet alerts = new DashboardPortlet(GroupAlertsPortlet.NAME,
GroupAlertsPortlet.KEY, 220);
- dashboard.addPortlet(alerts, colRight, rowRight++);
- groupKeyNameMap.remove(GroupAlertsPortlet.KEY);
- }
- if (groupKeyNameMap.containsKey(GroupOperationsPortlet.KEY)) {//operations if
available
- DashboardPortlet ops = new DashboardPortlet(GroupOperationsPortlet.NAME,
GroupOperationsPortlet.KEY, 220);
- dashboard.addPortlet(ops, colRight, rowRight++);
- groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
- }
-
- //Fill out left column(typically smaller portlets) then alternate cols with
remaining
- boolean displayLeft = false;
- for (String key : groupKeyNameMap.keySet()) {
- DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key),
key, 100);
- if (rowLeft < 4) {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- } else {//alternate
- if (!displayLeft) {
- dashboard.addPortlet(portlet, colRight, rowRight++);
- } else {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- }
- //toggle
- displayLeft = !displayLeft;
- }
- }
- return dashboard;
- }
-
- @Override
- public boolean isInitialized() {
- return isInitialized;
- }
-
- public Set<Permission> getGlobalPermissions() {
- return globalPermissions;
- }
-
- /**
- * name update not supported because the name is derived from the entity id.
- * @return
- */
- public boolean supportsDashboardNameEdit() {
- return false;
- }
-
- public void updateDashboardNames() {
- return;
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java
new file mode 100644
index 0000000..d8ef22f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView3.java
@@ -0,0 +1,702 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 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.summary;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+import org.rhq.core.domain.content.InstalledPackageHistory;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.criteria.GroupBundleDeploymentCriteria;
+import org.rhq.core.domain.criteria.GroupOperationHistoryCriteria;
+import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
+import org.rhq.core.domain.criteria.InstalledPackageHistoryCriteria;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.operation.GroupOperationHistory;
+import org.rhq.core.domain.resource.ResourceTypeFacet;
+import org.rhq.core.domain.resource.group.GroupCategory;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * The content pane for the group Summary>Activity subtab.
+ *
+ * @author Simeon Pinder
+ */
+public class ActivityView3 extends AbstractActivityView {
+
+ private ResourceGroupComposite groupComposite;
+
+ public ActivityView3(String locatorId, ResourceGroupComposite groupComposite) {
+ super(locatorId, groupComposite, null);
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Initiates data request.
+ */
+ protected void loadData() {
+ ResourceGroup group = null;
+ GroupCategory groupCategory = null;
+ Set<ResourceTypeFacet> facets = null;
+ if ((groupComposite != null) && (groupComposite.getResourceGroup() !=
null)) {
+ group = groupComposite.getResourceGroup();
+ groupCategory = groupComposite.getResourceGroup().getGroupCategory();
+ //Load Facets to conditionally display relevant tabs
+ facets = groupComposite.getResourceFacets().getFacets();
+
+ getRecentAlerts();
+ //events
+ if (displayGroupEvents(groupCategory, facets)) {
+ getRecentEventUpdates();
+ }
+ //operations
+ if (displayGroupOperations(groupCategory, facets)) {
+ getRecentOperations();
+ }
+ //Config updates
+ if (displayGroupConfigurationUpdates(groupCategory, facets)) {
+ getRecentConfigurationUpdates();
+ }
+ //recentMetrics,oobs,pkghistory
+ if (groupCategory == GroupCategory.COMPATIBLE) {
+ getRecentOobs();
+ getRecentPkgHistory();
+ getRecentMetrics();
+ }
+
+ //conditionally display Bundle deployments for groups of platforms only
+ displayBundleDeploymentsForPlatformGroups(group);
+ }
+ }
+
+ /** Fetches alerts and updates the DynamicForm instance with the latest
+ * alert information.
+ */
+ private void getRecentAlerts() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ //fetches last five alerts for this resource
+ AlertCriteria criteria = new AlertCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceGroupIds(groupId);
+ GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (Alert alert : result) {
+ // alert history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
+ .getPriority()),
alert.getAlertDefinition().getPriority().getDisplayName());
+ LinkItem link = newLinkItem(alert.getAlertDefinition().getName()
+ ": ",
+ ReportDecorator.GWT_GROUP_URL + groupId +
"/Alerts/History/" + alert.getId());
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Alerts/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
+ RECENT_ALERTS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for group [" +
groupId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ /** Fetches operations and updates the DynamicForm instance with the latest
+ * operation information.
+ */
+ private void getRecentOperations() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ //fetches five most recent operations.
+ PageControl pageControl = new PageControl(0, 5);
+
+ GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+ List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
+ filterResourceGroupIds.add(groupId);
+ criteria.addFilterResourceGroupIds(filterResourceGroupIds);
+ criteria.setPageControl(pageControl);
+ criteria.addSortStatus(PageOrdering.DESC);
+
+
GWTServiceLookup.getOperationService().findGroupOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupOperationHistory>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent operations for group ["
+ groupId + "]:" + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<GroupOperationHistory> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (GroupOperationHistory report : result) {
+ // operation history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getOperationResultsIcon(report
+ .getStatus()), report.getStatus().getDisplayName());
+ LinkItem link =
newLinkItem(report.getOperationDefinition().getDisplayName() + ": ",
+ ReportDecorator.GWT_GROUP_URL + groupId +
"/Operations/History/" + report.getId());
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(report
+ .getStartedTime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //insert see more link
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Operations/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentOperationsContent
+ .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(column);
+ recentOperationsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches configuration updates and updates the DynamicForm instance with the
latest
+ * config change information.
+ */
+ private void getRecentConfigurationUpdates() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+
+ PageControl lastFive = new PageControl(0, 5);
+ GroupResourceConfigurationUpdateCriteria criteria = new
GroupResourceConfigurationUpdateCriteria();
+ criteria.setPageControl(lastFive);
+ criteria.addSortStatus(PageOrdering.DESC);
+ List<Integer> filterResourceGroupIds = new ArrayList<Integer>();
+ filterResourceGroupIds.add(groupId);
+ criteria.addFilterResourceGroupIds(filterResourceGroupIds);
+
+
GWTServiceLookup.getConfigurationService().findGroupResourceConfigurationUpdatesByCriteria(criteria,
+ new AsyncCallback<PageList<GroupResourceConfigurationUpdate>>()
{
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent configuration updates for
group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<GroupResourceConfigurationUpdate>
result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (GroupResourceConfigurationUpdate update : result) {
+ // config update history records do not have a usable
locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
+ .getStatus()), null);
+ String linkTitle =
MSG.view_resource_inventory_activity_changed_by() + " "
+ + update.getSubjectName() + ":";
+ if ((update.getSubjectName() == null) ||
(update.getSubjectName().trim().isEmpty())) {
+ linkTitle = MSG.common_msg_changeAutoDetected();
+ }
+ LinkItem link = newLinkItem(linkTitle,
ReportDecorator.GWT_GROUP_URL + groupId
+ + "/Configuration/History/" + update.getId());
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(update
+ .getCreatedTime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //insert see more link
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Configuration/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentConfigurationContent
+ .extendLocatorId("None"),
RECENT_CONFIGURATIONS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(column);
+ recentConfigurationContent.markForRedraw();
+
+ }
+ });
+ }
+
+ /** Fetches recent events and updates the DynamicForm instance with the latest
+ * event information over last 24hrs.
+ */
+ private void getRecentEventUpdates() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ long now = System.currentTimeMillis();
+ long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+ GWTServiceLookup.getEventService().getEventCountsBySeverityForGroup(groupId,
nowMinus24Hours, now,
+ new AsyncCallback<Map<EventSeverity, Integer>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log
+ .debug("Error retrieving recent event counts for group
[" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(Map<EventSeverity, Integer> eventCounts) {
+ //Now populated Tuples
+ List<GwtTuple<EventSeverity, Integer>> results = new
ArrayList<GwtTuple<EventSeverity, Integer>>();
+ for (EventSeverity severity : eventCounts.keySet()) {
+ int count = eventCounts.get(severity);
+ if (count > 0) {
+ results.add(new GwtTuple<EventSeverity,
Integer>(severity, count));
+ }
+ }
+ //build display
+ VLayout column = new VLayout();
+ column.setHeight(10);
+
+ if (!results.isEmpty()) {
+ int rowNum = 0;
+ for (GwtTuple<EventSeverity, Integer> tuple : results) {
+ // event history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(2);
+ row.setWidth(10);//pack.
+
+ //icon
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
+ .getLefty()), tuple.getLefty().name());
+ //count
+ StaticTextItem count =
newTextItem(String.valueOf(tuple.righty));
+ row.setItems(iconItem, count);
+
+ column.addMember(row);
+ }
+ //insert see more link
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent.extendLocatorId(String
+ .valueOf(rowNum)));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Events/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
+ RECENT_EVENTS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentEventsContent.getChildren()) {
+ child.destroy();
+ }
+ recentEventsContent.addChild(column);
+ recentEventsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
+ * oob change details.
+ */
+ private void getRecentOobs() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+
+ GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForGroup(groupId, 5,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent out of bound metrics for
group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (MeasurementOOBComposite oob : result) {
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentOobContent.extendLocatorId(oob
+ .getScheduleName()));
+ row.setNumCols(2);
+
+ String title = oob.getScheduleName() + ":";
+ String destination =
"/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId()
+ + "&id=" + groupId +
"&mode=chartSingleMetricSingleResource";
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
+
+ row.setItems(link, time);
+ column.addMember(row);
+ }
+ //insert see more link spinder(2/24/11): no page that displays
all oobs... See More not possible.
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
+ RECENT_OOB_NONE);
+ column.addMember(row);
+ }
+ recentOobContent.setContents("");
+ for (Canvas child : recentOobContent.getChildren()) {
+ child.destroy();
+ }
+ recentOobContent.addChild(column);
+ recentOobContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent package history information and updates the DynamicForm instance
with details.
+ */
+ private void getRecentPkgHistory() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ InstalledPackageHistoryCriteria criteria = new
InstalledPackageHistoryCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceGroupIds(groupId);
+ criteria.addSortStatus(PageOrdering.DESC);
+
+
GWTServiceLookup.getContentService().findInstalledPackageHistoryByCriteria(criteria,
+
+ new AsyncCallback<PageList<InstalledPackageHistory>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed package history for group
[" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<InstalledPackageHistory> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (InstalledPackageHistory history : result) {
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
+ .extendLocatorId(history.getPackageVersion().getFileName()
+ + history.getPackageVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Package_16.png", null);
+ String title = history.getPackageVersion().getFileName() +
":";
+ String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId
+ + "&selectedHistoryId=" + history.getId();
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(history.getTimestamp()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ // //insert see more link
+ // LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
+ //
.extendLocatorId("PkgHistoryContentSeeMore"));
+ // String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + groupId;
+ // addSeeMoreLink(row, destination, column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentPkgHistoryContent.extendLocatorId("None"),
+ RECENT_PKG_HISTORY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ child.destroy();
+ }
+ recentPkgHistoryContent.addChild(column);
+ recentPkgHistoryContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent metric information and updates the DynamicForm instance with
i)sparkline information,
+ * ii) link to recent metric graph for more details and iii) last metric value
formatted to show significant
+ * digits.
+ */
+ private void getRecentMetrics() {
+
+ //display container
+ final VLayout column = new VLayout();
+ column.setHeight(10);//pack
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+
+ //retrieve all relevant measurement definition ids.
+ Set<MeasurementDefinition> definitions =
this.groupComposite.getResourceGroup().getResourceType()
+ .getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory ->
MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new
HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+ //bundle definition ids for asynch call.
+ int[] definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] =
measurementDefMap.get(definitionToDisplay).getId();
+ }
+
+ //make the asynchronous call for all the measurement data
+ GWTServiceLookup.getMeasurementDataService().findDataForCompatibleGroup(groupId,
definitionArrayIds,
+ System.currentTimeMillis() - (1000L * 60 * 60 * 8),
System.currentTimeMillis(), 60,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent metrics charting data for
group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+ //retrieve the correct measurement definition
+ MeasurementDefinition md =
measurementDefMap.get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data =
results.get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
+ }
+ lastValue = d.getValue();
+ }
+ }
+
+ //collapse the data into comma delimited list for consumption
by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
+ }
+ }
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
+ .extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ HTMLFlow graph = new HTMLFlow();
+ // String contents = "<span
id='sparkline_" + index + "' class='dynamicsparkline'
width='0'>"
+ // + commaDelimitedList +
"</span>";
+ String contents = "<span id='sparkline_" +
index + "' class='dynamicsparkline' width='0' "
+ + "values='" + commaDelimitedList +
"'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //diable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ //TODO: spinder, change link whenever portal.war/graphing is
removed.
+ String title = md.getDisplayName() + ":";
+ // String destination =
"/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ // + resourceId +
"&m=" + md.getId();
+ String destination =
"/resource/common/monitor/Visibility.do?mode=chartSingleMetricMultiResource&groupId="
+ + groupId + "&m=" + md.getId();
+ LinkItem link = newLinkItem(title, destination);
+
+ //Value
+ String convertedValue = lastValue + " " +
md.getUnits();
+ convertedValue = convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = newTextItem(convertedValue);
+
+ row.setItems(graphContainer, link, value);
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
&& (lastValue != -1)) {
+ column.addMember(row);
+ someChartedData = true;
+ }
+ }
+ if (!someChartedData) {// when there are results but no chartable
entries.
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
+
.extendLocatorId("RecentMeasurementsContentSeeMore"));
+ addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + groupId +
"/Monitoring/Graphs/", column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
+ }
+ });
+
+ //cleanup
+ for (Canvas child : recentMeasurementsContent.getChildren()) {
+ child.destroy();
+ }
+ recentMeasurementsContent.addChild(column);
+ recentMeasurementsContent.markForRedraw();
+ }
+
+ /** Fetches recent bundle deployment information and updates the DynamicForm instance
with details.
+ */
+ protected void getRecentBundleDeployments() {
+ final int groupId = this.groupComposite.getResourceGroup().getId();
+ GroupBundleDeploymentCriteria criteria = new GroupBundleDeploymentCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceGroupIds(groupId);
+ criteria.addSortStatus(PageOrdering.DESC);
+ criteria.fetchDestination(true);
+ criteria.fetchBundleVersion(true);
+
+ GWTServiceLookup.getBundleService().findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed bundle deployments for
group [" + groupId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<BundleDeployment> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (BundleDeployment deployment : result) {
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent
+ .extendLocatorId(deployment.getBundleVersion().getName()
+ + deployment.getBundleVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Content_16.png", null);
+ String title = deployment.getBundleVersion().getName() +
"["
+ + deployment.getBundleVersion().getVersion() +
"]:";
+ String destination = ReportDecorator.GWT_BUNDLE_URL
+ + deployment.getBundleVersion().getBundle().getId() +
"/destinations/"
+ + deployment.getDestination().getId();
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter
+ .format(deployment.getCtime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //insert see more link
+ //TODO: spinder:2/25/11 (add this later) no current view for
seeing all bundle deployments
+ // LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent.extendLocatorId("RecentBundleContentSeeMore"));
+ // addSeeMoreLink(row,
LinkManager.getResourceGroupLink(groupId) + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentBundleDeployContent
+ .extendLocatorId("None"),
RECENT_BUNDLE_DEPLOY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentBundleDeployContent.getChildren()) {
+ child.destroy();
+ }
+ recentBundleDeployContent.addChild(column);
+ recentBundleDeployContent.markForRedraw();
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index aec77ac..38e09eb 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -67,8 +67,8 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitorin
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleListView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.Activity2View;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView3;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -287,7 +287,7 @@ public class ResourceDetailView extends
AbstractTwoLevelTabSetView<ResourceCompo
updateSubTab(this.summaryTab, this.summaryActivity2, true, true, new
ViewFactory() {
@Override
public Canvas createView() {
- return new
Activity2View(summaryActivity2.extendLocatorId("View"), resourceComposite);
+ return new
ActivityView3(summaryActivity2.extendLocatorId("View"), resourceComposite);
}
});
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
deleted file mode 100644
index ad6e607..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
+++ /dev/null
@@ -1,243 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.util.BooleanCallback;
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-
-import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.DashboardCriteria;
-import org.rhq.core.domain.dashboard.Dashboard;
-import org.rhq.core.domain.dashboard.DashboardCategory;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.InitializableView;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
-import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * The content pane for the resource Summary>Dashboard subtab.
- *
- * @author Jay Shaughnessy
- */
-
-public class Activity2View extends LocatableVLayout implements DashboardContainer,
InitializableView {
-
- private static final String DASHBOARD_NAME_PREFIX = "ResourceDashboard_";
-
- private ResourceComposite resourceComposite;
-
- private DashboardGWTServiceAsync dashboardService =
GWTServiceLookup.getDashboardService();
-
- private DashboardView dashboardView;
-
- private LocatableToolStrip footer;
- private IButton editButton;
- private IButton resetButton;
-
- // Capture the user's global permissions for use by any dashboard or portlet that
may need it for rendering.
- private Set<Permission> globalPermissions;
-
- private boolean editMode = false;
-
- private boolean isInitialized = false;
-
- public Activity2View(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId);
- this.resourceComposite = resourceComposite;
- }
-
- @Override
- protected void onInit() {
- if (!isInitialized()) {
- super.onInit();
-
- // first async call to get global permissions
- new PermissionsLoader().loadExplicitGlobalPermissions(new
PermissionsLoadedListener() {
-
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
-
- // now make async call to look for customized dash for this user and
entity
- DashboardCriteria criteria = new DashboardCriteria();
- criteria.addFilterCategory(DashboardCategory.RESOURCE);
-
criteria.addFilterResourceId(resourceComposite.getResource().getId());
- dashboardService.findDashboardsByCriteria(criteria, new
AsyncCallback<PageList<Dashboard>>() {
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
- }
-
- public void onSuccess(final PageList<Dashboard> result) {
- Dashboard dashboard = result.isEmpty() ?
getDefaultDashboard() : result.get(0);
- setDashboard(dashboard);
-
- isInitialized = true;
-
- // draw() may be done since onInit finishes asynchronously,
if so redraw
- if (isDrawn()) {
- markForRedraw();
- }
- }
- });
- }
- });
- }
- }
-
- private void setDashboard(Dashboard dashboard) {
- Canvas[] members = getMembers();
- removeMembers(members);
- //pass in the resource information
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, null,
- resourceComposite);
- addMember(dashboardView);
-
- footer = new LocatableToolStrip(extendLocatorId("Footer"));
- footer.setPadding(5);
- footer.setWidth100();
- footer.setMembersMargin(15);
-
- editButton = new LocatableIButton(footer.extendLocatorId("Mode"),
editMode ? MSG.common_title_view_mode() : MSG
- .common_title_edit_mode());
- editButton.setAutoFit(true);
- editButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- editMode = !editMode;
- editButton.setTitle(editMode ? MSG.common_title_view_mode() :
MSG.common_title_edit_mode());
- dashboardView.setEditMode(editMode);
- }
- });
-
- resetButton = new LocatableIButton(footer.extendLocatorId("Reset"),
MSG.common_button_reset());
- resetButton.setAutoFit(true);
- resetButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- String message = MSG.view_summaryDashboard_resetConfirm();
-
- SC.ask(message, new BooleanCallback() {
- public void execute(Boolean confirmed) {
- if (confirmed) {
- dashboardView.delete();
- setDashboard(getDefaultDashboard());
- markForRedraw();
- }
- }
- });
- }
- });
-
- footer.addMember(editButton);
- footer.addMember(resetButton);
-
- addMember(footer);
- }
-
- protected Dashboard getDefaultDashboard() {
- Subject sessionSubject = UserSessionManager.getSessionSubject();
- Resource resource = resourceComposite.getResource();
-
- Dashboard dashboard = new Dashboard();
-
- dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_"
+ resource.getId());
- dashboard.setCategory(DashboardCategory.RESOURCE);
- dashboard.setResource(resource);
- dashboard.setColumns(2);
-
- // TODO, add real portlets
- // set leftmost column and let the rest be equally divided
- dashboard.setColumnWidths("40%");
- dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
-
- //figure out which portlets to display and how
- HashMap<String, String> resKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
- resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap,
resourceComposite);
- int colLeft = 0;
- int colRight = 1;
- int rowLeft = 0;
- int rowRight = 0;
- //Left Column
- if (resKeyNameMap.containsKey(ResourceMetricsPortlet.KEY)) {//measurments top
left if available
- DashboardPortlet measurements = new
DashboardPortlet(ResourceMetricsPortlet.NAME,
- ResourceMetricsPortlet.KEY, 220);
- dashboard.addPortlet(measurements, colLeft, rowLeft++);
- resKeyNameMap.remove(ResourceMetricsPortlet.KEY);
- }
-
- // right Column(approx 60%. As larger more room to display table and N rows.)
- if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) {//alerts top right if
available
- DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME,
ResourceAlertsPortlet.KEY, 220);
- dashboard.addPortlet(alerts, colRight, rowRight++);
- resKeyNameMap.remove(ResourceAlertsPortlet.KEY);
- }
- if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) {//operations if
available
- DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME,
ResourceOperationsPortlet.KEY,
- 220);
- dashboard.addPortlet(ops, colRight, rowRight++);
- resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
- }
-
- //Fill out left column(typically smaller portlets) then alternate cols with
remaining
- boolean displayLeft = false;
- for (String key : resKeyNameMap.keySet()) {
- DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key,
100);
- if (rowLeft < 4) {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- } else {//alternate
- if (!displayLeft) {
- dashboard.addPortlet(portlet, colRight, rowRight++);
- } else {
- dashboard.addPortlet(portlet, colLeft, rowLeft++);
- }
- //toggle
- displayLeft = !displayLeft;
- }
- }
-
- return dashboard;
- }
-
- @Override
- public boolean isInitialized() {
- return isInitialized;
- }
-
- public Set<Permission> getGlobalPermissions() {
- return globalPermissions;
- }
-
- /**
- * name update not supported because the name is derived from the entity id.
- * @return
- */
- public boolean supportsDashboardNameEdit() {
- return false;
- }
-
- public void updateDashboardNames() {
- return;
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
index 1ef75de..ee64837 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView.java
@@ -1,691 +1,243 @@
-/*
- * 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.summary;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Set;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.util.BooleanCallback;
+import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.LinkItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.bundle.BundleDeployment;
-import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
-import org.rhq.core.domain.content.InstalledPackageHistory;
-import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.InstalledPackageCriteria;
-import org.rhq.core.domain.criteria.ResourceBundleDeploymentCriteria;
-import org.rhq.core.domain.event.EventSeverity;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
-import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
-import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.DashboardCriteria;
+import org.rhq.core.domain.dashboard.Dashboard;
+import org.rhq.core.domain.dashboard.DashboardCategory;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.ResourceTypeFacet;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.InitializableView;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
+import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
+import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
+import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
-import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
-import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
-import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
-import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
- * The content pane of the Resource Summary>Activity tab.
+ * The content pane for the resource Summary>Dashboard subtab.
*
- * @author Simeon Pinder
+ * @author Jay Shaughnessy
*/
-public class ActivityView extends AbstractActivityView {
-
- private ResourceComposite resourceComposite;
-
- public ActivityView(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId, null, resourceComposite);
- this.resourceComposite = resourceComposite;
- }
- @Override
- protected void onInit() {
- super.onInit();
- loadData();
- }
+public class ActivityView extends LocatableVLayout implements DashboardContainer,
InitializableView {
- /**Initiates data request.
- */
- protected void loadData() {
-
- ResourceType type = null;
- Resource resource = null;
- Set<ResourceTypeFacet> facets = null;
-
- if ((resourceComposite != null) && (resourceComposite.getResource() !=
null)) {
- resource = resourceComposite.getResource();
- type = this.resourceComposite.getResource().getResourceType();
- facets = this.resourceComposite.getResourceFacets().getFacets();
-
- //alerts
- getRecentAlerts();
- //operations
- if (facets.contains(ResourceTypeFacet.OPERATION)) {
- getRecentOperations();
- }
- //config updates
- if (facets.contains(ResourceTypeFacet.CONFIGURATION)) {
- getRecentConfigurationUpdates();
- }
- //events
- if (facets.contains(ResourceTypeFacet.EVENT)) {
- getRecentEventUpdates();
- }
- //measurements
- getRecentOobs();
- getRecentPkgHistory();
- getRecentMetrics();
-
- //conditionally display Bundle Deployments region.
- if (displayBundlesForResource(resource)) {
- getRecentBundleDeployments();
- }
- }
- }
-
- /** Fetches alerts and updates the DynamicForm instance with the latest
- * alert information.
- */
- private void getRecentAlerts() {
- final int resourceId = this.resourceComposite.getResource().getId();
- //fetches last five alerts for this resource
- AlertCriteria criteria = new AlertCriteria();
- PageControl pageControl = new PageControl(0, 5);
- pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceIds(resourceId);
- GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
- @Override
- public void onSuccess(PageList<Alert> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (Alert alert : result) {
- // alert history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- row.setNumCols(3);
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
- .getPriority()),
alert.getAlertDefinition().getPriority().getDisplayName());
- LinkItem link = newLinkItem(alert.getAlertDefinition().getName()
+ ": ",
- ReportDecorator.GWT_RESOURCE_URL + resourceId +
"/Alerts/History/" + alert.getId());
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId +
"/Alerts/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
- RECENT_ALERTS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentAlertsContent.getChildren()) {
- child.destroy();
- }
- recentAlertsContent.addChild(column);
- recentAlertsContent.markForRedraw();
- }
+ private static final String DASHBOARD_NAME_PREFIX = "ResourceDashboard_";
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent alerts for resource [" +
resourceId + "]:" + caught.getMessage());
- }
- });
- }
-
- /** Fetches operations and updates the DynamicForm instance with the latest
- * operation information.
- */
- private void getRecentOperations() {
- final int resourceId = this.resourceComposite.getResource().getId();
- //fetches five most recent operations.
- PageControl pageControl = new PageControl(0, 5);
- pageControl.initDefaultOrderingField("ro.createdTime",
PageOrdering.DESC);
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(resourceId,
pageControl,
- new
AsyncCallback<PageList<ResourceOperationLastCompletedComposite>>() {
-
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent operations for resource
[" + resourceId + "]:"
- + caught.getMessage());
- }
+ private ResourceComposite resourceComposite;
- @Override
- public void
onSuccess(PageList<ResourceOperationLastCompletedComposite> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (ResourceOperationLastCompletedComposite report : result) {
- // operation history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getOperationResultsIcon(report
- .getOperationStatus()),
report.getOperationStatus().getDisplayName());
- LinkItem link = newLinkItem(report.getOperationName() +
": ", LinkManager
- .getResourceLink(resourceId)
- + "/Operations/History/" +
report.getOperationHistoryId());
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(report
- .getOperationStartTime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
- .extendLocatorId(String.valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Operations/History/",
- column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentOperationsContent
- .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
- column.addMember(row);
- }
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(column);
- recentOperationsContent.markForRedraw();
- }
- });
- }
+ private DashboardGWTServiceAsync dashboardService =
GWTServiceLookup.getDashboardService();
- /** Fetches configuration updates and updates the DynamicForm instance with the
latest
- * config change information.
- */
- private void getRecentConfigurationUpdates() {
- final int resourceId = this.resourceComposite.getResource().getId();
+ private DashboardView dashboardView;
- PageControl lastFive = new PageControl(0, 5);
- lastFive.initDefaultOrderingField("cu.createdTime",
PageOrdering.DESC);
+ private LocatableToolStrip footer;
+ private IButton editButton;
+ private IButton resetButton;
-
GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdates(resourceId,
null, null, true,
- lastFive, new
AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+ // Capture the user's global permissions for use by any dashboard or portlet that
may need it for rendering.
+ private Set<Permission> globalPermissions;
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent configuration updates for
resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ private boolean editMode = false;
- @Override
- public void onSuccess(PageList<ResourceConfigurationUpdate> result)
{
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (ResourceConfigurationUpdate update : result) {
- // config update history records do not have a usable
locatorId, we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
- .getStatus()), null);
- String linkTitle =
MSG.view_resource_inventory_activity_changed_by() + " "
- + update.getSubjectName() + ":";
- if ((update.getSubjectName() == null) ||
(update.getSubjectName().trim().isEmpty())) {
- linkTitle = MSG.common_msg_changeAutoDetected();
- }
- LinkItem link = newLinkItem(linkTitle,
LinkManager.getResourceLink(resourceId)
- + "/Configuration/History/" + update.getId());
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(update
- .getCreatedTime()));
+ private boolean isInitialized = false;
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
- .extendLocatorId(String.valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Configuration/History/",
- column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentConfigurationContent
- .extendLocatorId("None"),
RECENT_CONFIGURATIONS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentConfigurationContent.getChildren()) {
- child.destroy();
- }
- recentConfigurationContent.addChild(column);
- recentConfigurationContent.markForRedraw();
- }
- });
+ public ActivityView(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId);
+ this.resourceComposite = resourceComposite;
}
- /** Fetches recent events and updates the DynamicForm instance with the latest
- * event information over last 24hrs.
- */
- private void getRecentEventUpdates() {
-
- final int resourceId = this.resourceComposite.getResource().getId();
- long now = System.currentTimeMillis();
- long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+ @Override
+ protected void onInit() {
+ if (!isInitialized()) {
+ super.onInit();
+
+ // first async call to get global permissions
+ new PermissionsLoader().loadExplicitGlobalPermissions(new
PermissionsLoadedListener() {
+
+ public void onPermissionsLoaded(Set<Permission> permissions) {
+ globalPermissions = permissions;
+
+ // now make async call to look for customized dash for this user and
entity
+ DashboardCriteria criteria = new DashboardCriteria();
+ criteria.addFilterCategory(DashboardCategory.RESOURCE);
+
criteria.addFilterResourceId(resourceComposite.getResource().getId());
+ dashboardService.findDashboardsByCriteria(criteria, new
AsyncCallback<PageList<Dashboard>>() {
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.view_dashboardsManager_error1(), caught);
+ }
- GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId,
nowMinus24Hours, now,
- new AsyncCallback<Map<EventSeverity, Integer>>() {
+ public void onSuccess(final PageList<Dashboard> result) {
+ Dashboard dashboard = result.isEmpty() ?
getDefaultDashboard() : result.get(0);
+ setDashboard(dashboard);
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent event counts for resource
[" + resourceId + "]:"
- + caught.getMessage());
- }
+ isInitialized = true;
- @Override
- public void onSuccess(Map<EventSeverity, Integer> eventCounts) {
- //Now populated Tuples
- List<GwtTuple<EventSeverity, Integer>> results = new
ArrayList<GwtTuple<EventSeverity, Integer>>();
- for (EventSeverity severity : eventCounts.keySet()) {
- int count = eventCounts.get(severity);
- if (count > 0) {
- results.add(new GwtTuple<EventSeverity,
Integer>(severity, count));
- }
- }
- //build display
- VLayout column = new VLayout();
- column.setHeight(10);
-
- if (!results.isEmpty()) {
- int rowNum = 0;
- for (GwtTuple<EventSeverity, Integer> tuple : results) {
- // event history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent
- .extendLocatorId(String.valueOf(rowNum)));
- row.setNumCols(2);
- row.setWidth(10);//pack.
-
- //icon
- StaticTextItem iconItem =
newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
- .getLefty()), tuple.getLefty().name());
- //count
- StaticTextItem count =
newTextItem(String.valueOf(tuple.righty));
- row.setItems(iconItem, count);
-
- column.addMember(row);
+ // draw() may be done since onInit finishes asynchronously,
if so redraw
+ if (isDrawn()) {
+ markForRedraw();
+ }
}
- LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Events/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
- RECENT_EVENTS_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentEventsContent.getChildren()) {
- child.destroy();
- }
- recentEventsContent.addChild(column);
- recentEventsContent.markForRedraw();
+ });
}
});
+ }
}
- /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
- * oob change details.
- */
- private void getRecentOobs() {
- final int resourceId = this.resourceComposite.getResource().getId();
-
GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, 5,
- new AsyncCallback<PageList<MeasurementOOBComposite>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent out of bound metrics for
resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ private void setDashboard(Dashboard dashboard) {
+ Canvas[] members = getMembers();
+ removeMembers(members);
+ //pass in the resource information
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, null,
+ resourceComposite);
+ addMember(dashboardView);
+
+ footer = new LocatableToolStrip(extendLocatorId("Footer"));
+ footer.setPadding(5);
+ footer.setWidth100();
+ footer.setMembersMargin(15);
+
+ editButton = new LocatableIButton(footer.extendLocatorId("Mode"),
editMode ? MSG.common_title_view_mode() : MSG
+ .common_title_edit_mode());
+ editButton.setAutoFit(true);
+ editButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ editMode = !editMode;
+ editButton.setTitle(editMode ? MSG.common_title_view_mode() :
MSG.common_title_edit_mode());
+ dashboardView.setEditMode(editMode);
+ }
+ });
- @Override
- public void onSuccess(PageList<MeasurementOOBComposite> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- for (MeasurementOOBComposite oob : result) {
- LocatableDynamicForm row = new
LocatableDynamicForm(recentOobContent.extendLocatorId(oob
- .getScheduleName()));
- row.setNumCols(2);
-
- String title = oob.getScheduleName() + ":";
- String destination =
"/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId()
- + "&id=" + resourceId +
"&mode=chartSingleMetricSingleResource";
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
-
- row.setItems(link, time);
- column.addMember(row);
+ resetButton = new LocatableIButton(footer.extendLocatorId("Reset"),
MSG.common_button_reset());
+ resetButton.setAutoFit(true);
+ resetButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ String message = MSG.view_summaryDashboard_resetConfirm();
+
+ SC.ask(message, new BooleanCallback() {
+ public void execute(Boolean confirmed) {
+ if (confirmed) {
+ dashboardView.delete();
+ setDashboard(getDefaultDashboard());
+ markForRedraw();
}
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
- RECENT_OOB_NONE);
- column.addMember(row);
- }
- recentOobContent.setContents("");
- for (Canvas child : recentOobContent.getChildren()) {
- child.destroy();
}
- recentOobContent.addChild(column);
- recentOobContent.markForRedraw();
- }
- });
- }
+ });
+ }
+ });
- /** Fetches recent package history information and updates the DynamicForm instance
with details.
- */
- private void getRecentPkgHistory() {
- final int resourceId = this.resourceComposite.getResource().getId();
- InstalledPackageCriteria criteria = new InstalledPackageCriteria();
- criteria.addFilterResourceId(resourceId);
- PageControl pageControl = new PageControl(0, 5);
- criteria.setPageControl(pageControl);
-
-
GWTServiceLookup.getContentService().getInstalledPackageHistoryForResource(resourceId, 5,
- new AsyncCallback<PageList<InstalledPackageHistory>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving installed package history for
resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ footer.addMember(editButton);
+ footer.addMember(resetButton);
- @Override
- public void onSuccess(PageList<InstalledPackageHistory> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- for (InstalledPackageHistory history : result) {
- LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
-
.extendLocatorId(history.getPackageVersion().getFileName()
- + history.getPackageVersion().getVersion()));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Package_16.png", null);
- String title = history.getPackageVersion().getFileName() +
":";
- String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId
- + "&selectedHistoryId=" + history.getId();
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(history
- .getTimestamp()));
-
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- // //insert see more link
- // LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
- //
.extendLocatorId("RecentPkgHistorySeeMore"));
- // String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId;
- // addSeeMoreLink(row, destination,
column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentPkgHistoryContent
- .extendLocatorId("None"),
RECENT_PKG_HISTORY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentPkgHistoryContent.getChildren()) {
- child.destroy();
- }
- recentPkgHistoryContent.addChild(column);
- recentPkgHistoryContent.markForRedraw();
- }
- });
+ addMember(footer);
}
- /** Fetches recent metric information and updates the DynamicForm instance with
i)sparkline information,
- * ii) link to recent metric graph for more details and iii) last metric value
formatted to show significant
- * digits.
- */
- private void getRecentMetrics() {
- //display container
- final VLayout column = new VLayout();
- column.setHeight(10);//pack
- final int resourceId = this.resourceComposite.getResource().getId();
-
- //retrieve all relevant measurement definition ids.
- Set<MeasurementDefinition> definitions =
this.resourceComposite.getResource().getResourceType()
- .getMetricDefinitions();
-
- //build id mapping for measurementDefinition instances Ex. Free Memory ->
MeasurementDefinition[100071]
- final HashMap<String, MeasurementDefinition> measurementDefMap = new
HashMap<String, MeasurementDefinition>();
- for (MeasurementDefinition definition : definitions) {
- measurementDefMap.put(definition.getDisplayName(), definition);
+ protected Dashboard getDefaultDashboard() {
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ Resource resource = resourceComposite.getResource();
+
+ Dashboard dashboard = new Dashboard();
+
+ dashboard.setName(DASHBOARD_NAME_PREFIX + sessionSubject.getId() + "_"
+ resource.getId());
+ dashboard.setCategory(DashboardCategory.RESOURCE);
+ dashboard.setResource(resource);
+ dashboard.setColumns(2);
+
+ // TODO, add real portlets
+ // set leftmost column and let the rest be equally divided
+ dashboard.setColumnWidths("40%");
+ dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
+
+ //figure out which portlets to display and how
+ HashMap<String, String> resKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
+ resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap,
resourceComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (resKeyNameMap.containsKey(ResourceMetricsPortlet.KEY)) {//measurments top
left if available
+ DashboardPortlet measurements = new
DashboardPortlet(ResourceMetricsPortlet.NAME,
+ ResourceMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ resKeyNameMap.remove(ResourceMetricsPortlet.KEY);
}
- //bundle definition ids for asynch call.
- int[] definitionArrayIds = new int[definitions.size()];
- final String[] displayOrder = new String[definitions.size()];
- measurementDefMap.keySet().toArray(displayOrder);
- //sort the charting data ex. Free Memory, Free Swap Space,..System Load
- Arrays.sort(displayOrder);
-
- //organize definitionArrayIds for ordered request on server.
- int index = 0;
- for (String definitionToDisplay : displayOrder) {
- definitionArrayIds[index++] =
measurementDefMap.get(definitionToDisplay).getId();
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) {//alerts top right if
available
+ DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME,
ResourceAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceAlertsPortlet.KEY);
+ }
+ if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) {//operations if
available
+ DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME,
ResourceOperationsPortlet.KEY,
+ 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
}
- //make the asynchronous call for all the measurement data
- GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
definitionArrayIds,
- System.currentTimeMillis() - (1000L * 60 * 60 * 8),
System.currentTimeMillis(), 60,
- new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent metrics charting data for
resource [" + resourceId + "]:"
- + caught.getMessage());
- }
- @Override
- public void
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
- if (!results.isEmpty()) {
- boolean someChartedData = false;
- //iterate over the retrieved charting data
- for (int index = 0; index < displayOrder.length; index++) {
-
- //retrieve the correct measurement definition
- MeasurementDefinition md =
measurementDefMap.get(displayOrder[index]);
-
- //load the data results for the given metric definition
- List<MeasurementDataNumericHighLowComposite> data =
results.get(index);
-
- //locate last and minimum values.
- double lastValue = -1;
- double minValue = Double.MAX_VALUE;//
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- if (d.getValue() < minValue) {
- minValue = d.getValue();
- }
- lastValue = d.getValue();
- }
- }
+ //Fill out left column(typically smaller portlets) then alternate cols with
remaining
+ boolean displayLeft = false;
+ for (String key : resKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key,
100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
- //collapse the data into comma delimited list for consumption
by third party javascript library(jquery.sparkline)
- String commaDelimitedList = "";
+ return dashboard;
+ }
- for (MeasurementDataNumericHighLowComposite d : data) {
- if ((!Double.isNaN(d.getValue()))
- &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
- commaDelimitedList += d.getValue() + ",";
- }
- }
- LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
- .extendLocatorId(md.getName()));
- row.setNumCols(3);
- HTMLFlow graph = new HTMLFlow();
- // String contents = "<span
id='sparkline_" + index + "' class='dynamicsparkline'
width='0'>"
- // + commaDelimitedList +
"</span>";
- String contents = "<span id='sparkline_" +
index + "' class='dynamicsparkline' width='0' "
- + "values='" + commaDelimitedList +
"'>...</span>";
- graph.setContents(contents);
- graph.setContentsType(ContentsType.PAGE);
- //diable scrollbars on span
- graph.setScrollbarSize(0);
-
- CanvasItem graphContainer = new CanvasItem();
- graphContainer.setShowTitle(false);
- graphContainer.setHeight(16);
- graphContainer.setWidth(60);
- graphContainer.setCanvas(graph);
-
- //Link/title element
- //TODO: spinder, change link whenever portal.war/graphing is
removed.
- String title = md.getDisplayName() + ":";
- String destination =
"/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
- + resourceId + "&m=" + md.getId();
- LinkItem link = newLinkItem(title, destination);
-
- //Value
- String convertedValue = lastValue + " " +
md.getUnits();
- convertedValue = convertLastValueForDisplay(lastValue, md);
- StaticTextItem value = newTextItem(convertedValue);
-
- row.setItems(graphContainer, link, value);
- //if graph content returned
- if ((md.getName().trim().indexOf("Trait.") == -1)
&& (lastValue != -1)) {
- column.addMember(row);
- someChartedData = true;
- }
- }
- if (!someChartedData) {// when there are results but no chartable
entries.
- LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- } else {
- //insert see more link
- LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
-
.extendLocatorId("RecentMeasurementsContentSeeMore"));
- addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL +
resourceId + "/Monitoring/Graphs/",
- column);
- }
- //call out to 3rd party javascript lib
- BrowserUtility.graphSparkLines();
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
- .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
- column.addMember(row);
- }
- }
- });
+ @Override
+ public boolean isInitialized() {
+ return isInitialized;
+ }
- //cleanup
- for (Canvas child : recentMeasurementsContent.getChildren()) {
- child.destroy();
- }
- recentMeasurementsContent.addChild(column);
- recentMeasurementsContent.markForRedraw();
+ public Set<Permission> getGlobalPermissions() {
+ return globalPermissions;
}
- /** Fetches recent bundle deployment information and updates the DynamicForm instance
with details.
+ /**
+ * name update not supported because the name is derived from the entity id.
+ * @return
*/
- protected void getRecentBundleDeployments() {
- final int resourceId = this.resourceComposite.getResource().getId();
- ResourceBundleDeploymentCriteria criteria = new
ResourceBundleDeploymentCriteria();
- PageControl pageControl = new PageControl(0, 5);
- criteria.setPageControl(pageControl);
- criteria.addFilterResourceIds(resourceId);
- criteria.addSortStatus(PageOrdering.DESC);
- criteria.fetchDestination(true);
- criteria.fetchBundleVersion(true);
- criteria.fetchResourceDeployments(true);
-
- GWTServiceLookup.getBundleService().findBundleDeploymentsByCriteria(criteria,
- new AsyncCallback<PageList<BundleDeployment>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving installed bundle deployments for
resource [" + resourceId + "]:"
- + caught.getMessage());
- }
+ public boolean supportsDashboardNameEdit() {
+ return false;
+ }
- @Override
- public void onSuccess(PageList<BundleDeployment> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- for (BundleDeployment deployment : result) {
- LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent
- .extendLocatorId(deployment.getBundleVersion().getName()
- + deployment.getBundleVersion().getVersion()));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Content_16.png", null);
- String title = deployment.getBundleVersion().getName() +
"["
- + deployment.getBundleVersion().getVersion() +
"]:";
-
- String destination = ReportDecorator.GWT_BUNDLE_URL
- + deployment.getBundleVersion().getBundle().getId() +
"/destinations/"
- + deployment.getDestination().getId();
- LinkItem link = newLinkItem(title, destination);
- StaticTextItem time =
newTextItem(GwtRelativeDurationConverter
- .format(deployment.getCtime()));
-
- row.setItems(iconItem, link, time);
- column.addMember(row);
- }
- //insert see more link
- //TODO: spinder:2/25/11 (add this later) no current view for
seeing all bundle deployments
- // LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent.extendLocatorId("RecentBundleContentSeeMore"));
- // addSeeMoreLink(row,
LinkManager.getResourceGroupLink(groupId) + "/Events/History/", column);
- } else {
- LocatableDynamicForm row =
createEmptyDisplayRow(recentBundleDeployContent
- .extendLocatorId("None"),
RECENT_BUNDLE_DEPLOY_NONE);
- column.addMember(row);
- }
- //cleanup
- for (Canvas child : recentBundleDeployContent.getChildren()) {
- child.destroy();
- }
- recentBundleDeployContent.addChild(column);
- recentBundleDeployContent.markForRedraw();
- }
- });
+ public void updateDashboardNames() {
+ return;
}
+
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java
new file mode 100644
index 0000000..355a19a
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ActivityView3.java
@@ -0,0 +1,691 @@
+/*
+ * 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.summary;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ContentsType;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.bundle.BundleDeployment;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.content.InstalledPackageHistory;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.criteria.InstalledPackageCriteria;
+import org.rhq.core.domain.criteria.ResourceBundleDeploymentCriteria;
+import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite;
+import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite;
+import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.ResourceTypeFacet;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.GwtTuple;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * The content pane of the Resource Summary>Activity tab.
+ *
+ * @author Simeon Pinder
+ */
+public class ActivityView3 extends AbstractActivityView {
+
+ private ResourceComposite resourceComposite;
+
+ public ActivityView3(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId, null, resourceComposite);
+ this.resourceComposite = resourceComposite;
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Initiates data request.
+ */
+ protected void loadData() {
+
+ ResourceType type = null;
+ Resource resource = null;
+ Set<ResourceTypeFacet> facets = null;
+
+ if ((resourceComposite != null) && (resourceComposite.getResource() !=
null)) {
+ resource = resourceComposite.getResource();
+ type = this.resourceComposite.getResource().getResourceType();
+ facets = this.resourceComposite.getResourceFacets().getFacets();
+
+ //alerts
+ getRecentAlerts();
+ //operations
+ if (facets.contains(ResourceTypeFacet.OPERATION)) {
+ getRecentOperations();
+ }
+ //config updates
+ if (facets.contains(ResourceTypeFacet.CONFIGURATION)) {
+ getRecentConfigurationUpdates();
+ }
+ //events
+ if (facets.contains(ResourceTypeFacet.EVENT)) {
+ getRecentEventUpdates();
+ }
+ //measurements
+ getRecentOobs();
+ getRecentPkgHistory();
+ getRecentMetrics();
+
+ //conditionally display Bundle Deployments region.
+ if (displayBundlesForResource(resource)) {
+ getRecentBundleDeployments();
+ }
+ }
+ }
+
+ /** Fetches alerts and updates the DynamicForm instance with the latest
+ * alert information.
+ */
+ private void getRecentAlerts() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ //fetches last five alerts for this resource
+ AlertCriteria criteria = new AlertCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ pageControl.initDefaultOrderingField("ctime", PageOrdering.DESC);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceIds(resourceId);
+ GWTServiceLookup.getAlertService().findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (Alert alert : result) {
+ // alert history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ row.setNumCols(3);
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getAlertIcon(alert.getAlertDefinition()
+ .getPriority()),
alert.getAlertDefinition().getPriority().getDisplayName());
+ LinkItem link = newLinkItem(alert.getAlertDefinition().getName()
+ ": ",
+ ReportDecorator.GWT_RESOURCE_URL + resourceId +
"/Alerts/History/" + alert.getId());
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(alert.getCtime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId +
"/Alerts/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentAlertsContent.extendLocatorId("None"),
+ RECENT_ALERTS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for resource [" +
resourceId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ /** Fetches operations and updates the DynamicForm instance with the latest
+ * operation information.
+ */
+ private void getRecentOperations() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ //fetches five most recent operations.
+ PageControl pageControl = new PageControl(0, 5);
+ pageControl.initDefaultOrderingField("ro.createdTime",
PageOrdering.DESC);
+ GWTServiceLookup.getOperationService().findRecentCompletedOperations(resourceId,
pageControl,
+ new
AsyncCallback<PageList<ResourceOperationLastCompletedComposite>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent operations for resource
[" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void
onSuccess(PageList<ResourceOperationLastCompletedComposite> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (ResourceOperationLastCompletedComposite report : result) {
+ // operation history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getOperationResultsIcon(report
+ .getOperationStatus()),
report.getOperationStatus().getDisplayName());
+ LinkItem link = newLinkItem(report.getOperationName() +
": ", LinkManager
+ .getResourceLink(resourceId)
+ + "/Operations/History/" +
report.getOperationHistoryId());
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(report
+ .getOperationStartTime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentOperationsContent
+ .extendLocatorId(String.valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Operations/History/",
+ column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentOperationsContent
+ .extendLocatorId("None"), RECENT_OPERATIONS_NONE);
+ column.addMember(row);
+ }
+ for (Canvas child : recentOperationsContent.getChildren()) {
+ child.destroy();
+ }
+ recentOperationsContent.addChild(column);
+ recentOperationsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches configuration updates and updates the DynamicForm instance with the
latest
+ * config change information.
+ */
+ private void getRecentConfigurationUpdates() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+
+ PageControl lastFive = new PageControl(0, 5);
+ lastFive.initDefaultOrderingField("cu.createdTime",
PageOrdering.DESC);
+
+
GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdates(resourceId,
null, null, true,
+ lastFive, new
AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent configuration updates for
resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<ResourceConfigurationUpdate> result)
{
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (ResourceConfigurationUpdate update : result) {
+ // config update history records do not have a usable
locatorId, we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getResourceConfigurationIcon(update
+ .getStatus()), null);
+ String linkTitle =
MSG.view_resource_inventory_activity_changed_by() + " "
+ + update.getSubjectName() + ":";
+ if ((update.getSubjectName() == null) ||
(update.getSubjectName().trim().isEmpty())) {
+ linkTitle = MSG.common_msg_changeAutoDetected();
+ }
+ LinkItem link = newLinkItem(linkTitle,
LinkManager.getResourceLink(resourceId)
+ + "/Configuration/History/" + update.getId());
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(update
+ .getCreatedTime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentConfigurationContent
+ .extendLocatorId(String.valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Configuration/History/",
+ column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentConfigurationContent
+ .extendLocatorId("None"),
RECENT_CONFIGURATIONS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentConfigurationContent.getChildren()) {
+ child.destroy();
+ }
+ recentConfigurationContent.addChild(column);
+ recentConfigurationContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent events and updates the DynamicForm instance with the latest
+ * event information over last 24hrs.
+ */
+ private void getRecentEventUpdates() {
+
+ final int resourceId = this.resourceComposite.getResource().getId();
+ long now = System.currentTimeMillis();
+ long nowMinus24Hours = now - (24 * 60 * 60 * 1000);
+
+ GWTServiceLookup.getEventService().getEventCountsBySeverity(resourceId,
nowMinus24Hours, now,
+ new AsyncCallback<Map<EventSeverity, Integer>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent event counts for resource
[" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(Map<EventSeverity, Integer> eventCounts) {
+ //Now populated Tuples
+ List<GwtTuple<EventSeverity, Integer>> results = new
ArrayList<GwtTuple<EventSeverity, Integer>>();
+ for (EventSeverity severity : eventCounts.keySet()) {
+ int count = eventCounts.get(severity);
+ if (count > 0) {
+ results.add(new GwtTuple<EventSeverity,
Integer>(severity, count));
+ }
+ }
+ //build display
+ VLayout column = new VLayout();
+ column.setHeight(10);
+
+ if (!results.isEmpty()) {
+ int rowNum = 0;
+ for (GwtTuple<EventSeverity, Integer> tuple : results) {
+ // event history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent
+ .extendLocatorId(String.valueOf(rowNum)));
+ row.setNumCols(2);
+ row.setWidth(10);//pack.
+
+ //icon
+ StaticTextItem iconItem =
newTextItemIcon(ImageManager.getEventSeverityIcon(tuple
+ .getLefty()), tuple.getLefty().name());
+ //count
+ StaticTextItem count =
newTextItem(String.valueOf(tuple.righty));
+ row.setItems(iconItem, count);
+
+ column.addMember(row);
+ }
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentEventsContent.extendLocatorId("None"),
+ RECENT_EVENTS_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentEventsContent.getChildren()) {
+ child.destroy();
+ }
+ recentEventsContent.addChild(column);
+ recentEventsContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches OOB measurements and updates the DynamicForm instance with the latest 5
+ * oob change details.
+ */
+ private void getRecentOobs() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+
GWTServiceLookup.getMeasurementDataService().getHighestNOOBsForResource(resourceId, 5,
+ new AsyncCallback<PageList<MeasurementOOBComposite>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent out of bound metrics for
resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<MeasurementOOBComposite> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (MeasurementOOBComposite oob : result) {
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentOobContent.extendLocatorId(oob
+ .getScheduleName()));
+ row.setNumCols(2);
+
+ String title = oob.getScheduleName() + ":";
+ String destination =
"/resource/common/monitor/Visibility.do?m=" + oob.getDefinitionId()
+ + "&id=" + resourceId +
"&mode=chartSingleMetricSingleResource";
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(oob.getTimestamp()));
+
+ row.setItems(link, time);
+ column.addMember(row);
+ }
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentOobContent.extendLocatorId("None"),
+ RECENT_OOB_NONE);
+ column.addMember(row);
+ }
+ recentOobContent.setContents("");
+ for (Canvas child : recentOobContent.getChildren()) {
+ child.destroy();
+ }
+ recentOobContent.addChild(column);
+ recentOobContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent package history information and updates the DynamicForm instance
with details.
+ */
+ private void getRecentPkgHistory() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ InstalledPackageCriteria criteria = new InstalledPackageCriteria();
+ criteria.addFilterResourceId(resourceId);
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+
+
GWTServiceLookup.getContentService().getInstalledPackageHistoryForResource(resourceId, 5,
+ new AsyncCallback<PageList<InstalledPackageHistory>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed package history for
resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<InstalledPackageHistory> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (InstalledPackageHistory history : result) {
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
+
.extendLocatorId(history.getPackageVersion().getFileName()
+ + history.getPackageVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Package_16.png", null);
+ String title = history.getPackageVersion().getFileName() +
":";
+ String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId
+ + "&selectedHistoryId=" + history.getId();
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter.format(history
+ .getTimestamp()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ // //insert see more link
+ // LocatableDynamicForm row = new
LocatableDynamicForm(recentPkgHistoryContent
+ //
.extendLocatorId("RecentPkgHistorySeeMore"));
+ // String destination =
"/rhq/resource/content/audit-trail-item.xhtml?id=" + resourceId;
+ // addSeeMoreLink(row, destination,
column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentPkgHistoryContent
+ .extendLocatorId("None"),
RECENT_PKG_HISTORY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentPkgHistoryContent.getChildren()) {
+ child.destroy();
+ }
+ recentPkgHistoryContent.addChild(column);
+ recentPkgHistoryContent.markForRedraw();
+ }
+ });
+ }
+
+ /** Fetches recent metric information and updates the DynamicForm instance with
i)sparkline information,
+ * ii) link to recent metric graph for more details and iii) last metric value
formatted to show significant
+ * digits.
+ */
+ private void getRecentMetrics() {
+ //display container
+ final VLayout column = new VLayout();
+ column.setHeight(10);//pack
+ final int resourceId = this.resourceComposite.getResource().getId();
+
+ //retrieve all relevant measurement definition ids.
+ Set<MeasurementDefinition> definitions =
this.resourceComposite.getResource().getResourceType()
+ .getMetricDefinitions();
+
+ //build id mapping for measurementDefinition instances Ex. Free Memory ->
MeasurementDefinition[100071]
+ final HashMap<String, MeasurementDefinition> measurementDefMap = new
HashMap<String, MeasurementDefinition>();
+ for (MeasurementDefinition definition : definitions) {
+ measurementDefMap.put(definition.getDisplayName(), definition);
+ }
+
+ //bundle definition ids for asynch call.
+ int[] definitionArrayIds = new int[definitions.size()];
+ final String[] displayOrder = new String[definitions.size()];
+ measurementDefMap.keySet().toArray(displayOrder);
+ //sort the charting data ex. Free Memory, Free Swap Space,..System Load
+ Arrays.sort(displayOrder);
+
+ //organize definitionArrayIds for ordered request on server.
+ int index = 0;
+ for (String definitionToDisplay : displayOrder) {
+ definitionArrayIds[index++] =
measurementDefMap.get(definitionToDisplay).getId();
+ }
+ //make the asynchronous call for all the measurement data
+ GWTServiceLookup.getMeasurementDataService().findDataForResource(resourceId,
definitionArrayIds,
+ System.currentTimeMillis() - (1000L * 60 * 60 * 8),
System.currentTimeMillis(), 60,
+ new
AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent metrics charting data for
resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void
onSuccess(List<List<MeasurementDataNumericHighLowComposite>> results) {
+ if (!results.isEmpty()) {
+ boolean someChartedData = false;
+ //iterate over the retrieved charting data
+ for (int index = 0; index < displayOrder.length; index++) {
+
+ //retrieve the correct measurement definition
+ MeasurementDefinition md =
measurementDefMap.get(displayOrder[index]);
+
+ //load the data results for the given metric definition
+ List<MeasurementDataNumericHighLowComposite> data =
results.get(index);
+
+ //locate last and minimum values.
+ double lastValue = -1;
+ double minValue = Double.MAX_VALUE;//
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ if (d.getValue() < minValue) {
+ minValue = d.getValue();
+ }
+ lastValue = d.getValue();
+ }
+ }
+
+ //collapse the data into comma delimited list for consumption
by third party javascript library(jquery.sparkline)
+ String commaDelimitedList = "";
+
+ for (MeasurementDataNumericHighLowComposite d : data) {
+ if ((!Double.isNaN(d.getValue()))
+ &&
(String.valueOf(d.getValue()).indexOf("NaN") == -1)) {
+ commaDelimitedList += d.getValue() + ",";
+ }
+ }
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
+ .extendLocatorId(md.getName()));
+ row.setNumCols(3);
+ HTMLFlow graph = new HTMLFlow();
+ // String contents = "<span
id='sparkline_" + index + "' class='dynamicsparkline'
width='0'>"
+ // + commaDelimitedList +
"</span>";
+ String contents = "<span id='sparkline_" +
index + "' class='dynamicsparkline' width='0' "
+ + "values='" + commaDelimitedList +
"'>...</span>";
+ graph.setContents(contents);
+ graph.setContentsType(ContentsType.PAGE);
+ //diable scrollbars on span
+ graph.setScrollbarSize(0);
+
+ CanvasItem graphContainer = new CanvasItem();
+ graphContainer.setShowTitle(false);
+ graphContainer.setHeight(16);
+ graphContainer.setWidth(60);
+ graphContainer.setCanvas(graph);
+
+ //Link/title element
+ //TODO: spinder, change link whenever portal.war/graphing is
removed.
+ String title = md.getDisplayName() + ":";
+ String destination =
"/resource/common/monitor/Visibility.do?mode=chartSingleMetricSingleResource&id="
+ + resourceId + "&m=" + md.getId();
+ LinkItem link = newLinkItem(title, destination);
+
+ //Value
+ String convertedValue = lastValue + " " +
md.getUnits();
+ convertedValue = convertLastValueForDisplay(lastValue, md);
+ StaticTextItem value = newTextItem(convertedValue);
+
+ row.setItems(graphContainer, link, value);
+ //if graph content returned
+ if ((md.getName().trim().indexOf("Trait.") == -1)
&& (lastValue != -1)) {
+ column.addMember(row);
+ someChartedData = true;
+ }
+ }
+ if (!someChartedData) {// when there are results but no chartable
entries.
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ } else {
+ //insert see more link
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentMeasurementsContent
+
.extendLocatorId("RecentMeasurementsContentSeeMore"));
+ addSeeMoreLink(row, ReportDecorator.GWT_RESOURCE_URL +
resourceId + "/Monitoring/Graphs/",
+ column);
+ }
+ //call out to 3rd party javascript lib
+ BrowserUtility.graphSparkLines();
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentMeasurementsContent
+ .extendLocatorId("None"),
RECENT_MEASUREMENTS_NONE);
+ column.addMember(row);
+ }
+ }
+ });
+
+ //cleanup
+ for (Canvas child : recentMeasurementsContent.getChildren()) {
+ child.destroy();
+ }
+ recentMeasurementsContent.addChild(column);
+ recentMeasurementsContent.markForRedraw();
+ }
+
+ /** Fetches recent bundle deployment information and updates the DynamicForm instance
with details.
+ */
+ protected void getRecentBundleDeployments() {
+ final int resourceId = this.resourceComposite.getResource().getId();
+ ResourceBundleDeploymentCriteria criteria = new
ResourceBundleDeploymentCriteria();
+ PageControl pageControl = new PageControl(0, 5);
+ criteria.setPageControl(pageControl);
+ criteria.addFilterResourceIds(resourceId);
+ criteria.addSortStatus(PageOrdering.DESC);
+ criteria.fetchDestination(true);
+ criteria.fetchBundleVersion(true);
+ criteria.fetchResourceDeployments(true);
+
+ GWTServiceLookup.getBundleService().findBundleDeploymentsByCriteria(criteria,
+ new AsyncCallback<PageList<BundleDeployment>>() {
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving installed bundle deployments for
resource [" + resourceId + "]:"
+ + caught.getMessage());
+ }
+
+ @Override
+ public void onSuccess(PageList<BundleDeployment> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ for (BundleDeployment deployment : result) {
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent
+ .extendLocatorId(deployment.getBundleVersion().getName()
+ + deployment.getBundleVersion().getVersion()));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
newTextItemIcon("subsystems/content/Content_16.png", null);
+ String title = deployment.getBundleVersion().getName() +
"["
+ + deployment.getBundleVersion().getVersion() +
"]:";
+
+ String destination = ReportDecorator.GWT_BUNDLE_URL
+ + deployment.getBundleVersion().getBundle().getId() +
"/destinations/"
+ + deployment.getDestination().getId();
+ LinkItem link = newLinkItem(title, destination);
+ StaticTextItem time =
newTextItem(GwtRelativeDurationConverter
+ .format(deployment.getCtime()));
+
+ row.setItems(iconItem, link, time);
+ column.addMember(row);
+ }
+ //insert see more link
+ //TODO: spinder:2/25/11 (add this later) no current view for
seeing all bundle deployments
+ // LocatableDynamicForm row = new
LocatableDynamicForm(recentBundleDeployContent.extendLocatorId("RecentBundleContentSeeMore"));
+ // addSeeMoreLink(row,
LinkManager.getResourceGroupLink(groupId) + "/Events/History/", column);
+ } else {
+ LocatableDynamicForm row =
createEmptyDisplayRow(recentBundleDeployContent
+ .extendLocatorId("None"),
RECENT_BUNDLE_DEPLOY_NONE);
+ column.addMember(row);
+ }
+ //cleanup
+ for (Canvas child : recentBundleDeployContent.getChildren()) {
+ child.destroy();
+ }
+ recentBundleDeployContent.addChild(column);
+ recentBundleDeployContent.markForRedraw();
+ }
+ });
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
index df35e27..f9ac79c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java
@@ -291,7 +291,9 @@ public class MessageCenterView extends Table implements
MessageCenter.MessageLis
public void refresh() {
try {
super.refresh();
-
getListGrid().setRecords(transform(CoreGUI.getMessageCenter().getMessages()));
+ if ((getListGrid() != null) &&
(CoreGUI.getMessageCenter().getMessages() != null)) {
+
getListGrid().setRecords(transform(CoreGUI.getMessageCenter().getMessages()));
+ }
refreshTableInfo();
} catch (Throwable e) {
Log.error("Cannot refresh messages", e);
commit b0a6460388ce646db376eebad485212f7d7427d1
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sun Mar 20 22:15:48 2011 -0400
i)fix for MeasurementRangeEditor alignment issue
ii)configuration editor widget property cleanup
iii)fix icon refresh issue with event portlets
iv)fix data init duplication issue with resourceOperationsPortlet
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
index d8c69b8..1978665 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
@@ -219,6 +219,7 @@ public abstract class AbstractMeasurementRangeEditor extends
LocatableDynamicFor
advancedStartItem.enable();
advancedEndItem.enable();
advancedSimpleButton.enable();
+ markForRedraw();
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
index 01794cb..f349f5d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
@@ -36,8 +36,8 @@ public class CustomConfigMeasurementRangeEditor extends
AbstractMeasurementRange
public static final String ALERT_METRIC_RANGE_ENABLE = Constant.METRIC_RANGE_ENABLE;
public static final String DEFAULT_VALUE_RANGE_RO = Boolean.FALSE.toString();
- public static final Integer DEFAULT_VALUE_RANGE_LASTN = Integer.valueOf(8);
- public static final Integer DEFAULT_VALUE_RANGE_UNIT = Integer.valueOf(3);
+ public static final Integer DEFAULT_VALUE_RANGE_LASTN =
Integer.valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT);
+ public static final Integer DEFAULT_VALUE_RANGE_UNIT =
Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT);
private ConfigurationMeasurementPreferences measurementPrefs;
@@ -106,7 +106,7 @@ public class CustomConfigMeasurementRangeEditor extends
AbstractMeasurementRange
if (metricRangePreferences == null) {
metricRangePreferences = new MetricRangePreferences();
}
- // //parse config and lazily init timing elements
+ //parse config and lazily init timing elements
metricRangePreferences.explicitBeginEnd = Boolean.valueOf(
config.getSimple(PREF_METRIC_RANGE_BEGIN_END_FLAG).getStringValue()).booleanValue();
//check to display advanced settings widget components
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
index 6eb15c4..cea94a9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
@@ -46,41 +46,50 @@ public class PortletConfigurationEditorComponent {
public interface Constant {
String ALERT_PRIORITY = "ALERT_PRIORITY";
+ String ALERT_PRIORITY_DEFAULT = "";//all priorities==no priorities
String METRIC_RANGE_ENABLE = "METRIC_RANGE_ENABLE";
+ String METRIC_RANGE_ENABLE_DEFAULT = String.valueOf(false);//disabled
String METRIC_RANGE_BEGIN_END_FLAG = "METRIC_RANGE_BEGIN_END_FLAG";
+ String METRIC_RANGE_BEGIN_END_FLAG_DEFAULT = String.valueOf(false);//disabled
String METRIC_RANGE = "METRIC_RANGE";
+ String METRIC_RANGE_DEFAULT = "";//no previous range.
String METRIC_RANGE_LASTN = "METRIC_RANGE_LASTN";
String METRIC_RANGE_LASTN_DEFAULT = String.valueOf(8);
String METRIC_RANGE_UNIT = "METRIC_RANGE_UNIT";
String METRIC_RANGE_UNIT_DEFAULT =
String.valueOf(MeasurementUtility.UNIT_HOURS);
String RESULT_SEVERITY = "severities";
+ String RESULT_SEVERITY_DEFAULT = "";//all severities
String RESULT_SORT_ORDER = "RESULT_SORT_ORDER";
+ String RESULT_SORT_ORDER_DEFAULT = PageOrdering.DESC.name();//descending
String RESULT_SORT_PRIORITY = "sort.priority";
+ // String RESULT_SORT_PRIORITY_DEFAULT = "sort.priority";
String RESULT_COUNT = "RESULT_COUNT";
String RESULT_COUNT_DEFAULT = "5";
String CUSTOM_REFRESH = "CUSTOM_REFRESH";
String OPERATION_STATUS = "OPERATION_STATUS";
+ String OPERATION_STATUS_DEFAULT = "";//empty
}
//configuration map initialization
public static Map<String, String> CONFIG_PROPERTY_INITIALIZATION = new
HashMap<String, String>();
static {// Key, Default value
//alert priority, if empty initialize to "" i.e. all priorities
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.ALERT_PRIORITY, "");
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.ALERT_PRIORITY,
Constant.ALERT_PRIORITY_DEFAULT);
//result sort order, if empty initialize to "DESC"
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_SORT_ORDER,
PageOrdering.DESC.name());
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_SORT_ORDER,
Constant.RESULT_SORT_ORDER_DEFAULT);
//result count, if empty initialize to 5
CONFIG_PROPERTY_INITIALIZATION.put(Constant.RESULT_COUNT,
Constant.RESULT_COUNT_DEFAULT);
//whether to specify time range for alerts. Defaults to false
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_ENABLE,
String.valueOf(false));
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_ENABLE,
Constant.METRIC_RANGE_ENABLE_DEFAULT);
//whether Begin and End values set for time. Aka. Advanced/full range setting
Defaults to false
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG,
String.valueOf(false));
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG,
+ Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT);
//whether in simple mode. Ex. 8 hrs. Defaults to 8
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_LASTN,
Constant.METRIC_RANGE_LASTN_DEFAULT);
- //whether in simple mode. Ex. 8 hrs. Defaults to 8
+ //whether in simple mode. Ex. hrs. Defaults to hours
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_UNIT,
Constant.METRIC_RANGE_UNIT_DEFAULT);
//operation status, if empty initialize to "" i.e. all stati
- CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, "");
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS,
Constant.OPERATION_STATUS_DEFAULT);
}
/* Single select combobox for number of items to display on the dashboard
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
index 120c974..4fa8807 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
@@ -273,7 +273,6 @@ public class GroupAlertsPortlet extends AlertHistoryView implements
CustomSettin
refreshTimer = new Timer() {
public void run() {
-
redraw();
}
};
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index 2ee782e..35d5886 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -250,6 +250,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements
CustomSettin
column.addMember(row);
}
+ column.markForRedraw();
//insert see more link
LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent.extendLocatorId(String
.valueOf(rowNum)));
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index 0e2e00c..e148b1e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -58,7 +58,6 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDataSource;
@@ -83,7 +82,7 @@ public class GroupOperationsPortlet extends LocatableVLayout implements
CustomSe
// set on initial configuration, the window for this portlet view.
protected PortletWindow portletWindow;
- protected GroupOperationsCriteriaHistoryListView dataSource;
+ private GroupOperationsCriteriaHistoryListView groupOperations;
//defines the list of configuration elements to load/persist for this portlet
protected static List<String> CONFIG_INCLUDE = new ArrayList<String>();
@@ -111,7 +110,6 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
protected String baseViewPath = "";
protected LocatableCanvas recentOperationsContent = new
LocatableCanvas(extendLocatorId("RecentOperations"));
protected String locatorId;
- private GroupOperationsCriteriaHistoryListView groupOperations;
public GroupOperationsPortlet(String locatorId) {
super(locatorId);
@@ -233,7 +231,6 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
form.setMargin(5);
//add label about what configuration affects? redundant?
-
//add filter operation status type selector
final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
.getOperationStatusEditor(portletConfig);
@@ -256,7 +253,6 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
public void onSubmitValues(SubmitValuesEvent event) {
//result count
- String selectedValue;
portletConfig =
AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
//time range configuration
@@ -350,16 +346,16 @@ class GroupOperationsCriteriaHistoryListView extends
GroupOperationHistoryListVi
private ResourceGroupComposite composite;
- public GroupOperationsCriteriaHistoryListView(String locatorId,
AbstractOperationHistoryDataSource dataSource,
+ public GroupOperationsCriteriaHistoryListView(String locatorId,
GroupOperationsCriteriaDataSource dataSource,
String title, Criteria criteria, ResourceGroupComposite composite) {
super(locatorId, composite);
- setDataSource(dataSource);
+ super.setDataSource(dataSource);
this.composite = composite;
setShowFooterRefresh(false); //disable footer refresh
}
- public void setDatasource(AbstractOperationHistoryDataSource datasource) {
- setDataSource(datasource);
+ public void setDatasource(GroupOperationsCriteriaDataSource datasource) {
+ super.setDataSource(datasource);
}
@Override
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
index 01a0b96..d915351 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceEventsPortlet.java
@@ -60,7 +60,6 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
//figure out which page we're loading
String currentPage = History.getToken();
String[] elements = currentPage.split("/");
- // int currentGroupIdentifier = Integer.valueOf(elements[1]);
this.resourceId = Integer.valueOf(elements[1]);
}
@@ -157,7 +156,6 @@ public class ResourceEventsPortlet extends GroupEventsPortlet {
//insert see more link
LocatableDynamicForm row = new
LocatableDynamicForm(recentEventsContent.extendLocatorId(String
.valueOf(rowNum)));
- //
AbstractActivityView.addSeeMoreLink(row, ReportDecorator.GWT_GROUP_URL + resourceId
AbstractActivityView.addSeeMoreLink(row,
ReportDecorator.GWT_RESOURCE_URL + resourceId
+ "/Events/History/", column);
} else {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
index 96be005..30929c1 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -18,6 +18,8 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
+import java.util.ArrayList;
+
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -25,6 +27,10 @@ import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.widgets.Canvas;
+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 org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -37,15 +43,20 @@ import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
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.portlets.PortletConfigurationEditorComponent;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Simeon Pinder
@@ -74,11 +85,73 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet
{
@Override
protected void onInit() {
- super.onInit();
+ // super.onInit();
initializeUi();
+ // loadData();
+ }
+
+ @Override
+ public void redraw() {
loadData();
}
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new
LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new
LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new
LocatableDynamicForm(page.extendLocatorId("alert-filter"));
+ form.setMargin(5);
+
+ //add label about what configuration affects? redundant?
+ //add filter operation status type selector
+ final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
+ .getOperationStatusEditor(portletConfig);
+ //add sort priority selector
+ final SelectItem resultSortSelector = PortletConfigurationEditorComponent
+ .getResulSortOrderEditor(portletConfig);
+ //add result count selector
+ final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ //add range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ form.setItems(operationStatusSelector, resultSortSelector, resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+
+ //result count
+ portletConfig =
AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
+
+ //time range configuration
+ portletConfig =
AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
+
+ //operation priority
+ portletConfig =
AbstractActivityView.saveOperationStatusSelectorSettings(operationStatusSelector,
+ portletConfig);
+
+ //persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ //resynch the config object in the datasource
+ resourceOperations.setDatasource(new
ResourceOperationsCriteriaDataSource(portletConfig));
+ //apply latest settings to the visible result set
+ redraw();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
private void loadData() {
//populate composite data
ResourceCriteria criteria = new ResourceCriteria();
@@ -134,9 +207,9 @@ public class ResourceOperationsPortlet extends GroupOperationsPortlet
{
*/
class ResourceOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView
{
- private AbstractOperationHistoryDataSource datasource;
+ private ResourceOperationsCriteriaDataSource datasource;
- public ResourceOperationsCriteriaHistoryListView(String locatorId,
AbstractOperationHistoryDataSource dataSource,
+ public ResourceOperationsCriteriaHistoryListView(String locatorId,
ResourceOperationsCriteriaDataSource dataSource,
String title, Criteria criteria, ResourceComposite composite) {
super(locatorId, dataSource, title, criteria);
this.datasource = dataSource;
@@ -156,11 +229,11 @@ class ResourceOperationsCriteriaHistoryListView extends
AbstractOperationHistory
return new
ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"),
this.resourceComposite);
}
- public AbstractOperationHistoryDataSource getDatasource() {
+ public ResourceOperationsCriteriaDataSource getDatasource() {
return datasource;
}
- public void setDatasource(AbstractOperationHistoryDataSource datasource) {
+ public void setDatasource(ResourceOperationsCriteriaDataSource datasource) {
this.datasource = datasource;
}
@@ -219,12 +292,34 @@ class ResourceOperationsCriteriaDataSource extends
ResourceOperationHistoryDataS
//result timeframe if enabled
property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
- property = portletConfig.getSimple(Constant.METRIC_RANGE);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property =
portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd =
MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index c67dce9..2da6e15 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -58,6 +58,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfig
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.BrowserUtility;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.measurement.GwtMonitorUtils;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -517,29 +518,40 @@ public abstract class AbstractActivityView extends LocatableVLayout
implements R
//time range filter. Check for enabled and then persist property. Dealing
with compound widget.
FormItem item =
measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
CheckboxItem itemC = (CheckboxItem) item;
- selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
selectedValue));
- }
-
- //time advanced time filter enabled.
- boolean isAdvanceTimeSetting = false;
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
- portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
- }
-
- //time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (isAdvanceTimeSetting) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
(begEnd.get(0) + "," + begEnd.get(1))));
- } else {
- //save not advanced time range
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN,
measurementRangeEditor
- .getMetricRangePreferences().lastN));
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT,
measurementRangeEditor
- .getMetricRangePreferences().unit));
+ boolean persistTimeRangeSettings = itemC.getValueAsBoolean();
+ if (persistTimeRangeSettings) {//retrieve values and persist
+ selectedValue = String.valueOf(itemC.getValueAsBoolean());
+ if (!selectedValue.trim().isEmpty()) {//then call
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
selectedValue));
+ }
+
+ //time advanced time filter enabled.
+ boolean isAdvanceTimeSetting = false;
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty()))
{
+ portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
+ }
+
+ //time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (isAdvanceTimeSetting) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
(begEnd.get(0) + "," + begEnd.get(1))));
+ } else {
+ //save not advanced time range
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN,
measurementRangeEditor
+ .getMetricRangePreferences().lastN));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT,
measurementRangeEditor
+ .getMetricRangePreferences().unit));
+ }
+ } else {//if disabled, reset time defaults
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
false));
+ portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, false));
+ List<Long> rangeArray =
MeasurementUtility.calculateTimeFrame(Integer
+ .valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT),
Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT));
+ // String[] range =
{String.valueOf(rangeArray.get(0)),String.valueOf(rangeArray.get(1))};
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
+ (String.valueOf(rangeArray.get(0)) + "," +
String.valueOf(rangeArray.get(1)))));
}
}
return portletConfig;
commit e581e677447f29be3be27fedf9849284e299c1b4
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 19 21:18:13 2011 -0400
i)edit config bug ii)fix dashboard edit mode on init iii)display messages.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 1d17199..a1a1c98 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -460,7 +460,6 @@ public class DashboardView extends LocatableVLayout {
this.refreshMenuButton.markForRedraw();
markForRedraw();
//attempt to initialize
- editForm.show();
editForm.markForRedraw();
markForRedraw();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
index c02f378..6eb15c4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/PortletConfigurationEditorComponent.java
@@ -33,6 +33,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.Messages;
import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/** Shared portlet configuration component where initial configuration settings
* and widgets shared across portlet editors is defined.
@@ -51,6 +52,7 @@ public class PortletConfigurationEditorComponent {
String METRIC_RANGE_LASTN = "METRIC_RANGE_LASTN";
String METRIC_RANGE_LASTN_DEFAULT = String.valueOf(8);
String METRIC_RANGE_UNIT = "METRIC_RANGE_UNIT";
+ String METRIC_RANGE_UNIT_DEFAULT =
String.valueOf(MeasurementUtility.UNIT_HOURS);
String RESULT_SEVERITY = "severities";
String RESULT_SORT_ORDER = "RESULT_SORT_ORDER";
String RESULT_SORT_PRIORITY = "sort.priority";
@@ -75,6 +77,8 @@ public class PortletConfigurationEditorComponent {
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_BEGIN_END_FLAG,
String.valueOf(false));
//whether in simple mode. Ex. 8 hrs. Defaults to 8
CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_LASTN,
Constant.METRIC_RANGE_LASTN_DEFAULT);
+ //whether in simple mode. Ex. 8 hrs. Defaults to 8
+ CONFIG_PROPERTY_INITIALIZATION.put(Constant.METRIC_RANGE_UNIT,
Constant.METRIC_RANGE_UNIT_DEFAULT);
//operation status, if empty initialize to "" i.e. all stati
CONFIG_PROPERTY_INITIALIZATION.put(Constant.OPERATION_STATUS, "");
}
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 2e37d6c..aebcd71 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
@@ -1472,7 +1472,7 @@ view_portlet_defaultName_resource_pkg_hisory = Resource: Package
History
view_portlet_help_autodiscovery = This portlet allows import or ignore of newly
discovered resources. Imported resources are added to inventory for monitoring and
management. Ignored resources are not imported and are hidden from view unless explicitly
unignored.
view_portlet_help_bundle_deps = This portlet shows relevant bundle deployments based on
display criteria configured.
-view_portlet_help_eventcounts = This portlet displays Event counts based consistent with
display criteria configured.
+view_portlet_help_eventcounts = This portlet displays Event counts consistent with
display criteria configured.
view_portlet_help_favoriteResources = This portlet displays the current user''s
favorite resources.
view_portlet_help_graph = This portlet displays the resource metric graph.
view_portlet_help_inventorySummary = This portlet displays a short summary of the current
user''s viewable inventory and metric collection rate.
commit 4fc496a1cf495e44ed2cd19a21f2d69998c23031
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 19 19:28:35 2011 -0400
define default portlet ordering for res and group portlets.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
index 5f2de37..af8d09c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
@@ -18,6 +18,7 @@
*/
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary;
+import java.util.HashMap;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -45,7 +46,10 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -180,25 +184,52 @@ public class ActivityView2 extends LocatableVLayout implements
DashboardContaine
dashboard.setGroup(group);
dashboard.setColumns(2);
- // TODO, add real portlets
// set leftmost column and let the rest be equally divided
dashboard.setColumnWidths("40%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
- // Left Column
- // DashboardPortlet dummyLeft = new DashboardPortlet(MessagePortlet.NAME,
MessagePortlet.KEY, 220);
- // dummyLeft.getConfiguration().put(new
PropertySimple("message", "<br/>Coming Soon... :-)"));
- // dashboard.addPortlet(dummyLeft, 0, 0);
-
- // DashboardPortlet groupAlerts = new
DashboardPortlet(GroupAlertsPortlet3.NAME, GroupAlertsPortlet3.KEY, 220);
- // groupAlerts.getConfiguration().put(new
PropertySimple("message", "<br/>Coming Soon... :-)"));
- // dashboard.addPortlet(groupAlerts, 0, 0);
+ //figure out which portlets to display and how
+ HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
+ groupKeyNameMap = DashboardView.processPortletNameMapForGroup(groupKeyNameMap,
groupComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (groupKeyNameMap.containsKey(GroupMetricsPortlet.KEY)) {//measurments top left
if available
+ DashboardPortlet measurements = new
DashboardPortlet(GroupMetricsPortlet.NAME, GroupMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ }
- // right Column
- DashboardPortlet dummyRight = new DashboardPortlet(MessagePortlet.NAME,
MessagePortlet.KEY, 220);
- dummyRight.getConfiguration().put(new PropertySimple("message",
"<br/>Coming Soon... :-)"));
- dashboard.addPortlet(dummyRight, 1, 0);
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (groupKeyNameMap.containsKey(GroupAlertsPortlet.KEY)) {//alerts top right if
available
+ DashboardPortlet alerts = new DashboardPortlet(GroupAlertsPortlet.NAME,
GroupAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupAlertsPortlet.KEY);
+ }
+ if (groupKeyNameMap.containsKey(GroupOperationsPortlet.KEY)) {//operations if
available
+ DashboardPortlet ops = new DashboardPortlet(GroupOperationsPortlet.NAME,
GroupOperationsPortlet.KEY, 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
+ }
+ //Fill out left column(typically smaller portlets) then alternate cols with
remaining
+ boolean displayLeft = false;
+ for (String key : groupKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(groupKeyNameMap.get(key),
key, 100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
return dashboard;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
index 20b5e65..ad6e607 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
@@ -1,5 +1,6 @@
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
+import java.util.HashMap;
import java.util.Set;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -27,7 +28,10 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletFactory;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
@@ -167,15 +171,50 @@ public class Activity2View extends LocatableVLayout implements
DashboardContaine
dashboard.setColumnWidths("40%");
dashboard.getConfiguration().put(new PropertySimple(Dashboard.CFG_BACKGROUND,
"#F1F2F3"));
- // Left Column
- DashboardPortlet dummyLeft = new DashboardPortlet(MessagePortlet.NAME,
MessagePortlet.KEY, 220);
- dummyLeft.getConfiguration().put(new PropertySimple("message",
"<br/>Coming Soon... :-)"));
- dashboard.addPortlet(dummyLeft, 0, 0);
+ //figure out which portlets to display and how
+ HashMap<String, String> resKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
+ resKeyNameMap = DashboardView.processPortletNameMapForResource(resKeyNameMap,
resourceComposite);
+ int colLeft = 0;
+ int colRight = 1;
+ int rowLeft = 0;
+ int rowRight = 0;
+ //Left Column
+ if (resKeyNameMap.containsKey(ResourceMetricsPortlet.KEY)) {//measurments top
left if available
+ DashboardPortlet measurements = new
DashboardPortlet(ResourceMetricsPortlet.NAME,
+ ResourceMetricsPortlet.KEY, 220);
+ dashboard.addPortlet(measurements, colLeft, rowLeft++);
+ resKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ }
+
+ // right Column(approx 60%. As larger more room to display table and N rows.)
+ if (resKeyNameMap.containsKey(ResourceAlertsPortlet.KEY)) {//alerts top right if
available
+ DashboardPortlet alerts = new DashboardPortlet(ResourceAlertsPortlet.NAME,
ResourceAlertsPortlet.KEY, 220);
+ dashboard.addPortlet(alerts, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceAlertsPortlet.KEY);
+ }
+ if (resKeyNameMap.containsKey(ResourceOperationsPortlet.KEY)) {//operations if
available
+ DashboardPortlet ops = new DashboardPortlet(ResourceOperationsPortlet.NAME,
ResourceOperationsPortlet.KEY,
+ 220);
+ dashboard.addPortlet(ops, colRight, rowRight++);
+ resKeyNameMap.remove(ResourceOperationsPortlet.KEY);
+ }
- // right Column
- DashboardPortlet dummyRight = new DashboardPortlet(MessagePortlet.NAME,
MessagePortlet.KEY, 220);
- dummyRight.getConfiguration().put(new PropertySimple("message",
"<br/>Coming Soon... :-)"));
- dashboard.addPortlet(dummyRight, 1, 0);
+ //Fill out left column(typically smaller portlets) then alternate cols with
remaining
+ boolean displayLeft = false;
+ for (String key : resKeyNameMap.keySet()) {
+ DashboardPortlet portlet = new DashboardPortlet(resKeyNameMap.get(key), key,
100);
+ if (rowLeft < 4) {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ } else {//alternate
+ if (!displayLeft) {
+ dashboard.addPortlet(portlet, colRight, rowRight++);
+ } else {
+ dashboard.addPortlet(portlet, colLeft, rowLeft++);
+ }
+ //toggle
+ displayLeft = !displayLeft;
+ }
+ }
return dashboard;
}
commit a5993d8891b49bbba0d897f8d44b0e3b1609b9d9
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Sat Mar 19 18:45:35 2011 -0400
i)conditionally render available dash portlets based on group/resource
ii)groupEvents portlet refresh issue
iii)groupOperationsPortlet null link fix.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 25923ba..1d17199 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -23,6 +23,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.TreeMap;
+import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.AnimationCallback;
@@ -48,14 +49,32 @@ import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.dashboard.Dashboard;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceTypeFacet;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.form.ColorButtonItem;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
+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.resource.ResourceBundleDeploymentsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceEventsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceMetricsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceOperationsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourcePkgHistoryPortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -94,8 +113,10 @@ public class DashboardView extends LocatableVLayout {
private int refreshInterval = 0;
private LocatableIMenuButton refreshMenuButton;
private HashMap<String, PortletViewFactory> portletMap = null;
- private ResourceGroup focusGroup = null;
- private Resource focusResource = null;
+ private ResourceGroup group = null;
+ private ResourceGroupComposite groupComposite = null;
+ private Resource resource = null;
+ private ResourceComposite resourceComposite = null;
// this is used to prevent an odd smartgwt problem where onInit() can get called
multiple times if
// the view is set to a Tab's pane.
@@ -109,10 +130,16 @@ public class DashboardView extends LocatableVLayout {
}
public DashboardView(String locatorId, DashboardContainer dashboardContainer,
Dashboard storedDashboard,
- ResourceGroup group, Resource resource) {
+ ResourceGroupComposite groupCompositeValue, ResourceComposite
resourceCompositeValue) {
this(locatorId, dashboardContainer, storedDashboard);
- this.focusGroup = group;
- this.focusResource = resource;
+ groupComposite = groupCompositeValue;
+ if (groupComposite != null) {
+ group = groupCompositeValue.getResourceGroup();
+ }
+ resourceComposite = resourceCompositeValue;
+ if (resourceComposite != null) {
+ resource = resourceComposite.getResource();
+ }
}
@Override
@@ -167,10 +194,62 @@ public class DashboardView extends LocatableVLayout {
private DynamicForm buildEditForm() {
editForm = new LocatableDynamicForm(extendLocatorId("Editor"));
+ final HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
+ //remove BundleDeployment and add back later if relevant.
+ groupKeyNameMap.remove(GroupBundleDeploymentsPortlet.KEY);
+ //if group, need to do asynch check for bundlePortlet to ensure only Platform
members
+ if (groupComposite != null) {
+ final ResourceGroup group = groupComposite.getResourceGroup();
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.addFilterId(group.getId());
+ criteria.fetchExplicitResources(true);
+ criteria.setPageControl(new PageControl(0, 1));
+
GWTServiceLookup.getResourceGroupService().findResourceGroupsByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceGroup>>() {
+ @Override
+ public void onSuccess(PageList<ResourceGroup> results) {
+ if (!results.isEmpty()) {
+ ResourceGroup grp = results.get(0);
+ Set<Resource> explicitMembers =
grp.getExplicitResources();
+ Resource[] currentResources = new
Resource[explicitMembers.size()];
+ explicitMembers.toArray(currentResources);
+ //membership dynamically determined if all platforms then
will be compatible.
+ if
(group.getGroupCategory().equals(GroupCategory.COMPATIBLE)) {
+ if
(currentResources[0].getResourceType().getCategory().equals(
+ ResourceCategory.PLATFORM)) {
+ //this portlet allowed to add bundle portlet
monitoring
+
groupKeyNameMap.put(GroupBundleDeploymentsPortlet.KEY,
+ GroupBundleDeploymentsPortlet.NAME);
+ }
+ }
+ }
+ //now complet populating of portlet edit form.
+ populateBuildEditForm(groupKeyNameMap);
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving information for group [" +
group.getId() + "]:"
+ + caught.getMessage());
+ }
+ });
+
+ } else {//otherwise default groupKeyNameMap is sufficient as won't be used.
+ populateBuildEditForm(groupKeyNameMap);
+ }
+
+ return editForm;
+ }
+
+ /** Responsible for populating the edit form widget.
+ * groupKepNameMap is updated for bundles.
+ *
+ * @param groupKeyNameMap
+ */
+ private void populateBuildEditForm(HashMap<String, String> groupKeyNameMap) {
editForm.setMargin(5);
editForm.setAutoWidth();
editForm.setNumCols(canEditName() ? 12 : 10);
-
TextItem nameItem = null;
if (dashboardContainer.supportsDashboardNameEdit()) {
@@ -232,47 +311,40 @@ public class DashboardView extends LocatableVLayout {
}
});
- Menu addPortletMenu = new
LocatableMenu(editForm.extendLocatorId("PortletMenu"));
+ final Menu addPortletMenu = new
LocatableMenu(editForm.extendLocatorId("PortletMenu"));
HashMap<String, String> keyNameMap =
PortletFactory.getRegisteredPortletNameMap();
// the assumption here is that the portlet names are unique. we want a sorted
menu here, so create a
// sorted map from portlet name to portlet key and use that to generate the menu.
It would be nice if you
// could just call Menu.sort() but it's not supported (yet?).
- TreeMap<String, String> nameKeyMap = new TreeMap<String, String>();
+ final TreeMap<String, String> nameKeyMap = new TreeMap<String,
String>();
for (String portletKey : keyNameMap.keySet()) {
nameKeyMap.put(keyNameMap.get(portletKey), portletKey);
}
- //if resourceGroup passed in then add additional portlets to list
- if (this.focusGroup != null) {
- HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
- // //find current list of portlets already stored. Exclude them
- // for (DashboardPortlet currentPortlet :
storedDashboard.getPortlets()) {
- // if
(groupKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
- //
groupKeyNameMap.remove(currentPortlet.getPortletKey());
- // }
- // }
-
- //TODO: spinder 3/16/11: still need to be done.
+
+ //if resourceGroup passed in then upate portlets list depending on grouptype and
facets
+ if (this.group != null) {
+
//filter out portlets not relevent for group(compat|mixed) or facets
+ groupKeyNameMap = processPortletNameMapForGroup(groupKeyNameMap,
this.groupComposite);
+
+ //add to default list of portlets.
for (String portletKey : groupKeyNameMap.keySet()) {
nameKeyMap.put(groupKeyNameMap.get(portletKey), portletKey);
}
}
+ HashMap<String, String> resourceKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
//if resource passed in then add additional portlets to list
- if (this.focusResource != null) {
- HashMap<String, String> resourceKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
- // //find current list of portlets already stored. Exclude them
- // for (DashboardPortlet currentPortlet :
storedDashboard.getPortlets()) {
- // if
(resourceKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
- //
resourceKeyNameMap.remove(currentPortlet.getPortletKey());
- // }
- // }
+ if (this.resource != null) {
+ //trim out portlets that should not be visible
+ resourceKeyNameMap = processPortletNameMapForResource(resourceKeyNameMap,
this.resourceComposite);
for (String portletKey : resourceKeyNameMap.keySet()) {
nameKeyMap.put(resourceKeyNameMap.get(portletKey), portletKey);
}
}
+ //build the addPortlet Menu item
// now use the reversed map for the menu generation
for (String portletName : nameKeyMap.keySet()) {
MenuItem menuItem = new MenuItem(portletName);
@@ -387,8 +459,82 @@ public class DashboardView extends LocatableVLayout {
updateRefreshMenu();
this.refreshMenuButton.markForRedraw();
markForRedraw();
+ //attempt to initialize
+ editForm.show();
+ editForm.markForRedraw();
+ markForRedraw();
+ }
- return editForm;
+ /**Process the portletName map to exclude portlets that should not be visible for
this
+ * resource.
+ */
+ public static HashMap<String, String>
processPortletNameMapForResource(HashMap<String, String> resourceKeyNameMap,
+ ResourceComposite composite) {
+ if ((composite != null) && (composite.getResource() != null) &&
(resourceKeyNameMap != null)
+ && !resourceKeyNameMap.isEmpty()) {
+ Resource resource = composite.getResource();
+ //filter out portlets not relevent for facets
+ Set<ResourceTypeFacet> facets =
composite.getResourceFacets().getFacets();
+ //Operation related portlets
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ resourceKeyNameMap.remove(ResourceOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ resourceKeyNameMap.remove(ResourceMetricsPortlet.KEY);
+ }
+ //Content related portlets
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ resourceKeyNameMap.remove(ResourcePkgHistoryPortlet.KEY);
+ }
+ //Event related portlets
+ if (!facets.contains(ResourceTypeFacet.EVENT)) {
+ resourceKeyNameMap.remove(ResourceEventsPortlet.KEY);
+ }
+ //Bundle related portlet
+ if
(!resource.getResourceType().getCategory().equals(ResourceCategory.PLATFORM)) {
+ resourceKeyNameMap.remove(ResourceBundleDeploymentsPortlet.KEY);
+ }
+ }
+ return resourceKeyNameMap;
+ }
+
+ /**Process the portletName map to exclude portlets that should not be visible for
this
+ * group. All except BundleDeployment visibility is handled here. Bundle requires
runtime check.
+ */
+ public static HashMap<String, String>
processPortletNameMapForGroup(HashMap<String, String> groupKeyNameMap,
+ ResourceGroupComposite composite) {
+ if ((composite != null) && (composite.getResourceGroup() != null)
&& (groupKeyNameMap != null)
+ && !groupKeyNameMap.isEmpty()) {
+
+ //filter out portlets not relevent for facets
+ Set<ResourceTypeFacet> facets =
composite.getResourceFacets().getFacets();
+ GroupCategory groupCategory =
composite.getResourceGroup().getGroupCategory();
+ // ResourceGroup group = composite.getResourceGroup();
+ //compatible if not a compatible group may need to do some pruning.
+ if (groupCategory != GroupCategory.COMPATIBLE) {
+ //Operations related portlets(Config,PkgHistory)
+ if (!facets.contains(ResourceTypeFacet.OPERATION)) {
+ groupKeyNameMap.remove(GroupOperationsPortlet.KEY);
+ }
+ //MEASUREMENT related portlets(METRICS)
+ if (!facets.contains(ResourceTypeFacet.MEASUREMENT)) {
+ groupKeyNameMap.remove(GroupMetricsPortlet.KEY);
+ groupKeyNameMap.remove(GroupOobsPortlet.KEY);
+ }
+ //CONTENT related portlets(CONTENT)
+ if (!facets.contains(ResourceTypeFacet.CONTENT)) {
+ groupKeyNameMap.remove(GroupPkgHistoryPortlet.KEY);
+ }
+ // //EVENT related portlets
+ // if (!facets.contains(ResourceTypeFacet.EVENT)) {
+ // groupKeyNameMap.remove(GroupEventsPortlet.KEY);
+ // }
+
+ }
+ }
+ return groupKeyNameMap;
}
private void loadPortletWindows() {
@@ -671,6 +817,7 @@ public class DashboardView extends LocatableVLayout {
this.editMode = editMode;
if (editMode) {
this.editForm.show();
+ //
} else {
this.editForm.hide();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
index 636a844..2ee782e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupEventsPortlet.java
@@ -266,6 +266,7 @@ public class GroupEventsPortlet extends LocatableVLayout implements
CustomSettin
}
recentEventsContent.addChild(column);
recentEventsContent.markForRedraw();
+ markForRedraw();
}
});
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index d840bcc..0e2e00c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -348,10 +348,13 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
*/
class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListView {
+ private ResourceGroupComposite composite;
+
public GroupOperationsCriteriaHistoryListView(String locatorId,
AbstractOperationHistoryDataSource dataSource,
String title, Criteria criteria, ResourceGroupComposite composite) {
super(locatorId, composite);
setDataSource(dataSource);
+ this.composite = composite;
setShowFooterRefresh(false); //disable footer refresh
}
@@ -368,6 +371,11 @@ class GroupOperationsCriteriaHistoryListView extends
GroupOperationHistoryListVi
MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()),
String.valueOf(count)));
}
}
+
+ @Override
+ protected String getBasePath() {
+ return "ResourceGroup/" + composite.getResourceGroup().getId() +
"/Operations/History";
+ }
}
/** Provide implementation of GroupOperationHistoryDataSource that dynamically
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
index 3ce4561..3cb8256 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceBundleDeploymentsPortlet.java
@@ -163,6 +163,7 @@ public class ResourceBundleDeploymentsPortlet extends
GroupBundleDeploymentsPort
for (Canvas child : recentBundleDeployContent.getChildren()) {
child.destroy();
}
+ column.markForRedraw();
recentBundleDeployContent.addChild(column);
recentBundleDeployContent.markForRedraw();
markForRedraw();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index f9fae66..c67dce9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -156,7 +156,6 @@ public abstract class AbstractActivityView extends LocatableVLayout
implements R
Set<ResourceTypeFacet> resourceFacets = null;
if ((groupComposite != null) && (groupComposite.getResourceGroup() !=
null)) {
group = groupComposite.getResourceGroup();
- group = groupComposite.getResourceGroup();
groupCategory = groupComposite.getResourceGroup().getGroupCategory();
facets = groupComposite.getResourceFacets().getFacets();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
index c57b591..5f2de37 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
@@ -125,10 +125,8 @@ public class ActivityView2 extends LocatableVLayout implements
DashboardContaine
private void setDashboard(Dashboard dashboard) {
Canvas[] members = getMembers();
removeMembers(members);
-
//pass in the group information
- dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, this.groupComposite
- .getResourceGroup(), null);
+ dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, groupComposite, null);
addMember(dashboardView);
footer = new LocatableToolStrip(extendLocatorId("Footer"));
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
index 867251f..20b5e65 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/Activity2View.java
@@ -106,10 +106,9 @@ public class Activity2View extends LocatableVLayout implements
DashboardContaine
private void setDashboard(Dashboard dashboard) {
Canvas[] members = getMembers();
removeMembers(members);
-
//pass in the resource information
dashboardView = new DashboardView(extendLocatorId(dashboard.getName()), this,
dashboard, null,
- this.resourceComposite.getResource());
+ resourceComposite);
addMember(dashboardView);
footer = new LocatableToolStrip(extendLocatorId("Footer"));
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 9d9da4f..2e37d6c 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
@@ -1459,13 +1459,13 @@ view_portlet_defaultName_group_alerts =Group: Alerts
view_portlet_defaultName_group_bundles = Group: Bundle Deployments
view_portlet_defaultName_group_events = Group: Event Counts
view_portlet_defaultName_group_metrics = Group: Metrics
-view_portlet_defaultName_group_oobs = Group: OOB Metrics
+view_portlet_defaultName_group_oobs = Group: OOB Conditions
view_portlet_defaultName_group_operations = Group: Operations
view_portlet_defaultName_group_pkg_hisory = Group: Package History
view_portlet_defaultName_resource_alerts = Resource: Alerts
view_portlet_defaultName_resource_bundles = Resource: Bundle Deployments
view_portlet_defaultName_resource_events = Resource: Event Counts
-view_portlet_defaultName_resource_metrics = Resource: Metrics
+view_portlet_defaultName_resource_metrics = Resource: Measurements
view_portlet_defaultName_resource_oobs = Resource: OOB Metrics
view_portlet_defaultName_resource_operations = Resource: Operations
view_portlet_defaultName_resource_pkg_hisory = Resource: Package History
commit d95526648b72a4f82620a1cda714e820dbba1dbf
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 18 08:34:45 2011 -0400
some portlet cleanup.
i)get rid of (non-table) GroupAlerts portlet
ii)rename tabular GroupAlerts portlet
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 aa63d77..b8d2ddc 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
@@ -24,7 +24,7 @@ import java.util.List;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupBundleDeploymentsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupEventsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupMetricsPortlet;
@@ -104,8 +104,7 @@ public class PortletFactory {
//############## Group Activity Dashboard
############################################
//defines mapping for Group Activity Dashboard
registeredGroupPortletFactoryMap = new HashMap<String,
PortletViewFactory>();
- // registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY,
GroupAlertsPortlet.Factory.INSTANCE);
- registeredGroupPortletFactoryMap.put(GroupAlertsPortlet2.KEY,
GroupAlertsPortlet2.Factory.INSTANCE);
+ registeredGroupPortletFactoryMap.put(GroupAlertsPortlet.KEY,
GroupAlertsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupMetricsPortlet.KEY,
GroupMetricsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupOobsPortlet.KEY,
GroupOobsPortlet.Factory.INSTANCE);
registeredGroupPortletFactoryMap.put(GroupEventsPortlet.KEY,
GroupEventsPortlet.Factory.INSTANCE);
@@ -116,8 +115,7 @@ public class PortletFactory {
//register group portlet names
registeredGroupPortletNameMap = new HashMap<String,
String>(registeredGroupPortletFactoryMap.size());
- // registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY,
GroupAlertsPortlet.NAME);
- registeredGroupPortletNameMap.put(GroupAlertsPortlet2.KEY,
GroupAlertsPortlet2.NAME);
+ registeredGroupPortletNameMap.put(GroupAlertsPortlet.KEY,
GroupAlertsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupMetricsPortlet.KEY,
GroupMetricsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupOobsPortlet.KEY, GroupOobsPortlet.NAME);
registeredGroupPortletNameMap.put(GroupEventsPortlet.KEY,
GroupEventsPortlet.NAME);
@@ -153,8 +151,7 @@ public class PortletFactory {
//############## Portlet icon mappings
############################################
//register portlet names
registeredPortletIconMap = new HashMap<String,
String>(registeredPortletFactoryMap.size());
- // registeredPortletIconMap.put(GroupAlertsPortlet.KEY,
ImageManager.getAlertIcon());
- registeredPortletIconMap.put(GroupAlertsPortlet2.KEY,
ImageManager.getAlertIcon());
+ registeredPortletIconMap.put(GroupAlertsPortlet.KEY,
ImageManager.getAlertIcon());
registeredPortletIconMap.put(ResourceAlertsPortlet.KEY,
ImageManager.getAlertIcon());
registeredPortletIconMap.put(GroupMetricsPortlet.KEY,
ImageManager.getMonitorIcon());
registeredPortletIconMap.put(ResourceMetricsPortlet.KEY,
ImageManager.getMonitorIcon());
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
index 483d858..120c974 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java
@@ -18,35 +18,35 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups;
-import java.util.List;
+import java.util.HashMap;
+import java.util.Set;
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
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.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.LinkItem;
import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.core.domain.util.PageOrdering;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource;
import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
@@ -54,68 +54,80 @@ 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.dashboard.portlets.PortletConfigurationEditorComponent;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
-import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
-import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
-import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-/**This portlet allows the end user to customize the:
- * i)range
- * ii)priority
- * iii)etc.
- * of alerts to display for the given group
- *
+/**
* @author Simeon Pinder
*/
-public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettingsPortlet, AutoRefreshPortlet {
- private int groupId = -1;
- protected LocatableCanvas recentAlertsContent = new
LocatableCanvas(extendLocatorId("RecentAlerts"));
- private static AlertGWTServiceAsync alertService =
GWTServiceLookup.getAlertService();
- private boolean currentlyLoading = false;
- private Configuration portletConfig = null;
- private DashboardPortlet storedPortlet;
+public class GroupAlertsPortlet extends AlertHistoryView implements
CustomSettingsPortlet, AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupAlerts";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_group_alerts();
+
+ public static final String ALERT_RANGE_RESOURCES_VALUE =
"alert-range-resource-value";
+ public static final String ALERT_RANGE_RESOURCE_IDS =
"alert-range-resource-ids";
+ public static final String RESOURCES_ALL = MSG.common_label_all_resources();
+ public static final String RESOURCES_SELECTED =
MSG.common_label_selected_resources();
+ public static final String defaultResourceValue = RESOURCES_ALL;
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ protected PortletWindow portletWindow;
+
+ //shared private UI elements
+ protected AlertResourceSelectorRegion resourceSelector;
+
+ protected AlertPortletConfigurationDataSource dataSource;
+ //instance ui widgets
+ protected Canvas containerCanvas;
+
+ protected Timer refreshTimer;
+ protected DashboardPortlet storedPortlet;
+ protected Configuration portletConfig;
+ private int groupId;
+ protected boolean portletConfigInitialized = false;
+
+ protected static HashMap<String, String> updatedMapping = new
HashMap<String, String>();
+ static {
+
updatedMapping.putAll(PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION);
+ //Key, default
+ updatedMapping.put(ALERT_RANGE_RESOURCES_VALUE, RESOURCES_ALL);
+ updatedMapping.put(ALERT_RANGE_RESOURCE_IDS, RESOURCES_ALL);
+ }
public GroupAlertsPortlet(String locatorId) {
super(locatorId);
+
+ //override the shared datasource
//figure out which page we're loading
String currentPage = History.getToken();
String[] elements = currentPage.split("/");
- int currentGroupIdentifier = Integer.valueOf(elements[1]);
- this.groupId = currentGroupIdentifier;
- initializeUi();
- }
+ this.groupId = Integer.valueOf(elements[1]);
- @Override
- protected void onInit() {
- super.onInit();
- loadData();
+ setShowFilterForm(false); //disable filter form for portlet
+ setOverflow(Overflow.VISIBLE);
}
- /**Defines layout for the Activity page.
+ /**Defines layout for the portlet page.
*/
protected void initializeUi() {
- setPadding(5);
- setMembersMargin(5);
- addMember(recentAlertsContent);
- }
+ //initalize the datasource
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet,
portletConfig, this.groupId, null);
+ setDataSource(this.dataSource);
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts";
- // A default displayed, persisted name for the portlet
- public static final String NAME = "Group: Alerts";
- public static final String ID = "id";
+ setShowHeader(false);
+ setShowFooter(true);
+ setShowFooterRefresh(false); //disable footer refresh
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
- //instance ui widgets
-
- private Timer refreshTimer;
+ getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
/** Responsible for initialization and lazy configuration of the portlet values
*/
@@ -131,6 +143,12 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
this.storedPortlet = storedPortlet;
portletConfig = storedPortlet.getConfiguration();
+ if (!portletConfigInitialized) {
+ this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet,
portletConfig, this.groupId, null);
+ setDataSource(this.dataSource);
+ portletConfigInitialized = true;
+ }
+
//lazy init any elements not yet configured.
for (String key :
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
if (portletConfig.getSimple(key) == null) {
@@ -138,137 +156,33 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
}
}
- }
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
+ //resource ids to be conditionally included in the query
+ Integer[] filterResourceIds = null;
+ filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet,
filterResourceIds);
+ //no defaults
- public final Portlet getInstance(String locatorId) {
- return new GroupAlertsPortlet(locatorId);
+ if (filterResourceIds != null) {
+ getDataSource().setAlertFilterResourceId(filterResourceIds);
}
- }
- /** Fetches alerts and updates the DynamicForm instance with the latest
- * alert information.
- */
- private void getRecentAlerts() {
- final int groupId = this.groupId;
- currentlyLoading = false;
- //fetches last five alerts for this resource
- AlertCriteria criteria = new AlertCriteria();
- //filter priority
- PropertySimple property = portletConfig.getSimple(Constant.ALERT_PRIORITY);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] parsedValues = currentSetting.trim().split(",");
- if (currentSetting.trim().isEmpty() || parsedValues.length == 3) {
- //all alert priorities assumed
- } else {
- AlertPriority[] filterPriorities = new
AlertPriority[parsedValues.length];
- int indx = 0;
- for (String priority : parsedValues) {
- AlertPriority p = AlertPriority.valueOf(priority);
- filterPriorities[indx++] = p;
- }
- criteria.addFilterPriorities(filterPriorities);
- }
- }
- PageControl pc = new PageControl();
- //result sort order
- property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
- criteria.addSortCtime(PageOrdering.DESC);
- pc.setPrimarySortOrder(PageOrdering.DESC);
- } else {
- criteria.addSortCtime(PageOrdering.ASC);
- pc.setPrimarySortOrder(PageOrdering.ASC);
+ //conditionally display the selected resources ui
+ if (containerCanvas != null) {
+ //empty out earlier canvas
+ for (Canvas c : containerCanvas.getChildren()) {
+ c.destroy();
}
- }
- //result timeframe if enabled
- property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
- if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
- property = portletConfig.getSimple(Constant.METRIC_RANGE);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
- }
- }
-
- //result count
- property = portletConfig.getSimple(Constant.RESULT_COUNT);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase("5")) {
- PageControl pageControl = new PageControl(0, 5);
- pc.setPageSize(5);
+ if ((resourceSelector != null) &&
getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) {
+ containerCanvas.addChild(resourceSelector.getCanvas());
} else {
- PageControl pageControl = new PageControl(0,
Integer.valueOf(currentSetting));
- pc.setPageSize(Integer.valueOf(currentSetting));
+ containerCanvas.addChild(new Canvas());
}
}
- criteria.setPageControl(pc);
- criteria.addFilterResourceGroupIds(groupId);
- alertService.findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
- @Override
- public void onSuccess(PageList<Alert> result) {
- VLayout column = new VLayout();
- column.setHeight(10);
- if (!result.isEmpty()) {
- int rowNum = 0;
- for (Alert alert : result) {
- // alert history records do not have a usable locatorId,
we'll use rownum, which is unique and
- // may be repeatable.
- LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- row.setNumCols(3);
-
- StaticTextItem iconItem =
AbstractActivityView.newTextItemIcon(ImageManager.getAlertIcon(alert
- .getAlertDefinition().getPriority()),
alert.getAlertDefinition().getPriority()
- .getDisplayName());
- LinkItem link =
AbstractActivityView.newLinkItem(alert.getAlertDefinition().getName() + ": ",
- ReportDecorator.GWT_GROUP_URL + groupId +
"/Alerts/History/" + alert.getId());
- StaticTextItem time =
AbstractActivityView.newTextItem(GwtRelativeDurationConverter
- .format(alert.getCtime()));
- row.setItems(iconItem, link, time);
-
- column.addMember(row);
- }
- //link to more details
- LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
- .valueOf(rowNum++)));
- AbstractActivityView.addSeeMoreLink(row,
ReportDecorator.GWT_GROUP_URL + groupId
- + "/Alerts/History/", column);
- } else {
- LocatableDynamicForm row =
AbstractActivityView.createEmptyDisplayRow(recentAlertsContent
- // .extendLocatorId("None"),
AbstractActivityView.RECENT_ALERTS_NONE);
- .extendLocatorId("None"), "No results found using
criteria specified.");
- column.addMember(row);
- }
- for (Canvas child : recentAlertsContent.getChildren()) {
- child.destroy();
- }
- recentAlertsContent.addChild(column);
- recentAlertsContent.markForRedraw();
- }
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving recent alerts for group [" +
groupId + "]:" + caught.getMessage());
- }
- });
}
- protected void loadData() {
- currentlyLoading = true;
- getRecentAlerts();
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
}
@Override
@@ -289,11 +203,11 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
// .getResulSortOrderEditor(portletConfig);
//add result count selector
final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
//add range selector
final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
.getMeasurementRangeEditor(portletConfig);
- //TODO: spinder 3/10/11 renable sort selector once it's working in criteria
- // form.setItems(alertPrioritySelector, resultSortSelector,
resultCountSelector);
+
form.setItems(alertPrioritySelector, resultCountSelector);
//submit handler
@@ -301,13 +215,10 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
@Override
public void onSubmitValues(SubmitValuesEvent event) {
+ String selectedValue;
//alert severity
- String selectedValue = alertPrioritySelector.getValue().toString();
- if ((selectedValue.trim().isEmpty()) ||
(selectedValue.split(",").length == 3)) {//then no alertPriority specified
- portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY,
""));
- } else {//some subset of available alertPriorities will be used
- portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY,
selectedValue));
- }
+ portletConfig =
AbstractActivityView.saveAlertPrioritySettings(alertPrioritySelector, portletConfig);
+
// //result sort order
// selectedValue =
resultSortSelector.getValue().toString();
// if ((selectedValue.trim().isEmpty()) ||
(selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
@@ -316,37 +227,16 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
// portletConfig.put(new
PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC));
// }
//result count
- selectedValue = resultCountSelector.getValue().toString();
- if ((selectedValue.trim().isEmpty()) ||
(selectedValue.equalsIgnoreCase(Constant.RESULT_COUNT_DEFAULT))) {//then 5
- portletConfig.put(new PropertySimple(Constant.RESULT_COUNT,
Constant.RESULT_COUNT_DEFAULT));
- } else {
- portletConfig.put(new PropertySimple(Constant.RESULT_COUNT,
selectedValue));
- }
-
- //alert time range filter. Check for enabled and then persist property.
Dealing with compound widget.
- FormItem item =
measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
- CheckboxItem itemC = (CheckboxItem) item;
- selectedValue = String.valueOf(itemC.getValueAsBoolean());
- if (!selectedValue.trim().isEmpty()) {//then call
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
selectedValue));
- }
-
- //alert time advanced time filter enabled.
- selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
- if ((selectedValue != null) && (!selectedValue.trim().isEmpty()))
{
- portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
- }
+ portletConfig =
AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
- //alert time frame
- List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
- portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
(begEnd.get(0) + "," + begEnd.get(1))));
- }
+ //time range settings
+ portletConfig =
AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
+ portletConfig);
- //persist
+ //persist and reload portlet
storedPortlet.setConfiguration(portletConfig);
configure(portletWindow, storedPortlet);
- loadData();
+ refresh();
}
});
form.markForRedraw();
@@ -356,6 +246,19 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
return customSettings;
}
+ public AlertPortletConfigurationDataSource getDataSource() {
+ return dataSource;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new GroupAlertsPortlet(locatorId);
+ }
+ }
+
@Override
public void startRefreshCycle() {
//current setting
@@ -370,10 +273,8 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
refreshTimer = new Timer() {
public void run() {
- if (!currentlyLoading) {
- loadData();
- redraw();
- }
+
+ redraw();
}
};
@@ -384,15 +285,110 @@ public class GroupAlertsPortlet extends LocatableVLayout implements
CustomSettin
@Override
protected void onDestroy() {
if (refreshTimer != null) {
-
refreshTimer.cancel();
}
+
super.onDestroy();
}
@Override
- public void redraw() {
- super.redraw();
- loadData();
+ protected void setupTableInteractions(boolean hasWriteAccess) {
+ // The portlet is a "subsystem" view. Meaning the alerts displayed can
be from any accessible group for
+ // the user. This means the user can have varying permissions on the underlying
groups and/or resources,
+ // which makes button enablement tricky. So, for the portlet don't even show
the buttons unless the user
+ // is inventory manager. Other users will just have to navigate to the alert in
question in order to
+ // manipulate it.
+
+ //determine if the user is inventory manager and if so render the buttons
+ Set<Permission> permissions = this.portletWindow.getGlobalPermissions();
+ if ((null != permissions) &&
permissions.contains(Permission.MANAGE_INVENTORY)) {
+ super.setupTableInteractions(true);
+ }
+ }
+
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ Integer recordId = getId(record);
+ Integer resourceId = record.getAttributeAsInt("resourceId");
+ String detailsUrl = LinkManager.getSubsystemAlertHistoryLink(resourceId,
recordId);
+ return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(),
null);
+ }
+ };
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length == 1) {
+ Integer recordId = getId(selectedRows[0]);
+ Integer resourceId =
selectedRows[0].getAttributeAsInt("resourceId");
+ CoreGUI.goToView(LinkManager.getSubsystemAlertHistoryLink(resourceId,
recordId));
+ }
+ }
+ });
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ initializeUi();
+ // getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()),
String.valueOf(count)));
+ }
+ }
+}
+
+/** Bundles a ResourceSelector instance with labeling in Canvas for display.
+ * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act
accordingly.
+ */
+//class AlertResourceSelectorRegion extends LocatableVLayout {
+final class AlertResourceSelectorRegion extends LocatableVLayout {
+ public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) {
+ super(locatorId);
+ this.currentlyAssignedIds = assigned;
+ }
+
+ private static final Messages MSG = CoreGUI.getMessages();
+ private PortletAlertSelector selector = null;
+
+ private Integer[] currentlyAssignedIds;
+
+ public Integer[] getCurrentlyAssignedIds() {
+ return currentlyAssignedIds;
+ }
+
+ public Integer[] getListGridValues() {
+ Integer[] listGridValues = new Integer[0];
+ if (null != selector) {
+ listGridValues = selector.getAssignedListGridValues();
+ }
+ return listGridValues;
+ }
+
+ public Canvas getCanvas() {
+ if (selector == null) {
+ selector = new
PortletAlertSelector(extendLocatorId("AlertSelector"),
this.currentlyAssignedIds,
+ ResourceType.ANY_PLATFORM_TYPE, false);
+ }
+ return selector;
+ }
+
+ public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) {
+ this.currentlyAssignedIds = currentlyAssignedIds;
}
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
deleted file mode 100644
index 565b46b..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet2.java
+++ /dev/null
@@ -1,394 +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.groups;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.Timer;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.events.DoubleClickEvent;
-import com.smartgwt.client.widgets.events.DoubleClickHandler;
-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.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource;
-import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
-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.dashboard.portlets.PortletConfigurationEditorComponent;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * @author Simeon Pinder
- */
-public class GroupAlertsPortlet2 extends AlertHistoryView implements
CustomSettingsPortlet, AutoRefreshPortlet {
-
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "GroupAlerts";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_group_alerts();
-
- public static final String ALERT_RANGE_RESOURCES_VALUE =
"alert-range-resource-value";
- public static final String ALERT_RANGE_RESOURCE_IDS =
"alert-range-resource-ids";
- public static final String RESOURCES_ALL = MSG.common_label_all_resources();
- public static final String RESOURCES_SELECTED =
MSG.common_label_selected_resources();
- public static final String defaultResourceValue = RESOURCES_ALL;
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- protected PortletWindow portletWindow;
-
- //shared private UI elements
- protected AlertResourceSelectorRegion resourceSelector;
-
- protected AlertPortletConfigurationDataSource dataSource;
- //instance ui widgets
- protected Canvas containerCanvas;
-
- protected Timer refreshTimer;
- protected DashboardPortlet storedPortlet;
- protected Configuration portletConfig;
- private int groupId;
- protected boolean portletConfigInitialized = false;
-
- protected static HashMap<String, String> updatedMapping = new
HashMap<String, String>();
- static {
-
updatedMapping.putAll(PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION);
- //Key, default
- updatedMapping.put(ALERT_RANGE_RESOURCES_VALUE, RESOURCES_ALL);
- updatedMapping.put(ALERT_RANGE_RESOURCE_IDS, RESOURCES_ALL);
- }
-
- public GroupAlertsPortlet2(String locatorId) {
- super(locatorId);
-
- //override the shared datasource
- //figure out which page we're loading
- String currentPage = History.getToken();
- String[] elements = currentPage.split("/");
- this.groupId = Integer.valueOf(elements[1]);
-
- setShowFilterForm(false); //disable filter form for portlet
- setOverflow(Overflow.VISIBLE);
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- //initalize the datasource
- this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet,
portletConfig, this.groupId, null);
- setDataSource(this.dataSource);
-
- setShowHeader(false);
- setShowFooter(true);
- setShowFooterRefresh(false); //disable footer refresh
-
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
-
- /** Responsible for initialization and lazy configuration of the portlet values
- */
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
- //populate portlet configuration details
- if (null == this.portletWindow && null != portletWindow) {
- this.portletWindow = portletWindow;
- }
-
- if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
- return;
- }
- this.storedPortlet = storedPortlet;
- portletConfig = storedPortlet.getConfiguration();
-
- if (!portletConfigInitialized) {
- this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet,
portletConfig, this.groupId, null);
- setDataSource(this.dataSource);
- portletConfigInitialized = true;
- }
-
- //lazy init any elements not yet configured.
- for (String key :
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
- if (portletConfig.getSimple(key) == null) {
- portletConfig.put(new PropertySimple(key,
-
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
- }
- }
-
- //resource ids to be conditionally included in the query
- Integer[] filterResourceIds = null;
- filterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet,
filterResourceIds);
- //no defaults
-
- if (filterResourceIds != null) {
- getDataSource().setAlertFilterResourceId(filterResourceIds);
- }
-
- //conditionally display the selected resources ui
- if (containerCanvas != null) {
- //empty out earlier canvas
- for (Canvas c : containerCanvas.getChildren()) {
- c.destroy();
- }
- if ((resourceSelector != null) &&
getDataSource().getAlertResourcesToUse().equals(RESOURCES_SELECTED)) {
- containerCanvas.addChild(resourceSelector.getCanvas());
- } else {
- containerCanvas.addChild(new Canvas());
- }
- }
-
- }
-
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
- }
-
- @Override
- public DynamicForm getCustomSettingsForm() {
- LocatableDynamicForm customSettings = new
LocatableDynamicForm(extendLocatorId("customSettings"));
- LocatableVLayout page = new
LocatableVLayout(customSettings.extendLocatorId("page"));
- //build editor form container
- final LocatableDynamicForm form = new
LocatableDynamicForm(page.extendLocatorId("alert-filter"));
- form.setMargin(5);
-
- //add label about what configuration affects
-
- //add alert priority selector
- final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent
- .getAlertPriorityEditor(portletConfig);
- //add sort priority selector
- // final SelectItem resultSortSelector =
PortletConfigurationEditorComponent
- // .getResulSortOrderEditor(portletConfig);
- //add result count selector
- final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
-
- //add range selector
- final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
- .getMeasurementRangeEditor(portletConfig);
-
- form.setItems(alertPrioritySelector, resultCountSelector);
-
- //submit handler
- customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
-
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
- String selectedValue;
- //alert severity
- portletConfig =
AbstractActivityView.saveAlertPrioritySettings(alertPrioritySelector, portletConfig);
-
- // //result sort order
- // selectedValue =
resultSortSelector.getValue().toString();
- // if ((selectedValue.trim().isEmpty()) ||
(selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
- // portletConfig.put(new
PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC));
- // } else {
- // portletConfig.put(new
PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC));
- // }
- //result count
- portletConfig =
AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
-
- //time range settings
- portletConfig =
AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
- portletConfig);
-
- //persist and reload portlet
- storedPortlet.setConfiguration(portletConfig);
- configure(portletWindow, storedPortlet);
- refresh();
- }
- });
- form.markForRedraw();
- page.addMember(measurementRangeEditor);
- page.addMember(form);
- customSettings.addChild(page);
- return customSettings;
- }
-
- public AlertPortletConfigurationDataSource getDataSource() {
- return dataSource;
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance(String locatorId) {
-
- return new GroupAlertsPortlet2(locatorId);
- }
- }
-
- @Override
- public void startRefreshCycle() {
- //current setting
- final int refreshInterval =
UserSessionManager.getUserPreferences().getPageRefreshInterval();
-
- //cancel any existing timer
- if (refreshTimer != null) {
- refreshTimer.cancel();
- }
-
- if (refreshInterval >= MeasurementUtility.MINUTES) {
-
- refreshTimer = new Timer() {
- public void run() {
-
- redraw();
- }
- };
-
- refreshTimer.scheduleRepeating(refreshInterval);
- }
- }
-
- @Override
- protected void onDestroy() {
- if (refreshTimer != null) {
- refreshTimer.cancel();
- }
-
- super.onDestroy();
- }
-
- @Override
- protected void setupTableInteractions(boolean hasWriteAccess) {
- // The portlet is a "subsystem" view. Meaning the alerts displayed can
be from any accessible group for
- // the user. This means the user can have varying permissions on the underlying
groups and/or resources,
- // which makes button enablement tricky. So, for the portlet don't even show
the buttons unless the user
- // is inventory manager. Other users will just have to navigate to the alert in
question in order to
- // manipulate it.
-
- //determine if the user is inventory manager and if so render the buttons
- Set<Permission> permissions = this.portletWindow.getGlobalPermissions();
- if ((null != permissions) &&
permissions.contains(Permission.MANAGE_INVENTORY)) {
- super.setupTableInteractions(true);
- }
- }
-
- protected CellFormatter getDetailsLinkColumnCellFormatter() {
- return new CellFormatter() {
- public String format(Object value, ListGridRecord record, int i, int i1) {
- Integer recordId = getId(record);
- Integer resourceId = record.getAttributeAsInt("resourceId");
- String detailsUrl = LinkManager.getSubsystemAlertHistoryLink(resourceId,
recordId);
- return SeleniumUtility.getLocatableHref(detailsUrl, value.toString(),
null);
- }
- };
- }
-
- @Override
- protected void configureTable() {
- super.configureTable();
-
- setListGridDoubleClickHandler(new DoubleClickHandler() {
- @Override
- public void onDoubleClick(DoubleClickEvent event) {
- ListGrid listGrid = (ListGrid) event.getSource();
- ListGridRecord[] selectedRows = listGrid.getSelection();
- if (selectedRows != null && selectedRows.length == 1) {
- Integer recordId = getId(selectedRows[0]);
- Integer resourceId =
selectedRows[0].getAttributeAsInt("resourceId");
- CoreGUI.goToView(LinkManager.getSubsystemAlertHistoryLink(resourceId,
recordId));
- }
- }
- });
- }
-
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- // getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
-
- @Override
- protected void refreshTableInfo() {
- super.refreshTableInfo();
- if (getTableInfo() != null) {
- int count = getListGrid().getSelection().length;
- getTableInfo().setContents(
- MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()),
String.valueOf(count)));
- }
- }
-}
-
-/** Bundles a ResourceSelector instance with labeling in Canvas for display.
- * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act
accordingly.
- */
-//class AlertResourceSelectorRegion extends LocatableVLayout {
-final class AlertResourceSelectorRegion extends LocatableVLayout {
- public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) {
- super(locatorId);
- this.currentlyAssignedIds = assigned;
- }
-
- private static final Messages MSG = CoreGUI.getMessages();
- private PortletAlertSelector selector = null;
-
- private Integer[] currentlyAssignedIds;
-
- public Integer[] getCurrentlyAssignedIds() {
- return currentlyAssignedIds;
- }
-
- public Integer[] getListGridValues() {
- Integer[] listGridValues = new Integer[0];
- if (null != selector) {
- listGridValues = selector.getAssignedListGridValues();
- }
- return listGridValues;
- }
-
- public Canvas getCanvas() {
- if (selector == null) {
- selector = new
PortletAlertSelector(extendLocatorId("AlertSelector"),
this.currentlyAssignedIds,
- ResourceType.ANY_PLATFORM_TYPE, false);
- }
- return selector;
- }
-
- public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) {
- this.currentlyAssignedIds = currentlyAssignedIds;
- }
-}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
new file mode 100644
index 0000000..7c166ad
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
@@ -0,0 +1,398 @@
+/*
+ * 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.groups;
+
+import java.util.List;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+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.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.alert.Alert;
+import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.AlertCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+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.dashboard.portlets.PortletConfigurationEditorComponent;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.AlertGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
+import org.rhq.enterprise.gui.coregui.client.resource.disambiguation.ReportDecorator;
+import org.rhq.enterprise.gui.coregui.client.util.GwtRelativeDurationConverter;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**This portlet allows the end user to customize the:
+ * i)range
+ * ii)priority
+ * iii)etc.
+ * of alerts to display for the given group
+ *
+ * @author Simeon Pinder
+ */
+public class GroupAlertsPortlet3 extends LocatableVLayout implements
CustomSettingsPortlet, AutoRefreshPortlet {
+ private int groupId = -1;
+ protected LocatableCanvas recentAlertsContent = new
LocatableCanvas(extendLocatorId("RecentAlerts"));
+ private static AlertGWTServiceAsync alertService =
GWTServiceLookup.getAlertService();
+ private boolean currentlyLoading = false;
+ private Configuration portletConfig = null;
+ private DashboardPortlet storedPortlet;
+
+ public GroupAlertsPortlet3(String locatorId) {
+ super(locatorId);
+ //figure out which page we're loading
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int currentGroupIdentifier = Integer.valueOf(elements[1]);
+ this.groupId = currentGroupIdentifier;
+ initializeUi();
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+ loadData();
+ }
+
+ /**Defines layout for the Activity page.
+ */
+ protected void initializeUi() {
+ setPadding(5);
+ setMembersMargin(5);
+ addMember(recentAlertsContent);
+ }
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "GroupAlerts";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = "Group: Alerts";
+ public static final String ID = "id";
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+ //instance ui widgets
+
+ private Timer refreshTimer;
+
+ /** Responsible for initialization and lazy configuration of the portlet values
+ */
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+ //populate portlet configuration details
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+ this.storedPortlet = storedPortlet;
+ portletConfig = storedPortlet.getConfiguration();
+
+ //lazy init any elements not yet configured.
+ for (String key :
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (portletConfig.getSimple(key) == null) {
+ portletConfig.put(new PropertySimple(key,
+
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.get(key)));
+ }
+ }
+ }
+
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+ return new GroupAlertsPortlet3(locatorId);
+ }
+ }
+
+ /** Fetches alerts and updates the DynamicForm instance with the latest
+ * alert information.
+ */
+ private void getRecentAlerts() {
+ final int groupId = this.groupId;
+ currentlyLoading = false;
+ //fetches last five alerts for this resource
+ AlertCriteria criteria = new AlertCriteria();
+ //filter priority
+ PropertySimple property = portletConfig.getSimple(Constant.ALERT_PRIORITY);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (currentSetting.trim().isEmpty() || parsedValues.length == 3) {
+ //all alert priorities assumed
+ } else {
+ AlertPriority[] filterPriorities = new
AlertPriority[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ AlertPriority p = AlertPriority.valueOf(priority);
+ filterPriorities[indx++] = p;
+ }
+ criteria.addFilterPriorities(filterPriorities);
+ }
+ }
+ PageControl pc = new PageControl();
+ //result sort order
+ property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
+ criteria.addSortCtime(PageOrdering.DESC);
+ pc.setPrimarySortOrder(PageOrdering.DESC);
+ } else {
+ criteria.addSortCtime(PageOrdering.ASC);
+ pc.setPrimarySortOrder(PageOrdering.ASC);
+ }
+ }
+ //result timeframe if enabled
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
+ if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ }
+
+ //result count
+ property = portletConfig.getSimple(Constant.RESULT_COUNT);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase("5")) {
+ PageControl pageControl = new PageControl(0, 5);
+ pc.setPageSize(5);
+ } else {
+ PageControl pageControl = new PageControl(0,
Integer.valueOf(currentSetting));
+ pc.setPageSize(Integer.valueOf(currentSetting));
+ }
+ }
+ criteria.setPageControl(pc);
+ criteria.addFilterResourceGroupIds(groupId);
+ alertService.findAlertsByCriteria(criteria, new
AsyncCallback<PageList<Alert>>() {
+ @Override
+ public void onSuccess(PageList<Alert> result) {
+ VLayout column = new VLayout();
+ column.setHeight(10);
+ if (!result.isEmpty()) {
+ int rowNum = 0;
+ for (Alert alert : result) {
+ // alert history records do not have a usable locatorId,
we'll use rownum, which is unique and
+ // may be repeatable.
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ row.setNumCols(3);
+
+ StaticTextItem iconItem =
AbstractActivityView.newTextItemIcon(ImageManager.getAlertIcon(alert
+ .getAlertDefinition().getPriority()),
alert.getAlertDefinition().getPriority()
+ .getDisplayName());
+ LinkItem link =
AbstractActivityView.newLinkItem(alert.getAlertDefinition().getName() + ": ",
+ ReportDecorator.GWT_GROUP_URL + groupId +
"/Alerts/History/" + alert.getId());
+ StaticTextItem time =
AbstractActivityView.newTextItem(GwtRelativeDurationConverter
+ .format(alert.getCtime()));
+ row.setItems(iconItem, link, time);
+
+ column.addMember(row);
+ }
+ //link to more details
+ LocatableDynamicForm row = new
LocatableDynamicForm(recentAlertsContent.extendLocatorId(String
+ .valueOf(rowNum++)));
+ AbstractActivityView.addSeeMoreLink(row,
ReportDecorator.GWT_GROUP_URL + groupId
+ + "/Alerts/History/", column);
+ } else {
+ LocatableDynamicForm row =
AbstractActivityView.createEmptyDisplayRow(recentAlertsContent
+ // .extendLocatorId("None"),
AbstractActivityView.RECENT_ALERTS_NONE);
+ .extendLocatorId("None"), "No results found using
criteria specified.");
+ column.addMember(row);
+ }
+ for (Canvas child : recentAlertsContent.getChildren()) {
+ child.destroy();
+ }
+ recentAlertsContent.addChild(column);
+ recentAlertsContent.markForRedraw();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving recent alerts for group [" +
groupId + "]:" + caught.getMessage());
+ }
+ });
+ }
+
+ protected void loadData() {
+ currentlyLoading = true;
+ getRecentAlerts();
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+ LocatableDynamicForm customSettings = new
LocatableDynamicForm(extendLocatorId("customSettings"));
+ LocatableVLayout page = new
LocatableVLayout(customSettings.extendLocatorId("page"));
+ //build editor form container
+ final LocatableDynamicForm form = new
LocatableDynamicForm(page.extendLocatorId("alert-filter"));
+ form.setMargin(5);
+
+ //add label about what configuration affects
+
+ //add alert priority selector
+ final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent
+ .getAlertPriorityEditor(portletConfig);
+ //add sort priority selector
+ // final SelectItem resultSortSelector =
PortletConfigurationEditorComponent
+ // .getResulSortOrderEditor(portletConfig);
+ //add result count selector
+ final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+ //add range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+ //TODO: spinder 3/10/11 renable sort selector once it's working in criteria
+ // form.setItems(alertPrioritySelector, resultSortSelector,
resultCountSelector);
+ form.setItems(alertPrioritySelector, resultCountSelector);
+
+ //submit handler
+ customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ //alert severity
+ String selectedValue = alertPrioritySelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty()) ||
(selectedValue.split(",").length == 3)) {//then no alertPriority specified
+ portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY,
""));
+ } else {//some subset of available alertPriorities will be used
+ portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY,
selectedValue));
+ }
+ // //result sort order
+ // selectedValue =
resultSortSelector.getValue().toString();
+ // if ((selectedValue.trim().isEmpty()) ||
(selectedValue.equalsIgnoreCase(PageOrdering.DESC.name()))) {//then desc
+ // portletConfig.put(new
PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.DESC));
+ // } else {
+ // portletConfig.put(new
PropertySimple(Constant.RESULT_SORT_ORDER, PageOrdering.ASC));
+ // }
+ //result count
+ selectedValue = resultCountSelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty()) ||
(selectedValue.equalsIgnoreCase(Constant.RESULT_COUNT_DEFAULT))) {//then 5
+ portletConfig.put(new PropertySimple(Constant.RESULT_COUNT,
Constant.RESULT_COUNT_DEFAULT));
+ } else {
+ portletConfig.put(new PropertySimple(Constant.RESULT_COUNT,
selectedValue));
+ }
+
+ //alert time range filter. Check for enabled and then persist property.
Dealing with compound widget.
+ FormItem item =
measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
+ CheckboxItem itemC = (CheckboxItem) item;
+ selectedValue = String.valueOf(itemC.getValueAsBoolean());
+ if (!selectedValue.trim().isEmpty()) {//then call
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
selectedValue));
+ }
+
+ //alert time advanced time filter enabled.
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty()))
{
+ portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ }
+
+ //alert time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (begEnd.get(0) != 0) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
(begEnd.get(0) + "," + begEnd.get(1))));
+ }
+
+ //persist
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ loadData();
+ }
+ });
+ form.markForRedraw();
+ page.addMember(measurementRangeEditor);
+ page.addMember(form);
+ customSettings.addChild(page);
+ return customSettings;
+ }
+
+ @Override
+ public void startRefreshCycle() {
+ //current setting
+ final int refreshInterval =
UserSessionManager.getUserPreferences().getPageRefreshInterval();
+
+ //cancel any existing timer
+ if (refreshTimer != null) {
+ refreshTimer.cancel();
+ }
+
+ if (refreshInterval >= MeasurementUtility.MINUTES) {
+
+ refreshTimer = new Timer() {
+ public void run() {
+ if (!currentlyLoading) {
+ loadData();
+ redraw();
+ }
+ }
+ };
+
+ refreshTimer.scheduleRepeating(refreshInterval);
+ }
+ }
+
+ @Override
+ protected void onDestroy() {
+ if (refreshTimer != null) {
+
+ refreshTimer.cancel();
+ }
+ super.onDestroy();
+ }
+
+ @Override
+ public void redraw() {
+ super.redraw();
+ loadData();
+ }
+}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
index 53ba926..c79b9f9 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
@@ -36,14 +36,14 @@ 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.dashboard.portlets.PortletConfigurationEditorComponent;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet2;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
/**
* @author Simeon Pinder
*/
-public class ResourceAlertsPortlet extends GroupAlertsPortlet2 {
+public class ResourceAlertsPortlet extends GroupAlertsPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceAlerts";
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
index d819d8b..c57b591 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/summary/ActivityView2.java
@@ -45,7 +45,6 @@ import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardContainer;
import org.rhq.enterprise.gui.coregui.client.dashboard.DashboardView;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MessagePortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.DashboardGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
@@ -193,9 +192,9 @@ public class ActivityView2 extends LocatableVLayout implements
DashboardContaine
// dummyLeft.getConfiguration().put(new
PropertySimple("message", "<br/>Coming Soon... :-)"));
// dashboard.addPortlet(dummyLeft, 0, 0);
- DashboardPortlet groupAlerts = new DashboardPortlet(GroupAlertsPortlet.NAME,
GroupAlertsPortlet.KEY, 220);
+ // DashboardPortlet groupAlerts = new
DashboardPortlet(GroupAlertsPortlet3.NAME, GroupAlertsPortlet3.KEY, 220);
// groupAlerts.getConfiguration().put(new
PropertySimple("message", "<br/>Coming Soon... :-)"));
- dashboard.addPortlet(groupAlerts, 0, 0);
+ // dashboard.addPortlet(groupAlerts, 0, 0);
// right Column
DashboardPortlet dummyRight = new DashboardPortlet(MessagePortlet.NAME,
MessagePortlet.KEY, 220);
commit fc6850969088d587f4cf8faee4a7b7bc73ec7cdb
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Fri Mar 18 08:25:05 2011 -0400
i)fix problem with time range not reloading settings correctly
ii)enable duplicate portlets on dashboard.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
index 82be574..d8c69b8 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/AbstractMeasurementRangeEditor.java
@@ -48,9 +48,9 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
public abstract class AbstractMeasurementRangeEditor extends LocatableDynamicForm
implements TableWidget {
//keyed map of translated date units Ex. minutes,hours,days
- private static LinkedHashMap<String, String> lastUnits;
+ protected static LinkedHashMap<String, String> lastUnits;
//array of values available for displaying/selecting 'last N
hours|minutes|days'.
- private static String[] lastValues;
+ protected static String[] lastValues;
protected boolean advanced;
private ButtonItem advancedSimpleButton;
@@ -222,7 +222,7 @@ public abstract class AbstractMeasurementRangeEditor extends
LocatableDynamicFor
}
}
- private void update() {
+ protected void update() {
if (advanced) {
advancedSimpleButton.setTitle(MSG.view_measureRange_simple());
showItem("start");
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
index f4e9a0e..01794cb 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/measurement/CustomConfigMeasurementRangeEditor.java
@@ -19,6 +19,7 @@
package org.rhq.enterprise.gui.coregui.client.components.measurement;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.rhq.core.domain.configuration.Configuration;
@@ -59,6 +60,8 @@ public class CustomConfigMeasurementRangeEditor extends
AbstractMeasurementRange
} else {
int lastN = Integer.valueOf(simpleLastValuesItem.getValueAsString());
String unit = simpleLastUnitsItem.getValueAsString();
+ measurementPrefs.metricRangePreferences.lastN = lastN;
+ measurementPrefs.metricRangePreferences.unit = Integer.valueOf(unit);
return MeasurementUtility.calculateTimeFrame(lastN, Integer.valueOf(unit));
}
}
@@ -108,7 +111,11 @@ public class CustomConfigMeasurementRangeEditor extends
AbstractMeasurementRange
config.getSimple(PREF_METRIC_RANGE_BEGIN_END_FLAG).getStringValue()).booleanValue();
//check to display advanced settings widget components
if (metricRangePreferences.explicitBeginEnd == false) {
+ //retrieve lastN
metricRangePreferences.lastN =
config.getSimple(PREF_METRIC_RANGE_LASTN).getIntegerValue();
+ //retrieve lastN units
+ metricRangePreferences.unit =
config.getSimple(PREF_METRIC_RANGE_UNIT).getIntegerValue();
+
List<Long> range =
MeasurementUtility.calculateTimeFrame(metricRangePreferences.lastN,
metricRangePreferences.unit);
metricRangePreferences.begin = range.get(0);
@@ -170,10 +177,21 @@ public class CustomConfigMeasurementRangeEditor extends
AbstractMeasurementRange
enableRangeItem.setValue(false);
enableMeasurementRange(true);
}
- //AlertMetric rangeValues
- cp = measurementPrefs.configuration.getSimple(PREF_METRIC_RANGE);
- if ((cp != null) && (!cp.getStringValue().trim().isEmpty())) {
- String metricRange = cp.getStringValue();
+ //is advanced
+ boolean advanced = measurementPrefs.metricRangePreferences.explicitBeginEnd;
+ if (advanced) {
+ ArrayList<Long> beginEnd =
measurementPrefs.metricRangePreferences.getBeginEndTimes();
+ if ((beginEnd != null) && (!beginEnd.isEmpty())) {
+ advancedStartItem.setValue(beginEnd.get(0));
+ advancedEndItem.setValue(beginEnd.get(1));
+ }
+ } else {//simple: set LastN and Units
+ if
(lastUnits.containsKey(String.valueOf(measurementPrefs.metricRangePreferences.unit))) {
+
simpleLastUnitsItem.setValue(String.valueOf(measurementPrefs.metricRangePreferences.unit));
+ }
+ if
(Arrays.asList(lastValues).contains(String.valueOf(measurementPrefs.metricRangePreferences.lastN)))
{
+
simpleLastValuesItem.setValue(String.valueOf(measurementPrefs.metricRangePreferences.lastN));
+ }
}
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
index 384895d..25923ba 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java
@@ -244,12 +244,12 @@ public class DashboardView extends LocatableVLayout {
//if resourceGroup passed in then add additional portlets to list
if (this.focusGroup != null) {
HashMap<String, String> groupKeyNameMap =
PortletFactory.getRegisteredGroupPortletNameMap();
- //find current list of portlets already stored. Exclude them
- for (DashboardPortlet currentPortlet : storedDashboard.getPortlets()) {
- if (groupKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
- groupKeyNameMap.remove(currentPortlet.getPortletKey());
- }
- }
+ // //find current list of portlets already stored. Exclude them
+ // for (DashboardPortlet currentPortlet :
storedDashboard.getPortlets()) {
+ // if
(groupKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
+ //
groupKeyNameMap.remove(currentPortlet.getPortletKey());
+ // }
+ // }
//TODO: spinder 3/16/11: still need to be done.
//filter out portlets not relevent for group(compat|mixed) or facets
@@ -261,12 +261,12 @@ public class DashboardView extends LocatableVLayout {
//if resource passed in then add additional portlets to list
if (this.focusResource != null) {
HashMap<String, String> resourceKeyNameMap =
PortletFactory.getRegisteredResourcePortletNameMap();
- //find current list of portlets already stored. Exclude them
- for (DashboardPortlet currentPortlet : storedDashboard.getPortlets()) {
- if (resourceKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
- resourceKeyNameMap.remove(currentPortlet.getPortletKey());
- }
- }
+ // //find current list of portlets already stored. Exclude them
+ // for (DashboardPortlet currentPortlet :
storedDashboard.getPortlets()) {
+ // if
(resourceKeyNameMap.containsKey(currentPortlet.getPortletKey())) {
+ //
resourceKeyNameMap.remove(currentPortlet.getPortletKey());
+ // }
+ // }
for (String portletKey : resourceKeyNameMap.keySet()) {
nameKeyMap.put(resourceKeyNameMap.get(portletKey), portletKey);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index 072d82c..d840bcc 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -59,11 +59,10 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigura
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDataSource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryDetailsView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableCanvas;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
@@ -347,36 +346,17 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
*
* @author spinder
*/
-class GroupOperationsCriteriaHistoryListView extends AbstractOperationHistoryListView {
-
- private AbstractOperationHistoryDataSource datasource;
+class GroupOperationsCriteriaHistoryListView extends GroupOperationHistoryListView {
public GroupOperationsCriteriaHistoryListView(String locatorId,
AbstractOperationHistoryDataSource dataSource,
String title, Criteria criteria, ResourceGroupComposite composite) {
- super(locatorId, dataSource, title, criteria);
- this.datasource = dataSource;
- this.groupComposite = composite;
+ super(locatorId, composite);
+ setDataSource(dataSource);
setShowFooterRefresh(false); //disable footer refresh
}
- private ResourceGroupComposite groupComposite;
-
- @Override
- protected boolean hasControlPermission() {
- return this.groupComposite.getResourcePermission().isControl();
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- return new
GroupOperationHistoryDetailsView(extendLocatorId("DetailsView"),
this.groupComposite);
- }
-
- public AbstractOperationHistoryDataSource getDatasource() {
- return datasource;
- }
-
public void setDatasource(AbstractOperationHistoryDataSource datasource) {
- this.datasource = datasource;
+ setDataSource(datasource);
}
@Override
@@ -405,8 +385,10 @@ class GroupOperationsCriteriaDataSource extends
GroupOperationHistoryDataSource
@Override
protected void executeFetch(final DSRequest request, final DSResponse response) {
+ //initialize criteria
GroupOperationHistoryCriteria criteria = new GroupOperationHistoryCriteria();
+ //retrieve group identifier
if (request.getCriteria().getValues().containsKey(CriteriaField.GROUP_ID)) {
int groupId = Integer.parseInt((String)
request.getCriteria().getValues().get(CriteriaField.GROUP_ID));
criteria.addFilterResourceGroupIds(Arrays.asList(groupId));
@@ -431,12 +413,34 @@ class GroupOperationsCriteriaDataSource extends
GroupOperationHistoryDataSource
//result timeframe if enabled
property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
- property = portletConfig.getSimple(Constant.METRIC_RANGE);
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ property =
portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ String currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd =
MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
index 37b0052..f9fae66 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/summary/AbstractActivityView.java
@@ -524,15 +524,23 @@ public abstract class AbstractActivityView extends LocatableVLayout
implements R
}
//time advanced time filter enabled.
+ boolean isAdvanceTimeSetting = false;
selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
if ((selectedValue != null) && (!selectedValue.trim().isEmpty())) {
portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
}
//time frame
List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
- if (begEnd.get(0) != 0) {//advanced settings
+ if (isAdvanceTimeSetting) {//advanced settings
portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
(begEnd.get(0) + "," + begEnd.get(1))));
+ } else {
+ //save not advanced time range
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN,
measurementRangeEditor
+ .getMetricRangePreferences().lastN));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT,
measurementRangeEditor
+ .getMetricRangePreferences().unit));
}
}
return portletConfig;
commit f5920e31ffb0e47f5113679938029d1fe240279d
Author: Simeon Pinder <spinder(a)redhat.com>
Date: Thu Mar 17 16:46:35 2011 -0400
i)D12N problem with Group alerts portlet.
ii)Have GroupOperationsPortlet fill it's portlet.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
index 8ebfed5..39f2f52 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java
@@ -26,6 +26,7 @@ import com.smartgwt.client.rpc.RPCResponse;
import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
@@ -53,6 +54,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource
{
private Integer groupId = null;
private Integer[] resourceIds = null;
private String alertResourcesToUse;
+ private EntityContext entityContext;
public AlertPortletConfigurationDataSource() {
super();
@@ -65,6 +67,11 @@ public class AlertPortletConfigurationDataSource extends
AlertDataSource {
this.configuration = configuration;
this.groupId = groupId;
this.resourceIds = resourceIds;
+ if (groupId != null) {
+ entityContext = EntityContext.forGroup(groupId);
+ } else if ((resourceIds != null) && (resourceIds.length > 0)) {
+ entityContext = EntityContext.forResource(resourceIds[0]);
+ }
}
/** Override the executeFetch for AlertPortlet to allow specifying smaller than
total
@@ -155,9 +162,13 @@ public class AlertPortletConfigurationDataSource extends
AlertDataSource {
public void onSuccess(PageList<Alert> result) {
long fetchTime = System.currentTimeMillis() - start;
Log.info(result.size() + " alerts fetched in: " + fetchTime +
"ms");
- response.setData(buildRecords(result));
- response.setTotalRows(result.size());
- processResponse(request.getRequestId(), response);
+ if (entityContext.type != EntityContext.Type.Resource) {
+ dataRetrieved(result, response, request);
+ } else {
+ response.setData(buildRecords(result));
+ response.setTotalRows(result.size());
+ processResponse(request.getRequestId(), response);
+ }
}
});
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
index 0a7bc76..072d82c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupOperationsPortlet.java
@@ -190,8 +190,10 @@ public class GroupOperationsPortlet extends LocatableVLayout
implements CustomSe
protected void initializeUi() {
setPadding(5);
setMembersMargin(5);
- setHeight100();
+ setHeight("*");
setWidth100();
+ //tell canvas to fill it's component
+ recentOperationsContent.setHeight100();
addMember(recentOperationsContent);
markForRedraw();
}