[rhq] 2 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java | 5 ++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java | 2 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java | 5 +++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java | 3 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java | 3 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 6 +++---
6 files changed, 13 insertions(+), 11 deletions(-)
New commits:
commit 4ca57bc786e2ce8772dce7fd0981f9e618d6b67e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 16:09:31 2011 -0400
format more cols
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
index cde6b9e..a9c1dc7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourceDS.java
@@ -28,7 +28,6 @@ import java.util.Date;
import java.util.List;
import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
@@ -185,7 +184,7 @@ public class RecentlyAddedResourceDS extends DataSource {
setAttribute("id", id);
setAttribute("parentId", parentId);
setAttribute("name", recentlyAdded.getName());
- setAttribute("timestamp", DateTimeFormat.getMediumDateTimeFormat().format(dateAdded));
+ setAttribute("timestamp", dateAdded);
setIsFolder(recentlyAdded.getParentId() == 0);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
index e570a04..c4685da 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/imported/RecentlyAddedResourcesPortlet.java
@@ -38,6 +38,7 @@ import com.smartgwt.client.widgets.tree.TreeGrid;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.dashboard.DashboardPortlet;
import org.rhq.enterprise.gui.coregui.client.components.HeaderLabel;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
@@ -95,7 +96,7 @@ public class RecentlyAddedResourcesPortlet extends LocatableVLayout implements C
});
ListGridField timestampField = new ListGridField("timestamp", MSG.common_title_timestamp());
-
+ TimestampCellFormatter.prepareDateField(timestampField);
treeGrid.setFields(resourceNameField, timestampField);
if (!simple) {
commit 13609683074b17265180c9b704479989b2095d16
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 14:52:32 2011 -0400
quick fix some more columns and hovers
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
index b99ab75..42711b6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentListView.java
@@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deployment;
import java.util.HashMap;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.DateDisplayFormat;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
import com.smartgwt.client.widgets.events.DoubleClickHandler;
@@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.bundle.list.BundleVersionDataSource;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
/**
* @author Greg Hinkle
@@ -70,9 +70,8 @@ public class BundleDeploymentListView extends Table<BundleDeploymentDataSource>
.common_title_status());
ListGridField deployTimeField = new ListGridField(BundleDeploymentDataSource.FIELD_DEPLOY_TIME, MSG
.view_bundle_deploy_time());
-
+ TimestampCellFormatter.prepareDateField(deployTimeField);
deployTimeField.setType(ListGridFieldType.DATE);
- deployTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
// only users that are authorized can see deployments
if (canManageBundles) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
index f9dbe30..d1e5a74 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleResourceDeploymentHistoryListView.java
@@ -50,6 +50,7 @@ import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleResourceDeployment;
import org.rhq.core.domain.bundle.BundleResourceDeploymentHistory;
import org.rhq.enterprise.gui.coregui.client.ErrorMessageWindow;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -103,6 +104,7 @@ public class BundleResourceDeploymentHistoryListView extends LocatableVLayout {
user.setHidden(true);
ListGridField timestamp = new ListGridField("timestamp", MSG.common_title_timestamp());
+ TimestampCellFormatter.prepareDateField(timestamp);
timestamp.setWidth("40%");
ListGridField status = new ListGridField("status", MSG.common_title_status());
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
index e95626c..d3ca12c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/destination/BundleDestinationListView.java
@@ -25,7 +25,6 @@ package org.rhq.enterprise.gui.coregui.client.bundle.destination;
import java.util.HashMap;
import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.types.DateDisplayFormat;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.events.DoubleClickEvent;
import com.smartgwt.client.widgets.events.DoubleClickHandler;
@@ -38,6 +37,7 @@ import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
/**
* @author Greg Hinkle
@@ -74,7 +74,7 @@ public class BundleDestinationListView extends Table<BundleDestinationDataSource
BundleDestinationDataSource.FIELD_LATEST_DEPLOY_STATUS, MSG.view_bundle_dest_lastDeploymentStatus());
latestDeploymentDateField.setType(ListGridFieldType.DATE);
- latestDeploymentDateField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ TimestampCellFormatter.prepareDateField(latestDeploymentDateField);
nameField.setCellFormatter(new CellFormatter() {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
@@ -107,6 +107,7 @@ public class BundleDestinationListView extends Table<BundleDestinationDataSource
latestDeploymentStatusField.setValueIcons(statusIcons);
latestDeploymentStatusField.setValueIconHeight(11);
latestDeploymentStatusField.setValueIconWidth(11);
+ latestDeploymentStatusField.setShowValueIconOnly(true);
idField.setWidth(50);
nameField.setWidth("20%");
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index dd7d3f3..ba62aa4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
@@ -19,7 +19,6 @@
package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -40,6 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem;
import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGroupGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -199,11 +199,11 @@ public class GeneralProperties extends LocatableVLayout {
formItems.add(recursiveItem);
StaticTextItem createdItem = new StaticTextItem("created", MSG.common_title_dateCreated());
- createdItem.setValue(new Date(group.getCtime()));
+ createdItem.setValue(TimestampCellFormatter.format(group.getCtime()));
formItems.add(createdItem);
StaticTextItem lastModifiedItem = new StaticTextItem("lastModified", MSG.common_title_lastUpdated());
- lastModifiedItem.setValue(new Date(group.getMtime()));
+ lastModifiedItem.setValue(TimestampCellFormatter.format(group.getMtime()));
formItems.add(lastModifiedItem);
StaticTextItem lastModifiedByItem = new StaticTextItem("lastModifiedBy", MSG.common_title_lastUpdatedBy());
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js | 119 ----------
1 file changed, 119 deletions(-)
New commits:
commit b73e1a2fdeca8cf1d1e5739e79807fe1ba8afcf7
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Mar 30 15:53:27 2011 -0400
remove unused http://www.dyn-web.com/ javascript code (https://bugzilla.redhat.com/show_bug.cgi?id=536549)
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js b/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js
index ca82a55..c9e6b2e 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/js/popup.js
@@ -123,122 +123,3 @@ var overlay = {
WindowResizeTracker.addListener(function() {
overlay.refresh();
});
-
-/*************************************************************************
- This code is from Dynamic Web Coding at http://www.dyn-web.com/
- Copyright 2003 by Sharon Paine
- See Terms of Use at http://www.dyn-web.com/bus/terms.html
- regarding conditions under which you may use this code.
- This notice must be retained in the code as is!
-*************************************************************************/
-
-var viewport = {
- getWinWidth: function () {
- this.width = 0;
- if (window.innerWidth) this.width = window.innerWidth - 18;
- else if (document.documentElement && document.documentElement.clientWidth)
- this.width = document.documentElement.clientWidth;
- else if (document.body && document.body.clientWidth)
- this.width = document.body.clientWidth;
- },
-
- getWinHeight: function () {
- this.height = 0;
- if (window.innerHeight) this.height = window.innerHeight - 18;
- else if (document.documentElement && document.documentElement.clientHeight)
- this.height = document.documentElement.clientHeight;
- else if (document.body && document.body.clientHeight)
- this.height = document.body.clientHeight;
- },
-
- getScrollX: function () {
- this.scrollX = 0;
- if (typeof window.pageXOffset == "number") this.scrollX = window.pageXOffset
-;
- else if (document.documentElement && document.documentElement.scrollLeft)
- this.scrollX = document.documentElement.scrollLeft;
- else if (document.body && document.body.scrollLeft)
- this.scrollX = document.body.scrollLeft;
- else if (window.scrollX) this.scrollX = window.scrollX;
- },
-
- getScrollY: function () {
- this.scrollY = 0;
- if (typeof window.pageYOffset == "number") this.scrollY = window.pageYOffset
-;
- else if (document.documentElement && document.documentElement.scrollTop)
- this.scrollY = document.documentElement.scrollTop;
- else if (document.body && document.body.scrollTop)
- this.scrollY = document.body.scrollTop;
- else if (window.scrollY) this.scrollY = window.scrollY;
- },
-
- getAll: function () {
- this.getWinWidth(); this.getWinHeight();
- this.getScrollX(); this.getScrollY();
- }
-
-}
-
-var menuLayers = {
- timer: null,
- activeMenuID: null,
- offX: 3, // horizontal offset
- offY: 5, // vertical offset
-
- show: function(id, e) {
- var mnu = $? $(id): null;
- if (!mnu) return;
- this.activeMenuID = id;
- if ( mnu.onmouseout == null ) mnu.onmouseout = this.mouseoutCheck;
- if ( mnu.onmouseover == null ) mnu.onmouseover = this.clearTimer;
- viewport.getAll();
- this.position(mnu, e);
- },
-
- hide: function() {
- this.clearTimer();
- if (this.activeMenuID && $)
- this.timer = setTimeout("$('"+menuLayers.activeMenuID+"').style.visibility = 'hidden'", 200);
- },
-
- position: function(mnu, e) {
- var x = e.pageX? e.pageX: e.clientX + viewport.scrollX;
- var y = e.pageY? e.pageY: e.clientY + viewport.scrollY;
-
- if ( x + mnu.offsetWidth + this.offX > viewport.width + viewport.scrollX )
- x = x - mnu.offsetWidth - this.offX;
- else x = x + this.offX;
-
- if ( y + mnu.offsetHeight + this.offY >
- viewport.height + viewport.scrollY )
- y = ( y - mnu.offsetHeight - this.offY > viewport.scrollY )?
- y - mnu.offsetHeight - this.offY :
- viewport.height + viewport.scrollY - mnu.offsetHeight;
- else y = y + this.offY;
-
- this.timer = setTimeout("$('" + menuLayers.activeMenuID + "').style.visibility = 'visible'", 200);
- mnu.style.left = x + "px"; mnu.style.top = y + "px";
- },
-
- mouseoutCheck: function(e) {
- e = e? e: window.event;
- // is element moused into contained by menu? or is it menu (ul or li or a to menu div)?
- var mnu = $(menuLayers.activeMenuID);
- var toEl = e.relatedTarget? e.relatedTarget: e.toElement;
- if ( mnu != toEl && !menuLayers.contained(toEl, mnu) ) menuLayers.hide();
- },
-
- // returns true of oNode is contained by oCont (container)
- contained: function(oNode, oCont) {
- if (!oNode) return; // in case alt-tab away while hovering (prevent error)
- while ( oNode = oNode.parentNode )
- if ( oNode == oCont ) return true;
- return false;
- },
-
- clearTimer: function() {
- if (menuLayers.timer) clearTimeout(menuLayers.timer);
- }
-}
-
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java | 4 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 4 +---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
New commits:
commit f38951d435424a8e601ffbf7060ed01afb7b4fde
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 14:24:07 2011 -0400
normally don't need to pass in the attrib name explicitly since the name of the field is normally the same as the attrib name
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
index 3cf8695..f17c62f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
@@ -80,6 +80,10 @@ public class TimestampCellFormatter implements CellFormatter {
return (null == dateTimeFormat) ? DATE_TIME_FORMAT_MEDIUM.format(date) : dateTimeFormat.format(date);
}
+ public static void prepareDateField(final ListGridField field) {
+ prepareDateField(field, field.getName());
+ }
+
public static void prepareDateField(final ListGridField field, final String dateTimeAttributeName) {
field.setCellFormatter(new TimestampCellFormatter());
field.setShowHover(true);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
index 3980125..e4e62e8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
@@ -75,11 +75,9 @@ public class ResourceErrorsView extends Table<ResourceErrorsDataSource> {
ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG
.dataSource_resourceErrors_field_timeOccured());
timeField.setType(ListGridFieldType.DATE);
- timeField.setCellFormatter(new TimestampCellFormatter());
timeField.setAlign(Alignment.CENTER);
timeField.setWidth("20%");
- timeField.setShowHover(true);
- timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(Field.TIME_OCCURED));
+ TimestampCellFormatter.prepareDateField(timeField);
ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary());
summaryField.setAlign(Alignment.CENTER);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 6955700..31732c1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -131,7 +131,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
description = new TreeGridField("description");
status = new TreeGridField("statusLabel");
ctime = new TreeGridField("ctime");
- TimestampCellFormatter.prepareDateField(ctime, "ctime");
+ TimestampCellFormatter.prepareDateField(ctime);
if (!simple) {
treeGrid.setFields(name, key, type, description, status, ctime);
13 years, 1 month
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 16 ++++++----
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 1
2 files changed, 12 insertions(+), 5 deletions(-)
New commits:
commit e515acc7a0c083dd3969305d095f3a5274b6c8bd
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 30 14:17:21 2011 -0400
Protect against NPE and improve hover text.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index 9fde105..71a698a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -165,11 +165,17 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
statusField.setHoverCustomizer(new HoverCustomizer() {
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
String ackSubject = record.getAttribute("acknowledgingSubject");
- Date ackTime = record.getAttributeAsDate("acknowledgeTime");
- String ackTimeString = TimestampCellFormatter.format(ackTime,
- TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
- StringBuilder sb = new StringBuilder("<p style='width:500px'>");
- sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackTimeString));
+ StringBuilder sb = new StringBuilder("<p");
+ if (ackSubject == null) {
+ sb.append(" style='width:150px'>");
+ sb.append(MSG.view_alerts_field_ack_status_noAckHover());
+ } else {
+ sb.append(" style='width:500px'>");
+ Date ackTime = record.getAttributeAsDate("acknowledgeTime");
+ String ackTimeString = TimestampCellFormatter.format(ackTime,
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
+ sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackTimeString));
+ }
sb.append("</p>");
return sb.toString();
}
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 7bc3ea4..ae8ccbd 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
@@ -881,6 +881,7 @@ view_alerts_field_ack_time = Acknowledge Time
view_alerts_field_ack_subject = Acknowledge Subject
view_alerts_field_ack_status = Status
view_alerts_field_ack_status_noAck = No Ack
+view_alerts_field_ack_status_noAckHover = Not yet Acknowledged
view_alerts_field_ack_status_ack = Ack ({0})
view_alerts_field_ack_status_ackHover = Acknowledged by {0} at {1}
view_alerts_field_name = Name
13 years, 1 month
[rhq] 3 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java | 7 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 6 ++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 2 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/message/MessageCenterView.java | 5 ++++-
4 files changed, 17 insertions(+), 3 deletions(-)
New commits:
commit 4871543e3fd99c94efcb5b27f9039e25642244c3
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 14:17:01 2011 -0400
quick fix to ctime field
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
index 1c75bcc..3980125 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
@@ -22,7 +22,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.AutoFitWidthApproach;
-import com.smartgwt.client.types.DateDisplayFormat;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.SelectionStyle;
@@ -42,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource.Field;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -75,9 +75,11 @@ public class ResourceErrorsView extends Table<ResourceErrorsDataSource> {
ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG
.dataSource_resourceErrors_field_timeOccured());
timeField.setType(ListGridFieldType.DATE);
- timeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ timeField.setCellFormatter(new TimestampCellFormatter());
timeField.setAlign(Alignment.CENTER);
timeField.setWidth("20%");
+ timeField.setShowHover(true);
+ timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(Field.TIME_OCCURED));
ListGridField summaryField = new ListGridField(Field.SUMMARY, MSG.dataSource_resourceErrors_field_summary());
summaryField.setAlign(Alignment.CENTER);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index c2b3748..6955700 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -50,6 +50,7 @@ import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.TableUtility;
@@ -130,6 +131,7 @@ public class ResourceAutodiscoveryView extends LocatableVLayout {
description = new TreeGridField("description");
status = new TreeGridField("statusLabel");
ctime = new TreeGridField("ctime");
+ TimestampCellFormatter.prepareDateField(ctime, "ctime");
if (!simple) {
treeGrid.setFields(name, key, type, description, status, ctime);
commit e7ec5cfe2a6da8ea2a0487e256e284cb9d03b8a8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 14:13:20 2011 -0400
add a convienence method that prepares a list grid field as a data field, complete wiht a hover and a standard time format
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
index d8a86c7..3cf8695 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
@@ -5,6 +5,7 @@ import java.util.Date;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
/**
@@ -79,6 +80,12 @@ public class TimestampCellFormatter implements CellFormatter {
return (null == dateTimeFormat) ? DATE_TIME_FORMAT_MEDIUM.format(date) : dateTimeFormat.format(date);
}
+ public static void prepareDateField(final ListGridField field, final String dateTimeAttributeName) {
+ field.setCellFormatter(new TimestampCellFormatter());
+ field.setShowHover(true);
+ field.setHoverCustomizer(getHoverCustomizer(dateTimeAttributeName));
+ }
+
public static HoverCustomizer getHoverCustomizer(final String dateTimeAttributeName) {
return new HoverCustomizer() {
commit 874fd083a82b0b42a39f3d1b001fed2c55312ace
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 13:50:45 2011 -0400
fix message center time
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 b5907fd..f692f44 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
@@ -49,6 +49,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
@@ -182,6 +183,8 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
timeField.setType(ListGridFieldType.TIME);
timeField.setAttribute("displayFormat", TimeFormatter.TOPADDEDTIME);
timeField.setAlign(Alignment.LEFT);
+ timeField.setShowHover(true);
+ timeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(FIELD_TIME));
ListGridField messageField = new ListGridField(FIELD_CONCISEMESSAGE, MSG.common_title_message());
@@ -339,7 +342,7 @@ public class MessageCenterView extends Table implements MessageCenter.MessageLis
severity.setValue(message.severity.name());
StaticTextItem date = new StaticTextItem("time", MSG.view_messageCenter_messageTime());
- date.setValue(message.fired);
+ date.setValue(TimestampCellFormatter.format(message.fired, TimestampCellFormatter.DATE_TIME_FORMAT_FULL));
StaticTextItem detail = new StaticTextItem("detail", MSG.view_messageCenter_messageDetail());
detail.setTitleVAlign(VerticalAlignment.TOP);
13 years, 1 month
[rhq] modules/enterprise
by ips
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java | 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 371 +++++-----
2 files changed, 207 insertions(+), 180 deletions(-)
New commits:
commit e558e9be8dd60a5e4478dc183a8fa1ba2937a8b8
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Mar 30 13:54:12 2011 -0400
fix a bunch of group config editor bugs including https://bugzilla.redhat.com/show_bug.cgi?id=680229
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
index d991515..ac2d132 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/ConfigurationEditor.java
@@ -65,6 +65,8 @@ import com.smartgwt.client.widgets.form.fields.SpacerItem;
import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
+import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
@@ -713,7 +715,6 @@ public class ConfigurationEditor extends LocatableVLayout {
}
protected void firePropertyChangedEvent(Property property, PropertyDefinition propertyDefinition, boolean isValid) {
- boolean wasValidBefore = this.invalidPropertyNameToDisplayNameMap.isEmpty();
PropertyDefinition topLevelPropertyDefinition = getTopLevelPropertyDefinition(propertyDefinition);
boolean invalidPropertySetChanged;
if (isValid) {
@@ -1404,14 +1405,13 @@ public class ConfigurationEditor extends LocatableVLayout {
final PropertySimple propertySimple, final FormItem valueItem) {
FormItem item;
if (!propertyDefinitionSimple.isRequired()) {
- final CheckboxItem unsetItem = new CheckboxItem();
+ final CheckboxItem unsetItem = new CheckboxItem("unset-" + valueItem.getName());
boolean unset = isUnset(propertyDefinitionSimple, propertySimple);
unsetItem.setValue(unset);
unsetItem.setDisabled(isReadOnly(propertyDefinitionSimple, propertySimple));
unsetItem.setShowLabel(false);
unsetItem.setShowTitle(false);
unsetItem.setLabelAsTitle(false);
- unsetItem.setColSpan(1);
unsetItem.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent changeEvent) {
@@ -1429,6 +1429,14 @@ public class ConfigurationEditor extends LocatableVLayout {
}
});
+ valueItem.addBlurHandler(new BlurHandler() {
+ public void onBlur(BlurEvent event) {
+ boolean isUnset = (event.getItem().getValue() == null);
+ unsetItem.setValue(isUnset);
+ valueItem.disable();
+ }
+ });
+
item = unsetItem;
} else {
item = new SpacerItem();
@@ -1441,7 +1449,7 @@ public class ConfigurationEditor extends LocatableVLayout {
return (!propertyDefinition.isRequired() && (propertySimple == null || propertySimple.getStringValue() == null));
}
- private boolean isReadOnly(PropertyDefinition propertyDefinition, Property property) {
+ protected boolean isReadOnly(PropertyDefinition propertyDefinition, Property property) {
if (this.readOnly) {
return true;
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index eafbd15..c7b087c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -65,9 +65,11 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
* @author Ian Springer
*/
public class GroupConfigurationEditor extends ConfigurationEditor {
+
+ private static final String RHQ_STATIC_ITEM_NAME_ATTRIBUTE = "rhq:staticItemName";
+ private static final String RHQ_UNSET_ITEM_NAME_ATTRIBUTE = "rhq:unsetItemName";
+
private List<GroupMemberConfiguration> memberConfigurations;
- private Map<String, FormItem> valueItemNameToStaticItemMap = new HashMap<String, FormItem>();
- private Map<String, FormItem> valueItemNameToUnsetItemMap = new HashMap<String, FormItem>();
public GroupConfigurationEditor(String locatorId, ConfigurationDefinition configurationDefinition,
List<GroupMemberConfiguration> memberConfigurations) {
@@ -94,7 +96,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
if (isAggregateProperty(propertySimple)) {
// Create the "MEMBER VALUES DIFFER" label that is displayed when member values are heterogeneous.
- final StaticTextItem staticItem = new StaticTextItem();
+ final StaticTextItem staticItem = new StaticTextItem("static-" + propertySimple.getName());
staticItem.setValue(MSG.view_groupConfigEdit_valsDiff());
staticItem.setTextBoxStyle("InlineNote");
staticItem.setShowTitle(false);
@@ -106,7 +108,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
FormItemIcon icon = buildEditMemberValuesIcon(propertyDefinitionSimple, propertySimple, valueItem);
staticItem.setIcons(icon);
- this.valueItemNameToStaticItemMap.put(valueItem.getName(), staticItem);
+ valueItem.setAttribute(RHQ_STATIC_ITEM_NAME_ATTRIBUTE, staticItem.getName());
fields.add(3, staticItem);
}
@@ -147,7 +149,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
item.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent changedEvent) {
Object value = changedEvent.getValue();
- updateMemberProperties(propertyDefinitionSimple, propertySimple, value);
+ updateMemberProperties(propertySimple, value);
}
});
@@ -159,7 +161,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
}
private FormItemIcon buildEditMemberValuesIcon(final PropertyDefinitionSimple propertyDefinitionSimple,
- final PropertySimple propertySimple, final FormItem dynamicItem) {
+ final PropertySimple propertySimple, final FormItem dynamicItem) {
FormItemIcon icon = new FormItemIcon();
icon.setSrc(ImageManager.getEditIcon());
@@ -178,8 +180,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
return icon;
}
- private void updateMemberProperties(PropertyDefinitionSimple propertyDefinitionSimple,
- PropertySimple propertySimple, Object value) {
+ private void updateMemberProperties(PropertySimple propertySimple, Object value) {
for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) {
Configuration configuration = memberConfiguration.getConfiguration();
PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, propertySimple, null);
@@ -196,12 +197,13 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
unsetItem.setValue(false);
unsetItem.setDisabled(true);
}
- this.valueItemNameToUnsetItemMap.put(valueItem.getName(), unsetItem);
+ valueItem.setAttribute(RHQ_UNSET_ITEM_NAME_ATTRIBUTE, unsetItem.getName());
return unsetItem;
}
private void displayMemberValuesEditor(String locatorId, final PropertyDefinitionSimple propertyDefinitionSimple,
- final PropertySimple aggregatePropertySimple, Integer index, final FormItem aggregateValueItem) {
+ final PropertySimple aggregatePropertySimple, Integer index,
+ final FormItem aggregateValueItem) {
final Window popup = new Window();
popup.setTitle(MSG.view_groupConfigEdit_valsDiffForProp(propertyDefinitionSimple.getName()));
popup.setWidth(800);
@@ -215,101 +217,11 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
layout.setHeight100();
layout.setMargin(11);
- final DynamicForm setAllForm = new DynamicForm();
- setAllForm.setNumCols(4);
- setAllForm.setColWidths(175, 25, 200, 100);
- setAllForm.setCellPadding(5);
-
- List<FormItem> setAllItems = new ArrayList<FormItem>();
-
- // Header Row
- SpacerItem spacerItem = new SpacerItem();
- setAllItems.add(spacerItem);
-
- StaticTextItem unsetAllHeader = new StaticTextItem();
- unsetAllHeader.setShowTitle(false);
- if (!propertyDefinitionSimple.isRequired()) {
- unsetAllHeader.setDefaultValue("<h4>" + MSG.view_groupConfigEdit_unset() + "</h4>");
- }
- setAllItems.add(unsetAllHeader);
-
- StaticTextItem valueAllHeader = new StaticTextItem();
- valueAllHeader.setShowTitle(false);
- valueAllHeader.setDefaultValue("<h4>" + MSG.common_title_value() + "</h4>");
-
- setAllItems.add(valueAllHeader);
-
- spacerItem = new SpacerItem();
- //spacerItem.setEndRow(true);
- setAllItems.add(spacerItem);
-
- // Input Row
- StaticTextItem setAllValuesToItem = new StaticTextItem();
- setAllValuesToItem.setShowTitle(false);
- setAllValuesToItem.setDefaultValue("<b>" + MSG.view_groupConfigEdit_setAll() + "</b>");
- setAllValuesToItem.setAlign(Alignment.RIGHT);
- setAllItems.add(setAllValuesToItem);
-
- PropertySimple masterPropertySimple = new PropertySimple(propertyDefinitionSimple.getName(), null);
- final FormItem masterValueItem = super.buildSimpleField(propertyDefinitionSimple, masterPropertySimple);
- masterValueItem.setDisabled(false);
-
- FormItem masterUnsetItem = buildUnsetItem(propertyDefinitionSimple, masterPropertySimple, masterValueItem);
- if (masterUnsetItem instanceof CheckboxItem) {
- masterUnsetItem.setValue(false);
- }
-
- setAllItems.add(masterUnsetItem);
- setAllItems.add(masterValueItem);
-
- //ButtonItem applyButtonItem = new ButtonItem();
- //applyButtonItem.setTitle("Apply");
- //applyButtonItem.setEndRow(true);
- //setAllItems.add(applyButtonItem);
-
- // NOTE (ips, 10/27/10): Using a ButtonItem didn't work out, because SmartGWT would always display it in a new
- // table row, rather than in the next column in the current row (most likely a bug). So
- // we use an IButton wrapped in a CanvasItem instead.
- CanvasItem canvasItem = new CanvasItem();
- canvasItem.setShowTitle(false);
- HLayout buttonCanvas = new HLayout();
- buttonCanvas.setWidth(90);
- buttonCanvas.setHeight100();
- buttonCanvas.setAlign(Alignment.LEFT);
- final IButton applyButton = new LocatableIButton(layout.extendLocatorId("Apply"), MSG.common_button_apply());
- applyButton.setDisabled(true);
- buttonCanvas.addMember(applyButton);
- canvasItem.setCanvas(buttonCanvas);
- canvasItem.setEndRow(true);
- setAllItems.add(canvasItem);
-
- masterValueItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent changedEvent) {
- applyButton.enable();
- //applyButton.focus();
- }
- });
-
- masterUnsetItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent changedEvent) {
- applyButton.enable();
- applyButton.focus();
- }
- });
-
- setAllForm.setFields(setAllItems.toArray(new FormItem[setAllItems.size()]));
- layout.addMember(setAllForm);
-
- VLayout spacerLayout = new VLayout();
- spacerLayout.setHeight(20);
- layout.addMember(spacerLayout);
-
final DynamicForm membersForm = new DynamicForm();
membersForm.setHeight100();
membersForm.setNumCols(3);
membersForm.setColWidths("52%", "8%", "40%");
membersForm.setHiliteRequiredFields(true);
- layout.addMember(membersForm);
// Add header row.
List<FormItem> items = new ArrayList<FormItem>();
@@ -362,57 +274,72 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
valueItem.setDisabled(false);
}
+ // TODO: Anchor the button bar at the bottom of the modal window, so it's always visible.
+ HLayout buttonBar = new HLayout();
+ buttonBar.setAlign(Alignment.CENTER);
+ buttonBar.setMembersMargin(7);
+
final IButton okButton = new LocatableIButton(layout.extendLocatorId("OK"), MSG.common_button_ok());
- okButton.disable();
+ final boolean propertyIsReadOnly = isReadOnly(propertyDefinitionSimple, aggregatePropertySimple);
+ if (!propertyIsReadOnly) {
+ okButton.disable();
+ }
okButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
public void onClick(ClickEvent clickEvent) {
- boolean valuesHomogeneous = true;
- boolean isValid = true;
-
- Object firstValue = valueItems.get(0).getValue();
- for (FormItem valueItem : valueItems) {
- Object value = valueItem.getValue();
- if ((value != null && !value.equals(firstValue)) || (value == null && firstValue != null)) {
- valuesHomogeneous = false;
+ if (!propertyIsReadOnly) {
+ boolean valuesHomogeneous = true;
+ boolean isValid = true;
+
+ Object firstValue = valueItems.get(0).getValue();
+ for (FormItem valueItem : valueItems) {
+ Object value = valueItem.getValue();
+ if ((value != null && !value.equals(firstValue)) || (value == null && firstValue != null)) {
+ valuesHomogeneous = false;
+ }
+ isValid = isValid && valueItem.validate();
+ PropertySimple memberPropertySimple = valueItemNameToPropertySimpleMap.get(valueItem.getName());
+ memberPropertySimple.setValue(value);
+ memberPropertySimple.setErrorMessage(null);
}
- isValid = isValid && valueItem.validate();
- PropertySimple memberPropertySimple = valueItemNameToPropertySimpleMap.get(valueItem.getName());
- memberPropertySimple.setValue(value);
- memberPropertySimple.setErrorMessage(null);
- }
- FormItem aggregateStaticItem = valueItemNameToStaticItemMap.get(aggregateValueItem.getName());
+ String aggregateStaticItemName = aggregateValueItem.getAttribute(RHQ_STATIC_ITEM_NAME_ATTRIBUTE);
+ FormItem aggregateStaticItem = aggregateValueItem.getForm().getField(aggregateStaticItemName);
- FormItem aggregateUnsetItem = valueItemNameToUnsetItemMap.get(aggregateValueItem.getName());
- aggregateUnsetItem.setDisabled(!valuesHomogeneous);
+ String aggregateUnsetItemName = aggregateValueItem.getAttribute(RHQ_UNSET_ITEM_NAME_ATTRIBUTE);
+ FormItem aggregateUnsetItem = aggregateValueItem.getForm().getField(aggregateUnsetItemName);
+ aggregateUnsetItem.setDisabled(!valuesHomogeneous);
- if (valuesHomogeneous) {
- // Update the value of the aggregate property and set its override flag to true.
- aggregatePropertySimple.setValue(firstValue);
- aggregatePropertySimple.setOverride(true);
+ if (valuesHomogeneous) {
+ // Update the value of the aggregate property and set its override flag to true.
+ aggregatePropertySimple.setValue(firstValue);
+ aggregatePropertySimple.setOverride(true);
- aggregateUnsetItem.setValue(firstValue == null);
+ boolean isUnset = (firstValue == null);
+ aggregateUnsetItem.setValue(isUnset);
- // Set the aggregate value item's value to the homogeneous value, unhide it, and enable it.
- setValue(aggregateValueItem, firstValue);
- aggregateValueItem.show();
- aggregateValueItem.setDisabled(false);
+ // Set the aggregate value item's value to the homogeneous value, unhide it, and enable it
+ // unless it's unset.
+ setValue(aggregateValueItem, firstValue);
+ aggregateValueItem.show();
+ aggregateValueItem.setDisabled(isUnset);
- aggregateStaticItem.hide();
- } else {
- aggregatePropertySimple.setValue(null);
- aggregatePropertySimple.setOverride(false);
+ aggregateStaticItem.hide();
+ } else {
+ aggregatePropertySimple.setValue(null);
+ aggregatePropertySimple.setOverride(false);
- aggregateValueItem.hide();
+ aggregateValueItem.hide();
- aggregateStaticItem.show();
- }
+ aggregateStaticItem.show();
+ }
- firePropertyChangedEvent(aggregatePropertySimple, propertyDefinitionSimple, isValid);
+ firePropertyChangedEvent(aggregatePropertySimple, propertyDefinitionSimple, isValid);
+ }
popup.destroy();
}
});
+ buttonBar.addMember(okButton);
// Only enable the OK button if all properties are valid.
membersForm.addItemChangedHandler(new ItemChangedHandler() {
@@ -421,42 +348,130 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
}
});
- applyButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- @Override
- public void onClick(ClickEvent clickEvent) {
- Object value = masterValueItem.getValue();
- // Update the aggregate property.
- aggregatePropertySimple.setValue(value);
-
- // Update the member properties.
- for (FormItem valueItem : valueItems) {
- setValue(valueItem, value);
-
- FormItem unsetItem = valueItemNameToUnsetItemMap.get(valueItem.getName());
- if (unsetItem instanceof CheckboxItem) {
- unsetItem.setValue((value == null));
- valueItem.setDisabled((value == null));
- }
+ if (!propertyIsReadOnly) {
+ final DynamicForm setAllForm = new DynamicForm();
+ setAllForm.setNumCols(4);
+ setAllForm.setColWidths(175, 25, 200, 100);
+ setAllForm.setCellPadding(5);
- okButton.setDisabled(!membersForm.validate());
- }
+ List<FormItem> setAllItems = new ArrayList<FormItem>();
+
+ // Header Row
+ SpacerItem spacerItem = new SpacerItem();
+ setAllItems.add(spacerItem);
+
+ StaticTextItem unsetAllHeader = new StaticTextItem();
+ unsetAllHeader.setShowTitle(false);
+ if (!propertyDefinitionSimple.isRequired()) {
+ unsetAllHeader.setDefaultValue("<h4>" + MSG.view_groupConfigEdit_unset() + "</h4>");
}
- });
+ setAllItems.add(unsetAllHeader);
- final IButton cancelButton = new LocatableIButton(layout.extendLocatorId("Cancel"), MSG.common_button_cancel());
- cancelButton.focus();
- cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- popup.destroy();
+ StaticTextItem valueAllHeader = new StaticTextItem();
+ valueAllHeader.setShowTitle(false);
+ valueAllHeader.setDefaultValue("<h4>" + MSG.common_title_value() + "</h4>");
+
+ setAllItems.add(valueAllHeader);
+
+ spacerItem = new SpacerItem();
+ //spacerItem.setEndRow(true);
+ setAllItems.add(spacerItem);
+
+ // Input Row
+ StaticTextItem setAllValuesToItem = new StaticTextItem();
+ setAllValuesToItem.setShowTitle(false);
+ setAllValuesToItem.setDefaultValue("<b>" + MSG.view_groupConfigEdit_setAll() + "</b>");
+ setAllValuesToItem.setAlign(Alignment.RIGHT);
+ setAllItems.add(setAllValuesToItem);
+
+ PropertySimple masterPropertySimple = new PropertySimple(propertyDefinitionSimple.getName(), null);
+ final FormItem masterValueItem = super.buildSimpleField(propertyDefinitionSimple, masterPropertySimple);
+ masterValueItem.setName("master-" + masterValueItem.getName());
+ masterValueItem.setDisabled(false);
+
+ FormItem masterUnsetItem = buildUnsetItem(propertyDefinitionSimple, masterPropertySimple, masterValueItem);
+ if (masterUnsetItem instanceof CheckboxItem) {
+ masterUnsetItem.setValue(false);
}
- });
- // TODO: Anchor the button bar at the bottom of the modal window, so it's always visible.
- HLayout buttons = new HLayout();
- buttons.setAlign(Alignment.CENTER);
- buttons.setMembersMargin(7);
- buttons.setMembers(okButton, cancelButton);
- layout.addMember(buttons);
+ setAllItems.add(masterUnsetItem);
+ setAllItems.add(masterValueItem);
+
+ //ButtonItem applyButtonItem = new ButtonItem();
+ //applyButtonItem.setTitle("Apply");
+ //applyButtonItem.setEndRow(true);
+ //setAllItems.add(applyButtonItem);
+
+ // NOTE (ips, 10/27/10): Using a ButtonItem didn't work out, because SmartGWT would always display it in a new
+ // table row, rather than in the next column in the current row (most likely a bug). So
+ // we use an IButton wrapped in a CanvasItem instead.
+ CanvasItem canvasItem = new CanvasItem();
+ canvasItem.setShowTitle(false);
+ HLayout buttonCanvas = new HLayout();
+ buttonCanvas.setWidth(90);
+ buttonCanvas.setHeight100();
+ buttonCanvas.setAlign(Alignment.LEFT);
+ final IButton applyButton = new LocatableIButton(layout.extendLocatorId("Apply"), MSG.common_button_apply());
+ applyButton.setDisabled(true);
+
+ applyButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ @Override
+ public void onClick(ClickEvent clickEvent) {
+ Object value = masterValueItem.getValue();
+
+ // Update the member property value items.
+ for (FormItem valueItem : valueItems) {
+ setValue(valueItem, value);
+
+ String unsetItemName = valueItem.getAttribute(RHQ_UNSET_ITEM_NAME_ATTRIBUTE);
+ FormItem unsetItem = valueItem.getForm().getField(unsetItemName);
+ if (unsetItem instanceof CheckboxItem) {
+ unsetItem.setValue((value == null));
+ valueItem.setDisabled((value == null));
+ }
+
+ okButton.setDisabled(!membersForm.validate());
+ }
+ }
+ });
+
+ buttonCanvas.addMember(applyButton);
+ canvasItem.setCanvas(buttonCanvas);
+ canvasItem.setEndRow(true);
+ setAllItems.add(canvasItem);
+
+ masterValueItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent changedEvent) {
+ applyButton.enable();
+ }
+ });
+
+ masterUnsetItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent changedEvent) {
+ applyButton.enable();
+ applyButton.focus();
+ }
+ });
+
+ setAllForm.setFields(setAllItems.toArray(new FormItem[setAllItems.size()]));
+ layout.addMember(setAllForm);
+
+ VLayout spacerLayout = new VLayout();
+ spacerLayout.setHeight(20);
+ layout.addMember(spacerLayout);
+
+ final IButton cancelButton = new LocatableIButton(layout.extendLocatorId("Cancel"), MSG.common_button_cancel());
+ cancelButton.focus();
+ cancelButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ popup.destroy();
+ }
+ });
+ buttonBar.addMember(cancelButton);
+ }
+
+ layout.addMember(membersForm);
+ layout.addMember(buttonBar);
popup.addItem(layout);
popup.show();
@@ -472,16 +487,19 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
@Override
protected void updatePropertySimpleValue(Object value, PropertySimple propertySimple,
PropertyDefinitionSimple propertyDefinitionSimple) {
- // Update the aggregate property
- super.updatePropertySimpleValue(value, propertySimple, propertyDefinitionSimple);
- propertySimple.setOverride(true);
-
- // Update all the member properties.
- for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) {
- Configuration configuration = memberConfiguration.getConfiguration();
- PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, propertySimple, null);
- memberPropertySimple.setErrorMessage(null);
- memberPropertySimple.setValue(value);
+ if ((propertySimple.getConfiguration() != null) || (propertySimple.getParentMap() != null) ||
+ (propertySimple.getParentList() != null)) {
+ // Update the aggregate property.
+ super.updatePropertySimpleValue(value, propertySimple, propertyDefinitionSimple);
+ propertySimple.setOverride(true);
+
+ // Update all the member properties.
+ for (GroupMemberConfiguration memberConfiguration : this.memberConfigurations) {
+ Configuration configuration = memberConfiguration.getConfiguration();
+ PropertySimple memberPropertySimple = (PropertySimple) getProperty(configuration, propertySimple, null);
+ memberPropertySimple.setErrorMessage(null);
+ memberPropertySimple.setValue(value);
+ }
}
}
@@ -564,4 +582,5 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
Property topLevelProperty = getTopLevelProperty(property);
return topLevelProperty.getConfiguration();
}
+
}
13 years, 1 month
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 35 ++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 18 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java | 49 +++++++++-
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 17 +--
5 files changed, 98 insertions(+), 25 deletions(-)
New commits:
commit eca868ae89eed3a67cc0ea5fee4a7d0974a233a3
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 30 12:45:20 2011 -0400
AlertHistoryView fixes
- fix bad link for create time field to alert detail
- consolidate timestamp formats for the createTime and status columns,
shortening value but adding verbose hover.
- replace "Ack" with "Acknowledge" where width is not an issue.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index d9d1eda..9fde105 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -111,6 +111,8 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
ListGridField ctimeField = new ListGridField(AlertCriteria.SORT_FIELD_CTIME, MSG
.view_alerts_field_created_time());
ctimeField.setCellFormatter(new TimestampCellFormatter());
+ ctimeField.setShowHover(true);
+ ctimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(AlertCriteria.SORT_FIELD_CTIME));
fields.add(ctimeField);
ListGridField nameField = new ListGridField("name", MSG.view_alerts_field_name());
@@ -153,14 +155,25 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
String ackSubject = listGridRecord.getAttribute("acknowledgingSubject");
if (ackSubject == null) {
- return MSG.view_alerts_field_ack_status_empty();
+ return MSG.view_alerts_field_ack_status_noAck();
} else {
- Date ackTime = listGridRecord.getAttributeAsDate("acknowledgeTime");
- String formattedTime = TimestampCellFormatter.format(ackTime);
- return MSG.view_alerts_field_ack_status_filled(ackSubject, formattedTime);
+ return MSG.view_alerts_field_ack_status_ack(ackSubject);
}
}
});
+ statusField.setShowHover(true);
+ statusField.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String ackSubject = record.getAttribute("acknowledgingSubject");
+ Date ackTime = record.getAttributeAsDate("acknowledgeTime");
+ String ackTimeString = TimestampCellFormatter.format(ackTime,
+ TimestampCellFormatter.DATE_TIME_FORMAT_FULL);
+ StringBuilder sb = new StringBuilder("<p style='width:500px'>");
+ sb.append(MSG.view_alerts_field_ack_status_ackHover(ackSubject, ackTimeString));
+ sb.append("</p>");
+ return sb.toString();
+ }
+ });
fields.add(statusField);
if (this.entityContext.type != EntityContext.Type.Resource) {
@@ -184,17 +197,17 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
- ctimeField.setWidth(125);
- nameField.setWidth("20%");
- conditionField.setWidth("30%");
+ ctimeField.setWidth(100);
+ nameField.setWidth("15%");
+ conditionField.setWidth("35%");
priorityField.setWidth(50);
- statusField.setWidth("80");
+ statusField.setWidth(100);
resourceNameField.setWidth("25%");
ancestryField.setWidth("25%");
} else {
- ctimeField.setWidth(125);
- nameField.setWidth("35%");
- conditionField.setWidth("40%");
+ ctimeField.setWidth(200);
+ nameField.setWidth("15%");
+ conditionField.setWidth("60%");
priorityField.setWidth(50);
statusField.setWidth("25%");
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
index 49b2484..14cfc8a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDetailsView.java
@@ -161,7 +161,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi
if (record.getAttribute("acknowledgingSubject") != null) {
ackByItem.setValue(record.getAttribute("acknowledgingSubject"));
} else {
- ackByItem.setValue(MSG.view_alerts_field_ack_status_empty());
+ ackByItem.setValue(MSG.view_alerts_field_ack_status_noAck());
}
items.add(ackByItem);
@@ -170,7 +170,7 @@ public class AlertDetailsView extends LocatableVLayout implements BookmarkableVi
if (ack_time != null) {
ackTimeItem.setValue(TimestampCellFormatter.format(ack_time));
} else {
- ackTimeItem.setValue(MSG.view_alerts_field_ack_status_empty());
+ ackTimeItem.setValue(MSG.view_alerts_field_ack_status_noAck());
}
items.add(ackTimeItem);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index f5fd917..e321819 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -29,6 +29,7 @@ import com.smartgwt.client.types.MultipleAppearance;
import com.smartgwt.client.types.SortDirection;
import com.smartgwt.client.widgets.Canvas;
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.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -38,13 +39,17 @@ import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.AlertCriteria;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
* A view that displays a paginated table of fired {@link org.rhq.core.domain.alert.Alert alert}s, along with the
@@ -131,6 +136,19 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
return AlertCriteria.SORT_FIELD_CTIME;
}
+ @Override
+ protected CellFormatter getDetailsLinkColumnCellFormatter() {
+ return new CellFormatter() {
+ public String format(Object value, ListGridRecord record, int i, int i1) {
+ Integer resourceId = record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ Integer alertHistoryId = getId(record);
+ String url = LinkManager.getSubsystemAlertHistoryLink(resourceId, alertHistoryId);
+ String formattedValue = TimestampCellFormatter.format(value);
+ return SeleniumUtility.getLocatableHref(url, formattedValue, null);
+ }
+ };
+ }
+
protected void setupTableInteractions(final boolean hasWriteAccess) {
TableActionEnablement singleTargetEnablement = hasWriteAccess ? TableActionEnablement.ANY
: TableActionEnablement.NEVER;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
index b08c0ee..d8a86c7 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/TimestampCellFormatter.java
@@ -4,6 +4,7 @@ import java.util.Date;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
import com.smartgwt.client.widgets.grid.ListGridRecord;
/**
@@ -12,10 +13,36 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
* @author Ian Springer
*/
public class TimestampCellFormatter implements CellFormatter {
- public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getMediumDateTimeFormat();
+
+ public static final DateTimeFormat DATE_TIME_FORMAT_FULL = DateTimeFormat.getFullDateTimeFormat();
+ public static final DateTimeFormat DATE_TIME_FORMAT_LONG = DateTimeFormat.getLongDateTimeFormat();
+ public static final DateTimeFormat DATE_TIME_FORMAT_MEDIUM = DateTimeFormat.getMediumDateTimeFormat();
+ public static final DateTimeFormat DATE_TIME_FORMAT_SHORT = DateTimeFormat.getShortDateTimeFormat();
+
+ private DateTimeFormat dateTimeFormat;
+
+ /**
+ * Uses SHORT format.
+ */
+ public TimestampCellFormatter() {
+ this(DATE_TIME_FORMAT_MEDIUM);
+ }
+
+ public TimestampCellFormatter(DateTimeFormat dateTimeFormat) {
+ super();
+ this.dateTimeFormat = dateTimeFormat;
+ }
public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
- return format(value);
+ return format(value, dateTimeFormat);
+ }
+
+ /**
+ * @param value
+ * @return SHORT format for value
+ */
+ public static String format(Object value) {
+ return format(value, DATE_TIME_FORMAT_MEDIUM);
}
/**
@@ -24,10 +51,11 @@ public class TimestampCellFormatter implements CellFormatter {
* consistent across the app, whether the data is in a cell or not.
*
* @param value the date to format as a Date, Long, Integer or a String
+ * @param dateTimeFormat the format to use. If null defaults to SHORT format
*
* @return the formatted date string
*/
- public static String format(Object value) {
+ public static String format(Object value, DateTimeFormat dateTimeFormat) {
if (value == null) {
return "";
}
@@ -47,6 +75,19 @@ public class TimestampCellFormatter implements CellFormatter {
}
date = new Date(longValue);
}
- return DATE_TIME_FORMAT.format(date);
+
+ return (null == dateTimeFormat) ? DATE_TIME_FORMAT_MEDIUM.format(date) : dateTimeFormat.format(date);
+ }
+
+ public static HoverCustomizer getHoverCustomizer(final String dateTimeAttributeName) {
+ return new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ StringBuilder sb = new StringBuilder("<p style='width:300px'>");
+ sb.append(format(record.getAttributeAsDate(dateTimeAttributeName), DATE_TIME_FORMAT_FULL));
+ sb.append("</p>");
+ return sb.toString();
+ }
+ };
}
}
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 a965934..7bc3ea4 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
@@ -13,8 +13,8 @@ common_buildInfo_gwtVersion = ${gwt.version}
# Button Labels
#--------------
-common_button_ack = Ack
-common_button_ack_all = Ack All
+common_button_ack = Acknowlege
+common_button_ack_all = Acknowledge All
common_button_add = Add
common_button_advanced = Advanced...
common_button_apply = Apply
@@ -877,11 +877,12 @@ view_alerts_table_filter_priority = Priority Filter
view_alerts_field_created_time = Creation Time
view_alerts_field_modified_time = Modified Time
view_alerts_field_enabled = Enabled
-view_alerts_field_ack_time = Ack Time
-view_alerts_field_ack_subject = Ack Subject
+view_alerts_field_ack_time = Acknowledge Time
+view_alerts_field_ack_subject = Acknowledge Subject
view_alerts_field_ack_status = Status
-view_alerts_field_ack_status_empty = Not Acknowledged
-view_alerts_field_ack_status_filled = {0} acknowledged on {1}
+view_alerts_field_ack_status_noAck = No Ack
+view_alerts_field_ack_status_ack = Ack ({0})
+view_alerts_field_ack_status_ackHover = Acknowledged by {0} at {1}
view_alerts_field_name = Name
view_alerts_field_condition_text = Condition Text
view_alerts_field_condition_text_none = No Conditions
@@ -897,8 +898,8 @@ view_alerts_delete_confirm_all = Delete all alerts from this source?
view_alerts_delete_success = Successfully deleted {0} alerts
view_alerts_delete_failure = Failed to delete alerts with id''s: {0}
view_alerts_delete_failure_all = Failed to delete all alerts from this source
-view_alerts_ack_confirm = Ack the selected alert(s)?
-view_alerts_ack_confirm_all = Ack all alerts from this source?
+view_alerts_ack_confirm = Acknowledge the selected alert(s)?
+view_alerts_ack_confirm_all = Acknowledge all alerts from this source?
view_alerts_ack_success = Successfully acknowledged {0} alerts
view_alerts_ack_failure = Failed to acknowledge alerts with id''s: {0}
view_alerts_ack_failure_all = Failed to acknowledge all alerts from this source
13 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java | 15 +++++-----
1 file changed, 8 insertions(+), 7 deletions(-)
New commits:
commit fe0030c1b3965b1a45e6374e40de3e243ea9af74
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Mar 30 09:55:29 2011 -0400
fix selenium locator conflicts
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
index 36e2ff8..c84223e 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/tag/TaggedView.java
@@ -113,14 +113,15 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView {
Tab tab;
- BundlesListView bundlesView = new BundlesListView(getLocatorId(), criteria, null);
+ BundlesListView bundlesView = new BundlesListView(extendLocatorId("bundleListView"), criteria, null);
viewsWithTags.add(bundlesView);
tab = new LocatableTab(extendLocatorId("bundleList"), MSG.view_bundle_bundles());
tab.setIcon(ImageManager.getBundleIcon());
tab.setPane(bundlesView);
container.addTab(tab);
- BundleVersionListView bundleVersionListView = new BundleVersionListView(getLocatorId(), criteria);
+ BundleVersionListView bundleVersionListView = new BundleVersionListView(
+ extendLocatorId("bundleVersionListView"), criteria);
viewsWithTags.add(bundleVersionListView);
tab = new LocatableTab(extendLocatorId("bundleVersionList"), MSG.view_bundle_bundleVersions());
tab.setIcon("subsystems/bundle/BundleVersion_16.png");
@@ -128,23 +129,23 @@ public class TaggedView extends LocatableVLayout implements BookmarkableView {
container.addTab(tab);
// TODO: get manage_bundle perm, if user has it pass true
- BundleDeploymentListView bundleDeploymentListView = new BundleDeploymentListView(getLocatorId(), criteria,
- false);
+ BundleDeploymentListView bundleDeploymentListView = new BundleDeploymentListView(
+ extendLocatorId("bundleDeploymentListView"), criteria, false);
viewsWithTags.add(bundleDeploymentListView);
tab = new LocatableTab(extendLocatorId("bundleDeploymentsList"), MSG.view_bundle_bundleDeployments());
tab.setIcon("subsystems/bundle/BundleDeployment_16.png");
tab.setPane(bundleDeploymentListView);
container.addTab(tab);
- BundleDestinationListView bundleDestinationListView = new BundleDestinationListView(getLocatorId(),
- criteria);
+ BundleDestinationListView bundleDestinationListView = new BundleDestinationListView(
+ extendLocatorId("bundleDestinationListView"), criteria);
viewsWithTags.add(bundleDestinationListView);
tab = new LocatableTab(extendLocatorId("bundleDestinationsList"), MSG.view_bundle_bundleDestinations());
tab.setIcon("subsystems/bundle/BundleDestination_16.png");
tab.setPane(bundleDestinationListView);
container.addTab(tab);
- ResourceSearchView resourceView = new ResourceSearchView(getLocatorId(), criteria, MSG
+ ResourceSearchView resourceView = new ResourceSearchView(extendLocatorId("resourceView"), criteria, MSG
.view_taggedResources_title());
viewsWithTags.add(resourceView);
tab = new LocatableTab(extendLocatorId("resourceList"), MSG.view_taggedResources_title());
13 years, 1 month
[rhq] modules/enterprise
by Jay Shaughnessy
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java | 87 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java | 34
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletConfigurationDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java | 168 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet.java | 352 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java | 378 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java | 376 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java | 96 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 626 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java | 151 --
12 files changed, 520 insertions(+), 1775 deletions(-)
New commits:
commit ccbc787a51ecd53ab364e43046b8b4f49147c81d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Mar 30 09:27:30 2011 -0400
Fix several issues in Alerts Portlets
- refactor to share a common abstract base class to simplify the
concrete classes and conslidate fixes.
- Fixed issue causing retrieval of all alerts
- Fixed issue with ordering of alerts
- Fixed issues with button enablement (affected resource alert history view as well)
- Removed some obsolete classes
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
index 3e51b24..d9d1eda 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertDataSource.java
@@ -225,56 +225,61 @@ public class AlertDataSource extends RPCDataSource<Alert, AlertCriteria> {
long fetchTime = System.currentTimeMillis() - start;
Log.info(result.size() + " alerts fetched in: " + fetchTime + "ms");
- if (entityContext.type != EntityContext.Type.Resource) {
- dataRetrieved(result, response, request);
- } else {
- response.setData(buildRecords(result));
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
- processResponse(request.getRequestId(), response);
- }
+ dataRetrieved(result, response, request);
+ processResponse(request.getRequestId(), response);
}
});
}
/**
- * Additional processing to support a cross-resource view)
- * @param result
- * @param response
- * @param request
+ * Additional processing to support entity-specific or cross-resource views, and something that can be overidden.
*/
protected void dataRetrieved(final PageList<Alert> result, final DSResponse response, final DSRequest request) {
- HashSet<Integer> typesSet = new HashSet<Integer>();
- HashSet<String> ancestries = new HashSet<String>();
- for (Alert alert : result) {
- Resource resource = alert.getAlertDefinition().getResource();
- typesSet.add(resource.getResourceType().getId());
- ancestries.add(resource.getAncestry());
- }
-
- // In addition to the types of the result resources, get the types of their ancestry
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+ switch (entityContext.type) {
+
+ // no need to disambiguate, the alerts are for a singe resource
+ case Resource:
+ response.setData(buildRecords(result));
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize());
+ break;
+
+ // disambiguate as the results could be cross-resource
+ default:
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (Alert alert : result) {
+ Resource resource = alert.getAlertDefinition().getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
- ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
- typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
- AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
-
- Record[] records = buildRecords(result);
- for (Record record : records) {
- // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
- // Store the types map off the records so we can build a detailed hover string as needed.
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
-
- // Build the decoded ancestry Strings now for display
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ // In addition to the types of the result resources, get the types of their ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES, typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record
+ .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE, AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize());
}
- response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we have to specify size of full result set
- processResponse(request.getRequestId(), response);
- }
- });
+ });
+ }
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
index 98e4b34..f5fd917 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertHistoryView.java
@@ -67,18 +67,31 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
SortDirection.DESCENDING);
EntityContext context;
boolean hasWriteAccess;
+ AlertDataSource dataSource;
// for subsystem views
public AlertHistoryView(String locatorId) {
this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), EntityContext.forSubsystemView(), false);
}
+ public AlertHistoryView(String locatorId, EntityContext entityContext) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), entityContext, false);
+ }
+
protected AlertHistoryView(String locatorId, String tableTitle, EntityContext context, boolean hasWriteAccess) {
super(locatorId, tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
this.context = context;
this.hasWriteAccess = hasWriteAccess;
- setDataSource(new AlertDataSource(context));
+ setDataSource(getDataSource());
+ }
+
+ @Override
+ public AlertDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new AlertDataSource(context);
+ }
+ return this.dataSource;
}
@Override
@@ -128,28 +141,28 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
delete(selection);
}
});
+ addTableAction("AcknowledgeAlert", MSG.common_button_ack(), MSG.view_alerts_ack_confirm(),
+ new AbstractTableAction(singleTargetEnablement) {
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ acknowledge(selection);
+ }
+ });
addTableAction("DeleteAll", MSG.common_button_delete_all(), MSG.view_alerts_delete_confirm_all(),
new TableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
ListGrid grid = getListGrid();
- return (hasWriteAccess && grid != null && (getListGrid().getRecords().length >= 1));
+ return (hasWriteAccess && grid != null && !grid.getResultSet().isEmpty());
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
deleteAll();
}
});
- addTableAction("AcknowledgeAlert", MSG.common_button_ack(), MSG.view_alerts_ack_confirm(),
- new AbstractTableAction(singleTargetEnablement) {
- public void executeAction(ListGridRecord[] selection, Object actionValue) {
- acknowledge(selection);
- }
- });
addTableAction("AcknowledgeAll", MSG.common_button_ack_all(), MSG.view_alerts_ack_confirm_all(),
new TableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
ListGrid grid = getListGrid();
- return (hasWriteAccess && grid != null && (grid.getRecords().length >= 1));
+ return (hasWriteAccess && grid != null && !grid.getResultSet().isEmpty());
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -234,4 +247,7 @@ public class AlertHistoryView extends TableSection<AlertDataSource> {
return AlertDetailsView.getInstance();
}
+ public EntityContext getContext() {
+ return context;
+ }
}
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 2cb7f74..db1e4ef 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
@@ -41,7 +41,6 @@ import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
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.recent.alerts.RecentAlertsPortlet;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
/** Customize the AlertDataSource to pull fetch criteria information from
@@ -221,8 +220,7 @@ public class AlertPortletConfigurationDataSource extends AlertDataSource {
}
public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[] filterResourceIds) {
- PropertyList propertyList = storedPortlet.getConfiguration().getList(
- RecentAlertsPortlet.ALERT_RANGE_RESOURCE_IDS);
+ PropertyList propertyList = storedPortlet.getConfiguration().getList("alert-range-resource-ids");
if ((propertyList != null) && (propertyList.getList() != null) && (!propertyList.getList().isEmpty())
&& (propertyList.getList().get(0) != null)) {
Property container = propertyList.getList().get(0);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
deleted file mode 100644
index a2d0aba..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/AlertPortletDataSource.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.alert;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-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.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-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.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
-
-public class AlertPortletDataSource extends AlertDataSource {
- //configuration attributes
- private int alertRangeCompleted = -1;
- private int alertPriorityIndex = -1;
- private long alertTimeRange = -1;
- private String alertResourcesToUse = "all";
- private Integer[] alertFilterResourceIds = {};
- private DashboardPortlet portlet = null;
-
- public AlertPortletDataSource() {
- super();
- }
-
- public AlertPortletDataSource(DashboardPortlet recentAlertsPortlet) {
- super();
- this.portlet = recentAlertsPortlet;
- }
-
- @Override
- protected AlertCriteria getFetchCriteria(DSRequest request) {
- //retrieve previous settings from portlet config
- if ((portlet != null) && (this.portlet instanceof DashboardPortlet)) {
- //must check for whether portlet config
- PropertySimple property = portlet.getConfiguration().getSimple(
- RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- if (retrieved.trim().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED)) {
- setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_SELECTED);
- } else {
- setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL);
- }
- //if 'selected' then check for previously set resource ids to filter on
- if (getAlertResourcesToUse().equals(RecentAlertsPortlet.RESOURCES_SELECTED)) {
- Integer[] alertResourceFilterIds = null;
- alertResourceFilterIds = extractFilterResourceIds(portlet, alertResourceFilterIds);
- if (alertFilterResourceIds != null) {
- setAlertFilterResourceId(alertFilterResourceIds);
- }
- }
- } else {//create setting
- portlet.getConfiguration().put(
- new PropertySimple(RecentAlertsPortlet.ALERT_RANGE_RESOURCES_VALUE,
- RecentAlertsPortlet.defaultResourceValue));
- setAlertResourcesToUse(RecentAlertsPortlet.RESOURCES_ALL);
- }
- }
-
- AlertCriteria criteria = new AlertCriteria();
- criteria.fetchAlertDefinition(true);
- criteria.fetchRecoveryAlertDefinition(true);
- // TODO: Uncomment the below once the bad performance of it has been fixed.
- //criteria.fetchConditionLogs(true);
- PageControl pc = new PageControl(0, getAlertRangeCompleted());
- criteria.setPageControl(pc);//display per page
- criteria.addFilterStartTime(getAlertTimeRange());//alert age
- if ((getAlertResourcesToUse().equalsIgnoreCase(RecentAlertsPortlet.RESOURCES_SELECTED))
- && (getAlertFilterResourceIds().length > 0)) {
- //add resource ids to filter on
- criteria.addFilterResourceIds(getAlertFilterResourceIds());
- }
- if (getAlertPriorityIndex() > 0) {//add priority selection
- criteria.addFilterPriorities(AlertPriority.getByLegacyIndex(getAlertPriorityIndex()));
- }
-
- return criteria;
- }
-
- /** Override the executeFetch for AlertPortlet to allow specifying smaller than total
- * result displays.
- */
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response, final AlertCriteria criteria) {
- getAlertService().findAlertsByCriteria(criteria, new AsyncCallback<PageList<Alert>>() {
-
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_alerts_loadFailed(), caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<Alert> result) {
- dataRetrieved(result, response, request);
- }
- });
- }
-
- public int getAlertRangeCompleted() {
- return alertRangeCompleted;
- }
-
- public void setAlertRangeCompleted(int alertRangeCompleted) {
- this.alertRangeCompleted = alertRangeCompleted;
- }
-
- public int getAlertPriorityIndex() {
- return alertPriorityIndex;
- }
-
- public void setAlertPriorityIndex(int alertPriorityIndex) {
- this.alertPriorityIndex = alertPriorityIndex;
- }
-
- public long getAlertTimeRange() {
- return alertTimeRange;
- }
-
- public void setAlertTimeRange(long alertTimeRange) {
- this.alertTimeRange = alertTimeRange;
- }
-
- public String getAlertResourcesToUse() {
- return alertResourcesToUse;
- }
-
- public void setAlertResourcesToUse(String resourcesToUse) {
- this.alertResourcesToUse = resourcesToUse;
- }
-
- public Integer[] getAlertFilterResourceIds() {
- return alertFilterResourceIds;
- }
-
- public void setAlertFilterResourceId(Integer[] alertFilterResourceId) {
- this.alertFilterResourceIds = alertFilterResourceId;
- }
-
- public Integer[] extractFilterResourceIds(DashboardPortlet storedPortlet, Integer[] filterResourceIds) {
- PropertyList propertyList = storedPortlet.getConfiguration().getList(
- RecentAlertsPortlet.ALERT_RANGE_RESOURCE_IDS);
- if ((propertyList != null) && (propertyList.getList() != null) && (!propertyList.getList().isEmpty())
- && (propertyList.getList().get(0) != null)) {
- Property container = propertyList.getList().get(0);
- if (container instanceof PropertyList) {
- PropertyList anotherList = (PropertyList) container;
- if (anotherList.getList() != null) {
- filterResourceIds = new Integer[anotherList.getList().size()];
- int index = 0;
- for (Property p : anotherList.getList()) {
- filterResourceIds[index++] = ((PropertySimple) p).getIntegerValue();
- }
- }
- }
- }
- return filterResourceIds;
- }
-
-}
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 4c19ac1..ba91415 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
@@ -889,4 +889,13 @@ public class DashboardView extends LocatableVLayout {
public Dashboard getStoredDashboard() {
return storedDashboard;
}
+
+ public ResourceGroupComposite getGroupComposite() {
+ return groupComposite;
+ }
+
+ public ResourceComposite getResourceComposite() {
+ return resourceComposite;
+ }
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
index 75710a8..e8d51d1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletWindow.java
@@ -41,6 +41,7 @@ import com.smartgwt.client.widgets.events.MouseOverHandler;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHeaderControl;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
@@ -246,4 +247,17 @@ public class PortletWindow extends LocatableWindow {
return dashboardView.getGlobalPermissions();
}
+ public ResourcePermission getResourcePermissions() {
+
+ ResourcePermission result = null;
+
+ if (null != dashboardView.getResourceComposite()) {
+ result = dashboardView.getResourceComposite().getResourcePermission();
+ } else if (null != dashboardView.getGroupComposite()) {
+ result = dashboardView.getGroupComposite().getResourcePermission();
+ }
+
+ return result;
+ }
+
}
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 6ac9afe..337989b 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,363 +18,63 @@
*/
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.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.AutoRefreshPortletUtil;
-import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.core.domain.common.EntityContext;
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.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.AbstractRecentAlertsPortlet;
/**
+ * @author Jay Shaughnessy
* @author Simeon Pinder
*/
-public class GroupAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
+public class GroupAlertsPortlet extends AbstractRecentAlertsPortlet {
// 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";
- private boolean currentlyRefreshing = false;
-
- // 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, int groupId) {
- public GroupAlertsPortlet(String locatorId) {
- super(locatorId);
+ // Since the group id is only used for filtering I don't think it matters whether this is a
+ // standard group, autogroup, or autocluster, but if so, we'll have to provide more specific
+ // contexts and more specific context handling.
+ super(locatorId, EntityContext.forGroup(groupId));
- //override the shared datasource
- //figure out which page we're loading
- String currentPage = History.getToken();
- //get groupId
- int groupId = AbstractActivityView.groupIdLookup(currentPage);
this.groupId = groupId;
-
- 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) {
- //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 int getResourceId() {
+ return groupId;
}
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ /* (non-Javadoc)
+ * TODO: This factory ASSUMES the user is currently navigated to a group detail view, and generates a portlet
+ * for that group. It will fail in other scenarios. This mechanism should be improved such that the
+ * factory method can take an EntityContext explicitly indicating, in this case, the group.
+ * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String)
+ */
public final Portlet getInstance(String locatorId) {
- return new GroupAlertsPortlet(locatorId);
- }
- }
-
- public void startRefreshCycle() {
- refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
- }
-
- @Override
- protected void onDestroy() {
- AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
-
- super.onDestroy();
- }
-
- public boolean isRefreshing() {
- return this.currentlyRefreshing;
- }
-
- @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));
- }
+ String currentPage = History.getToken();
+ int groupId = -1;
+ String[] elements = currentPage.split("/");
+ // process for groups and auto groups Ex. ResourceGroup/10111 or ResourceGroup/AutoCluster/10321
+ try {
+ groupId = Integer.valueOf(elements[1]);
+ } catch (NumberFormatException nfe) {
+ groupId = Integer.valueOf(elements[2]);
}
- });
- }
-
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
- }
-
- @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)));
- }
- }
-
- @Override
- public void redraw() {
- super.redraw();
- refresh();//is table so need to call this to reload
- }
-}
-
-/** 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 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 new GroupAlertsPortlet(locatorId, groupId);
}
- 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
deleted file mode 100644
index 2a2b3ac..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/groups/GroupAlertsPortlet3.java
+++ /dev/null
@@ -1,378 +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.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.components.measurement.CustomConfigMeasurementRangeEditor;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
-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.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;
- }
-
- public void startRefreshCycle() {
- refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
- }
-
- @Override
- protected void onDestroy() {
- AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
-
- super.onDestroy();
- }
-
- public boolean isRefreshing() {
- return this.currentlyLoading;
- }
-
- @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/recent/alerts/AbstractRecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
new file mode 100644
index 0000000..013e5be
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/AbstractRecentAlertsPortlet.java
@@ -0,0 +1,376 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.types.Overflow;
+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.SelectItem;
+
+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.common.EntityContext;
+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.resource.composite.ResourcePermission;
+import org.rhq.core.domain.util.OrderingField;
+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.alert.AlertDataSource;
+import org.rhq.enterprise.gui.coregui.client.alert.AlertHistoryView;
+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.AutoRefreshPortletUtil;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+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.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A base class for deriving recent alerts portlets for different entity contexts. In this way the
+ * basic plumbing is shared, giving a consistent behavior and configuration for the concrete portlets.
+ *
+ * @author Jay Shaughnessy
+ * @author Simeon Pinder
+ */
+public abstract class AbstractRecentAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet,
+ AutoRefreshPortlet {
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ private AlertsPortletDataSource dataSource;
+
+ // autorefresh timer
+ private Timer refreshTimer;
+
+ public AbstractRecentAlertsPortlet(String locatorId, EntityContext entityContext) {
+ super(locatorId, entityContext);
+
+ setShowFilterForm(false); //disable filter form for portlet
+ setOverflow(Overflow.VISIBLE);
+ }
+
+ public Timer getRefreshTimer() {
+ return refreshTimer;
+ }
+
+ public void setRefreshTimer(Timer refreshTimer) {
+ this.refreshTimer = refreshTimer;
+ }
+
+ public PortletWindow getPortletWindow() {
+ return portletWindow;
+ }
+
+ @Override
+ public AlertsPortletDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new AlertsPortletDataSource(getContext());
+ }
+ return this.dataSource;
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ // the portletWindow does not change, so we can hold onto it locally
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ // if there is no configuration there is nothing to set
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ Configuration config = storedPortlet.getConfiguration();
+
+ // not sure I love the fact that this common portlet config assigns some irrelevant/unused config props,
+ // may be better to prune the common set and add the specific properties locally in this method
+ for (String key : PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (config.getSimple(key) == null) {
+ config.put(new PropertySimple(key, PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION
+ .get(key)));
+ }
+ }
+
+ getDataSource().setConfiguration(config);
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+
+ LocatableDynamicForm customSettingsForm = new LocatableDynamicForm(extendLocatorId("CustomSettings"));
+ LocatableVLayout page = new LocatableVLayout(customSettingsForm.extendLocatorId("Page"));
+ LocatableDynamicForm filterForm = new LocatableDynamicForm(page.extendLocatorId("Filter"));
+ filterForm.setMargin(5);
+
+ final DashboardPortlet storedPortlet = this.portletWindow.getStoredPortlet();
+ final Configuration portletConfig = storedPortlet.getConfiguration();
+
+ // alert priority selector
+ final SelectItem alertPrioritySelector = PortletConfigurationEditorComponent
+ .getAlertPriorityEditor(portletConfig);
+
+ // result count selector
+ final SelectItem resultCountSelector = PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ // range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor = PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ filterForm.setItems(alertPrioritySelector, resultCountSelector);
+
+ //submit handler
+ customSettingsForm.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ // alert severity
+ String selectedValue = alertPrioritySelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty())
+ || (selectedValue.split(",").length == AlertPriority.values().length)) {
+ // no severity filter
+ selectedValue = Constant.ALERT_PRIORITY_DEFAULT;
+ }
+ portletConfig.put(new PropertySimple(Constant.ALERT_PRIORITY, selectedValue));
+
+ // result count
+ selectedValue = resultCountSelector.getValue().toString();
+ if (selectedValue.trim().isEmpty()) {
+ selectedValue = Constant.RESULT_COUNT_DEFAULT;
+ }
+ portletConfig.put(new PropertySimple(Constant.RESULT_COUNT, selectedValue));
+
+ // time range settings
+ saveMeasurementRangeEditorSettings(measurementRangeEditor, portletConfig);
+
+ // persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ }
+ });
+
+ page.addMember(measurementRangeEditor);
+ page.addMember(filterForm);
+ customSettingsForm.addChild(page);
+
+ return customSettingsForm;
+ }
+
+ /**
+ * Takes the current value of the widget and persists it into the configuration object passed in.
+ *
+ * @param measurementRangeEditor
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ private void saveMeasurementRangeEditorSettings(final CustomConfigMeasurementRangeEditor measurementRangeEditor,
+ Configuration portletConfig) {
+ String selectedValue = null;
+ if ((measurementRangeEditor != null) && (portletConfig != null)) {
+ //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;
+ 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)))));
+ }
+ }
+ }
+
+ @Override
+ protected void setupTableInteractions(boolean hasWriteAccess) {
+ if (!hasWriteAccess) {
+ Set<Permission> globalPerm = this.getPortletWindow().getGlobalPermissions();
+ ResourcePermission resPerm = this.getPortletWindow().getResourcePermissions();
+ hasWriteAccess = (globalPerm.contains(Permission.MANAGE_INVENTORY) || (null != resPerm && resPerm.isAlert()));
+ }
+ super.setupTableInteractions(hasWriteAccess);
+ }
+
+ public void startRefreshCycle() {
+ refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
+ }
+
+ public boolean isRefreshing() {
+ // TODO: actually keep track of when the portlet is refreshing data
+ return false;
+ }
+
+ @Override
+ protected void onDestroy() {
+ AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
+
+ super.onDestroy();
+ }
+
+ static public class AlertsPortletDataSource extends AlertDataSource {
+ private Configuration configuration;
+
+ public AlertsPortletDataSource(EntityContext entityContext) {
+ this(entityContext, null);
+ }
+
+ public AlertsPortletDataSource(EntityContext entityContext, Configuration configuration) {
+ super(entityContext);
+ this.configuration = configuration;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /* (non-Javadoc)
+ * This override allows us to set the total rows to the number of recent alerts configured for
+ * the portlet. This sets the counter appropriately and stops further queries to the server.
+ *
+ * @see org.rhq.enterprise.gui.coregui.client.alert.AlertDataSource#dataRetrieved(org.rhq.core.domain.util.PageList, com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest)
+ */
+ @Override
+ protected void dataRetrieved(PageList<Alert> result, DSResponse response, DSRequest request) {
+ super.dataRetrieved(result, response, request);
+
+ response.setTotalRows(result.size());
+ }
+
+ @Override
+ protected AlertCriteria getFetchCriteria(DSRequest request) {
+ AlertCriteria criteria = new AlertCriteria();
+
+ // result count
+ String currentSetting = this.configuration.getSimpleValue(Constant.RESULT_COUNT,
+ Constant.RESULT_COUNT_DEFAULT);
+
+ // We have to set a PageControl override here, or RPCDataSource will apply default paging based on the
+ // request. But, once setting a paging override the CriteriaQueryGenerator will use it for
+ // paging *and* sorting, so we need to also ensure our desired sorting is included in the override. So,
+ // to get the most recent alerts, apply a descending ordering on create time.
+ int pageNumber = 0;
+ int pageSize = Integer.valueOf(currentSetting);
+ OrderingField orderingField = new OrderingField("ctime", PageOrdering.DESC);
+ criteria.setPageControl(new PageControl(pageNumber, pageSize, orderingField));
+
+ // filter priority
+ currentSetting = this.configuration
+ .getSimpleValue(Constant.ALERT_PRIORITY, Constant.ALERT_PRIORITY_DEFAULT);
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (!(currentSetting.trim().isEmpty() || parsedValues.length == 3)) {
+ AlertPriority[] filterPriorities = new AlertPriority[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ AlertPriority p = AlertPriority.valueOf(priority);
+ filterPriorities[indx++] = p;
+ }
+ criteria.addFilterPriorities(filterPriorities);
+ }
+
+ //result timeframe if enabled
+ currentSetting = this.configuration.getSimpleValue(Constant.METRIC_RANGE_ENABLE, null);
+ if (Boolean.valueOf(currentSetting)) {//then proceed setting
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ PropertySimple property = this.configuration.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ if (property != null) {
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = this.configuration.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property = this.configuration.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property = this.configuration.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)));
+ }
+ }
+ }
+
+ // add any context related filters
+ switch (getEntityContext().type) {
+ case Resource:
+ criteria.addFilterResourceIds(getEntityContext().getResourceId());
+ break;
+
+ case ResourceGroup:
+ criteria.addFilterResourceGroupIds(getEntityContext().getGroupId());
+ }
+
+ criteria.fetchAlertDefinition(true);
+ criteria.fetchRecoveryAlertDefinition(true);
+
+ return criteria;
+ }
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java
deleted file mode 100644
index dae36c2..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java
+++ /dev/null
@@ -1,96 +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, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * 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 and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.RecordList;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDatasource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector;
-
-/**
- * @author Simeon Pinder
- */
-public class PortletAlertSelector extends ResourceSelector {
-
- public PortletAlertSelector(String locatorId, Integer[] currentlyAssignedIds, ResourceType resourceTypeFilter,
- boolean forceResourceTypeFilter) {
- super(locatorId, resourceTypeFilter, forceResourceTypeFilter);
-
- //populate fields for grid.
- ListGridField nameField = new ListGridField("name", MSG.common_title_name());
- ListGridField iconField = new ListGridField("icon", MSG.common_title_icon(), 50);
- iconField.setType(ListGridFieldType.ICON);
- assignedGrid.setFields(iconField, nameField);
-
- setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH);
-
- //retrieve the previously assigned resource ids
- if ((currentlyAssignedIds != null) && currentlyAssignedIds.length > 0) {
- //build listgrid records
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterIds(currentlyAssignedIds);
-
- GWTServiceLookup.getResourceService().findResourcesByCriteria(criteria,
- new AsyncCallback<PageList<Resource>>() {
- @Override
- public void onSuccess(PageList<Resource> result) {
- if (result.size() > 0) {
- ListGridRecord[] data = (new ResourceDatasource()).buildRecords(result);
- assignedGrid.setData(data);
- }
- }
-
- @Override
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_portlet_recentAlerts_fail_msg(), caught);
- }
- });
- }
- }
-
- public Integer[] getAssignedListGridValues() {
- Integer[] listGridValues = new Integer[0];
- if ((null != assignedGrid)) {
- RecordList allRecords = assignedGrid.getDataAsRecordList();
- if (allRecords.getLength() > 0) {
- listGridValues = new Integer[allRecords.getLength()];
- for (int i = 0; i < allRecords.getLength(); i++) {
- Record record = allRecords.get(i);
- listGridValues[i] = record.getAttributeAsInt(RecentAlertsPortlet.ID);
- }
- }
- }
- return listGridValues;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
index fed9070..51e12b6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java
@@ -18,542 +18,22 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
-import java.util.Set;
-
-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.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.core.domain.alert.AlertPriority;
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.core.domain.configuration.PropertyList;
-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.alert.AlertHistoryView;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletDataSource;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
-import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.core.domain.common.EntityContext;
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.util.MeasurementUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/**
- * @author Simeon Pinder
- * @author Greg Hinkle
+ * @author Jay Shaughnessy
*/
-public class RecentAlertsPortlet extends AlertHistoryView implements CustomSettingsPortlet, AutoRefreshPortlet {
+public class RecentAlertsPortlet extends AbstractRecentAlertsPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "RecentAlerts";
// A default displayed, persisted name for the portlet
public static final String NAME = MSG.view_portlet_defaultName_recentAlerts();
- //widget keys also used in form population
- public static final String ALERT_RANGE_DISPLAY_AMOUNT_VALUE = "alert-range-display-amount-value";
- public static final String ALERT_RANGE_PRIORITY_VALUE = "alert-range-priority-value";
- public static final String ALERT_RANGE_TIME_VALUE = "alert-range-time-value";
- public static final String ALERT_RANGE_RESOURCES_VALUE = "alert-range-resource-value";
- public static final String ALERT_RANGE_RESOURCE_IDS = "alert-range-resource-ids";
- //configuration default information
- private static final String defaultAlertCountValue = "5";
- private static final String PRIORITY_ALL = MSG.common_label_all();
- private static final String PRIORITY_HIGH = AlertPriority.HIGH.getDisplayName();
- private static final String PRIORITY_MEDIUM = AlertPriority.MEDIUM.getDisplayName();
- private static final String PRIORITY_LOW = AlertPriority.LOW.getDisplayName();
- private static final String defaultPriorityValue = PRIORITY_ALL;
- private static final String TIME_30_MINS = "30 " + MSG.common_label_minutes();
- private static final String TIME_HOUR = MSG.common_label_hour();
- private static final String TIME_12_HRS = "12 " + MSG.common_label_hours();
- private static final String TIME_DAY = MSG.common_label_day();
- private static final String TIME_WEEK = MSG.common_label_week();
- private static final String TIME_MONTH = MSG.common_label_month();
- private static final String defaultTimeValue = TIME_DAY;
- 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;
- private static final String unlimited = MSG.common_label_unlimited();
- //alert resource labels
- public static final String ALERT_LABEL_SELECTED_RESOURCES = MSG.common_title_selected_resources();
- public static final String ALERT_LABEL_AVAILABLE_RESOURCES = MSG.common_title_available_resources();
- public static final String ALERT_LABEL_RESOURCE_INVENTORY = MSG.common_title_resource_inventory();
- public static final int ALERT_RESOURCE_SELECTION_WIDTH = 800;
- public static final String ID = "id";
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
-
- //shared private UI elements
- private AlertResourceSelectorRegion resourceSelector;
-
- private AlertPortletDataSource dataSource;
- //instance ui widgets
- private Canvas containerCanvas;
-
- private Timer refreshTimer;
-
public RecentAlertsPortlet(String locatorId) {
- super(locatorId);
-
- //override the shared datasource
- this.dataSource = new AlertPortletDataSource();
- setDataSource(this.dataSource);
-
- setShowHeader(false);
- setShowFooter(true);
- setShowFooterRefresh(false); //disable footer refresh
- setShowFilterForm(false); //disable filter form for portlet
-
- setOverflow(Overflow.VISIBLE);
- }
-
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
-
- if (null == this.portletWindow && null != portletWindow) {
- this.portletWindow = portletWindow;
- }
-
- if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
- return;
- }
-
- //Operation range property - retrieve existing value
- PropertySimple property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- int translatedAlertRangeSelection = translatedAlertRangeSelection(retrieved);
- getDataSource().setAlertRangeCompleted(translatedAlertRangeSelection);
- } else {//create setting
- storedPortlet.getConfiguration().put(
- new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, defaultAlertCountValue));
- getDataSource().setAlertRangeCompleted(Integer.parseInt(defaultAlertCountValue));
- }
- //Operation priority property setting
- property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- int translatedPriorityIndex = translatedPriorityToValidIndex(retrieved);
- getDataSource().setAlertPriorityIndex(translatedPriorityIndex);
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue));
- getDataSource().setAlertPriorityIndex(translatedPriorityToValidIndex(PRIORITY_ALL));
- }
-
- //Range to time that alerts will be shown for
- property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- long translatedRange = translateTimeToValidRange(retrieved);
- getDataSource().setAlertTimeRange(translatedRange);
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue));
- getDataSource().setAlertTimeRange(translateTimeToValidRange(defaultTimeValue));
- }
-
- //Range of resources to be included in the query
- property = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- if (retrieved.trim().equalsIgnoreCase(RESOURCES_SELECTED)) {
- getDataSource().setAlertResourcesToUse(RESOURCES_SELECTED);
- } else {
- getDataSource().setAlertResourcesToUse(RESOURCES_ALL);
- }
- } else {//create setting
- storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue));
- getDataSource().setAlertResourcesToUse(RESOURCES_ALL);
- }
-
- //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());
- }
- }
- }
-
- private int translatedAlertRangeSelection(String retrieved) {
- int translated = -1;
- if ((retrieved != null) && (!retrieved.trim().isEmpty())) {
- if (retrieved.equalsIgnoreCase(unlimited)) {
- translated = -1;
- } else {
- translated = Integer.parseInt(retrieved);//default to all
- }
- } else {//default to defaultValue
- if (defaultAlertCountValue.equalsIgnoreCase(unlimited)) {
- translated = -1;
- } else {
- translated = Integer.parseInt(defaultAlertCountValue);
- }
- }
- return translated;
- }
-
- private int translatedPriorityToValidIndex(String retrieved) {
- int translatedPriority = 0;//default to all
- if ((retrieved != null) && (!retrieved.trim().isEmpty())) {
- if (retrieved.equalsIgnoreCase(PRIORITY_HIGH)) {
- translatedPriority = 3;
- } else if (retrieved.equalsIgnoreCase(PRIORITY_MEDIUM)) {
- translatedPriority = 2;
- } else if (retrieved.equalsIgnoreCase(PRIORITY_LOW)) {
- translatedPriority = 1;
- } else {
- translatedPriority = 0;//default to all
- }
- }
- return translatedPriority;
- }
-
- /**Translates the UI selection options into time values for alert query.
- *
- * @param retrieved
- * @return long value mapping to string passed in.
- */
- private long translateTimeToValidRange(String retrieved) {
- long translated = 0;//default to ALL
- if ((retrieved != null) && (!retrieved.trim().isEmpty())) {
- if (retrieved.equalsIgnoreCase(TIME_30_MINS)) {
- translated = MeasurementUtility.MINUTES * 30;
- } else if (retrieved.equalsIgnoreCase(TIME_HOUR)) {
- translated = MeasurementUtility.HOURS;
- } else if (retrieved.equalsIgnoreCase(TIME_12_HRS)) {
- translated = MeasurementUtility.HOURS * 12;
- } else if (retrieved.equalsIgnoreCase(TIME_DAY)) {
- translated = MeasurementUtility.DAYS;
- } else if (retrieved.equalsIgnoreCase(TIME_WEEK)) {
- translated = MeasurementUtility.WEEKS;
- } else if (retrieved.equalsIgnoreCase(TIME_MONTH)) {
- translated = MeasurementUtility.DAYS * 28;//replicated from old struts def.
- } else {
- translated = MeasurementUtility.DAYS;//default to day otherwise.
- }
- }
- return translated;
- }
-
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
- }
-
- public DynamicForm getCustomSettingsForm() {
- //root dynamic form instance
- final LocatableDynamicForm form = new LocatableDynamicForm(extendLocatorId("custom-settings"));
- form.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH + 40);//largest widget display + 40 for buttons
- form.setHeight(400);
- form.setMargin(5);
-
- final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
-
- //vertical container
- VLayout column = new VLayout();
-
- //label
- LocatableLabel alertRangeLabel = new LocatableLabel(extendLocatorId("DynamicForm_Label_Alert_Range"), "<b>"
- + MSG.common_title_alert_range() + "</b>");
-
- //horizontal layout
- LocatableHLayout row = new LocatableHLayout(extendLocatorId("alert-range-settings-row-1"));
- row.setMembersMargin(10);
-
- //-------------combobox for number of completed scheduled ops to display on the dashboard
- final SelectItem alertRangeLastComboBox = new SelectItem(ALERT_RANGE_DISPLAY_AMOUNT_VALUE);
- alertRangeLastComboBox.setTitle(MSG.view_measureRange_last());
- alertRangeLastComboBox.setType("selection");
- alertRangeLastComboBox.setWrapTitle(false);
- //define acceptable values for display amount
- String[] acceptableDisplayValues = { "5", "10", MSG.common_label_unlimited() };
- alertRangeLastComboBox.setValueMap(acceptableDisplayValues);
- //set width of dropdown display region
- alertRangeLastComboBox.setWidth(100);
- alertRangeLastComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, selectedItem);
- }
- });
-
- //default selected value to 'unlimited'(live lists) and check both combobox settings here.
- String selectedValue = defaultAlertCountValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE) != null) {
- selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE)
- .getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(
- new PropertySimple(ALERT_RANGE_DISPLAY_AMOUNT_VALUE, defaultAlertCountValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- alertRangeLastComboBox.setDefaultValue(selectedValue);
-
- //-------------combobox for number of completed scheduled ops to display on the dashboard
- final SelectItem alertRangePriorityComboBox = new SelectItem(ALERT_RANGE_PRIORITY_VALUE);
- alertRangePriorityComboBox.setTitle("");
- alertRangePriorityComboBox.setHint("<nobr> <b> " + MSG.view_portlet_recentAlerts_config_priority_label()
- + "</b></nobr>");
- alertRangePriorityComboBox.setType("selection");
- //define acceptable values for display amount
- String[] acceptablePriorityDisplayValues = { PRIORITY_ALL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW };
- alertRangePriorityComboBox.setValueMap(acceptablePriorityDisplayValues);
- //set width of dropdown display region
- alertRangePriorityComboBox.setWidth(100);
- alertRangePriorityComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(ALERT_RANGE_PRIORITY_VALUE, selectedItem);
- }
- });
-
- //default selected value to 'unlimited'(live lists) and check both combobox settings here.
- selectedValue = defaultPriorityValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE) != null) {
- selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_PRIORITY_VALUE).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(
- new PropertySimple(ALERT_RANGE_PRIORITY_VALUE, defaultPriorityValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- alertRangePriorityComboBox.setDefaultValue(selectedValue);
- row.addMember(alertRangeLabel);
- DynamicForm wrappedRange = new DynamicForm();
- wrappedRange.setFields(alertRangeLastComboBox);
- row.addMember(wrappedRange);
-
- DynamicForm wrappedPriority = new DynamicForm();
- wrappedPriority.setFields(alertRangePriorityComboBox);
- row.addMember(wrappedPriority);
-
- //horizontal layout
- LocatableHLayout row2 = new LocatableHLayout(extendLocatorId("alert-range-settings-row-2"));
-
- LocatableLabel alertRangeSpanLabel = new LocatableLabel(extendLocatorId("range-span-label"), "<b>"
- + MSG.view_portlet_recentAlerts_config_when() + "<b>");
- //------------- Build second combobox for timeframe for problem resources search.
- final SelectItem alertRangeTimeComboBox = new SelectItem(ALERT_RANGE_TIME_VALUE);
- alertRangeTimeComboBox.setTitle("");
- alertRangeTimeComboBox.setHint("");
- alertRangeTimeComboBox.setType("selection");
- String[] acceptableTimeDisplayValues = { TIME_30_MINS, TIME_HOUR, TIME_12_HRS, TIME_DAY, TIME_WEEK, TIME_MONTH };
- alertRangeTimeComboBox.setValueMap(acceptableTimeDisplayValues);
- alertRangeTimeComboBox.setWidth(100);
- alertRangeTimeComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(ALERT_RANGE_TIME_VALUE, selectedItem);
- }
- });
-
- //set to default
- selectedValue = defaultTimeValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE) != null) {
- selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_TIME_VALUE).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(new PropertySimple(ALERT_RANGE_TIME_VALUE, defaultTimeValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- alertRangeTimeComboBox.setDefaultValue(selectedValue);
- DynamicForm timeSelectionWrapper = new DynamicForm();
- timeSelectionWrapper.setFields(alertRangeTimeComboBox);
-
- // build resource selection drop down
- //------------- Build second combobox for timeframe for problem resources search.
- final SelectItem alertResourcesComboBox = new SelectItem(ALERT_RANGE_RESOURCES_VALUE);
- alertResourcesComboBox.setTitle(MSG.common_val_for());
- alertResourcesComboBox.setHint("");
- alertResourcesComboBox.setType("selection");
- String[] acceptableResourceDisplayValues = { RESOURCES_ALL, RESOURCES_SELECTED };
- alertResourcesComboBox.setValueMap(acceptableResourceDisplayValues);
- alertResourcesComboBox.setWidth(150);
- alertResourcesComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(ALERT_RANGE_RESOURCES_VALUE, selectedItem);
- //empty out earlier canvas
- for (Canvas c : containerCanvas.getChildren()) {
- c.destroy();
- }
- if (selectedItem.equals(RESOURCES_SELECTED)) {
- containerCanvas.addChild(resourceSelector.getCanvas());
- } else {
- containerCanvas.addChild(new Canvas());
- }
- }
- });
-
- //set to default
- selectedValue = defaultResourceValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE) != null) {
- selectedValue = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE)
- .getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(
- new PropertySimple(ALERT_RANGE_RESOURCES_VALUE, defaultResourceValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- alertResourcesComboBox.setDefaultValue(selectedValue);
- DynamicForm resourceSelectionWrapper = new DynamicForm();
- resourceSelectionWrapper.setFields(alertResourcesComboBox);
-
- alertRangeSpanLabel.setWrap(false);
- alertRangeSpanLabel.setWidth(150);
- row2.addMember(alertRangeSpanLabel);
- row2.addMember(timeSelectionWrapper);
- row2.addMember(resourceSelectionWrapper);
-
- //if portlet config setting exist, then retrieve
- Integer[] alertFilterResourceIds = null;
- alertFilterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, alertFilterResourceIds);
-
- LocatableHLayout resourceSelectionRegion = new LocatableHLayout(extendLocatorId("selection-canvas"));
- resourceSelector = new AlertResourceSelectorRegion(extendLocatorId("ResourcesWithAlerts"),
- alertFilterResourceIds);
- resourceSelectionRegion.setWidth100();
-
- if (alertFilterResourceIds != null) {
- getDataSource().setAlertFilterResourceId(alertFilterResourceIds);
- resourceSelector.setCurrentlyAssignedIds(alertFilterResourceIds);
- }
-
- //instantiate canvas area to display empty or rich resource selection based on dropdown selection
- containerCanvas = new Canvas();
- String previousAlertFilterChoice = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE)
- .getStringValue();
-
- //reload the ResourceSelectionRegion if user has chosen to focus on specific resources with alerts
- if (previousAlertFilterChoice.equals(RESOURCES_SELECTED)) {
- containerCanvas.addChild(resourceSelector.getCanvas());
- } else {// define empty canvas
- containerCanvas.addChild(new Canvas());
- }
-
- //add contain resource selection region.
- resourceSelectionRegion.addMember(containerCanvas);
-
- //finish construction of the layout
- column.addMember(row);
- column.addMember(row2);
- SpacerItem verticalSpace = new SpacerItem();
- verticalSpace.setHeight(20);
- DynamicForm spacerWrapper = new DynamicForm();
- spacerWrapper.setItems(verticalSpace);
- column.addMember(spacerWrapper);
- column.addMember(resourceSelectionRegion);
- form.addChild(column);
-
- //submit handler
- form.addSubmitValuesHandler(new SubmitValuesHandler() {
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
- //no need to insert validation here as user not allowed to enter values
- parseFormAndPopulateConfiguration(form, storedPortlet, ALERT_RANGE_DISPLAY_AMOUNT_VALUE,
- ALERT_RANGE_PRIORITY_VALUE, ALERT_RANGE_RESOURCES_VALUE, ALERT_RANGE_TIME_VALUE);
-
- //retrieve alert-resource-selection property
- PropertySimple prop = storedPortlet.getConfiguration().getSimple(ALERT_RANGE_RESOURCES_VALUE);
-
- //check to see if "Selected Resources" or "All Resources"
- if (prop != null && RESOURCES_SELECTED.equals(prop.getStringValue())) {
- //retrieve currentlyAssignedIds
- Integer[] valuesToPersist = resourceSelector.getListGridValues();
- resourceSelector.setCurrentlyAssignedIds(valuesToPersist);
-
- //build property list of ids to persist
- PropertyList list = new PropertyList(ALERT_RANGE_RESOURCE_IDS);
- for (int rid : resourceSelector.getCurrentlyAssignedIds()) {
- list.add(new PropertySimple(ALERT_RANGE_RESOURCE_IDS, rid));
- }
- storedPortlet.getConfiguration().put(new PropertyList(ALERT_RANGE_RESOURCE_IDS, list));
- getDataSource().setAlertFilterResourceId(resourceSelector.getCurrentlyAssignedIds());
- }
-
- configure(portletWindow, storedPortlet);
-
- refresh();//reload form with new data selections
- markForRedraw();
- }
- });
-
- return form;
- }
-
- /**Iterates over DynamicForm instance to check for properties passed in and if they have been set
- * to put that property into the DashboardPortlet configuration.
- *
- * @param form Dynamic form storing user selections
- * @param portlet Container for configuration changes
- * @param properties Variable list of keys used to verify or populate properties.
- */
- private void parseFormAndPopulateConfiguration(final DynamicForm form, DashboardPortlet storedPortlet,
- String... properties) {
- if ((form != null) && (storedPortlet != null)) {
- for (String property : properties) {
- if (form.getValue(property) != null) {//if new value supplied
- storedPortlet.getConfiguration().put(new PropertySimple(property, form.getValue(property)));
- }
- }
- }
- }
-
- public AlertPortletDataSource getDataSource() {
- return dataSource;
+ super(locatorId, EntityContext.forSubsystemView());
}
public static final class Factory implements PortletViewFactory {
@@ -565,102 +45,4 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti
}
}
- public void startRefreshCycle() {
- refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this, refreshTimer);
- }
-
- @Override
- protected void onDestroy() {
- AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
-
- super.onDestroy();
- }
-
- public boolean isRefreshing() {
- return false;
- }
-
- @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() {
- // TODO Auto-generated method stub
- 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));
- }
- }
- });
- }
-
-}
-
-/** Bundles a ResourceSelector instance with labelling in Canvas for display.
- * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly.
- */
-class AlertResourceSelectorRegion extends LocatableVLayout {
- public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) {
- super(locatorId);
- this.currentlyAssignedIds = assigned;
- }
-
- 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/resource/ResourceAlertsPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceAlertsPortlet.java
index ff3a9939..c43068f 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
@@ -19,26 +19,17 @@
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
import com.google.gwt.user.client.History;
-import com.smartgwt.client.widgets.Canvas;
-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.Messages;
-import org.rhq.enterprise.gui.coregui.client.alert.AlertPortletConfigurationDataSource;
+import org.rhq.core.domain.common.EntityContext;
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.GroupAlertsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.PortletAlertSelector;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.AbstractRecentAlertsPortlet;
/**
+ * @author Jay Shaughnessy
* @author Simeon Pinder
*/
-public class ResourceAlertsPortlet extends GroupAlertsPortlet {
+public class ResourceAlertsPortlet extends AbstractRecentAlertsPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceAlerts";
@@ -47,138 +38,34 @@ public class ResourceAlertsPortlet extends GroupAlertsPortlet {
private int resourceId;
- public ResourceAlertsPortlet(String locatorId) {
- super(locatorId);
+ public ResourceAlertsPortlet(String locatorId, int resourceId) {
- //override the shared datasource
- //figure out which page we're loading
- String currentPage = History.getToken();
- String[] elements = currentPage.split("/");
- this.resourceId = Integer.valueOf(elements[1]);
- }
-
- /**Defines layout for the portlet page.
- */
- protected void initializeUi() {
- //initalize the datasource
- Integer[] resourceIds = new Integer[1];
- resourceIds[0] = this.resourceId;
- this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, null, resourceIds);
- setDataSource(this.dataSource);
-
- setShowHeader(false);
- setShowFooter(true);
- setShowFooterRefresh(false); //disable footer refresh
- setShowFilterForm(false); //disable filter form for portlet
-
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
+ super(locatorId, EntityContext.forResource(resourceId));
- @Override
- protected void onInit() {
- super.onInit();
- initializeUi();
+ this.resourceId = resourceId;
}
- /** 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) {
- Integer[] resourceIds = new Integer[1];
- resourceIds[0] = this.resourceId;
- this.dataSource = new AlertPortletConfigurationDataSource(storedPortlet, portletConfig, null, resourceIds);
- 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 int getResourceId() {
+ return resourceId;
}
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ /* (non-Javadoc)
+ * TODO: This factory ASSUMES the user is currently navigated to a resource detail view, and generates a portlet
+ * for that resource. It will fail in other scenarios. This mechanism should be improved such that the
+ * factory method can take an EntityContext explicitly indicating, in this case, the resource.
+ * @see org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String)
+ */
public final Portlet getInstance(String locatorId) {
- return new ResourceAlertsPortlet(locatorId);
- }
- }
-}
-
-/** 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 {
- public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) {
- super(locatorId);
- this.currentlyAssignedIds = assigned;
- }
-
- private static final Messages MSG = CoreGUI.getMessages();
- private PortletAlertSelector selector = null;
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int resourceId = Integer.valueOf(elements[1]);
- private Integer[] currentlyAssignedIds;
-
- public Integer[] getCurrentlyAssignedIds() {
- return currentlyAssignedIds;
- }
-
- public Integer[] getListGridValues() {
- Integer[] listGridValues = new Integer[0];
- if (null != selector) {
- listGridValues = selector.getAssignedListGridValues();
+ return new ResourceAlertsPortlet(locatorId, resourceId);
}
- 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
13 years, 1 month
[rhq] Branch 'as7plugin' - modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 29 --
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 62 +++--
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java | 121 ++++------
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 15 +
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 26 ++
5 files changed, 151 insertions(+), 102 deletions(-)
New commits:
commit 63147effa639ef08f8cff763393efbafcd3a8607
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 30 12:17:21 2011 +0200
Make executing of Operations more generic and implement add/remove of serverGroups.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 192a54f..401887b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -148,6 +148,8 @@ public class ASConnection {
outcome = outcomeNode.getTextValue();
if (outcome.equals("failed")) {
JsonNode reasonNode = in.findValue("failure-description");
+ if (reasonNode==null)
+ reasonNode = in.findValue("domain-failure-description");// TODO JBAS-9182
String reason = reasonNode.getTextValue();
log.info(reason);
return true;
@@ -163,11 +165,10 @@ public class ASConnection {
/**
* Execute an operation against the domain api
- * @param path Node to manipulate
- * @param operationName operation to run
- * @param attributeValue attribute-name-value pair
+ * @return JsonNode that describes the result
+ * @param operation an Operation that should be run on the domain controller
*/
- public JsonNode execute(String path, String operationName, NameValuePair attributeValue) {
+ public JsonNode execute(Operation operation) {
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -177,8 +178,6 @@ public class ASConnection {
ObjectMapper mapper = new ObjectMapper();
- Operation operation = new Operation(operationName,pathToAddress(path),attributeValue);
-
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
mapper.writeValue(out, operation);
@@ -224,22 +223,6 @@ public class ASConnection {
return null;
}
- private List<PROPERTY_VALUE> pathToAddress(String path) {
- if (path.endsWith("/"))
- path = path.substring(0,path.length()-1);
-
- if (path.startsWith("/"))
- path = path.substring(1);
-
- List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
- String[] components = path.split("/");
- for (int i = 0; i < components.length ; i+=2) {
- PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
- result.add(valuePair);
- }
-
- return result;
- }
private URL getBaseUrl(String base, String ops) throws MalformedURLException {
String spec;
@@ -268,6 +251,8 @@ public class ASConnection {
if (jsonNode==null)
return "getFailureDescription: -input was null-";
JsonNode node = jsonNode.findValue("failure-description");
+ if (node==null)
+ node = jsonNode.findValue("domain-failure-description"); // TODO JBAS-9182
return node.getValueAsText();
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 788531b..3b025f3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -45,9 +45,13 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -149,22 +153,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- ResourceComponent parentResourceComponent = context.getParentResourceComponent();
- String parentPath =null;
- String myPath;
- if (parentResourceComponent instanceof BaseComponent) {
- BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
- parentPath = parentComponent.getPath();
- }
-
- if (parentPath!=null) {
- if (parentPath.endsWith("/") || path.startsWith("/"))
- myPath = parentPath + path;
- else
- myPath = parentPath + "/" + path;
- }
- else
- myPath = path;
+ String myPath = getResultingPath();
JsonNode json = connection.getLevelData(myPath,true,false);
@@ -302,6 +291,26 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return ret;
}
+ private String getResultingPath() {
+ ResourceComponent parentResourceComponent = context.getParentResourceComponent();
+ String parentPath =null;
+ String myPath;
+ if (parentResourceComponent instanceof BaseComponent) {
+ BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
+ parentPath = parentComponent.getPath();
+ }
+
+ if (parentPath!=null) {
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ myPath = parentPath + path;
+ else
+ myPath = parentPath + "/" + path;
+ }
+ else
+ myPath = path;
+ return myPath;
+ }
+
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -309,7 +318,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
- JsonNode result= connection.execute(key,"write-attribute",nvp); // TODO path / key handling
+ Operation writeAttribute = new Operation("write-attribute",pathToAddress(getResultingPath()),nvp);
+ JsonNode result= connection.execute(writeAttribute);
if(connection.isErrorReply(result)) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessage(connection.getFailureDescription(result));
@@ -317,4 +327,22 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
}
+
+ private List<PROPERTY_VALUE> pathToAddress(String path) {
+ if (path.endsWith("/"))
+ path = path.substring(0,path.length()-1);
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
+ String[] components = path.split("/");
+ for (int i = 0; i < components.length ; i+=2) {
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
+ result.add(valuePair);
+ }
+
+ return result;
+ }
+
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 642b41f..898f176 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -20,10 +20,14 @@ package org.rhq.modules.plugins.jbossas7.json;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.annotate.JsonAnyGetter;
+import org.codehaus.jackson.annotate.JsonAnySetter;
+import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.annotate.JsonValue;
/**
* Operation to run on the server
@@ -31,23 +35,71 @@ import org.codehaus.jackson.annotate.JsonValue;
*/
public class Operation {
+ private String operation;
+ @JsonProperty
+ private List<PROPERTY_VALUE> address = Collections.emptyList();
+ private Map<String,String> additionalProperties;
+
+
public Operation(String operation, List<PROPERTY_VALUE> address, NameValuePair payload) {
this.operation = operation;
this.address = address;
- this.name = payload.name;
- this.value = payload.value;
+ additionalProperties = new HashMap<String,String>(2);
+ additionalProperties.put("name",payload.name);
+ additionalProperties.put("value",payload.value);
+
+ }
+
+ public Operation(String operation, List<PROPERTY_VALUE> address, Map<String,String> payload) {
+ this.operation = operation;
+ this.address = address;
+ this.additionalProperties = payload;
+ }
+
+ public Operation(String operation, List<PROPERTY_VALUE> address, String key, String value) {
+ this.operation = operation;
+ this.address = address;
+ additionalProperties = new HashMap<String,String>(1);
+ additionalProperties.put(key,value);
+
}
public Operation() {
// needed for Jackson
}
- private String operation;
- @JsonProperty
- private List<PROPERTY_VALUE> address = Collections.emptyList();
+ @JsonAnySetter
+ public void addAdditionalProperty(String key, String value) {
+ if (additionalProperties == null)
+ additionalProperties = new HashMap<String, String>();
+ additionalProperties.put(key,value);
+ }
- private String name;
- private String value;
+ public void setAdditionalProperties(Map<String, String> additionalProperties) {
+ this.additionalProperties = additionalProperties;
+ }
+
+ @JsonAnyGetter
+ public Map<String,String> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonIgnore
+ public String getName() {
+ return getProperty("name");
+ }
+
+ @JsonIgnore
+ public String getValue() {
+ return getProperty("value");
+ }
+
+ private String getProperty(String key) {
+ if (additionalProperties.containsKey(key))
+ return additionalProperties.get(key);
+ else
+ return null;
+ }
public String getOperation() {
return operation;
@@ -72,58 +124,5 @@ public class Operation {
return address;
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- /*
- [localhost:9999 /subsystem=web/connector=http] :write-attribute(name=socket-binding,value=jndi)
- yield JSON to send:
- {
- "operation" : "write-attribute",
- "name" : "socket-binding",
- "value" : "jndi",
- "address" : [
- {
- "PROPERTY_VALUE" : {
- "subsystem" : "web"
- }
- },
- {
- "PROPERTY_VALUE" : {
- "connector" : "http"
- }
- }
- ]
- }
- */
-
-// @JsonValue
-// public String toString() {
-// StringBuilder b = new StringBuilder();
-// b.append('{');
-// b.append("\"operation\":\"").append(operation).append("\",");
-// b.append("\"address\":");
-// if (address!=null && !address.isEmpty())
-// b.append(address);
-// else
-// b.append("[]");
-// b.append(',');
-// b.append(payload);
-// b.append("}");
-// return b.toString();
-// }
}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index ee6b21f..6af7de6 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -105,9 +105,21 @@
<server name="Domain"
discovery="DomainDiscovery"
- class="BaseComponent"
+ class="DomainComponent"
description="An AS7 management profile">
+ <operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
+ <parameters>
+ <c:simple-property name="name" description="Name of Group to add"/>
+ <c:simple-property name="profile" description="Profile to add this group to"/>
+ </parameters>
+ </operation>
+ <operation name="server-group:remove" displayName="Remove ServerGroup" description="Remove a server group from the Domain.">
+ <parameters>
+ <c:simple-property name="name" description="Name of Group to add"/>
+ </parameters>
+ </operation>
+
<server name="Profile"
description="One profile in a domain"
@@ -125,7 +137,6 @@
<plugin-configuration>
<c:simple-property name="path" default="/server-group/*" readOnly="true"/>
</plugin-configuration>
-
<resource-configuration>
<c:simple-property name="profile" />
<c:simple-property name="socket-binding-group"/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 4909595..929a87c 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -19,7 +19,9 @@
package org.rhq.modules.plugins.jbossas7;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
@@ -70,4 +72,28 @@ public class OperationJsonTest {
assert pv.getKey().equals("myKey") : "Key is " + pv.getKey();
assert pv.getValue().equals("myValue"): "Value is " + pv.getValue();
}
+
+ public void anyPayloadTest() throws Exception {
+
+ List<PROPERTY_VALUE> address=new ArrayList<PROPERTY_VALUE>(2);
+ PROPERTY_VALUE part = new PROPERTY_VALUE("/server-group","newOne");
+ address.add(part);
+
+ Map<String,String> props = new HashMap<String, String>();
+ props.put("profile","default");
+
+ Operation operation = new Operation("add",address,props);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(operation);
+ System.out.println(result);
+
+ assert !result.contains("name") : "Result contains a name property but should not : " + result;
+ assert !result.contains("null") : "Result contains null values but should not : " + result;
+
+ Operation op = mapper.readValue(result,Operation.class);
+ assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
+
+ }
}
13 years, 1 month