modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java | 97 ++++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/RecentAlertsPortlet.java | 84 ++------ modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 1 3 files changed, 118 insertions(+), 64 deletions(-)
New commits: commit c4003544a82e3aa8f0a1c4b67f9b67b00b7c2ee7 Merge: 7521850... 11720e2... Author: Simeon Pinder spinder@redhat.com Date: Mon Dec 13 10:00:37 2010 -0500
Merge branch 'track-master'
commit 11720e297face9b2e4736ca8f581817afa8f223d Author: Simeon Pinder spinder@redhat.com Date: Sun Dec 12 15:58:10 2010 -0500
oops. Forgot assignment.
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 8ca8525..ad26a09 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 @@ -570,7 +570,7 @@ class AlertResourceSelectorRegion extends LocatableVLayout { public Integer[] getListGridValues() { Integer[] listGridValues = new Integer[0]; if (null != selector) { - selector.getAssignedListGridValues(); + listGridValues = selector.getAssignedListGridValues(); } return listGridValues; }
commit b62561e0cfc02e90d86c1c1fea5308ba5a3e70e3 Author: Simeon Pinder spinder@redhat.com Date: Sun Dec 12 14:57:01 2010 -0500
fix recent alert portlet resource filtration ui bug. Refactored away use of deprecated methods.
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 07d204b..8ca8525 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 @@ -19,9 +19,6 @@ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts;
import com.google.gwt.user.client.Timer; -import com.smartgwt.client.data.Record; -import com.smartgwt.client.data.RecordList; -import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.form.DynamicForm; @@ -31,9 +28,6 @@ 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.ListGridField; -import com.smartgwt.client.widgets.grid.events.DataArrivedEvent; -import com.smartgwt.client.widgets.grid.events.DataArrivedHandler; import com.smartgwt.client.widgets.layout.VLayout;
import org.rhq.core.domain.alert.AlertPriority; @@ -50,11 +44,11 @@ import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.selection.ResourceSelector; 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;
/** * @author Simeon Pinder @@ -442,14 +436,17 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti //if portlet config setting exist, then retrieve Integer[] alertFilterResourceIds = null; alertFilterResourceIds = getDataSource().extractFilterResourceIds(storedPortlet, alertFilterResourceIds); - if (alertFilterResourceIds != null) { - getDataSource().setAlertFilterResourceId(alertFilterResourceIds); - }
LocatableHLayout resourceSelectionRegion = new LocatableHLayout(extendLocatorId("selection-canvas")); - resourceSelector = new AlertResourceSelectorRegion(alertFilterResourceIds); + 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) @@ -555,9 +552,14 @@ public class RecentAlertsPortlet extends AlertHistoryView implements CustomSetti /** Bundles a ResourceSelector instance with labelling in Canvas for display. * Also modifies the AssignedGrid to listen for AvailbleGrid completion and act accordingly. */ -class AlertResourceSelectorRegion { +class AlertResourceSelectorRegion extends LocatableVLayout { + public AlertResourceSelectorRegion(String locatorId, Integer[] assigned) { + super(locatorId); + this.currentlyAssignedIds = assigned; + } + private static final Messages MSG = CoreGUI.getMessages(); - private ResourceSelector selector = null; + private PortletAlertSelector selector = null;
private Integer[] currentlyAssignedIds;
@@ -567,62 +569,16 @@ class AlertResourceSelectorRegion {
public Integer[] getListGridValues() { Integer[] listGridValues = new Integer[0]; - if ((null != selector) && (null != selector.getAssignedGrid())) { - RecordList allRecords = selector.getAssignedGrid().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); - } - } + if (null != selector) { + selector.getAssignedListGridValues(); } return listGridValues; }
- public AlertResourceSelectorRegion(Integer[] assigned) { - this.currentlyAssignedIds = assigned; - } - public Canvas getCanvas() { if (selector == null) { - selector = new ResourceSelector(MSG.view_portlet_recentAlerts_config_members(), - ResourceType.ANY_PLATFORM_TYPE, true); - selector.setWidth100(); - selector.setWidth(RecentAlertsPortlet.ALERT_RESOURCE_SELECTION_WIDTH); - //widget ui updates - selector.getAvailableGrid().setTitle(MSG.common_title_available_resources()); - selector.getAvailableGrid().setEmptyMessage(MSG.common_msg_loading()); - selector.getAssignedGrid().setTitle(MSG.common_title_selected_resources()); - //disable display typeFilter. - selector.setDisplayResourceTypeFilter(false); - - //populate fields for grid. - ListGridField nameField = new ListGridField("name", MSG.common_title_name()); - ListGridField iconField = new ListGridField("icon", MSG.common_title_icon(), 50); - iconField.setImageURLPrefix("types/"); - iconField.setType(ListGridFieldType.ICON); - selector.getAssignedGrid().setFields(iconField, nameField); - - //add listener to AvailableGrid, to act after successfully populated. - selector.getAvailableGrid().addDataArrivedHandler(new DataArrivedHandler() { - @Override - public void onDataArrived(DataArrivedEvent event) { - if ((getCurrentlyAssignedIds() != null) && (getCurrentlyAssignedIds().length > 0)) { - //retrieve the loaded data and add to the table itself - RecordList recordList = selector.getAvailableGrid().getDataAsRecordList(); - //for each of the resource ids loaded from settings, select that row for transfer. - for (int ci : getCurrentlyAssignedIds()) { - int located = recordList.findIndex("id", ci); - if (located > -1) { - selector.getAvailableGrid().selectRecord(located); - } - } - //simulate 'add' button push. - selector.addSelectedRows(); - } - } - }); + selector = new PortletAlertSelector(extendLocatorId("AlertSelector"), this.currentlyAssignedIds, + ResourceType.ANY_PLATFORM_TYPE, false); } return selector; } @@ -630,4 +586,4 @@ class AlertResourceSelectorRegion { public void setCurrentlyAssignedIds(Integer[] currentlyAssignedIds) { this.currentlyAssignedIds = currentlyAssignedIds; } -} +} \ No newline at end of file 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 defb4a1..33ff980 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 @@ -1202,6 +1202,7 @@ view_portlet_recentAlerts_config_members = Select Members view_portlet_recentAlerts_config_priority_label = priority Alerts, view_portlet_recentAlerts_config_when = within the past view_portlet_recentAlerts_help_msg = Displays recent alerts fired on resources visible to the current user login. +view_portlet_recentAlerts_fail_msg = Failed to load resources assigned for alert filtering. # // dup in common view_portlet_recentAlerts_title = Recent Alerts view_portlet_recentlyAdded_approved_platforms = recently approved platforms on dashboard.
commit c8abbf40631f646b83d70bdb8c02ed526baf0ae0 Author: Simeon Pinder spinder@redhat.com Date: Sun Dec 12 14:51:38 2010 -0500
refactor of portlet alert resource filter selector.
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 new file mode 100644 index 0000000..c6ffa2a --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java @@ -0,0 +1,97 @@ +/* + * 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.setImageURLPrefix("types/"); + 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; + } +}
commit 7521850ce1a76409a6fe11f5d3e0961e6ca8832a Author: Simeon Pinder spinder@redhat.com Date: Sun Dec 12 14:51:38 2010 -0500
refactor of portlet alert resource filter selector.
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 new file mode 100644 index 0000000..c6ffa2a --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/alerts/PortletAlertSelector.java @@ -0,0 +1,97 @@ +/* + * 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.setImageURLPrefix("types/"); + 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; + } +}
rhq-commits@lists.fedorahosted.org