.classpath | 8 modules/enterprise/gui/coregui/pom.xml | 5 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java | 159 ------ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java | 109 +++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 71 ++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java | 202 -------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java | 229 ---------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java | 151 ------ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractSchedulesView.java | 158 ++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/SchedulesDataSource.java | 212 +++++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java | 11 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/ResourceGroupSchedulesView.java | 139 ++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 164 ------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesView.java | 56 -- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/ResourceSchedulesView.java | 143 ++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java | 159 ------ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesView.java | 56 -- 19 files changed, 810 insertions(+), 1230 deletions(-)
New commits: commit d075ae47ffd5036a728131bf05b8bdb360d1835f Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Jan 13 16:28:07 2012 -0500
[Bug 773662 - Unable to view resource or group metric schedules] Reorganize this dated impl with an approach more consistent with more recent views/datasources. The old impl does not seem to play with the smartgwt upgrade wrt the startegy employed for datasource/listgrid fields. - consolidate several datasource classes into new SchedulesDataSource - uses a cleaner EntityContent approach, and favors ListGridFields - move button-handling code into the view impl as opposed to the DS - as overrides of the abstract base view class - rename the view classes to be consistent with other views - i.e. use Abstract/Resource/ResourceGroup/Template *SchedulesView prefixes - Table changes: - fixed Table constructor to set autofetch correctly - moved contents.addMember(listGrid) up in onDraw(), closer to onInit where is is initialized - added a comment in onDraw about the potentially unnecessary guard against multiple invocations, and the effect it could have on calling addMember() in onInit() - convert several deprecated ListGrid.getSelection() calls to the new ListGrid.getSelectedRecords() call
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java deleted file mode 100644 index 63e49cd..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesDataSource.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.admin.templates; - -import java.util.List; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.fields.DataSourceIntegerField; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleCompositeDataSource; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -/** - * A DataSource for reading and updating the default metric schedules ("metric templates") for a particular ResourceType. - * - * @author Ian Springer - */ -public class TemplateSchedulesDataSource extends AbstractMeasurementScheduleCompositeDataSource { - private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); - private int resourceTypeId; - - public TemplateSchedulesDataSource(int resourceTypeId) { - this.resourceTypeId = resourceTypeId; - } - - @Override - protected List<DataSourceField> addDataSourceFields() { - List<DataSourceField> fields = super.addDataSourceFields(); - - DataSourceField resourceGroupIdField = new DataSourceIntegerField( - MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, "Resource Type Id"); - resourceGroupIdField.setHidden(true); - fields.add(resourceGroupIdField); - - return fields; - } - - @Override - protected EntityContext getEntityContext(DSRequest request) { - Criteria requestCriteria = request.getCriteria(); - Integer typeId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID); - return EntityContext.forTemplate(typeId); - } - - @Override - public ListGridRecord copyValues(MeasurementScheduleComposite from) { - ListGridRecord record = super.copyValues(from); - record.setAttribute(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, this.resourceTypeId); - return record; - } - - @Override - protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { - TemplateSchedulesView templateSchedulesView = (TemplateSchedulesView) measurementScheduleListView; - boolean updateExistingSchedules = templateSchedulesView.isUpdateExistingSchedules(); - final String s = (measurementDefinitionIds.length > 1) ? "s" : ""; - this.measurementService.enableSchedulesForResourceType(measurementDefinitionIds, updateExistingSchedules, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.datasource_templateSchedules_enabled_failed(s, - measurementDefinitionDisplayNames.toString(), String.valueOf(resourceTypeId)), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.datasource_templateSchedules_enabled(s), MSG - .datasource_templateSchedules_enabled_detailed(s, measurementDefinitionDisplayNames - .toString(), String.valueOf(resourceTypeId)), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - - @Override - protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { - TemplateSchedulesView templateSchedulesView = (TemplateSchedulesView) measurementScheduleListView; - boolean updateExistingSchedules = templateSchedulesView.isUpdateExistingSchedules(); - final String s = (measurementDefinitionIds.length > 1) ? "s" : ""; - this.measurementService.disableSchedulesForResourceType(measurementDefinitionIds, updateExistingSchedules, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.datasource_templateSchedules_disabled_failed(s, measurementDefinitionDisplayNames - .toString(), String.valueOf(resourceTypeId)), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.datasource_templateSchedules_disabled(s), MSG - .datasource_templateSchedules_disabled_detailed(s, measurementDefinitionDisplayNames - .toString(), String.valueOf(resourceTypeId)), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - - @Override - protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, - final long collectionInterval) { - TemplateSchedulesView templateSchedulesView = (TemplateSchedulesView) measurementScheduleListView; - boolean updateExistingSchedules = templateSchedulesView.isUpdateExistingSchedules(); - final String s = (measurementDefinitionIds.length > 1) ? "s" : ""; - this.measurementService.updateSchedulesForResourceType(measurementDefinitionIds, collectionInterval, - updateExistingSchedules, new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.datasource_templateSchedules_updated_failed(String.valueOf(collectionInterval / 1000), s, - measurementDefinitionDisplayNames.toString(), String.valueOf(resourceTypeId)), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter() - .notify( - new Message(MSG.datasource_templateSchedules_updated(s), MSG - .datasource_templateSchedules_updated_detail(s, measurementDefinitionDisplayNames - .toString(), String.valueOf(resourceTypeId), String - .valueOf(collectionInterval / 1000)), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java index 90d6c11..b08a5a1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/templates/TemplateSchedulesView.java @@ -18,48 +18,40 @@ */ package org.rhq.enterprise.gui.coregui.client.admin.templates;
+import java.util.List; import java.util.Set;
-import com.smartgwt.client.data.Criteria; +import com.google.gwt.user.client.rpc.AsyncCallback;
import org.rhq.core.domain.authz.Permission; -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; +import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.resource.ResourceType; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractSchedulesView; +import org.rhq.enterprise.gui.coregui.client.util.message.Message;
/** * A view for viewing and updating the default metric schedules ("metric templates") for a particular ResourceType. * + * @author Jay Shaughnessy * @author Ian Springer */ -public class TemplateSchedulesView extends AbstractMeasurementScheduleListView { - - private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID }; +public class TemplateSchedulesView extends AbstractSchedulesView {
private boolean updateExistingSchedules = true; - private Set<Permission> globalPermissions; + private String typeId;
public TemplateSchedulesView(String locatorId, ResourceType type, Set<Permission> globalPermissions) { - super(locatorId, getTitle(type), new TemplateSchedulesDataSource(type.getId()), createCriteria(type.getId()), - EXCLUDED_FIELD_NAMES); + super(locatorId, getTitle(type), EntityContext.forTemplate(type.getId()), globalPermissions + .contains(Permission.MANAGE_INVENTORY));
- this.globalPermissions = globalPermissions; + this.typeId = String.valueOf(type.getId()); }
public static String getTitle(ResourceType type) { return MSG.view_adminConfig_metricTemplates() + " [" + type.getName() + "]"; }
- public boolean hasManageMeasurementsPermission() { - return globalPermissions.contains(Permission.MANAGE_INVENTORY); - } - - private static Criteria createCriteria(int resourceTypeId) { - Criteria criteria = new Criteria(); - criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_TYPE_ID, resourceTypeId); - return criteria; - } - @Override protected void configureTable() { super.configureTable(); @@ -75,4 +67,81 @@ public class TemplateSchedulesView extends AbstractMeasurementScheduleListView { this.updateExistingSchedules = updateExistingSchedules; }
+ @Override + protected void enableSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames) { + + boolean updateExistingSchedules = isUpdateExistingSchedules(); + final String s = (measurementDefinitionIds.length > 1) ? "s" : ""; + this.measurementService.enableSchedulesForResourceType(measurementDefinitionIds, updateExistingSchedules, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.datasource_templateSchedules_enabled_failed(s, + measurementDefinitionDisplayNames.toString(), typeId), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.datasource_templateSchedules_enabled(s), MSG + .datasource_templateSchedules_enabled_detailed(s, + measurementDefinitionDisplayNames.toString(), typeId), Message.Severity.Info)); + refresh(); + } + }); + } + + @Override + protected void disableSchedules(int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { + + boolean updateExistingSchedules = isUpdateExistingSchedules(); + final String s = (measurementDefinitionIds.length > 1) ? "s" : ""; + this.measurementService.disableSchedulesForResourceType(measurementDefinitionIds, updateExistingSchedules, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.datasource_templateSchedules_disabled_failed(s, + measurementDefinitionDisplayNames.toString(), typeId), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.datasource_templateSchedules_disabled(s), MSG + .datasource_templateSchedules_disabled_detailed(s, + measurementDefinitionDisplayNames.toString(), typeId), Message.Severity.Info)); + refresh(); + } + }); + } + + @Override + protected void updateSchedules(int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames, final long collectionInterval) { + + boolean updateExistingSchedules = isUpdateExistingSchedules(); + final String s = (measurementDefinitionIds.length > 1) ? "s" : ""; + this.measurementService.updateSchedulesForResourceType(measurementDefinitionIds, collectionInterval, + updateExistingSchedules, new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.datasource_templateSchedules_updated_failed(String.valueOf(collectionInterval / 1000), s, + measurementDefinitionDisplayNames.toString(), typeId), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.datasource_templateSchedules_updated(s), MSG + .datasource_templateSchedules_updated_detail(s, + measurementDefinitionDisplayNames.toString(), typeId, + String.valueOf(collectionInterval / 1000)), Message.Severity.Info)); + refresh(); + } + }); + } } diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java index 302c55b..3be68ac 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java @@ -18,16 +18,35 @@ */ package org.rhq.enterprise.gui.coregui.client.components.table;
+import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.event.dom.client.KeyCodes; -import com.smartgwt.client.data.*; +import com.smartgwt.client.data.Criteria; +import com.smartgwt.client.data.DSCallback; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.DataSourceField; +import com.smartgwt.client.data.Record; +import com.smartgwt.client.data.ResultSet; +import com.smartgwt.client.data.SortSpecifier; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.types.SelectionStyle; import com.smartgwt.client.types.VerticalAlignment; import com.smartgwt.client.util.BooleanCallback; import com.smartgwt.client.util.SC; -import com.smartgwt.client.widgets.*; +import com.smartgwt.client.widgets.Canvas; +import com.smartgwt.client.widgets.HTMLFlow; +import com.smartgwt.client.widgets.IButton; +import com.smartgwt.client.widgets.Img; +import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.events.DoubleClickEvent; @@ -52,6 +71,7 @@ import com.smartgwt.client.widgets.layout.LayoutSpacer; import com.smartgwt.client.widgets.menu.IMenuButton; import com.smartgwt.client.widgets.menu.MenuItem; import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent; + import org.rhq.core.domain.search.SearchSubsystem; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.InitializableView; @@ -60,9 +80,15 @@ import org.rhq.enterprise.gui.coregui.client.components.form.SearchBarItem; import org.rhq.enterprise.gui.coregui.client.util.CriteriaUtility; import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; import org.rhq.enterprise.gui.coregui.client.util.message.Message; -import org.rhq.enterprise.gui.coregui.client.util.selenium.*; - -import java.util.*; +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.LocatableIButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableToolStrip; +import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; +import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** * A tabular view of set of data records from an {@link RPCDataSource}. @@ -76,7 +102,7 @@ import java.util.*; * @author Greg Hinkle * @author Ian Springer */ -@SuppressWarnings("unchecked") +@SuppressWarnings("rawtypes") public class Table<DS extends RPCDataSource> extends LocatableHLayout implements RefreshableView, InitializableView {
private static final int DATA_PAGE_SIZE = 50; @@ -137,7 +163,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements }
public Table(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers) { - this(locatorId, tableTitle, null, sortSpecifiers, null, false); + this(locatorId, tableTitle, null, sortSpecifiers, null, true); }
protected Table(String locatorId, String tableTitle, SortSpecifier[] sortSpecifiers, Criteria criteria) { @@ -304,10 +330,17 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements try { super.onDraw();
+ // I'm not sure this is necessary as I'm not sure it's the case that draw()/onDraw() will get called + // multiple times. But if it did/does, this protects us by removing the current members before they + // get set below. Note that by having this here we *can non* add members in onInit, because they will + // immediately get removed. -jshaughn for (Canvas child : contents.getMembers()) { contents.removeChild(child); }
+ // add the listGrid defined in onInit + contents.addMember(listGrid); + // Title this.titleCanvas = new HTMLFlow(); updateTitleCanvas(this.titleString); @@ -323,11 +356,9 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements contents.addMember(filterForm); }
- contents.addMember(listGrid); - // Footer
- // A se cond toolstrip that optionally appears before the main footer - it will contain extra widgets. + // A second toolstrip that optionally appears before the main footer - it will contain extra widgets. // This is hidden from view unless extra widgets are actually added to the table above the main footer. this.footerExtraWidgets = new LocatableToolStrip(contents.extendLocatorId("FooterExtraWidgets")); footerExtraWidgets.setPadding(5); @@ -406,7 +437,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements String contents; if (lengthIsKnown) { int totalRows = this.listGrid.getTotalRows(); - int selectedRows = this.listGrid.getSelection().length; + int selectedRows = this.listGrid.getSelectedRecords().length; contents = MSG.view_table_totalRows(String.valueOf(totalRows), String.valueOf(selectedRows)); } else { contents = MSG.view_table_totalRowsUnknown(); @@ -464,20 +495,20 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements public void onClick(ClickEvent clickEvent) { disableAllFooterControls(); if (tableAction.confirmMessage != null) { - String message = tableAction.confirmMessage.replaceAll("\#", String.valueOf(listGrid - .getSelection().length)); + String message = tableAction.confirmMessage.replaceAll("\#", + String.valueOf(listGrid.getSelectedRecords().length));
SC.ask(message, new BooleanCallback() { public void execute(Boolean confirmed) { if (confirmed) { - tableAction.action.executeAction(listGrid.getSelection(), null); + tableAction.action.executeAction(listGrid.getSelectedRecords(), null); } else { refreshTableInfo(); } } }); } else { - tableAction.action.executeAction(listGrid.getSelection(), null); + tableAction.action.executeAction(listGrid.getSelectedRecords(), null); } } }); @@ -494,7 +525,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() { public void onClick(MenuItemClickEvent event) { disableAllFooterControls(); - tableAction.getAction().executeAction(listGrid.getSelection(), menuEntries.get(key)); + tableAction.getAction().executeAction(listGrid.getSelectedRecords(), menuEntries.get(key)); } }); menu.addItem(item); @@ -969,7 +1000,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements for (TableActionInfo tableAction : this.tableActions) { if (tableAction.actionCanvas != null) { // if null, we haven't initialized our buttons yet, so skip this boolean enabled = (!this.tableActionDisableOverride && tableAction.action.isEnabled(this.listGrid - .getSelection())); + .getSelectedRecords())); tableAction.actionCanvas.setDisabled(!enabled); } } @@ -998,7 +1029,7 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements
protected void deleteSelectedRecords(DSRequest requestProperties) { ListGrid listGrid = getListGrid(); - final int selectedRecordCount = listGrid.getSelection().length; + final int selectedRecordCount = listGrid.getSelectedRecords().length; final List<String> deletedRecordNames = new ArrayList<String>(selectedRecordCount); listGrid.removeSelectedData(new DSCallback() { public void execute(DSResponse response, Object rawData, DSRequest request) { @@ -1010,8 +1041,8 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements } if (deletedRecordNames.size() == selectedRecordCount) { // all selected schedules were successfully deleted. - Message message = new Message(MSG.widget_recordEditor_info_recordsDeletedConcise(String - .valueOf(deletedRecordNames.size()), getDataTypeNamePlural()), MSG + Message message = new Message(MSG.widget_recordEditor_info_recordsDeletedConcise( + String.valueOf(deletedRecordNames.size()), getDataTypeNamePlural()), MSG .widget_recordEditor_info_recordsDeletedDetailed(String.valueOf(deletedRecordNames.size()), getDataTypeNamePlural(), deletedRecordNames.toString())); CoreGUI.getMessageCenter().notify(message); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java deleted file mode 100644 index dfc951c..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleCompositeDataSource.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.common; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DSResponse; -import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.Record; -import com.smartgwt.client.data.fields.DataSourceBooleanField; -import com.smartgwt.client.data.fields.DataSourceIntegerField; -import com.smartgwt.client.data.fields.DataSourceTextField; -import com.smartgwt.client.rpc.RPCResponse; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.core.domain.criteria.Criteria; -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.measurement.MeasurementDefinition; -import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; - -/** - * A server-side SmartGWT DataSource for reading and updating {@link MeasurementScheduleComposite}s. - * - * @author Ian Springer - */ -public abstract class AbstractMeasurementScheduleCompositeDataSource extends - RPCDataSource<MeasurementScheduleComposite, Criteria> { - private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); - - protected AbstractMeasurementScheduleCompositeDataSource() { - super(); - - setCanMultiSort(true); - - List<DataSourceField> fields = addDataSourceFields(); - addFields(fields); - } - - @Override - protected List<DataSourceField> addDataSourceFields() { - List<DataSourceField> fields = super.addDataSourceFields(); - - DataSourceIntegerField idField = new DataSourceIntegerField( - MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, MSG.common_title_id()); - idField.setPrimaryKey(true); - idField.setHidden(true); - fields.add(idField); - - DataSourceTextField nameField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, - MSG.common_title_metric()); - fields.add(nameField); - - DataSourceTextField descriptionField = new DataSourceTextField( - MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, MSG.common_title_description()); - fields.add(descriptionField); - - DataSourceTextField typeField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, MSG - .common_title_type()); - fields.add(typeField); - - DataSourceBooleanField enabledField = new DataSourceBooleanField( - MeasurementScheduleCriteria.SORT_FIELD_ENABLED, MSG.common_title_enabled()); - fields.add(enabledField); - - DataSourceIntegerField intervalField = new DataSourceIntegerField( - MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, MSG.view_inventory_collectionInterval()); - fields.add(intervalField); - - return fields; - } - - @Override - protected Criteria getFetchCriteria(DSRequest request) { - // we don't use criterias for this datasource, just return null - return null; - } - - @Override - protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) { - final EntityContext entityContext = getEntityContext(request); - - this.measurementService.getMeasurementScheduleCompositesByContext(entityContext, - new AsyncCallback<PageList<MeasurementScheduleComposite>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_loadFailedContext(entityContext.toString()), caught); - response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(request.getRequestId(), response); - } - - public void onSuccess(PageList<MeasurementScheduleComposite> result) { - response.setData(buildRecords(result)); - // For paging to work, we have to specify size of full result set. - response.setTotalRows(result.getTotalSize()); - processResponse(request.getRequestId(), response); - } - }); - } - - protected abstract EntityContext getEntityContext(DSRequest request); - - @Override - public MeasurementScheduleComposite copyValues(Record from) { - return null; - } - - @Override - public ListGridRecord copyValues(MeasurementScheduleComposite from) { - ListGridRecord record = new ListGridRecord(); - - MeasurementDefinition measurementDefinition = from.getMeasurementDefinition(); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, measurementDefinition.getId()); - record - .setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, measurementDefinition.getDisplayName()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, measurementDefinition.getDescription()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, measurementDefinition.getDataType() - .name().toLowerCase()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_ENABLED, from.getCollectionEnabled()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, from.getCollectionInterval()); - - return record; - } - - public void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) { - int[] ids = getMeasurementDefinitionIds(measurementScheduleListView); - List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView); - enableSchedules(measurementScheduleListView, ids, displayNames); - } - - protected abstract void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, - int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames); - - public void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) { - int[] ids = getMeasurementDefinitionIds(measurementScheduleListView); - List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView); - disableSchedules(measurementScheduleListView, ids, displayNames); - } - - protected abstract void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, - int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames); - - public void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, long interval) { - int[] ids = getMeasurementDefinitionIds(measurementScheduleListView); - List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView); - updateSchedules(measurementScheduleListView, ids, displayNames, interval); - } - - private int[] getMeasurementDefinitionIds(AbstractMeasurementScheduleListView measurementScheduleListView) { - ListGrid listGrid = measurementScheduleListView.getListGrid(); - ListGridRecord[] records = listGrid.getSelection(); - - int[] measurementDefinitionIds = new int[records.length]; - for (int i = 0, selectionLength = records.length; i < selectionLength; i++) { - ListGridRecord record = records[i]; - Integer measurementDefinitionId = record - .getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID); - measurementDefinitionIds[i] = measurementDefinitionId; - } - return measurementDefinitionIds; - } - - private List<String> getMeasurementDefinitionDisplayNames( - AbstractMeasurementScheduleListView measurementScheduleListView) { - ListGrid listGrid = measurementScheduleListView.getListGrid(); - ListGridRecord[] records = listGrid.getSelection(); - List<String> displayNames = new ArrayList<String>(records.length); - for (ListGridRecord record : records) { - String displayName = record.getAttributeAsString(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME); - displayNames.add(displayName); - } - return displayNames; - } - - protected abstract void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval); -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java deleted file mode 100644 index 657f2b0..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleDataSource.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.common; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DSResponse; -import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.Record; -import com.smartgwt.client.data.fields.DataSourceBooleanField; -import com.smartgwt.client.data.fields.DataSourceIntegerField; -import com.smartgwt.client.data.fields.DataSourceTextField; -import com.smartgwt.client.rpc.RPCResponse; -import com.smartgwt.client.widgets.grid.ListGrid; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.measurement.MeasurementSchedule; -import org.rhq.core.domain.util.PageList; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; - -/** - * A server-side SmartGWT DataSource for reading and updating {@link MeasurementSchedule}s. - * - * @deprecated this class has been replaced by {@link AbstractMeasurementScheduleCompositeDataSource}, but - * I'm keeping it around in case we want to switch back to fetching schedules via criteria at - * some point. (ips, 10/06/10) - * - * @author Ian Springer - */ -@Deprecated -public abstract class AbstractMeasurementScheduleDataSource extends - RPCDataSource<MeasurementSchedule, MeasurementScheduleCriteria> { - private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); - - protected AbstractMeasurementScheduleDataSource() { - super(); - - setCanMultiSort(true); - - List<DataSourceField> fields = createFields(); - addFields(fields); - } - - protected List<DataSourceField> createFields() { - List<DataSourceField> fields = new ArrayList<DataSourceField>(); - - DataSourceIntegerField idField = new DataSourceIntegerField( - MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, MSG.common_title_id()); - idField.setPrimaryKey(true); - idField.setHidden(true); - fields.add(idField); - - DataSourceTextField nameField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, - MSG.common_title_metric()); - fields.add(nameField); - - DataSourceTextField descriptionField = new DataSourceTextField( - MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, MSG.common_title_description()); - fields.add(descriptionField); - - DataSourceTextField typeField = new DataSourceTextField(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, MSG - .common_title_type()); - fields.add(typeField); - - DataSourceBooleanField enabledField = new DataSourceBooleanField( - MeasurementScheduleCriteria.SORT_FIELD_ENABLED, MSG.common_title_enabled()); - fields.add(enabledField); - - DataSourceIntegerField intervalField = new DataSourceIntegerField( - MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, MSG.view_inventory_collectionInterval()); - fields.add(intervalField); - - return fields; - } - - protected void executeFetch(final DSRequest request, final DSResponse response, - final MeasurementScheduleCriteria criteria) { - final long startTime = System.currentTimeMillis(); - - this.measurementService.findMeasurementSchedulesByCriteria(criteria, - new AsyncCallback<PageList<MeasurementSchedule>>() { - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_loadFailedCriteria(criteria.toString()), caught); - response.setStatus(RPCResponse.STATUS_FAILURE); - processResponse(request.getRequestId(), response); - } - - public void onSuccess(PageList<MeasurementSchedule> result) { - long fetchDuration = System.currentTimeMillis() - startTime; - com.allen_sauer.gwt.log.client.Log.info(result.size() + " measurement schedules fetched in: " - + fetchDuration + "ms"); - - response.setData(buildRecords(result)); - // For paging to work, we have to specify size of full result set. - response.setTotalRows(result.getTotalSize()); - processResponse(request.getRequestId(), response); - } - }); - } - - @Override - protected MeasurementScheduleCriteria getFetchCriteria(DSRequest request) { - MeasurementScheduleCriteria criteria = new MeasurementScheduleCriteria(); - criteria.fetchDefinition(true); - - Criteria requestCriteria = request.getCriteria(); - if (requestCriteria != null) { - Map values = requestCriteria.getValues(); - for (Object key : values.keySet()) { - String fieldName = (String) key; - if (fieldName.equals(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID)) { - Integer resourceId = (Integer) values.get(fieldName); - criteria.addFilterResourceId(resourceId); - } else if (fieldName.equals(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID)) { - Integer resourceGroupId = (Integer) values.get(fieldName); - criteria.addFilterResourceGroupId(resourceGroupId); - } - // TODO: Add support for other fields we need to filter by (e.g. resourceTypeId for metric templates). - } - } - - criteria.setPageControl(getPageControl(request)); - return criteria; - } - - @Override - public MeasurementSchedule copyValues(Record from) { - return null; - } - - @Override - public ListGridRecord copyValues(MeasurementSchedule from) { - ListGridRecord record = new ListGridRecord(); - - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID, from.getDefinition().getId()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, from.getDefinition().getDisplayName()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION, from.getDefinition().getDescription()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE, from.getDefinition().getDataType().name() - .toLowerCase()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_ENABLED, from.isEnabled()); - record.setAttribute(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL, from.getInterval()); - - // TODO: resourceId and resourceGroupId (in subclasses) - - return record; - } - - public void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) { - int[] ids = getMeasurementDefinitionIds(measurementScheduleListView); - List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView); - enableSchedules(measurementScheduleListView, ids, displayNames); - measurementScheduleListView.refresh(); - } - - protected abstract void enableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, - int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames); - - public void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView) { - int[] ids = getMeasurementDefinitionIds(measurementScheduleListView); - List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView); - disableSchedules(measurementScheduleListView, ids, displayNames); - measurementScheduleListView.refresh(); - } - - protected abstract void disableSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, - int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames); - - public void updateSchedules(AbstractMeasurementScheduleListView measurementScheduleListView, long interval) { - int[] ids = getMeasurementDefinitionIds(measurementScheduleListView); - List<String> displayNames = getMeasurementDefinitionDisplayNames(measurementScheduleListView); - updateSchedules(measurementScheduleListView, ids, displayNames, interval); - measurementScheduleListView.refresh(); - } - - private int[] getMeasurementDefinitionIds(AbstractMeasurementScheduleListView measurementScheduleListView) { - ListGrid listGrid = measurementScheduleListView.getListGrid(); - ListGridRecord[] records = listGrid.getSelection(); - - int[] measurementDefinitionIds = new int[records.length]; - for (int i = 0, selectionLength = records.length; i < selectionLength; i++) { - ListGridRecord record = records[i]; - Integer measurementDefinitionId = record - .getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID); - measurementDefinitionIds[i] = measurementDefinitionId; - } - return measurementDefinitionIds; - } - - private List<String> getMeasurementDefinitionDisplayNames( - AbstractMeasurementScheduleListView measurementScheduleListView) { - ListGrid listGrid = measurementScheduleListView.getListGrid(); - ListGridRecord[] records = listGrid.getSelection(); - List<String> displayNames = new ArrayList<String>(records.length); - for (ListGridRecord record : records) { - String displayName = record.getAttributeAsString(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME); - displayNames.add(displayName); - } - return displayNames; - } - - protected abstract void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, List<String> measurementDefinitionDisplayNames, final long interval); -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java deleted file mode 100644 index 67d6556..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMeasurementScheduleListView.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.common; - -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.data.SortSpecifier; -import com.smartgwt.client.types.SortDirection; -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; - -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.enterprise.gui.coregui.client.components.table.BooleanCellFormatter; -import org.rhq.enterprise.gui.coregui.client.components.table.Table; -import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; - -/** - * A view that displays a non-paginated table of {@link org.rhq.core.domain.measurement.MeasurementSchedule measurement - * schedule}s, along with the ability to sort, enable, disable, or update the collection interval on those schedules. - * - * @author Ian Springer - */ -public abstract class AbstractMeasurementScheduleListView extends Table { - - private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] { new SortSpecifier( - MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, SortDirection.ASCENDING) }; - - public AbstractMeasurementScheduleListView(String locatorId, String title, - AbstractMeasurementScheduleCompositeDataSource dataSource, Criteria criteria, String[] excludedFieldNames) { - super(locatorId, title, criteria, SORT_SPECIFIERS, excludedFieldNames); - setDataSource(dataSource); - } - - public abstract boolean hasManageMeasurementsPermission(); - - @Override - public AbstractMeasurementScheduleCompositeDataSource getDataSource() { - return (AbstractMeasurementScheduleCompositeDataSource) super.getDataSource(); - } - - protected void configureTable() { - ListGrid listGrid = getListGrid(); - - // Set widths and cell formatters on the fields. - listGrid.getField(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME).setWidth("20%"); - listGrid.getField(MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION).setWidth("40%"); - listGrid.getField(MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE).setWidth("10%"); - ListGridField enabledField = listGrid.getField(MeasurementScheduleCriteria.SORT_FIELD_ENABLED); - enabledField.setWidth("10%"); - enabledField.setCellFormatter(new CollectionEnabledCellFormatter()); - ListGridField intervalField = listGrid.getField(MeasurementScheduleCriteria.SORT_FIELD_INTERVAL); - intervalField.setCellFormatter(new CollectionIntervalCellFormatter()); - intervalField.setWidth("25%"); - - // Add action buttons and widgets. - addTableAction(extendLocatorId("Enable"), MSG.common_button_enable(), null, new TableAction() { - public boolean isEnabled(ListGridRecord[] selection) { - return ((selection.length >= 1) && hasManageMeasurementsPermission()); - } - - public void executeAction(ListGridRecord[] selection, Object actionValue) { - getDataSource().enableSchedules(AbstractMeasurementScheduleListView.this); - } - }); - addTableAction(extendLocatorId("Disable"), MSG.common_button_disable(), null, new TableAction() { - public boolean isEnabled(ListGridRecord[] selection) { - return ((selection.length >= 1) && hasManageMeasurementsPermission()); - } - - public void executeAction(ListGridRecord[] selection, Object actionValue) { - getDataSource().disableSchedules(AbstractMeasurementScheduleListView.this); - } - }); - addExtraWidget(new UpdateCollectionIntervalWidget(this.getLocatorId(), this), true); - } - - protected class CollectionEnabledCellFormatter extends BooleanCellFormatter { - @Override - public String format(Object value, ListGridRecord record, int rowNum, int colNum) { - String result = super.format(value, record, rowNum, colNum); - return ("".equals(result)) ? MSG.view_inventory_mixed() : result; - } - } - - protected class CollectionIntervalCellFormatter implements CellFormatter { - - public String format(Object value, ListGridRecord record, int rowNum, int colNum) { - if (value == null) { - return MSG.view_inventory_mixed(); - } - - long milliseconds = ((Number) value).longValue(); - if (milliseconds == 0) { - return MSG.view_inventory_mixed(); - } - - StringBuilder result = new StringBuilder(); - if (milliseconds > 1000) { - long seconds = milliseconds / 1000; - milliseconds = milliseconds % 1000; - if (seconds >= 60) { - long minutes = seconds / 60; - seconds = seconds % 60; - if (minutes > 60) { - long hours = minutes / 60; - minutes = minutes % 60; - result.append(hours).append(" ").append(MSG.common_unit_hours()); - } - if (minutes != 0) { - if (result.length() != 0) { - result.append(", "); - } - result.append(minutes).append(" ").append(MSG.common_unit_minutes()); - } - } - if (seconds != 0) { - if (result.length() != 0) { - result.append(", "); - } - result.append(seconds).append(" ").append(MSG.common_unit_seconds()); - } - } - if (milliseconds != 0) { - if (result.length() != 0) { - result.append(", "); - } - result.append(milliseconds).append(" ").append(MSG.common_unit_milliseconds()); - } - return result.toString(); - } - - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractSchedulesView.java new file mode 100644 index 0000000..f5e4dbb --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractSchedulesView.java @@ -0,0 +1,158 @@ +/* + * RHQ Management Platform + * Copyright (C) 2012 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common; + +import java.util.ArrayList; +import java.util.List; + +import com.smartgwt.client.data.SortSpecifier; +import com.smartgwt.client.types.SortDirection; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; +import org.rhq.enterprise.gui.coregui.client.components.table.Table; +import org.rhq.enterprise.gui.coregui.client.components.table.TableAction; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; + +/** + * A view that displays a non-paginated table of {@link org.rhq.core.domain.measurement.MeasurementSchedule measurement + * schedule}s, along with the ability to sort, enable, disable, or update the collection interval on those schedules. + * + * @author Jay Shaughnessy + * @author Ian Springer + */ +public abstract class AbstractSchedulesView extends Table<SchedulesDataSource> { + + protected MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); + + private static final SortSpecifier[] SORT_SPECIFIERS = new SortSpecifier[] { new SortSpecifier( + MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME, SortDirection.ASCENDING) }; + + private EntityContext entityContext; + private boolean hasWriteAccess; + + protected SchedulesDataSource dataSource; + + public AbstractSchedulesView(String locatorId, String tableTitle, EntityContext entityContext, + boolean hasWriteAccess) { + + super(locatorId, tableTitle, SORT_SPECIFIERS); + this.entityContext = entityContext; + this.hasWriteAccess = hasWriteAccess; + + setDataSource(getDataSource()); + } + + @Override + public SchedulesDataSource getDataSource() { + if (null == this.dataSource) { + this.dataSource = new SchedulesDataSource(entityContext); + } + return this.dataSource; + } + + @Override + protected void configureTable() { + ArrayList<ListGridField> listGridFields = getDataSource().getListGridFields(); + getListGrid().setFields(listGridFields.toArray(new ListGridField[listGridFields.size()])); + setupTableInteractions(this.hasWriteAccess); + + super.configureTable(); + } + + protected void setupTableInteractions(final boolean hasWriteAccess) { + + addTableAction(extendLocatorId("Enable"), MSG.common_button_enable(), null, new TableAction() { + public boolean isEnabled(ListGridRecord[] selection) { + return ((selection.length >= 1) && hasWriteAccess); + } + + public void executeAction(ListGridRecord[] selection, Object actionValue) { + enableSchedules(); + } + }); + addTableAction(extendLocatorId("Disable"), MSG.common_button_disable(), null, new TableAction() { + public boolean isEnabled(ListGridRecord[] selection) { + return ((selection.length >= 1) && hasWriteAccess); + } + + public void executeAction(ListGridRecord[] selection, Object actionValue) { + disableSchedules(); + } + }); + addExtraWidget(new UpdateCollectionIntervalWidget(this.getLocatorId(), this), true); + } + + protected abstract void enableSchedules(int[] measurementDefinitionIds, + List<String> measurementDefinitionDisplayNames); + + protected abstract void disableSchedules(int[] measurementDefinitionIds, + List<String> measurementDefinitionDisplayNames); + + protected abstract void updateSchedules(final int[] measurementDefinitionIds, + List<String> measurementDefinitionDisplayNames, final long interval); + + public void disableSchedules() { + int[] ids = getMeasurementDefinitionIds(); + List<String> displayNames = getMeasurementDefinitionDisplayNames(); + disableSchedules(ids, displayNames); + } + + public void enableSchedules() { + int[] ids = getMeasurementDefinitionIds(); + List<String> displayNames = getMeasurementDefinitionDisplayNames(); + enableSchedules(ids, displayNames); + } + + public void updateSchedules(long interval) { + int[] ids = getMeasurementDefinitionIds(); + List<String> displayNames = getMeasurementDefinitionDisplayNames(); + updateSchedules(ids, displayNames, interval); + } + + private int[] getMeasurementDefinitionIds() { + ListGridRecord[] records = getListGrid().getSelectedRecords(); + + int[] measurementDefinitionIds = new int[records.length]; + for (int i = 0, selectionLength = records.length; i < selectionLength; i++) { + ListGridRecord record = records[i]; + Integer measurementDefinitionId = record + .getAttributeAsInt(MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID); + measurementDefinitionIds[i] = measurementDefinitionId; + } + return measurementDefinitionIds; + } + + private List<String> getMeasurementDefinitionDisplayNames() { + ListGridRecord[] records = getListGrid().getSelectedRecords(); + List<String> displayNames = new ArrayList<String>(records.length); + for (ListGridRecord record : records) { + String displayName = record.getAttributeAsString(MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME); + displayNames.add(displayName); + } + return displayNames; + } + + public boolean hasWriteAccess() { + return hasWriteAccess; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/SchedulesDataSource.java new file mode 100644 index 0000000..e73cb66 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/SchedulesDataSource.java @@ -0,0 +1,212 @@ +/* + * RHQ Management Platform + * Copyright (C) 2012 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common; + +import java.util.ArrayList; + +import com.google.gwt.user.client.rpc.AsyncCallback; +import com.smartgwt.client.data.DSRequest; +import com.smartgwt.client.data.DSResponse; +import com.smartgwt.client.data.Record; +import com.smartgwt.client.rpc.RPCResponse; +import com.smartgwt.client.widgets.grid.CellFormatter; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.ListGridRecord; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.criteria.Criteria; +import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; +import org.rhq.core.domain.util.PageList; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.components.table.BooleanCellFormatter; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; +import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource; + +/** + * A server-side SmartGWT DataSource for reading and updating {@link MeasurementScheduleComposite}s. + * + * @author JayShaughnessy + * @author Ian Springer + */ +public class SchedulesDataSource extends RPCDataSource<MeasurementScheduleComposite, Criteria> { + + public static final String ATTR_ID = "id"; + public static final String ATTR_DATA_TYPE = MeasurementScheduleCriteria.SORT_FIELD_DATA_TYPE; + public static final String ATTR_DEFINITION_ID = MeasurementScheduleCriteria.SORT_FIELD_DEFINITION_ID; + public static final String ATTR_DESCRIPTION = MeasurementScheduleCriteria.SORT_FIELD_DESCRIPTION; + public static final String ATTR_DISPLAY_NAME = MeasurementScheduleCriteria.SORT_FIELD_DISPLAY_NAME; + public static final String ATTR_ENABLED = MeasurementScheduleCriteria.SORT_FIELD_ENABLED; + public static final String ATTR_INTERVAL = MeasurementScheduleCriteria.SORT_FIELD_INTERVAL; + + private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); + + protected EntityContext entityContext; + + public SchedulesDataSource() { + this(EntityContext.forSubsystemView()); + } + + public SchedulesDataSource(EntityContext entityContext) { + this.entityContext = entityContext; + addDataSourceFields(); + } + + /** + * The view that contains the list grid which will display this datasource's data will call this + * method to get the field information which is used to control the display of the data. + * + * @return list grid fields used to display the datasource data + */ + public ArrayList<ListGridField> getListGridFields() { + ArrayList<ListGridField> fields = new ArrayList<ListGridField>(); + + ListGridField displayNameField = new ListGridField(ATTR_DISPLAY_NAME, MSG.common_title_metric()); + fields.add(displayNameField); + + ListGridField descriptionField = new ListGridField(ATTR_DESCRIPTION, MSG.common_title_description()); + fields.add(descriptionField); + + ListGridField typeField = new ListGridField(ATTR_DATA_TYPE, MSG.common_title_type()); + fields.add(typeField); + + ListGridField enabledField = new ListGridField(ATTR_ENABLED, MSG.common_title_enabled()); + enabledField.setCellFormatter(new CollectionEnabledCellFormatter()); + fields.add(enabledField); + + ListGridField intervalField = new ListGridField(ATTR_INTERVAL, MSG.view_inventory_collectionInterval()); + intervalField.setCellFormatter(new CollectionIntervalCellFormatter()); + fields.add(intervalField); + + displayNameField.setWidth("20%"); + descriptionField.setWidth("40%"); + typeField.setWidth("10%"); + enabledField.setWidth("10%"); + intervalField.setWidth("*"); + + return fields; + } + + @Override + protected Criteria getFetchCriteria(DSRequest request) { + // we don't use criterias for this datasource, just return null + return null; + } + + @Override + protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) { + + this.measurementService.getMeasurementScheduleCompositesByContext(entityContext, + new AsyncCallback<PageList<MeasurementScheduleComposite>>() { + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_loadFailedContext(entityContext.toString()), caught); + response.setStatus(RPCResponse.STATUS_FAILURE); + processResponse(request.getRequestId(), response); + } + + public void onSuccess(PageList<MeasurementScheduleComposite> result) { + response.setData(buildRecords(result)); + // For paging to work, we have to specify size of full result set. + response.setTotalRows(result.getTotalSize()); + processResponse(request.getRequestId(), response); + } + }); + } + + @Override + public MeasurementScheduleComposite copyValues(Record from) { + return null; + } + + @Override + public ListGridRecord copyValues(MeasurementScheduleComposite from) { + + ListGridRecord record = new ListGridRecord(); + MeasurementDefinition measurementDefinition = from.getMeasurementDefinition(); + + record.setAttribute(ATTR_DEFINITION_ID, measurementDefinition.getId()); + record.setAttribute(ATTR_DISPLAY_NAME, measurementDefinition.getDisplayName()); + record.setAttribute(ATTR_DESCRIPTION, measurementDefinition.getDescription()); + record.setAttribute(ATTR_DATA_TYPE, measurementDefinition.getDataType().name().toLowerCase()); + record.setAttribute(ATTR_ENABLED, from.getCollectionEnabled()); + record.setAttribute(ATTR_INTERVAL, from.getCollectionInterval()); + + return record; + } + + protected class CollectionEnabledCellFormatter extends BooleanCellFormatter { + @Override + public String format(Object value, ListGridRecord record, int rowNum, int colNum) { + String result = super.format(value, record, rowNum, colNum); + return ("".equals(result)) ? MSG.view_inventory_mixed() : result; + } + } + + protected class CollectionIntervalCellFormatter implements CellFormatter { + + public String format(Object value, ListGridRecord record, int rowNum, int colNum) { + if (value == null) { + return MSG.view_inventory_mixed(); + } + + long milliseconds = ((Number) value).longValue(); + if (milliseconds == 0) { + return MSG.view_inventory_mixed(); + } + + StringBuilder result = new StringBuilder(); + if (milliseconds > 1000) { + long seconds = milliseconds / 1000; + milliseconds = milliseconds % 1000; + if (seconds >= 60) { + long minutes = seconds / 60; + seconds = seconds % 60; + if (minutes > 60) { + long hours = minutes / 60; + minutes = minutes % 60; + result.append(hours).append(" ").append(MSG.common_unit_hours()); + } + if (minutes != 0) { + if (result.length() != 0) { + result.append(", "); + } + result.append(minutes).append(" ").append(MSG.common_unit_minutes()); + } + } + if (seconds != 0) { + if (result.length() != 0) { + result.append(", "); + } + result.append(seconds).append(" ").append(MSG.common_unit_seconds()); + } + } + if (milliseconds != 0) { + if (result.length() != 0) { + result.append(", "); + } + result.append(milliseconds).append(" ").append(MSG.common_unit_milliseconds()); + } + return result.toString(); + } + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java index 2a84944..93ee444 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/UpdateCollectionIntervalWidget.java @@ -60,11 +60,11 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements VALUE_MAP.put(UNITS_HOURS, MSG.common_unit_hours()); }
- private AbstractMeasurementScheduleListView schedulesView; + private AbstractSchedulesView schedulesView; private DynamicForm form; private LocatableButton setButton;
- public UpdateCollectionIntervalWidget(String locatorId, AbstractMeasurementScheduleListView schedulesView) { + public UpdateCollectionIntervalWidget(String locatorId, AbstractSchedulesView schedulesView) { super(locatorId); this.schedulesView = schedulesView; } @@ -110,7 +110,7 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements } });
- if (!schedulesView.hasManageMeasurementsPermission()) { + if (!schedulesView.hasWriteAccess()) { intervalItem.setDisabled(true); unitsItem.setDisabled(true); } @@ -124,8 +124,7 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements public void onClick(ClickEvent clickEvent) { if (form.validate()) { UpdateCollectionIntervalWidget.this.schedulesView.disableAllFooterControls(); - UpdateCollectionIntervalWidget.this.schedulesView.getDataSource().updateSchedules( - UpdateCollectionIntervalWidget.this.schedulesView, getInterval()); + UpdateCollectionIntervalWidget.this.schedulesView.updateSchedules(getInterval()); } } }); @@ -138,7 +137,7 @@ public class UpdateCollectionIntervalWidget extends LocatableHLayout implements public void refresh(ListGrid listGrid) { if (isDrawn()) { boolean isValid = this.form.validate(); - int count = listGrid.getSelection().length; + int count = listGrid.getSelectedRecords().length; Long interval = getInterval(); this.setButton.setDisabled(!isValid || count == 0 || interval == null); } else { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java index 0085454..fbc12cd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java @@ -61,7 +61,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.configurati import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.GroupPluginConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.HistoryGroupPluginConfigurationView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.MembersView; -import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView; +import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.ResourceGroupSchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.table.GroupMonitoringTablesView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.history.GroupOperationHistoryListView; @@ -329,7 +329,7 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource viewFactory = (!visible) ? null : new ViewFactory() { @Override public Canvas createView() { - return new SchedulesView(monitorSched.extendLocatorId("View"), groupComposite); + return new ResourceGroupSchedulesView(monitorSched.extendLocatorId("View"), groupComposite); } }; updateSubTab(this.monitoringTab, this.monitorSched, visible, true, viewFactory); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/ResourceGroupSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/ResourceGroupSchedulesView.java new file mode 100644 index 0000000..001cd91 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/ResourceGroupSchedulesView.java @@ -0,0 +1,139 @@ +/* + * RHQ Management Platform + * Copyright (C) 2012 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules; + +import java.util.List; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractSchedulesView; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; + +/** + * The group Monitoring>Schedules subtab. + * + * @author Jay Shaughnessy + * @author Ian Springer + */ +public class ResourceGroupSchedulesView extends AbstractSchedulesView { + + private static final String TITLE = MSG.view_group_meas_schedules_title(); + + private ResourceGroupComposite resourceGroupComposite; + private int groupId; + + public ResourceGroupSchedulesView(String locatorId, ResourceGroupComposite resourceGroupComposite) { + super(locatorId, TITLE, EntityContext.forGroup(resourceGroupComposite.getResourceGroup().getId()), + resourceGroupComposite.getResourcePermission().isMeasure()); + + this.resourceGroupComposite = resourceGroupComposite; + this.groupId = resourceGroupComposite.getResourceGroup().getId(); + } + + @Override + protected void enableSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames) { + + this.measurementService.enableSchedulesForCompatibleGroup(this.groupId, measurementDefinitionIds, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_enableFailure_group(String.valueOf(measurementDefinitionIds.length), + String.valueOf(groupId), measurementDefinitionDisplayNames.toString()), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.dataSource_schedules_enableSuccessful_concise(String + .valueOf(measurementDefinitionIds.length)), MSG + .dataSource_schedules_enableSuccessful_full_group( + String.valueOf(measurementDefinitionIds.length), String.valueOf(groupId), + measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); + refresh(); + } + }); + } + + @Override + protected void disableSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames) { + + this.measurementService.disableSchedulesForCompatibleGroup(this.groupId, measurementDefinitionIds, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_disableFailure_group(String.valueOf(measurementDefinitionIds.length), + String.valueOf(groupId), measurementDefinitionDisplayNames.toString()), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.dataSource_schedules_disableSuccessful_concise(String + .valueOf(measurementDefinitionIds.length)), MSG + .dataSource_schedules_disableSuccessful_full_group( + String.valueOf(measurementDefinitionIds.length), String.valueOf(groupId), + measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); + refresh(); + } + }); + } + + @Override + protected void updateSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames, final long collectionInterval) { + + this.measurementService.updateSchedulesForCompatibleGroup(this.groupId, measurementDefinitionIds, + collectionInterval, new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_updateFailure_group(String.valueOf(measurementDefinitionIds.length), + String.valueOf(groupId), measurementDefinitionDisplayNames.toString(), + String.valueOf(collectionInterval / 1000)), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + String collIntervalStr = String.valueOf(collectionInterval / 1000); + CoreGUI.getMessageCenter().notify( + new Message(MSG.dataSource_schedules_updateSuccessful_concise(collIntervalStr, + String.valueOf(measurementDefinitionIds.length)), MSG + .dataSource_schedules_updateSuccessful_full_group(collIntervalStr, + String.valueOf(measurementDefinitionIds.length), String.valueOf(groupId), + measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); + refresh(); + } + }); + } + + public ResourceGroupComposite getResourceGroupComposite() { + return resourceGroupComposite; + } + + public int getGroupId() { + return groupId; + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java deleted file mode 100644 index c21484d..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010-2011 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules; - -import java.util.List; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.fields.DataSourceIntegerField; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleCompositeDataSource; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -/** - * A DataSource for reading and updating the metric schedules for the current group. - * - * @author Ian Springer - */ -public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDataSource { - - // Specify 60s timeout to compensate for schedule updates taking a long time for large groups. - // TODO (ips, 08/31/11): Remove this once updating of group schedules has been optimized. - private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(60 * 1000); - private int resourceGroupId; - - public SchedulesDataSource(int resourceGroupId) { - this.resourceGroupId = resourceGroupId; - } - - @Override - protected List<DataSourceField> addDataSourceFields() { - List<DataSourceField> fields = super.addDataSourceFields(); - - DataSourceField resourceGroupIdField = new DataSourceIntegerField( - MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID, MSG - .dataSource_schedules_field_resourceGroupId()); - resourceGroupIdField.setHidden(true); - fields.add(resourceGroupIdField); - - return fields; - } - - @Override - protected EntityContext getEntityContext(DSRequest request) { - Criteria requestCriteria = request.getCriteria(); - Integer groupId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID); - return EntityContext.forGroup(groupId); - } - - @Override - public ListGridRecord copyValues(MeasurementScheduleComposite from) { - ListGridRecord record = super.copyValues(from); - record.setAttribute(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID, this.resourceGroupId); - return record; - } - - @Override - protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { - - this.measurementService.enableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_enableFailure_group(String.valueOf(measurementDefinitionIds.length), - String.valueOf(resourceGroupId), measurementDefinitionDisplayNames.toString()), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.dataSource_schedules_enableSuccessful_concise(String - .valueOf(measurementDefinitionIds.length)), MSG - .dataSource_schedules_enableSuccessful_full_group(String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceGroupId), - measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - - @Override - protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { - - this.measurementService.disableSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_disableFailure_group(String.valueOf(measurementDefinitionIds.length), - String.valueOf(resourceGroupId), measurementDefinitionDisplayNames.toString()), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.dataSource_schedules_disableSuccessful_concise(String - .valueOf(measurementDefinitionIds.length)), MSG - .dataSource_schedules_disableSuccessful_full_group(String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceGroupId), - measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - - @Override - protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, - final long collectionInterval) { - - this.measurementService.updateSchedulesForCompatibleGroup(this.resourceGroupId, measurementDefinitionIds, - collectionInterval, new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_updateFailure_group(String.valueOf(measurementDefinitionIds.length), - String.valueOf(resourceGroupId), measurementDefinitionDisplayNames.toString(), String - .valueOf(collectionInterval / 1000)), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - String collIntervalStr = String.valueOf(collectionInterval / 1000); - CoreGUI.getMessageCenter().notify( - new Message(MSG.dataSource_schedules_updateSuccessful_concise(collIntervalStr, String - .valueOf(measurementDefinitionIds.length)), MSG - .dataSource_schedules_updateSuccessful_full_group(collIntervalStr, String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceGroupId), - measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesView.java deleted file mode 100644 index bd8d36d..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesView.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules; - -import com.smartgwt.client.data.Criteria; - -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView; - -/** - * The group Monitoring>Schedules subtab. - * - * @author Ian Springer - */ -public class SchedulesView extends AbstractMeasurementScheduleListView { - - private static final String TITLE = MSG.view_group_meas_schedules_title(); - private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID }; - - private ResourceGroupComposite resourceGroupComposite; - - public SchedulesView(String locatorId, ResourceGroupComposite resourceGroupComposite) { - super(locatorId, TITLE, new SchedulesDataSource(resourceGroupComposite.getResourceGroup().getId()), - createCriteria(resourceGroupComposite.getResourceGroup().getId()), EXCLUDED_FIELD_NAMES); - - this.resourceGroupComposite = resourceGroupComposite; - } - - public boolean hasManageMeasurementsPermission() { - return this.resourceGroupComposite.getResourcePermission().isMeasure(); - } - - private static Criteria createCriteria(int resourceGroupId) { - Criteria criteria = new Criteria(); - criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_GROUP_ID, resourceGroupId); - return criteria; - } - -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java index e17575e..3205d28 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java @@ -64,7 +64,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configura import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationEditView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.PluginConfigurationHistoryListView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceResourceAgentView; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.ResourceSchedulesView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.table.MeasurementTableView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView; @@ -440,7 +440,7 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo new ViewFactory() { @Override public Canvas createView() { - return new SchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resourceComposite); + return new ResourceSchedulesView(monitoringTab.extendLocatorId("SchedulesView"), resourceComposite); } });
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/ResourceSchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/ResourceSchedulesView.java new file mode 100644 index 0000000..8690d23 --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/ResourceSchedulesView.java @@ -0,0 +1,143 @@ +/* + * RHQ Management Platform + * Copyright (C) 2012 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules; + +import java.util.List; + +import com.google.gwt.user.client.rpc.AsyncCallback; + +import org.rhq.core.domain.common.EntityContext; +import org.rhq.core.domain.resource.composite.ResourceComposite; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractSchedulesView; +import org.rhq.enterprise.gui.coregui.client.util.message.Message; + +/** + * The Resource Monitoring>Schedules subtab. + * + * @author Jay Shaughnessy + * @author Ian Springer + */ +public class ResourceSchedulesView extends AbstractSchedulesView { + + private static final String TITLE = MSG.view_resource_monitor_schedules_title(); + + private ResourceComposite resourceComposite; + private int resourceId; + + public ResourceSchedulesView(String locatorId, ResourceComposite resourceComposite) { + super(locatorId, TITLE, EntityContext.forResource(resourceComposite.getResource().getId()), resourceComposite + .getResourcePermission().isMeasure()); + + this.resourceComposite = resourceComposite; + this.resourceId = resourceComposite.getResource().getId(); + } + + @Override + protected void enableSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames) { + + measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_enableFailure_resource( + String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), + measurementDefinitionDisplayNames.toString()), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.dataSource_schedules_enableSuccessful_concise(String + .valueOf(measurementDefinitionIds.length)), MSG + .dataSource_schedules_enableSuccessful_full_resource( + String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), + measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); + refresh(); + } + }); + } + + @Override + protected void disableSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames) { + + measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_disableFailure_resource( + String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), + measurementDefinitionDisplayNames.toString()), throwable); + } + + @Override + public void onSuccess(Void aVoid) { + CoreGUI.getMessageCenter().notify( + new Message(MSG.dataSource_schedules_disableSuccessful_concise(String + .valueOf(measurementDefinitionIds.length)), MSG + .dataSource_schedules_disableSuccessful_full_resource( + String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), + measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); + refresh(); + } + }); + } + + @Override + protected void updateSchedules(final int[] measurementDefinitionIds, + final List<String> measurementDefinitionDisplayNames, final long collectionInterval) { + + measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds, collectionInterval, + new AsyncCallback<Void>() { + @Override + public void onFailure(Throwable throwable) { + CoreGUI.getErrorHandler().handleError( + MSG.dataSource_schedules_updateFailure_resource( + String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), + measurementDefinitionDisplayNames.toString(), String.valueOf(collectionInterval / 1000)), + throwable); + } + + @Override + public void onSuccess(Void aVoid) { + String collIntervalStr = String.valueOf(collectionInterval / 1000); + CoreGUI.getMessageCenter().notify( + new Message(MSG.dataSource_schedules_updateSuccessful_concise(collIntervalStr, + String.valueOf(measurementDefinitionIds.length)), MSG + .dataSource_schedules_updateSuccessful_full_resource(collIntervalStr, + String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), + measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); + refresh(); + } + }); + } + + public ResourceComposite getResourceComposite() { + return resourceComposite; + } + + public int getResourceId() { + return resourceId; + } + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java deleted file mode 100644 index c131931..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesDataSource.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules; - -import java.util.List; - -import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.data.Criteria; -import com.smartgwt.client.data.DSRequest; -import com.smartgwt.client.data.DataSourceField; -import com.smartgwt.client.data.fields.DataSourceIntegerField; -import com.smartgwt.client.widgets.grid.ListGridRecord; - -import org.rhq.core.domain.common.EntityContext; -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.measurement.composite.MeasurementScheduleComposite; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.MeasurementDataGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleCompositeDataSource; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView; -import org.rhq.enterprise.gui.coregui.client.util.message.Message; - -/** - * A DataSource for reading and updating the metric schedules for the current Resource. - * - * @author Ian Springer - */ -public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDataSource { - private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); - private int resourceId; - - public SchedulesDataSource(int resourceId) { - this.resourceId = resourceId; - } - - @Override - protected List<DataSourceField> addDataSourceFields() { - List<DataSourceField> fields = super.addDataSourceFields(); - - DataSourceField resourceIdField = new DataSourceIntegerField( - MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID, MSG.common_title_resource_id()); - resourceIdField.setHidden(true); - fields.add(resourceIdField); - - return fields; - } - - @Override - protected EntityContext getEntityContext(DSRequest request) { - Criteria requestCriteria = request.getCriteria(); - Integer resourceId = requestCriteria.getAttributeAsInt(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID); - return EntityContext.forResource(resourceId); - } - - @Override - public ListGridRecord copyValues(MeasurementScheduleComposite from) { - ListGridRecord record = super.copyValues(from); - record.setAttribute(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID, this.resourceId); - return record; - } - - @Override - protected void enableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { - this.measurementService.enableSchedulesForResource(this.resourceId, measurementDefinitionIds, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_enableFailure_resource( - String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), - measurementDefinitionDisplayNames.toString()), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.dataSource_schedules_enableSuccessful_concise(String - .valueOf(measurementDefinitionIds.length)), MSG - .dataSource_schedules_enableSuccessful_full_resource(String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), - measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - - @Override - protected void disableSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames) { - this.measurementService.disableSchedulesForResource(this.resourceId, measurementDefinitionIds, - new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_disableFailure_resource(String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), - measurementDefinitionDisplayNames.toString()), throwable); - } - - @Override - public void onSuccess(Void aVoid) { - CoreGUI.getMessageCenter().notify( - new Message(MSG.dataSource_schedules_disableSuccessful_concise(String - .valueOf(measurementDefinitionIds.length)), MSG - .dataSource_schedules_disableSuccessful_full_resource(String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), - measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } - - @Override - protected void updateSchedules(final AbstractMeasurementScheduleListView measurementScheduleListView, - final int[] measurementDefinitionIds, final List<String> measurementDefinitionDisplayNames, - final long collectionInterval) { - this.measurementService.updateSchedulesForResource(this.resourceId, measurementDefinitionIds, - collectionInterval, new AsyncCallback<Void>() { - @Override - public void onFailure(Throwable throwable) { - CoreGUI.getErrorHandler().handleError( - MSG.dataSource_schedules_updateFailure_resource( - String.valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), - measurementDefinitionDisplayNames.toString(), String.valueOf(collectionInterval / 1000)), - throwable); - } - - @Override - public void onSuccess(Void aVoid) { - String collIntervalStr = String.valueOf(collectionInterval / 1000); - CoreGUI.getMessageCenter().notify( - new Message(MSG.dataSource_schedules_updateSuccessful_concise(collIntervalStr, String - .valueOf(measurementDefinitionIds.length)), MSG - .dataSource_schedules_updateSuccessful_full_resource(collIntervalStr, String - .valueOf(measurementDefinitionIds.length), String.valueOf(resourceId), - measurementDefinitionDisplayNames.toString()), Message.Severity.Info)); - measurementScheduleListView.refresh(); - } - }); - } -} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesView.java deleted file mode 100644 index 46ef463..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/schedules/SchedulesView.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2010 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules; - -import com.smartgwt.client.data.Criteria; - -import org.rhq.core.domain.criteria.MeasurementScheduleCriteria; -import org.rhq.core.domain.resource.composite.ResourceComposite; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMeasurementScheduleListView; - -/** - * The Resource Monitoring>Schedules subtab. - * - * @author Ian Springer - */ -public class SchedulesView extends AbstractMeasurementScheduleListView { - - private static final String TITLE = MSG.view_resource_monitor_schedules_title(); - private static final String[] EXCLUDED_FIELD_NAMES = new String[] { MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID }; - - private ResourceComposite resourceComposite; - - public SchedulesView(String locatorId, ResourceComposite resourceComposite) { - super(locatorId, TITLE, new SchedulesDataSource(resourceComposite.getResource().getId()), - createCriteria(resourceComposite.getResource().getId()), EXCLUDED_FIELD_NAMES); - - this.resourceComposite = resourceComposite; - } - - public boolean hasManageMeasurementsPermission() { - return resourceComposite.getResourcePermission().isMeasure(); - } - - private static Criteria createCriteria(int resourceId) { - Criteria criteria = new Criteria(); - criteria.addCriteria(MeasurementScheduleCriteria.FILTER_FIELD_RESOURCE_ID, resourceId); - return criteria; - } - -}
commit fdbf54ac94317d69343132281c1bdd82632a8658 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Jan 13 14:46:19 2012 -0500
update Eclipse .classpath with gwt/smartgw upgrades
diff --git a/.classpath b/.classpath index 24fb54d..f8d0aa3 100644 --- a/.classpath +++ b/.classpath @@ -101,10 +101,10 @@ <classpathentry exported="true" kind="var" path="M2_REPO/org/libvirt/libvirt/0.4.1/libvirt-0.4.1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/jboss/byteman/byteman/1.2.1/byteman-1.2.1.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/org/fedorahosted/cobbler/cobbler4j/0.1/cobbler4j-0.1.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/com/google/gwt/gwt-user/2.0.4/gwt-user-2.0.4.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/com/google/gwt/gwt-dev/2.0.4/gwt-dev-2.0.4.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/2.4/smartgwt-2.4.jar"/> - <classpathentry exported="true" kind="var" path="M2_REPO/com/google/code/gwt-log/gwt-log/3.0.4/gwt-log-3.0.4.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/com/google/gwt/gwt-user/2.4.0/gwt-user-2.4.0.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/com/google/gwt/gwt-dev/2.4.0/gwt-dev-2.4.0.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/com/smartgwt/smartgwt/3.0/smartgwt-3.0.jar"/> + <classpathentry exported="true" kind="var" path="M2_REPO/com/google/code/gwt-log/gwt-log/3.1.0/gwt-log-3.1.0.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/ca/nanometrics/gflot/1.0.0/gflot-1.0.0.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/com/jcraft/jsch/0.1.29/jsch-0.1.29.jar"/> <classpathentry exported="true" kind="var" path="M2_REPO/commons-jxpath/commons-jxpath/1.3/commons-jxpath-1.3.jar"/>
commit c0477cba10be31a9236ca82855d2eba98c62bce8 Author: Jay Shaughnessy jshaughn@redhat.com Date: Fri Jan 13 14:44:49 2012 -0500
Add <soyc> element to help optimize gwt compiles. By default don't optimize.
diff --git a/modules/enterprise/gui/coregui/pom.xml b/modules/enterprise/gui/coregui/pom.xml index 4d0fced..bcd909f 100644 --- a/modules/enterprise/gui/coregui/pom.xml +++ b/modules/enterprise/gui/coregui/pom.xml @@ -59,6 +59,10 @@ up gwt compilation. --> <gwt.draftCompile>false</gwt.draftCompile>
+ <!-- Change this to "false" via the mvn command line or your ~/.m2/settings.xml to speed + up gwt compilation and reduce memory consumption by avoiding report generation. --> + <gwt.soyc>true</gwt.soyc> + <!-- Comma-separated list of the locales that should be included during GWT compilation. The specified locales should each have two corresponding message bundle properties files under src/main/resources/org/rhq/enterprise/gui/coregui/client/. For example, the "ja" locale has @@ -274,6 +278,7 @@ <extraJvmArgs>${gwt-plugin.extraJvmArgs}</extraJvmArgs> <localWorkers>${gwt-plugin.localWorkers}</localWorkers> <draftCompile>${gwt.draftCompile}</draftCompile> + <soyc>${gwt.soyc}</soyc> <buildOutputDirectory>target/gwtclasses</buildOutputDirectory> <hostedWebapp>target/hostedWar</hostedWebapp> <debugSuspend>false</debugSuspend>
rhq-commits@lists.fedorahosted.org