modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
| 12
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
| 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
| 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java
| 394 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java
| 48
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java
| 356 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
| 530 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
| 357 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
| 81 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
| 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
| 447 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
| 179 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
| 314 -----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
| 25
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
| 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
| 78 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 5
21 files changed, 1558 insertions(+), 1322 deletions(-)
New commits:
commit 308b5785caa567a4b7770a33c8c16d8c7f181ac7
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 6 17:17:31 2011 -0400
More Op portlet tweaks
- Remove ID column for op hist views
- Fix result size issue for op schedule portlet
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
index a9a1c3f..eec9831 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
@@ -123,10 +123,6 @@ public class OperationHistoryDataSource extends
public ArrayList<ListGridField> getListGridFields() {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);
- ListGridField idField = new ListGridField(Field.ID, MSG.common_title_id());
- idField.setWidth(70);
- fields.add(idField);
-
ListGridField startTimeField = createStartedTimeField();
fields.add(startTimeField);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index d7bfdad..fca0e8f 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -212,7 +212,13 @@ public class ScheduledOperationsDataSource extends
RPCDataSource<ResourceOperati
record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE,
AncestryUtil.getAncestryValue(record));
}
response.setData(records);
- response.setTotalRows(result.getTotalSize()); // for paging to work we
have to specify size of full result set
+ // for paging to work we have to specify size of full result set, but if
a limit has been set,
+ // respect the limit
+ int resultSize = result.getTotalSize();
+ if (operationsRangeScheduled > 0 && operationsRangeScheduled
< resultSize) {
+ resultSize = operationsRangeScheduled;
+ }
+ response.setTotalRows(resultSize);
processResponse(request.getRequestId(), response);
}
});
commit 88e888b07dd22fe7155a7993d5a6b3f9a38ddb64
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Wed Apr 6 16:11:59 2011 -0400
Work on Operation History Portlets and Views
- Fixed issues in Operation portlets but went a bit further and normalized
all of the resource operation history views. So, the report view, global
portlet, resource portlet, and resource detail views now share the same
underlying code, normalizing presentation and consolidating fixes. The
config is more advanced for the global portlet as it now shares what
was in place for the resource level portlet.
- Split global operations portlet into two portlets: Recent Operations and
Scheduled Operations. Only Recent Operations is now on the default dash.
This saves some space in the dash, gives the user more options, and
is more clear as the configuration is different for each view.
- The new scheduled operations portlet fixes some legacy issues for the
scheduled ops from the original portlet.
- Added status filtering to non-portlet history views
- Fixed a bug preventing navigation to th operation schedule detail view for
readonly situations.
Note that due to the difficulty of the operation *schedule* data model and
the fewer number of related views, similar refactoring was not carried out
and the views may not be normalized. Also, group op history was not
affected as the views for group history in general are probably going to
be revised.
- Fixes overall spanned links, hover, ordering, buttin enablement, etc.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
index 2a6beeb..e4ed6f0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LinkManager.java
@@ -152,6 +152,18 @@ public class LinkManager {
return link;
}
+ public static String getSubsystemResourceOperationScheduleLink(int resourceId, int
opScheduleId) {
+ String link;
+ if (GWT) {
+ link = "#Resource/" + resourceId +
"/Operations/Schedules/" + opScheduleId;
+ } else {
+ link =
"/rhq/resource/operation/resourceOperationScheduleDetails-plain.xhtml?id=" +
resourceId + "&opId="
+ + opScheduleId;
+
+ }
+ return link;
+ }
+
public static String getSubsystemAlertHistoryLink(int resourceId, int alertHistoryId)
{
String link;
if (GWT) {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
index d72abbf..7d0ec7a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/DashboardsView.java
@@ -62,7 +62,7 @@ import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.NamedTabSet;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationHistoryPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.summary.InventorySummaryPortlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.util.MashupPortlet;
@@ -390,12 +390,8 @@ public class DashboardsView extends LocatableVLayout implements
DashboardContain
ProblemResourcesPortlet.defaultValue));
dashboard.addPortlet(problemResources, 1, 1);
- DashboardPortlet operations = new DashboardPortlet(OperationsPortlet.NAME,
OperationsPortlet.KEY, 350);
- //initialize config for the operations portlet.
- operations.getConfiguration().put(
- new PropertySimple(OperationsPortlet.OPERATIONS_RANGE_COMPLETED,
OperationsPortlet.defaultValue));
- operations.getConfiguration().put(
- new PropertySimple(OperationsPortlet.OPERATIONS_RANGE_SCHEDULED,
OperationsPortlet.defaultValue));
+ DashboardPortlet operations = new DashboardPortlet(OperationHistoryPortlet.NAME,
OperationHistoryPortlet.KEY,
+ 200);
dashboard.addPortlet(operations, 1, 2);
return dashboard;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
index 2ccb582..7b23c0a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/PortletFactory.java
@@ -45,7 +45,8 @@ import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resour
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.alerts.RecentAlertsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.imported.RecentlyAddedResourcesPortlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationHistoryPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationSchedulePortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.problems.ProblemResourcesPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceAlertsPortlet;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource.ResourceBundleDeploymentsPortlet;
@@ -96,7 +97,8 @@ public class PortletFactory {
registeredPortletFactoryMap.put(MashupPortlet.KEY,
MashupPortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(MessagePortlet.KEY,
MessagePortlet.Factory.INSTANCE);
registeredPortletFactoryMap.put(ProblemResourcesPortlet.KEY,
ProblemResourcesPortlet.Factory.INSTANCE);
- registeredPortletFactoryMap.put(OperationsPortlet.KEY,
OperationsPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(OperationHistoryPortlet.KEY,
OperationHistoryPortlet.Factory.INSTANCE);
+ registeredPortletFactoryMap.put(OperationSchedulePortlet.KEY,
OperationSchedulePortlet.Factory.INSTANCE);
// defines portlet name mappings for global Dashboard
registeredPortletNameMap = new HashMap<String,
String>(registeredPortletFactoryMap.size());
@@ -112,7 +114,8 @@ public class PortletFactory {
registeredPortletNameMap.put(MashupPortlet.KEY, MashupPortlet.NAME);
registeredPortletNameMap.put(MessagePortlet.KEY, MessagePortlet.NAME);
registeredPortletNameMap.put(ProblemResourcesPortlet.KEY,
ProblemResourcesPortlet.NAME);
- registeredPortletNameMap.put(OperationsPortlet.KEY, OperationsPortlet.NAME);
+ registeredPortletNameMap.put(OperationHistoryPortlet.KEY,
OperationHistoryPortlet.NAME);
+ registeredPortletNameMap.put(OperationSchedulePortlet.KEY,
OperationSchedulePortlet.NAME);
//############## Group Activity Dashboard
############################################
//defines mapping for Group Activity Dashboard
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java
new file mode 100644
index 0000000..77b8af8
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/AbstractOperationHistoryPortlet.java
@@ -0,0 +1,394 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.composite.ResourcePermission;
+import org.rhq.core.domain.util.OrderingField;
+import org.rhq.core.domain.util.PageControl;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
+import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * A base class for deriving recent resource operations portlets for different entity
contexts. In this way the
+ * basic plumbing is shared, giving a consistent behavior and configuration for the
concrete portlets.
+ *
+ * @author Jay Shaughnessy
+ * @author Simeon Pinder
+ */
+public abstract class AbstractOperationHistoryPortlet extends OperationHistoryView
implements CustomSettingsPortlet,
+ AutoRefreshPortlet {
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+ private OperationHistoryPortletDataSource dataSource;
+ private Boolean hasControlPermission;
+
+ // autorefresh timer
+ private Timer refreshTimer;
+
+ public AbstractOperationHistoryPortlet(String locatorId, EntityContext entityContext)
{
+ super(locatorId, null, entityContext);
+
+ setShowFilterForm(false); //disable filter form for portlet
+ setOverflow(Overflow.VISIBLE);
+ setShowFooterRefresh(false); //disable footer refresh button as redundant for
portlets
+ setShowHeader(false);//disable header for portlets
+ }
+
+ public Timer getRefreshTimer() {
+ return refreshTimer;
+ }
+
+ public void setRefreshTimer(Timer refreshTimer) {
+ this.refreshTimer = refreshTimer;
+ }
+
+ public PortletWindow getPortletWindow() {
+ return portletWindow;
+ }
+
+ @Override
+ public OperationHistoryPortletDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new OperationHistoryPortletDataSource(getContext());
+ }
+ return this.dataSource;
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_operations_criteria());
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ // the portletWindow does not change, so we can hold onto it locally
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ // if there is no configuration there is nothing to set
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ Configuration config = storedPortlet.getConfiguration();
+
+ // not sure I love the fact that this common portlet config assigns some
irrelevant/unused config props,
+ // may be better to prune the common set and add the specific properties locally
in this method
+ for (String key :
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION.keySet()) {
+ if (config.getSimple(key) == null) {
+ config.put(new PropertySimple(key,
PortletConfigurationEditorComponent.CONFIG_PROPERTY_INITIALIZATION
+ .get(key)));
+ }
+ }
+
+ getDataSource().setConfiguration(config);
+ }
+
+ @Override
+ public DynamicForm getCustomSettingsForm() {
+
+ LocatableDynamicForm customSettingsForm = new
LocatableDynamicForm(extendLocatorId("CustomSettings"));
+ LocatableVLayout page = new
LocatableVLayout(customSettingsForm.extendLocatorId("Page"));
+ LocatableDynamicForm filterForm = new
LocatableDynamicForm(page.extendLocatorId("Filter"));
+ filterForm.setMargin(5);
+
+ final DashboardPortlet storedPortlet = this.portletWindow.getStoredPortlet();
+ final Configuration portletConfig = storedPortlet.getConfiguration();
+
+ // operation history status selector
+ final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
+ .getOperationStatusEditor(portletConfig);
+
+ // result count selector
+ final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
+
+ // range selector
+ final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
+ .getMeasurementRangeEditor(portletConfig);
+
+ filterForm.setItems(operationStatusSelector, resultCountSelector);
+
+ //submit handler
+ customSettingsForm.addSubmitValuesHandler(new SubmitValuesHandler() {
+
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ // operation status
+ String selectedValue = operationStatusSelector.getValue().toString();
+ if ((selectedValue.trim().isEmpty())
+ || (selectedValue.split(",").length ==
OperationRequestStatus.values().length)) {
+ selectedValue = "";
+ }
+ portletConfig.put(new PropertySimple(Constant.OPERATION_STATUS,
selectedValue));
+
+ // result count
+ selectedValue = resultCountSelector.getValue().toString();
+ if (selectedValue.trim().isEmpty()) {
+ selectedValue = Constant.RESULT_COUNT_DEFAULT;
+ }
+ portletConfig.put(new PropertySimple(Constant.RESULT_COUNT,
selectedValue));
+
+ // time range settings
+ saveMeasurementRangeEditorSettings(measurementRangeEditor,
portletConfig);
+
+ // persist and reload portlet
+ storedPortlet.setConfiguration(portletConfig);
+ configure(portletWindow, storedPortlet);
+ //apply latest settings to the visible result set
+ refresh();
+ }
+ });
+
+ page.addMember(measurementRangeEditor);
+ page.addMember(filterForm);
+ customSettingsForm.addChild(page);
+
+ return customSettingsForm;
+ }
+
+ /**
+ * Takes the current value of the widget and persists it into the configuration
object passed in.
+ *
+ * @param measurementRangeEditor
+ * @param portletConfig
+ * returns populated configuration object.
+ */
+ private void saveMeasurementRangeEditorSettings(final
CustomConfigMeasurementRangeEditor measurementRangeEditor,
+ Configuration portletConfig) {
+ String selectedValue = null;
+ if ((measurementRangeEditor != null) && (portletConfig != null)) {
+ //time range filter. Check for enabled and then persist property. Dealing
with compound widget.
+ FormItem item =
measurementRangeEditor.getItem(CustomConfigMeasurementRangeEditor.ENABLE_RANGE_ITEM);
+ CheckboxItem itemC = (CheckboxItem) item;
+ boolean persistTimeRangeSettings = itemC.getValueAsBoolean();
+ if (persistTimeRangeSettings) {//retrieve values and persist
+ selectedValue = String.valueOf(itemC.getValueAsBoolean());
+ if (!selectedValue.trim().isEmpty()) {//then call
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
selectedValue));
+ }
+
+ //time advanced time filter enabled.
+ boolean isAdvanceTimeSetting = false;
+ selectedValue = String.valueOf(measurementRangeEditor.isAdvanced());
+ if ((selectedValue != null) && (!selectedValue.trim().isEmpty()))
{
+ portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, selectedValue));
+ isAdvanceTimeSetting = Boolean.valueOf(selectedValue);
+ }
+
+ //time frame
+ List<Long> begEnd = measurementRangeEditor.getBeginEndTimes();
+ if (isAdvanceTimeSetting) {//advanced settings
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
(begEnd.get(0) + "," + begEnd.get(1))));
+ } else {
+ //save not advanced time range
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_LASTN,
measurementRangeEditor
+ .getMetricRangePreferences().lastN));
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_UNIT,
measurementRangeEditor
+ .getMetricRangePreferences().unit));
+ }
+ } else {//if disabled, reset time defaults
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE_ENABLE,
false));
+ portletConfig.put(new
PropertySimple(Constant.METRIC_RANGE_BEGIN_END_FLAG, false));
+ List<Long> rangeArray =
MeasurementUtility.calculateTimeFrame(Integer
+ .valueOf(Constant.METRIC_RANGE_LASTN_DEFAULT),
Integer.valueOf(Constant.METRIC_RANGE_UNIT_DEFAULT));
+ // String[] range =
{String.valueOf(rangeArray.get(0)),String.valueOf(rangeArray.get(1))};
+ portletConfig.put(new PropertySimple(Constant.METRIC_RANGE,
+ (String.valueOf(rangeArray.get(0)) + "," +
String.valueOf(rangeArray.get(1)))));
+ }
+ }
+ }
+
+ protected boolean hasControlPermission() {
+ if (null == this.hasControlPermission) {
+ Set<Permission> globalPerm =
this.getPortletWindow().getGlobalPermissions();
+ ResourcePermission resPerm =
this.getPortletWindow().getResourcePermissions();
+
+ this.hasControlPermission = (globalPerm.contains(Permission.MANAGE_INVENTORY)
|| (null != resPerm && resPerm
+ .isControl()));
+ }
+
+ return this.hasControlPermission;
+ }
+
+ @Override
+ protected void refreshTableInfo() {
+ super.refreshTableInfo();
+ if (getTableInfo() != null) {
+ int count = getListGrid().getSelection().length;
+ getTableInfo().setContents(
+ MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()),
String.valueOf(count)));
+ }
+ }
+
+ public void startRefreshCycle() {
+ refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this,
refreshTimer);
+ }
+
+ public boolean isRefreshing() {
+ // TODO: actually keep track of when the portlet is refreshing data
+ return false;
+ }
+
+ @Override
+ protected void onDestroy() {
+ AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
+
+ super.onDestroy();
+ }
+
+ @Override
+ public void redraw() {
+ super.refresh();
+ markForRedraw();
+ }
+
+ static public class OperationHistoryPortletDataSource extends
OperationHistoryDataSource {
+ private Configuration configuration;
+
+ public OperationHistoryPortletDataSource(EntityContext entityContext) {
+ this(entityContext, null);
+ }
+
+ public OperationHistoryPortletDataSource(EntityContext entityContext,
Configuration configuration) {
+ super(entityContext);
+ this.configuration = configuration;
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void setConfiguration(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ /* (non-Javadoc)
+ * This override allows us to set the total rows to the number of recent op
histpry configured for
+ * the portlet. This sets the counter appropriately and stops further queries to
the server.
+ *
+ * @see
org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryDataSource#dataRetrieved(org.rhq.core.domain.util.PageList,
com.smartgwt.client.data.DSResponse, com.smartgwt.client.data.DSRequest)
+ */
+ @Override
+ protected void dataRetrieved(PageList<ResourceOperationHistory> result,
DSResponse response, DSRequest request) {
+ super.dataRetrieved(result, response, request);
+
+ response.setTotalRows(result.size());
+ }
+
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(DSRequest request) {
+ ResourceOperationHistoryCriteria criteria = new
ResourceOperationHistoryCriteria();
+
+ // result count
+ String currentSetting =
this.configuration.getSimpleValue(Constant.RESULT_COUNT,
+ Constant.RESULT_COUNT_DEFAULT);
+
+ // We have to set a PageControl override here, or RPCDataSource will apply
default paging based on the
+ // request. But, once setting a paging override the CriteriaQueryGenerator
will use it for
+ // paging *and* sorting, so we need to also ensure our desired sorting is
included in the override. So,
+ // to get the most recent op histories, apply a descending ordering on create
time.
+ int pageNumber = 0;
+ int pageSize = Integer.valueOf(currentSetting);
+ OrderingField orderingField = new
OrderingField(OperationHistoryDataSource.Field.CREATED_TIME,
+ PageOrdering.DESC);
+ criteria.setPageControl(new PageControl(pageNumber, pageSize,
orderingField));
+
+ // status
+ currentSetting = this.configuration.getSimpleValue(Constant.OPERATION_STATUS,
"");
+ String[] parsedValues = currentSetting.trim().split(",");
+ if (!(currentSetting.trim().isEmpty() || parsedValues.length ==
OperationRequestStatus.values().length)) {
+ OperationRequestStatus[] operationStatuses = new
OperationRequestStatus[parsedValues.length];
+ int indx = 0;
+ for (String priority : parsedValues) {
+ OperationRequestStatus s = OperationRequestStatus.valueOf(priority);
+ operationStatuses[indx++] = s;
+ }
+ criteria.addFilterStatuses(operationStatuses);
+ }
+
+ //result timeframe if enabled
+ currentSetting =
this.configuration.getSimpleValue(Constant.METRIC_RANGE_ENABLE, null);
+ if (Boolean.valueOf(currentSetting)) {//then proceed setting
+
+ boolean isAdvanced = false;
+ //detect type of widget[Simple|Advanced]
+ PropertySimple property =
this.configuration.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
+ if (property != null) {
+ isAdvanced = property.getBooleanValue();
+ }
+ if (isAdvanced) {
+ //Advanced time settings
+ property = this.configuration.getSimple(Constant.METRIC_RANGE);
+ if (property != null) {
+ currentSetting = property.getStringValue();
+ String[] range = currentSetting.split(",");
+ criteria.addFilterStartTime(Long.valueOf(range[0]));
+ criteria.addFilterEndTime(Long.valueOf(range[1]));
+ }
+ } else {
+ //Simple time settings
+ property =
this.configuration.getSimple(Constant.METRIC_RANGE_LASTN);
+ if (property != null) {
+ int lastN = property.getIntegerValue();
+ property =
this.configuration.getSimple(Constant.METRIC_RANGE_UNIT);
+ int lastUnits = property.getIntegerValue();
+ ArrayList<Long> beginEnd =
MeasurementUtility.calculateTimeFrame(lastN, Integer
+ .valueOf(lastUnits));
+ criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
+ criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
+ }
+ }
+ }
+
+ // add any context related filters
+ switch (getEntityContext().type) {
+ case Resource:
+ criteria.addFilterResourceIds(getEntityContext().getResourceId());
+ break;
+
+ case ResourceGroup:
+
criteria.addFilterGroupOperationHistoryId(getEntityContext().getGroupId());
+ }
+
+ return criteria;
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java
new file mode 100644
index 0000000..90aedd8
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationHistoryPortlet.java
@@ -0,0 +1,48 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+/*
+ * 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.
+ */
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class OperationHistoryPortlet extends AbstractOperationHistoryPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "Operations";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.view_portlet_defaultName_operations();
+
+ public OperationHistoryPortlet(String locatorId) {
+ super(locatorId, EntityContext.forSubsystemView());
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new OperationHistoryPortlet(locatorId);
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java
new file mode 100644
index 0000000..252f6d2
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationSchedulePortlet.java
@@ -0,0 +1,356 @@
+package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
+
+/*
+ * 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.
+ */
+
+import com.google.gwt.user.client.Timer;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
+import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.VStack;
+
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.domain.dashboard.DashboardPortlet;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
+import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
+import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
+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.LocatableListGrid;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * A view that displays a live table of completed Operations and scheduled operations.
+ *
+ * @author Simeon Pinder
+ */
+public class OperationSchedulePortlet extends LocatableVLayout implements
CustomSettingsPortlet, AutoRefreshPortlet {
+
+ // A non-displayed, persisted identifier for the portlet
+ public static final String KEY = "OperationSchedule";
+ // A default displayed, persisted name for the portlet
+ public static final String NAME = MSG.common_title_scheduled_operations();
+
+ public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED =
"operations-scheduled-enabled";
+ public static final String OPERATIONS_RANGE_SCHEDULED =
"operations-range-scheduled";
+ public static String RANGE_DISABLED_MESSAGE =
MSG.view_portlet_operations_disabled();
+ //TODO: change this to use the Smart GWT default value.
+ public static String RANGE_DISABLED_MESSAGE_DEFAULT =
MSG.common_msg_noItemsToShow();
+
+ private static final int WIDTH_RECENT_TIME = 150;
+ private static final int WIDTH_RECENT_STATUS = 50;
+ private static final int WIDTH_SCHEDULED_TIME = WIDTH_RECENT_TIME +
WIDTH_RECENT_STATUS;
+
+ // set on initial configuration, the window for this portlet view.
+ private PortletWindow portletWindow;
+
+ //ListGrids for operations
+ private LocatableListGrid scheduledOperationsGrid = null;
+
+ private ScheduledOperationsDataSource dataSourceScheduled;
+ public static String unlimited = MSG.common_label_unlimited();
+ public static String defaultValue = "5";
+ public static boolean defaultEnabled = true;
+
+ private Timer refreshTimer;
+
+ //default no-args constructor for serialization.
+ private OperationSchedulePortlet() {
+ super("(unitialized)");
+ }
+
+ public OperationSchedulePortlet(String locatorId) {
+ super(locatorId);
+ this.dataSourceScheduled = new ScheduledOperationsDataSource(this);
+ }
+
+ @Override
+ protected void onInit() {
+ super.onInit();
+
+ this.scheduledOperationsGrid = new
LocatableListGrid(extendLocatorId("Scheduled"));
+ scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
+ scheduledOperationsGrid.setAutoFetchData(true);
+ scheduledOperationsGrid.setWidth100();
+ scheduledOperationsGrid.setWrapCells(true);
+
+ addMember(scheduledOperationsGrid);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ ListGridField timeNext = new
ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(),
+ ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME);
+ timeNext.setCellFormatter(new TimestampCellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ if (value != null) {
+ String timestamp = super.format(value, record, rowNum, colNum);
+ Integer resourceId =
record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ Integer opScheduleId = record.getAttributeAsInt("id");
+ String url =
LinkManager.getSubsystemResourceOperationScheduleLink(resourceId, opScheduleId);
+ return SeleniumUtility.getLocatableHref(url, timestamp, null);
+ } else {
+ return "<i>" + MSG.common_label_none() +
"</i>";
+ }
+ }
+ });
+ timeNext.setShowHover(true);
+
timeNext.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(ScheduledOperationsDataSource.Field.TIME
+ .propertyName()));
+
+ ListGridField operationNext = new
ListGridField(ScheduledOperationsDataSource.Field.OPERATION.propertyName(),
+ ScheduledOperationsDataSource.Field.OPERATION.title());
+
+ ListGridField resourceNext = new
ListGridField(ScheduledOperationsDataSource.Field.RESOURCE.propertyName(),
+ ScheduledOperationsDataSource.Field.RESOURCE.title());
+ resourceNext.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1)
{
+ String url =
LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNext.setShowHover(true);
+ resourceNext.setHoverCustomizer(new HoverCustomizer() {
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int
rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+
+ ListGridField ancestryNext = AncestryUtil.setupAncestryListGridField();
+
+ scheduledOperationsGrid.setFields(timeNext, operationNext, resourceNext,
ancestryNext);
+ }
+
+ @Override
+ public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
+
+ if (null == this.portletWindow && null != portletWindow) {
+ this.portletWindow = portletWindow;
+ }
+
+ if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
+ return;
+ }
+
+ PropertySimple property =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
+ if ((property != null) && (property.getStringValue() != null)) {
+ //retrieve and translate to int
+ String retrieved = property.getStringValue();
+ if (unlimited.equals(retrieved)) {
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
+ } else {
+
getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved));
+ }
+ } else {//create setting
+ storedPortlet.getConfiguration().put(new
PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
+ getDataSourceScheduled().setOperationsRangeScheduled(-1);
+ }
+ //Checkbox settings property
+ property =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ if ((property != null) && (property.getBooleanValue() != null)) {
+
getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
+ } else {//create setting
+ storedPortlet.getConfiguration()
+ .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED,
defaultEnabled));
+ getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled);
+ }
+ }
+
+ @Override
+ public Canvas getHelpCanvas() {
+ return new HTMLFlow(MSG.view_portlet_help_scheduledOperations());
+ }
+
+ /** Constructs the dynamic form instance using 1 column and multiple row layouts.
+ */
+ public DynamicForm getCustomSettingsForm() {
+
+ //root dynamic form instance
+ final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("CustomSettings"));
+
+ final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
+
+ //vertical layout
+ VStack column = new VStack();
+
+ //horizontal layout
+ LocatableHLayout sheduledOperationsLayout = new
LocatableHLayout(extendLocatorId("EnableScheduledOperations"));
+
+ final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
+ enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ enableScheduledOperationsGrouping.setTitle(" " +
MSG.view_portlet_operations_config_show_next() + " ");
+ enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem);
+ }
+ });
+
+ //wrap field item in dynamicform for addition
+ DynamicForm fieldWrapper = new DynamicForm();
+ fieldWrapper.setFields(enableScheduledOperationsGrouping);
+ sheduledOperationsLayout.addMember(fieldWrapper);
+
+ //retrieve previous value otherwise initialize to true(live unlimited list)
+ PropertySimple retrieved =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
+ if (retrieved != null) {
+ enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue());
+ } else {
+ enableScheduledOperationsGrouping.setValue(true);
+ }
+
+ //------------- Build second combobox for timeframe for problem resources
search.
+ final SelectItem maximumScheduledOperationsComboBox = new
SelectItem(OPERATIONS_RANGE_SCHEDULED);
+ maximumScheduledOperationsComboBox.setTitle("");
+ maximumScheduledOperationsComboBox.setHint("<nobr><b> " +
MSG.common_label_scheduled_operations()
+ + ".</b></nobr>");
+ maximumScheduledOperationsComboBox.setType("selection");
+ //define acceptable values for display amount
+ String[] acceptableDisplayValues = { "1", "5",
"10", "15", unlimited };
+ maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues);
+ maximumScheduledOperationsComboBox.setWidth(100);
+ maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() {
+ public void onChange(ChangeEvent event) {
+ String selectedItem = "" + event.getValue();
+ //stuff into the master form for retrieval
+ form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem);
+ }
+ });
+
+ //set to default
+ String selectedValue = defaultValue;
+ if (storedPortlet != null) {
+ //if property exists retrieve it
+ if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) !=
null) {
+ selectedValue =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue();
+ } else {//insert default value
+ storedPortlet.getConfiguration().put(new
PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
+ }
+ }
+ //prepopulate the combobox with the previously stored selection
+ maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
+ DynamicForm fieldWrapper2 = new DynamicForm();
+ fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
+ sheduledOperationsLayout.addMember(fieldWrapper2);
+ column.addMember(sheduledOperationsLayout);
+ form.addChild(column);
+
+ //submit handler
+ form.addSubmitValuesHandler(new SubmitValuesHandler() {
+ @Override
+ public void onSubmitValues(SubmitValuesEvent event) {
+ //no need to insert validation here as user not allowed to enter values
+ if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value
supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_SCHEDULED,
form.getValue(OPERATIONS_RANGE_SCHEDULED)));
+ }
+ if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new
value supplied
+ storedPortlet.getConfiguration().put(
+ new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form
+ .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED)));
+ }
+
+ configure(portletWindow, storedPortlet);
+
+ redraw();
+ }
+ });
+
+ return form;
+ }
+
+ public static final class Factory implements PortletViewFactory {
+ public static PortletViewFactory INSTANCE = new Factory();
+
+ public final Portlet getInstance(String locatorId) {
+
+ return new OperationSchedulePortlet(locatorId);
+ }
+ }
+
+ /** Custom refresh operation as we cannot directly extend Table because it only
+ * contains one ListGrid while the OperationsPortlet displays two tables.
+ */
+ @Override
+ public void redraw() {
+ super.redraw();
+ //now reload the table data
+ this.scheduledOperationsGrid.invalidateCache();
+ this.scheduledOperationsGrid.markForRedraw();
+ }
+
+ public ConfigurationDefinition getConfigurationDefinition() {
+ ConfigurationDefinition definition = new
ConfigurationDefinition(MSG.view_portlet_configure_definitionTitle(),
+ MSG.view_portlet_configure_definitionDesc());
+
+ definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED, MSG
+ .view_portlet_operations_config_scheduled_maximum(), true,
PropertySimpleType.STRING));
+ definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED,
MSG
+ .view_portlet_operations_config_scheduled_enable(), true,
PropertySimpleType.BOOLEAN));
+
+ return definition;
+ }
+
+ public ScheduledOperationsDataSource getDataSourceScheduled() {
+ return this.dataSourceScheduled;
+ }
+
+ public LocatableListGrid getScheduledOperationsGrid() {
+ return this.scheduledOperationsGrid;
+ }
+
+ public void startRefreshCycle() {
+ refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this,
refreshTimer);
+ }
+
+ @Override
+ protected void onDestroy() {
+ AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
+
+ super.onDestroy();
+ }
+
+ public boolean isRefreshing() {
+ return false;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
deleted file mode 100644
index 0b02c38..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/recent/operations/OperationsPortlet.java
+++ /dev/null
@@ -1,530 +0,0 @@
-package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations;
-
-/*
- * 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.
- */
-
-import com.google.gwt.user.client.Timer;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
-import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.HeaderSpan;
-import com.smartgwt.client.widgets.grid.HoverCustomizer;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VStack;
-
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
-import org.rhq.core.domain.dashboard.DashboardPortlet;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.AutoRefreshPortletUtil;
-import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.operation.RecentOperationsDataSource;
-import org.rhq.enterprise.gui.coregui.client.operation.ScheduledOperationsDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableLabel;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
-
-/**
- * A view that displays a live table of completed Operations and scheduled operations.
- *
- * @author Simeon Pinder
- */
-public class OperationsPortlet extends LocatableVLayout implements CustomSettingsPortlet,
AutoRefreshPortlet {
-
- // A non-displayed, persisted identifier for the portlet
- public static final String KEY = "Operations";
- // A default displayed, persisted name for the portlet
- public static final String NAME = MSG.view_portlet_defaultName_operations();
-
- //unique field/form identifiers
- public static final String OPERATIONS_RANGE_COMPLETED_ENABLED =
"operations-completed-enabled";
- public static final String OPERATIONS_RANGE_SCHEDULED_ENABLED =
"operations-scheduled-enabled";
- public static final String OPERATIONS_RANGE_COMPLETED =
"operations-range-completed";
- public static final String OPERATIONS_RANGE_SCHEDULED =
"operations-range-scheduled";
- public static String RANGE_DISABLED_MESSAGE =
MSG.view_portlet_operations_disabled();
- //TODO: change this to use the Smart GWT default value.
- public static String RANGE_DISABLED_MESSAGE_DEFAULT =
MSG.common_msg_noItemsToShow();
-
- private static final String RECENT_OPERATIONS =
MSG.common_title_recent_operations();
- private static final String SCHEDULED_OPERATIONS =
MSG.common_title_scheduled_operations();
-
- private static final int WIDTH_RECENT_TIME = 150;
- private static final int WIDTH_RECENT_STATUS = 50;
- private static final int WIDTH_SCHEDULED_TIME = WIDTH_RECENT_TIME +
WIDTH_RECENT_STATUS;
-
- // set on initial configuration, the window for this portlet view.
- private PortletWindow portletWindow;
-
- //ListGrids for operations
- private LocatableListGrid recentOperationsGrid = null;
- private LocatableListGrid scheduledOperationsGrid = null;
-
- private RecentOperationsDataSource dataSourceCompleted;
- private ScheduledOperationsDataSource dataSourceScheduled;
- public static String unlimited = MSG.common_label_unlimited();
- public static String defaultValue = "5";
- public static boolean defaultEnabled = true;
-
- private Timer refreshTimer;
-
- //default no-args constructor for serialization.
- private OperationsPortlet() {
- super("(unitialized)");
- }
-
- public OperationsPortlet(String locatorId) {
- super(locatorId);
- this.dataSourceCompleted = new RecentOperationsDataSource(this);
- this.dataSourceScheduled = new ScheduledOperationsDataSource(this);
- }
-
- @Override
- protected void onInit() {
- super.onInit();
-
- this.recentOperationsGrid = new LocatableListGrid(RECENT_OPERATIONS);
- recentOperationsGrid.setDataSource(getDataSourceCompleted());
- recentOperationsGrid.setAutoFetchData(true);
- recentOperationsGrid.setTitle(RECENT_OPERATIONS);
- recentOperationsGrid.setWidth100();
- //defining header span
- String[] completedRows = new String[] { //
- RecentOperationsDataSource.Field.RESOURCE.propertyName(), //
- AncestryUtil.RESOURCE_ANCESTRY, //
- RecentOperationsDataSource.Field.OPERATION.propertyName(), //
- RecentOperationsDataSource.Field.TIME.propertyName(), //
- RecentOperationsDataSource.Field.STATUS.propertyName() };
- recentOperationsGrid.setHeaderSpans(new HeaderSpan(RECENT_OPERATIONS,
completedRows));
- recentOperationsGrid.setHeaderSpanHeight(20);
- recentOperationsGrid.setHeaderHeight(40);
- //recentOperationsGrid.setResizeFieldsInRealTime(true);
- recentOperationsGrid.setWrapCells(true);
- addMember(recentOperationsGrid);
-
- // Add the list table as the top half of the view.
- this.scheduledOperationsGrid = new LocatableListGrid(SCHEDULED_OPERATIONS);
- scheduledOperationsGrid.setDataSource(getDataSourceScheduled());
- scheduledOperationsGrid.setAutoFetchData(true);
- scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
- scheduledOperationsGrid.setWidth100();
- String[] scheduledRows = new String[] { //
- ScheduledOperationsDataSource.Field.RESOURCE.propertyName(), //
- AncestryUtil.RESOURCE_ANCESTRY, //
- ScheduledOperationsDataSource.Field.OPERATION.propertyName(), //
- ScheduledOperationsDataSource.Field.TIME.propertyName() };
- scheduledOperationsGrid.setHeaderSpans(new HeaderSpan(SCHEDULED_OPERATIONS,
scheduledRows));
- scheduledOperationsGrid.setHeaderSpanHeight(20);
- scheduledOperationsGrid.setHeaderHeight(40);
-
- scheduledOperationsGrid.setTitle(SCHEDULED_OPERATIONS);
- //scheduledOperationsGrid.setResizeFieldsInRealTime(true);
- scheduledOperationsGrid.setWrapCells(true);
-
- addMember(scheduledOperationsGrid);
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- ListGridField resourceRecent = new
ListGridField(RecentOperationsDataSource.Field.RESOURCE.propertyName(),
- RecentOperationsDataSource.Field.RESOURCE.title());
- resourceRecent.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1)
{
- String url =
LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
- }
- });
- resourceRecent.setShowHover(true);
- resourceRecent.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int
rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
-
- ListGridField ancestryRecent = AncestryUtil.setupAncestryListGridField();
-
- ListGridField operationRecent = new
ListGridField(RecentOperationsDataSource.Field.OPERATION.propertyName(),
- RecentOperationsDataSource.Field.OPERATION.title());
-
- ListGridField timeRecent = new
ListGridField(RecentOperationsDataSource.Field.TIME.propertyName(),
- RecentOperationsDataSource.Field.TIME.title(), WIDTH_RECENT_TIME);
- TimestampCellFormatter.prepareDateField(timeRecent);
-
- ListGridField statusRecent = new
ListGridField(RecentOperationsDataSource.Field.STATUS.propertyName(),
- RecentOperationsDataSource.Field.STATUS.title(), WIDTH_RECENT_STATUS);
- statusRecent.setAlign(Alignment.CENTER);
-
- recentOperationsGrid.setFields(resourceRecent, ancestryRecent, operationRecent,
timeRecent, statusRecent);
-
- ListGridField resourceNext = new
ListGridField(ScheduledOperationsDataSource.Field.RESOURCE.propertyName(),
- ScheduledOperationsDataSource.Field.RESOURCE.title());
- resourceNext.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1)
{
- String url =
LinkManager.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
- return SeleniumUtility.getLocatableHref(url, o.toString(), null);
- }
- });
- resourceNext.setShowHover(true);
- resourceNext.setHoverCustomizer(new HoverCustomizer() {
- public String hoverHTML(Object value, ListGridRecord listGridRecord, int
rowNum, int colNum) {
- return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
- }
- });
-
- ListGridField ancestryNext = AncestryUtil.setupAncestryListGridField();
-
- ListGridField operationNext = new
ListGridField(ScheduledOperationsDataSource.Field.OPERATION.propertyName(),
- ScheduledOperationsDataSource.Field.OPERATION.title());
-
- ListGridField timeNext = new
ListGridField(ScheduledOperationsDataSource.Field.TIME.propertyName(),
- ScheduledOperationsDataSource.Field.TIME.title(), WIDTH_SCHEDULED_TIME);
- TimestampCellFormatter.prepareDateField(timeNext);
-
- scheduledOperationsGrid.setFields(resourceNext, ancestryNext, operationNext,
timeNext);
- }
-
- @Override
- public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
-
- if (null == this.portletWindow && null != portletWindow) {
- this.portletWindow = portletWindow;
- }
-
- if ((null == storedPortlet) || (null == storedPortlet.getConfiguration())) {
- return;
- }
-
- //Operation range property - retrieve existing value
- PropertySimple property =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- if (unlimited.equals(retrieved)) {
- getDataSourceCompleted().setOperationsRangeCompleted(-1);
- } else {
-
getDataSourceCompleted().setOperationsRangeCompleted(Integer.parseInt(retrieved));
- }
- } else {//create setting
- storedPortlet.getConfiguration().put(new
PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
- getDataSourceCompleted().setOperationsRangeCompleted(-1);
- }
-
- property =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED);
- if ((property != null) && (property.getStringValue() != null)) {
- //retrieve and translate to int
- String retrieved = property.getStringValue();
- if (unlimited.equals(retrieved)) {
- getDataSourceScheduled().setOperationsRangeScheduled(-1);
- } else {
-
getDataSourceScheduled().setOperationsRangeScheduled(Integer.parseInt(retrieved));
- }
- } else {//create setting
- storedPortlet.getConfiguration().put(new
PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
- getDataSourceScheduled().setOperationsRangeScheduled(-1);
- }
- //Checkbox settings property
- property =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
- if ((property != null) && (property.getBooleanValue() != null)) {
-
getDataSourceScheduled().setOperationsRangeScheduleEnabled(property.getBooleanValue().booleanValue());
- } else {//create setting
- storedPortlet.getConfiguration()
- .put(new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED,
defaultEnabled));
- getDataSourceScheduled().setOperationsRangeScheduleEnabled(defaultEnabled);
- }
- property =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
- if ((property != null) && (property.getBooleanValue() != null)) {
-
getDataSourceCompleted().setOperationsRangeCompleteEnabled(property.getBooleanValue().booleanValue());
- } else {//create setting
- storedPortlet.getConfiguration()
- .put(new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED,
defaultEnabled));
- getDataSourceCompleted().setOperationsRangeCompleteEnabled(defaultEnabled);
- }
- }
-
- @Override
- public Canvas getHelpCanvas() {
- return new HTMLFlow(MSG.view_portlet_help_operations());
- }
-
- /** Constructs the dynamic form instance using 1 column and multiple row layouts.
- */
- public DynamicForm getCustomSettingsForm() {
-
- //root dynamic form instance
- final LocatableDynamicForm form = new
LocatableDynamicForm(extendLocatorId("custom-settings"));
-
- final DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
-
- //vertical layout
- VStack column = new VStack();
-
- //label
- LocatableLabel operationRange = new
LocatableLabel(extendLocatorId("operation-range"), MSG
- .common_title_operations_range());
- column.addMember(operationRange);
-
- //horizontal layout
- LocatableHLayout row = new
LocatableHLayout(extendLocatorId("enable.completed.operations"));
-
- //checkbox indicating whether to apply completed operations grouping settings
- final CheckboxItem enableCompletedOperationsGrouping = new CheckboxItem();
- enableCompletedOperationsGrouping.setName(OPERATIONS_RANGE_COMPLETED_ENABLED);
- enableCompletedOperationsGrouping.setTitle(" " +
MSG.view_portlet_operations_config_show_last() + " ");
- //add change listener
- enableCompletedOperationsGrouping.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_COMPLETED_ENABLED, selectedItem);
- }
- });
- //retrieve previous value otherwise initialize to true(live unlimited list)
- PropertySimple retrieved =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED_ENABLED);
- if (retrieved != null) {
- enableCompletedOperationsGrouping.setValue(retrieved.getBooleanValue());
- } else {//default
- enableCompletedOperationsGrouping.setValue(true);
- }
-
- //wrap field item in dynamicform for addition as a field item
- DynamicForm item = new DynamicForm();
- item.setFields(enableCompletedOperationsGrouping);
- row.addMember(item);
-
- //-------------combobox for number of completed scheduled ops to display on the
dashboard
- final SelectItem maximumCompletedOperationsComboBox = new
SelectItem(OPERATIONS_RANGE_COMPLETED);
- maximumCompletedOperationsComboBox.setTitle("");
- maximumCompletedOperationsComboBox.setHint("<nobr><b> " +
MSG.view_portlet_operations_config_completed()
- + ".</b></nobr>");
- //spinder: required to disable editability
- maximumCompletedOperationsComboBox.setType("selection");
- //define acceptable values for display amount
- String[] acceptableDisplayValues = { "1", "5",
"10", "15", unlimited };
- maximumCompletedOperationsComboBox.setValueMap(acceptableDisplayValues);
- //set width of dropdown display region
- maximumCompletedOperationsComboBox.setWidth(100);
- maximumCompletedOperationsComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_COMPLETED, selectedItem);
- }
- });
-
- //default selected value to 'unlimited'(live lists) and check both
combobox settings here.
- String selectedValue = defaultValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED) !=
null) {
- selectedValue =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_COMPLETED).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(new
PropertySimple(OPERATIONS_RANGE_COMPLETED, defaultValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- maximumCompletedOperationsComboBox.setDefaultValue(selectedValue);
- DynamicForm item2 = new DynamicForm();
- item2.setFields(maximumCompletedOperationsComboBox);
- row.addMember(item2);
-
- //horizontal layout
- LocatableHLayout sheduledOperationsLayout = new
LocatableHLayout(extendLocatorId("enable.scheduled.operations"));
-
- final CheckboxItem enableScheduledOperationsGrouping = new CheckboxItem();
- enableScheduledOperationsGrouping.setName(OPERATIONS_RANGE_SCHEDULED_ENABLED);
- enableScheduledOperationsGrouping.setTitle(" " +
MSG.view_portlet_operations_config_show_next() + " ");
- enableScheduledOperationsGrouping.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_SCHEDULED_ENABLED, selectedItem);
- }
- });
-
- //wrap field item in dynamicform for addition
- DynamicForm fieldWrapper = new DynamicForm();
- fieldWrapper.setFields(enableScheduledOperationsGrouping);
- sheduledOperationsLayout.addMember(fieldWrapper);
-
- //retrieve previous value otherwise initialize to true(live unlimited list)
- retrieved =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED);
- if (retrieved != null) {
- enableScheduledOperationsGrouping.setValue(retrieved.getBooleanValue());
- } else {
- enableScheduledOperationsGrouping.setValue(true);
- }
-
- //------------- Build second combobox for timeframe for problem resources
search.
- final SelectItem maximumScheduledOperationsComboBox = new
SelectItem(OPERATIONS_RANGE_SCHEDULED);
- maximumScheduledOperationsComboBox.setTitle("");
- maximumScheduledOperationsComboBox.setHint("<nobr><b> " +
MSG.common_label_scheduled_operations()
- + ".</b></nobr>");
- maximumScheduledOperationsComboBox.setType("selection");
- maximumScheduledOperationsComboBox.setValueMap(acceptableDisplayValues);
- maximumScheduledOperationsComboBox.setWidth(100);
- maximumScheduledOperationsComboBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- String selectedItem = "" + event.getValue();
- //stuff into the master form for retrieval
- form.setValue(OPERATIONS_RANGE_SCHEDULED, selectedItem);
- }
- });
-
- //set to default
- selectedValue = defaultValue;
- if (storedPortlet != null) {
- //if property exists retrieve it
- if (storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED) !=
null) {
- selectedValue =
storedPortlet.getConfiguration().getSimple(OPERATIONS_RANGE_SCHEDULED).getStringValue();
- } else {//insert default value
- storedPortlet.getConfiguration().put(new
PropertySimple(OPERATIONS_RANGE_SCHEDULED, defaultValue));
- }
- }
- //prepopulate the combobox with the previously stored selection
- maximumScheduledOperationsComboBox.setDefaultValue(selectedValue);
- DynamicForm fieldWrapper2 = new DynamicForm();
- fieldWrapper2.setFields(maximumScheduledOperationsComboBox);
- sheduledOperationsLayout.addMember(fieldWrapper2);
- column.addMember(row);
- column.addMember(sheduledOperationsLayout);
- form.addChild(column);
-
- //submit handler
- form.addSubmitValuesHandler(new SubmitValuesHandler() {
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
- //no need to insert validation here as user not allowed to enter values
- if (form.getValue(OPERATIONS_RANGE_SCHEDULED) != null) {//if new value
supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_SCHEDULED,
form.getValue(OPERATIONS_RANGE_SCHEDULED)));
- }
- if (form.getValue(OPERATIONS_RANGE_COMPLETED) != null) {//if new value
supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_COMPLETED,
form.getValue(OPERATIONS_RANGE_COMPLETED)));
- }
- if (form.getValue(OPERATIONS_RANGE_COMPLETED_ENABLED) != null) {//if new
value supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_COMPLETED_ENABLED, form
- .getValue(OPERATIONS_RANGE_COMPLETED_ENABLED)));
- }
- if (form.getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED) != null) {//if new
value supplied
- storedPortlet.getConfiguration().put(
- new PropertySimple(OPERATIONS_RANGE_SCHEDULED_ENABLED, form
- .getValue(OPERATIONS_RANGE_SCHEDULED_ENABLED)));
- }
-
- configure(portletWindow, storedPortlet);
-
- redraw();
- }
- });
-
- return form;
- }
-
- public static final class Factory implements PortletViewFactory {
- public static PortletViewFactory INSTANCE = new Factory();
-
- public final Portlet getInstance(String locatorId) {
-
- return new OperationsPortlet(locatorId);
- }
- }
-
- /** Custom refresh operation as we cannot directly extend Table because it only
- * contains one ListGrid while the OperationsPortlet displays two tables.
- */
- @Override
- public void redraw() {
- super.redraw();
- //now reload the table data
- this.recentOperationsGrid.invalidateCache();
- this.recentOperationsGrid.markForRedraw();
- this.scheduledOperationsGrid.invalidateCache();
- this.scheduledOperationsGrid.markForRedraw();
- }
-
- public ConfigurationDefinition getConfigurationDefinition() {
- ConfigurationDefinition definition = new
ConfigurationDefinition(MSG.view_portlet_configure_definitionTitle(),
- MSG.view_portlet_configure_definitionDesc());
-
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED, MSG
- .view_portlet_operations_config_completed_maximum(), true,
PropertySimpleType.STRING));
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED, MSG
- .view_portlet_operations_config_scheduled_maximum(), true,
PropertySimpleType.STRING));
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_COMPLETED_ENABLED,
MSG
- .view_portlet_operations_config_completed_enable(), true,
PropertySimpleType.BOOLEAN));
- definition.put(new PropertyDefinitionSimple(OPERATIONS_RANGE_SCHEDULED_ENABLED,
MSG
- .view_portlet_operations_config_scheduled_enable(), true,
PropertySimpleType.BOOLEAN));
-
- return definition;
- }
-
- public RecentOperationsDataSource getDataSourceCompleted() {
- return this.dataSourceCompleted;
- }
-
- public ScheduledOperationsDataSource getDataSourceScheduled() {
- return this.dataSourceScheduled;
- }
-
- public LocatableListGrid getCompletedOperationsGrid() {
- return this.recentOperationsGrid;
- }
-
- public LocatableListGrid getScheduledOperationsGrid() {
- return this.scheduledOperationsGrid;
- }
-
- public void startRefreshCycle() {
- refreshTimer = AutoRefreshPortletUtil.startRefreshCycle(this, this,
refreshTimer);
- }
-
- @Override
- protected void onDestroy() {
- AutoRefreshPortletUtil.onDestroy(this, refreshTimer);
-
- super.onDestroy();
- }
-
- public boolean isRefreshing() {
- return false;
- }
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
index 9ca8f5c..7862175 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/resource/ResourceOperationsPortlet.java
@@ -18,370 +18,45 @@
*/
package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.resource;
-import java.util.ArrayList;
-
-import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.events.SubmitValuesEvent;
-import com.smartgwt.client.widgets.form.events.SubmitValuesHandler;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.criteria.ResourceCriteria;
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import
org.rhq.enterprise.gui.coregui.client.components.measurement.CustomConfigMeasurementRangeEditor;
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.groups.GroupOperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.summary.AbstractActivityView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
-import org.rhq.enterprise.gui.coregui.client.util.MeasurementUtility;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.AbstractOperationHistoryPortlet;
/**
* @author Simeon Pinder
+ * @author Jay Shaughnessy
*/
-public class ResourceOperationsPortlet extends GroupOperationsPortlet {
+public class ResourceOperationsPortlet extends AbstractOperationHistoryPortlet {
// A non-displayed, persisted identifier for the portlet
public static final String KEY = "ResourceOperations";
// A default displayed, persisted name for the portlet
public static final String NAME =
MSG.view_portlet_defaultName_resource_operations();
- private int resourceId;
- private ResourceComposite resourceComposite;
- private ResourceOperationsCriteriaHistoryListView resourceOperations;
-
- public ResourceOperationsPortlet(String locatorId) {
- super(locatorId);
- this.locatorId = locatorId;
- //figure out which page we're loading
- String currentPage = History.getToken();
- String[] elements = currentPage.split("/");
- this.resourceId = Integer.valueOf(elements[1]);
- //populate basepath
- baseViewPath = elements[0];
- }
-
- @Override
- protected void onInit() {
- setCurrentlyRefreshing(true);
- initializeUi();
- loadData();
- }
-
- @Override
- public void redraw() {
- loadData();
- }
-
- @Override
- public DynamicForm getCustomSettingsForm() {
- LocatableDynamicForm customSettings = new
LocatableDynamicForm(extendLocatorId("customSettings"));
- LocatableVLayout page = new
LocatableVLayout(customSettings.extendLocatorId("page"));
- //build editor form container
- final LocatableDynamicForm form = new
LocatableDynamicForm(page.extendLocatorId("alert-filter"));
- form.setMargin(5);
-
- //add label about what configuration affects? redundant?
- //add filter operation status type selector
- final SelectItem operationStatusSelector = PortletConfigurationEditorComponent
- .getOperationStatusEditor(portletConfig);
- // //add sort priority selector
- // final SelectItem resultSortSelector =
PortletConfigurationEditorComponent
- // .getResulSortOrderEditor(portletConfig);
- //add result count selector
- final SelectItem resultCountSelector =
PortletConfigurationEditorComponent.getResultCountEditor(portletConfig);
-
- //add range selector
- final CustomConfigMeasurementRangeEditor measurementRangeEditor =
PortletConfigurationEditorComponent
- .getMeasurementRangeEditor(portletConfig);
-
- form.setItems(operationStatusSelector, resultCountSelector);
-
- //submit handler
- customSettings.addSubmitValuesHandler(new SubmitValuesHandler() {
-
- @Override
- public void onSubmitValues(SubmitValuesEvent event) {
-
- //result count
- portletConfig =
AbstractActivityView.saveResultCounterSettings(resultCountSelector, portletConfig);
-
- //time range configuration
- portletConfig =
AbstractActivityView.saveMeasurementRangeEditorSettings(measurementRangeEditor,
- portletConfig);
-
- //operation priority
- portletConfig =
AbstractActivityView.saveOperationStatusSelectorSettings(operationStatusSelector,
- portletConfig);
-
- //persist and reload portlet
- storedPortlet.setConfiguration(portletConfig);
- configure(portletWindow, storedPortlet);
- //resynch the config object in the datasource
- resourceOperations.setDatasource(new
ResourceOperationsCriteriaDataSource(portletConfig));
- //apply latest settings to the visible result set
- redraw();
- }
- });
- form.markForRedraw();
- page.addMember(measurementRangeEditor);
- page.addMember(form);
- customSettings.addChild(page);
- return customSettings;
- }
-
- private void loadData() {
- //populate composite data
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.addFilterId(this.resourceId);
-
- criteria.fetchOperationHistories(false);
-
- //locate the resource
- GWTServiceLookup.getResourceService().findResourceCompositesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceComposite>>() {
- @Override
- public void onFailure(Throwable caught) {
- Log.debug("Error retrieving resource composite for resource
[" + resourceId + "]:"
- + caught.getMessage());
- setCurrentlyRefreshing(false);
- }
-
- @Override
- public void onSuccess(PageList<ResourceComposite> results) {
- if (!results.isEmpty()) {
- resourceComposite = results.get(0);
- //instantiate view
- //populated GWT criteria objects
- Criteria criteria = new
Criteria(ResourceOperationHistoryDataSource.CriteriaField.RESOURCE_ID,
- String.valueOf(resourceComposite.getResource().getId()));
-
- resourceOperations = new
ResourceOperationsCriteriaHistoryListView(locatorId,
- new ResourceOperationsCriteriaDataSource(portletConfig),
null, criteria, resourceComposite);
-
- //cleanup
- for (Canvas child : recentOperationsContent.getChildren()) {
- child.destroy();
- }
- recentOperationsContent.addChild(resourceOperations);
- recentOperationsContent.markForRedraw();
- }
- setCurrentlyRefreshing(false);
- }
- });
+ public ResourceOperationsPortlet(String locatorId, int resourceId) {
+ super(locatorId, EntityContext.forResource(resourceId));
}
public static final class Factory implements PortletViewFactory {
public static PortletViewFactory INSTANCE = new Factory();
+ /* (non-Javadoc)
+ * TODO: This factory ASSUMES the user is currently navigated to a resource
detail view, and generates a portlet
+ * for that resource. It will fail in other scenarios. This mechanism
should be improved such that the
+ * factory method can take an EntityContext explicitly indicating, in this
case, the resource.
+ * @see
org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory#getInstance(java.lang.String)
+ */
public final Portlet getInstance(String locatorId) {
- return new ResourceOperationsPortlet(locatorId);
- }
- }
-}
-
-/** Provide implementation of ResourceOperationsHistoryListView using datasource
- * that customizes fetch based on Configuration parameters.
- *
- * @author spinder
- */
-class ResourceOperationsCriteriaHistoryListView extends
- AbstractOperationHistoryListView<ResourceOperationsCriteriaDataSource> {
-
- private ResourceOperationsCriteriaDataSource datasource;
-
- public ResourceOperationsCriteriaHistoryListView(String locatorId,
ResourceOperationsCriteriaDataSource dataSource,
- String title, Criteria criteria, ResourceComposite composite) {
- super(locatorId, dataSource, title, criteria);
- this.datasource = dataSource;
- this.resourceComposite = composite;
- setShowFooterRefresh(false); //disable footer refresh
- }
-
- private ResourceComposite resourceComposite;
-
- @Override
- protected boolean hasControlPermission() {
- return this.resourceComposite.getResourcePermission().isControl();
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- return new
ResourceOperationHistoryDetailsView(extendLocatorId("DetailsView"),
this.resourceComposite);
- }
-
- public ResourceOperationsCriteriaDataSource getDatasource() {
- return datasource;
- }
- public void setDatasource(ResourceOperationsCriteriaDataSource datasource) {
- this.datasource = datasource;
- }
+ String currentPage = History.getToken();
+ String[] elements = currentPage.split("/");
+ int resourceId = Integer.valueOf(elements[1]);
- @Override
- protected void refreshTableInfo() {
- super.refreshTableInfo();
- if (getTableInfo() != null) {
- int count = getListGrid().getSelection().length;
- getTableInfo().setContents(
- MSG.view_table_matchingRows(String.valueOf(getListGrid().getTotalRows()),
String.valueOf(count)));
+ return new ResourceOperationsPortlet(locatorId, resourceId);
}
- }
-
- @Override
- protected String getBasePath() {
- return "Resource/" + resourceComposite.getResource().getId() +
"/Operations/History";
- }
- @Override
- protected void onInit() {
- super.onInit();
- getListGrid().setEmptyMessage(MSG.view_portlet_results_empty());
- }
-}
-
-/** Provide implementation of ResourceOperationHistoryDataSource that dynamically
- * configures fetch requests for this table view.
- *
- * @author spinder
- */
-class ResourceOperationsCriteriaDataSource extends ResourceOperationHistoryDataSource {
-
- public ResourceOperationsCriteriaDataSource(Configuration portletConfig) {
- this.portletConfig = portletConfig;
- }
-
- private Configuration portletConfig;
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response,
- final ResourceOperationHistoryCriteria criteria) {
- operationService.findResourceOperationHistoriesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
-
CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(),
caught);
- }
-
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected ResourceOperationHistoryCriteria getFetchCriteria(final DSRequest request)
{
- ResourceOperationHistoryCriteria criteria = new
ResourceOperationHistoryCriteria();
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
- int resourceId = Integer
- .parseInt((String)
request.getCriteria().getValues().get(CriteriaField.RESOURCE_ID));
- Integer[] resourceIds = new Integer[1];
- resourceIds[0] = resourceId;
- criteria.addFilterResourceIds(resourceIds);
- }
-
- //initialize to only five for quick queries.
- PageControl pageControl = new PageControl(0, 5);//default to displaying five
- //customize query with latest configuration selections
-
- //retrieve previous settings from portlet config
- if (portletConfig != null) {
- // //result sort order
- // PropertySimple property =
portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
- // if (property != null) {
- // String currentSetting = property.getStringValue();
- // if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
- // criteria.addSortStatus(PageOrdering.DESC);
- // } else {
- // criteria.addSortStatus(PageOrdering.ASC);
- // }
- // }
- //result timeframe if enabled
- PropertySimple property =
portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
- if (Boolean.valueOf(property.getBooleanValue())) {//then proceed setting
-
- boolean isAdvanced = false;
- //detect type of widget[Simple|Advanced]
- property =
portletConfig.getSimple(Constant.METRIC_RANGE_BEGIN_END_FLAG);
- if (property != null) {
- isAdvanced = property.getBooleanValue();
- }
- if (isAdvanced) {
- //Advanced time settings
- property = portletConfig.getSimple(Constant.METRIC_RANGE);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] range = currentSetting.split(",");
- criteria.addFilterStartTime(Long.valueOf(range[0]));
- criteria.addFilterEndTime(Long.valueOf(range[1]));
- }
- } else {
- //Simple time settings
- property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
- if (property != null) {
- int lastN = property.getIntegerValue();
- property = portletConfig.getSimple(Constant.METRIC_RANGE_UNIT);
- int lastUnits = property.getIntegerValue();
- ArrayList<Long> beginEnd =
MeasurementUtility.calculateTimeFrame(lastN, Integer
- .valueOf(lastUnits));
- criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
- criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
- }
- }
- }
-
- //result count
- property = portletConfig.getSimple(Constant.RESULT_COUNT);
- if (property != null) {
- String currentSetting = property.getStringValue();
- if (currentSetting.trim().isEmpty() ||
currentSetting.equalsIgnoreCase("5")) {
- pageControl.setPageSize(5);
- } else {
- pageControl = new PageControl(0, Integer.valueOf(currentSetting));
- }
- }
- criteria.setPageControl(pageControl);
-
- //detect operation status filter
- property = portletConfig.getSimple(Constant.OPERATION_STATUS);
- if (property != null) {
- String currentSetting = property.getStringValue();
- String[] parsedValues = currentSetting.trim().split(",");
- if (currentSetting.trim().isEmpty() || parsedValues.length ==
OperationRequestStatus.values().length) {
- //all operation stati assumed
- } else {
- OperationRequestStatus[] operationStati = new
OperationRequestStatus[parsedValues.length];
- int indx = 0;
- for (String priority : parsedValues) {
- OperationRequestStatus s =
OperationRequestStatus.valueOf(priority);
- operationStati[indx++] = s;
- }
- criteria.addFilterStatuses(operationStati);
- }
- }
- }
- return criteria;
}
}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
index 118cec2..0cb1411 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -40,9 +40,9 @@ import com.smartgwt.client.widgets.form.fields.StaticTextItem;
import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
-
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.VLayout;
+
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
@@ -69,7 +69,8 @@ import
org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
*
* @author Ian Springer
*/
-public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecordEditor<AbstractOperationScheduleDataSource> {
+public abstract class AbstractOperationScheduleDetailsView extends
+ AbstractRecordEditor<AbstractOperationScheduleDataSource> {
private static final String FIELD_OPERATION_DESCRIPTION =
"operationDescription";
private static final String FIELD_OPERATION_PARAMETERS =
"operationParameters";
@@ -78,8 +79,7 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
private Map<Integer, String> operationIdToNameMap = new HashMap<Integer,
String>();
private Map<String, String> operationNameToDescriptionMap = new
HashMap<String, String>();
- private Map<String, ConfigurationDefinition>
operationNameToParametersDefinitionMap =
- new HashMap<String, ConfigurationDefinition>();
+ private Map<String, ConfigurationDefinition>
operationNameToParametersDefinitionMap = new HashMap<String,
ConfigurationDefinition>();
private StaticTextItem operationDescriptionItem;
private StaticTextItem operationParametersItem;
private LocatableHLayout operationParametersConfigurationHolder;
@@ -89,15 +89,15 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
private Integer operationDefinitionId;
public AbstractOperationScheduleDetailsView(String locatorId,
AbstractOperationScheduleDataSource dataSource,
- ResourceType resourceType, int
scheduleId) {
+ ResourceType resourceType, int scheduleId) {
super(locatorId, dataSource, scheduleId,
MSG.view_operationScheduleDetails_operationSchedule(), null);
Set<OperationDefinition> operationDefinitions =
resourceType.getOperationDefinitions();
for (OperationDefinition operationDefinition : operationDefinitions) {
this.operationIdToNameMap.put(operationDefinition.getId(),
operationDefinition.getName());
this.operationNameToDescriptionMap.put(operationDefinition.getName(),
operationDefinition.getDescription());
-
this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
- operationDefinition.getParametersConfigurationDefinition());
+
this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
operationDefinition
+ .getParametersConfigurationDefinition());
}
}
@@ -146,13 +146,13 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
}
});
- this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION,
- MSG.view_operationScheduleDetails_field_description());
+ this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION,
MSG
+ .view_operationScheduleDetails_field_description());
this.operationDescriptionItem.setShowTitle(false);
items.add(this.operationDescriptionItem);
- this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS,
- MSG.view_operationScheduleDetails_field_parameters());
+ this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS,
MSG
+ .view_operationScheduleDetails_field_parameters());
this.operationParametersItem.setColSpan(2);
items.add(this.operationParametersItem);
@@ -190,20 +190,20 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
supportedUnits.add(TimeUnit.SECONDS);
supportedUnits.add(TimeUnit.MINUTES);
supportedUnits.add(TimeUnit.HOURS);
- DurationItem timeoutItem = new
DurationItem(AbstractOperationScheduleDataSource.Field.TIMEOUT,
- MSG.view_operationScheduleDetails_field_timeout(),
- supportedUnits, false, isReadOnly(), this.notesForm);
+ DurationItem timeoutItem = new
DurationItem(AbstractOperationScheduleDataSource.Field.TIMEOUT, MSG
+ .view_operationScheduleDetails_field_timeout(), supportedUnits, false,
isReadOnly(), this.notesForm);
timeoutItem.setContextualHelp(MSG.view_operationScheduleDetails_fieldHelp_timeout());
notesFields.add(timeoutItem);
if (!isNewRecord()) {
- StaticTextItem nextFireTimeItem = new
StaticTextItem(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME,
- MSG.dataSource_operationSchedule_field_nextFireTime());
+ StaticTextItem nextFireTimeItem = new StaticTextItem(
+ AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME, MSG
+ .dataSource_operationSchedule_field_nextFireTime());
notesFields.add(nextFireTimeItem);
}
- TextAreaItem notesItem = new
TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION,
- MSG.dataSource_operationSchedule_field_description());
+ TextAreaItem notesItem = new
TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, MSG
+ .dataSource_operationSchedule_field_description());
notesItem.setWidth(450);
notesItem.setHeight(60);
notesItem.setShowTitle(true);
@@ -220,7 +220,11 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
@Override
protected ButtonBar buildButtonBar() {
ButtonBar buttonBar = super.buildButtonBar();
- buttonBar.getSaveButton().setTitle(MSG.common_button_schedule());
+
+ if (null != buttonBar) {
+ buttonBar.getSaveButton().setTitle(MSG.common_button_schedule());
+ }
+
return buttonBar;
}
@@ -239,8 +243,8 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
}
Subject sessionSubject = UserSessionManager.getSessionSubject();
- AbstractOperationScheduleDataSource.SubjectRecord subjectRecord =
- new AbstractOperationScheduleDataSource.SubjectRecord(sessionSubject);
+ AbstractOperationScheduleDataSource.SubjectRecord subjectRecord = new
AbstractOperationScheduleDataSource.SubjectRecord(
+ sessionSubject);
record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT,
subjectRecord);
return record;
@@ -256,26 +260,29 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
@Override
protected void editExistingRecord(Record record) {
- JavaScriptObject jobTriggerJavaScriptObject =
- (JavaScriptObject)
getForm().getValue(AbstractOperationScheduleDataSource.Field.JOB_TRIGGER);
- Record jobTriggerRecord = new ListGridRecord(jobTriggerJavaScriptObject);
+ JavaScriptObject jobTriggerJavaScriptObject = (JavaScriptObject)
getForm().getValue(
+ AbstractOperationScheduleDataSource.Field.JOB_TRIGGER);
+ Record jobTriggerRecord = new ListGridRecord(jobTriggerJavaScriptObject);
JobTrigger jobTrigger = getDataSource().createJobTrigger(jobTriggerRecord);
this.triggerEditor.setJobTrigger(jobTrigger);
FormItem nextFireTimeItem =
this.notesForm.getField(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
nextFireTimeItem.setValue(getForm().getValue(AbstractOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
- DurationItem timeoutItem = (DurationItem)
this.notesForm.getField(AbstractOperationScheduleDataSource.Field.TIMEOUT);
+ DurationItem timeoutItem = (DurationItem) this.notesForm
+ .getField(AbstractOperationScheduleDataSource.Field.TIMEOUT);
Object value =
getForm().getValue(AbstractOperationScheduleDataSource.Field.TIMEOUT);
Integer integerValue = TypeConversionUtility.toInteger(value);
timeoutItem.setValue(integerValue, UnitType.TIME);
- StaticTextItem notesItem = (StaticTextItem)
this.notesForm.getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
+ StaticTextItem notesItem = (StaticTextItem) this.notesForm
+ .getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
// Notes field is user-editable, so escape HTML to prevent an XSS attack.
notesItem.setOutputAsHTML(true);
notesItem.setValue(getForm().getValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION));
- this.parameters = (Configuration)
record.getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
+ this.parameters = (Configuration) record
+ .getAttributeAsObject(AbstractOperationScheduleDataSource.Field.PARAMETERS);
super.editExistingRecord(record);
}
@@ -309,16 +316,17 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
form.setValue(AbstractOperationScheduleDataSource.Field.JOB_TRIGGER,
jobTriggerRecord);
- DurationItem timeoutItem =
(DurationItem)this.notesForm.getItem(AbstractOperationScheduleDataSource.Field.TIMEOUT);
+ DurationItem timeoutItem = (DurationItem) this.notesForm
+ .getItem(AbstractOperationScheduleDataSource.Field.TIMEOUT);
Long timeout = timeoutItem.getValueAsLong();
if (timeout != null) {
form.setValue(AbstractOperationScheduleDataSource.Field.TIMEOUT, timeout);
} else {
- form.setValue(AbstractOperationScheduleDataSource.Field.TIMEOUT,
(String)null);
+ form.setValue(AbstractOperationScheduleDataSource.Field.TIMEOUT, (String)
null);
}
FormItem notesItem =
this.notesForm.getField(AbstractOperationScheduleDataSource.Field.DESCRIPTION);
- form.setValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION,
(String)notesItem.getValue());
+ form.setValue(AbstractOperationScheduleDataSource.Field.DESCRIPTION, (String)
notesItem.getValue());
super.save(requestProperties);
}
@@ -340,7 +348,8 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
if (operationName == null) {
value = "<i>" +
MSG.view_operationScheduleDetails_fieldDefault_parameters() + "</i>";
} else {
- ConfigurationDefinition parametersDefinition =
this.operationNameToParametersDefinitionMap.get(operationName);
+ ConfigurationDefinition parametersDefinition =
this.operationNameToParametersDefinitionMap
+ .get(operationName);
if (parametersDefinition == null ||
parametersDefinition.getPropertyDefinitions().isEmpty()) {
value = "<i>" +
MSG.view_operationScheduleDetails_noParameters() + "</i>";
@@ -361,13 +370,13 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
this.operationParametersConfigurationHolder.addMember(horizontalSpacer);
if (isNewRecord()) {
- this.parameters = (parametersDefinition.getDefaultTemplate() != null)
?
- parametersDefinition.getDefaultTemplate().createConfiguration() :
new Configuration();
+ this.parameters = (parametersDefinition.getDefaultTemplate() != null)
? parametersDefinition
+ .getDefaultTemplate().createConfiguration() : new
Configuration();
} else {
}
- ConfigurationEditor configurationEditor = new
ConfigurationEditor("ParametersEditor", parametersDefinition,
- this.parameters);
+ ConfigurationEditor configurationEditor = new
ConfigurationEditor("ParametersEditor",
+ parametersDefinition, this.parameters);
configurationEditor.setReadOnly(isReadOnly());
this.operationParametersConfigurationHolder.addMember(configurationEditor);
this.operationParametersConfigurationHolder.show();
@@ -378,7 +387,7 @@ public abstract class AbstractOperationScheduleDetailsView extends
AbstractRecor
private String getSelectedOperationName() {
FormItem operationNameItem =
getForm().getField(AbstractOperationScheduleDataSource.Field.OPERATION_NAME);
- return (String)operationNameItem.getValue();
+ return (String) operationNameItem.getValue();
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
index 291bf07..3d64039 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -19,24 +19,25 @@
*/
package
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history;
-import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.resource.composite.ResourceComposite;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
/**
* A table that displays all of the operation histories for a particular Resource.
*
* @author Ian Springer
+ * @author Jay Shaughnessy
*/
-public class ResourceOperationHistoryListView extends AbstractOperationHistoryListView {
+public class ResourceOperationHistoryListView extends OperationHistoryView {
private ResourceComposite resourceComposite;
public ResourceOperationHistoryListView(String locatorId, ResourceComposite
resourceComposite) {
- super(locatorId, new ResourceOperationHistoryDataSource(), null,
- new Criteria(ResourceOperationHistoryDataSource.CriteriaField.RESOURCE_ID,
- String.valueOf(resourceComposite.getResource().getId())));
+ super(locatorId, null,
EntityContext.forResource(resourceComposite.getResource().getId()));
+
this.resourceComposite = resourceComposite;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
new file mode 100644
index 0000000..a9a1c3f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryDataSource.java
@@ -0,0 +1,451 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 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.operation;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+
+import com.allen_sauer.gwt.log.client.Log;
+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.DataSourceTextField;
+import com.smartgwt.client.rpc.RPCResponse;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationHistory;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
+
+/**
+ * @author Jay Shaughnessy
+ * @author Ian Springer
+ */
+public class OperationHistoryDataSource extends
+ RPCDataSource<ResourceOperationHistory, ResourceOperationHistoryCriteria> {
+
+ private EntityContext entityContext;
+
+ private ResourceOperationHistory currentOperationHistory;
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String OPERATION_NAME = "operationName";
+ public static final String STATUS = "status";
+ public static final String STARTED_TIME = "startedTime";
+ public static final String CREATED_TIME = "createdTime";
+ public static final String DURATION = "duration";
+ public static final String SUBJECT = "subject";
+ public static final String OPERATION_DEFINITION =
"operationDefinition";
+ public static final String ERROR_MESSAGE = "errorMessage";
+ public static final String PARAMETERS = "parameters";
+ }
+
+ protected OperationGWTServiceAsync operationService =
GWTServiceLookup.getOperationService();
+
+ public OperationHistoryDataSource() {
+ this(EntityContext.forSubsystemView());
+ }
+
+ public OperationHistoryDataSource(EntityContext context) {
+ super();
+ this.entityContext = context;
+
+ addDataSourceFields();
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ // for some reason, the client seems to crash if you don't specify any data
source fields
+ // even though we know we defined override ListGridFields for all columns.
+ List<DataSourceField> fields = super.addDataSourceFields();
+ fields.add(new DataSourceTextField(Field.OPERATION_NAME));
+ return fields;
+ }
+
+ /**
+ * 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>(6);
+
+ ListGridField idField = new ListGridField(Field.ID, MSG.common_title_id());
+ idField.setWidth(70);
+ fields.add(idField);
+
+ ListGridField startTimeField = createStartedTimeField();
+ fields.add(startTimeField);
+
+ ListGridField opNameField = new ListGridField(Field.OPERATION_NAME, MSG
+ .view_operationHistoryDetails_operation());
+ fields.add(opNameField);
+
+ ListGridField subjectField = new ListGridField(Field.SUBJECT,
MSG.view_operationHistoryDetails_requestor());
+ fields.add(subjectField);
+
+ ListGridField statusField = createStatusField();
+ fields.add(statusField);
+
+ if (this.entityContext.type != EntityContext.Type.Resource) {
+ ListGridField resourceNameField = new
ListGridField(AncestryUtil.RESOURCE_NAME, MSG.common_title_resource());
+ resourceNameField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int
i1) {
+ String url = LinkManager
+
.getResourceLink(listGridRecord.getAttributeAsInt(AncestryUtil.RESOURCE_ID));
+ return SeleniumUtility.getLocatableHref(url, o.toString(), null);
+ }
+ });
+ resourceNameField.setShowHover(true);
+ resourceNameField.setHoverCustomizer(new HoverCustomizer() {
+
+ public String hoverHTML(Object value, ListGridRecord listGridRecord, int
rowNum, int colNum) {
+ return AncestryUtil.getResourceHoverHTML(listGridRecord, 0);
+ }
+ });
+ fields.add(resourceNameField);
+
+ ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
+ fields.add(ancestryField);
+
+ startTimeField.setWidth(200);
+ opNameField.setWidth("25%");
+ subjectField.setWidth("15%");
+ statusField.setWidth(100);
+ resourceNameField.setWidth("25%");
+ ancestryField.setWidth("35%");
+ } else {
+ startTimeField.setWidth(200);
+ opNameField.setWidth("*");
+ subjectField.setWidth("*");
+ statusField.setWidth(100);
+ }
+
+ return fields;
+ }
+
+ protected ListGridField createStartedTimeField() {
+ ListGridField startedTimeField = new ListGridField(Field.STARTED_TIME, MSG
+ .view_operationHistoryDetails_dateSubmitted());
+ startedTimeField.setAlign(Alignment.LEFT);
+ startedTimeField.setCellAlign(Alignment.LEFT);
+ startedTimeField.setCellFormatter(new TimestampCellFormatter() {
+ public String format(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ if (value != null) {
+ String timestamp = super.format(value, record, rowNum, colNum);
+ Integer resourceId =
record.getAttributeAsInt(AncestryUtil.RESOURCE_ID);
+ Integer opHistoryId = record.getAttributeAsInt("id");
+ String url =
LinkManager.getSubsystemResourceOperationHistoryLink(resourceId, opHistoryId);
+ return SeleniumUtility.getLocatableHref(url, timestamp, null);
+ } else {
+ return "<i>" +
MSG.view_operationHistoryList_notYetStarted() + "</i>";
+ }
+ }
+ });
+ startedTimeField.setShowHover(true);
+
startedTimeField.setHoverCustomizer(TimestampCellFormatter.getHoverCustomizer(Field.STARTED_TIME));
+
+ return startedTimeField;
+ }
+
+ protected ListGridField createStatusField() {
+ ListGridField statusField = new ListGridField(Field.STATUS,
MSG.view_operationHistoryDetails_status());
+ statusField.setAlign(Alignment.CENTER);
+ statusField.setCellAlign(Alignment.CENTER);
+ statusField.setShowHover(true);
+ statusField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
+ String statusStr = record.getAttribute(Field.STATUS);
+ OperationRequestStatus status =
OperationRequestStatus.valueOf(statusStr);
+ switch (status) {
+ case SUCCESS: {
+ return MSG.common_status_success();
+ }
+ case FAILURE: {
+ return MSG.common_status_failed();
+ }
+ case INPROGRESS: {
+ return MSG.common_status_inprogress();
+ }
+ case CANCELED: {
+ return MSG.common_status_canceled();
+ }
+ }
+ // should never get here
+ return MSG.common_status_unknown();
+ }
+ });
+ statusField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1)
{
+ OperationRequestStatus status = OperationRequestStatus.valueOf((String)
o);
+ String icon = ImageManager.getOperationResultsIcon(status);
+ return Canvas.imgHTML(icon, 16, 16);
+ }
+ });
+ statusField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ Record record = event.getRecord();
+ String statusStr = record.getAttribute(Field.STATUS);
+ OperationRequestStatus status =
OperationRequestStatus.valueOf(statusStr);
+ if (status == OperationRequestStatus.FAILURE) {
+ final Window winModal = new
LocatableWindow("StatusDetailsWin");
+ winModal.setTitle(MSG.common_title_details());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new
LocatableHTMLPane("StatusDetailsPane");
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ String errorMsg = record.getAttribute(Field.ERROR_MESSAGE);
+ if (errorMsg == null) {
+ errorMsg = MSG.common_status_failed();
+ }
+ htmlPane.setContents("<pre>" + errorMsg +
"</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+ }
+ });
+
+ return statusField;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response,
+ final ResourceOperationHistoryCriteria criteria) {
+
+ if (criteria == null) {
+ // the user selected no statuses in the filter - it makes sense from the UI
perspective to show 0 rows
+ response.setTotalRows(0);
+ processResponse(request.getRequestId(), response);
+ return;
+ }
+
+ final long start = System.currentTimeMillis();
+
+ this.operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler()
+
.handleError(MSG.view_operationHistoryDetails_error_fetchFailure(), caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ long fetchTime = System.currentTimeMillis() - start;
+ Log.info(result.size() + " operation histories fetched in:
" + fetchTime + "ms");
+
+ dataRetrieved(result, response, request);
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ /**
+ * Additional processing to support entity-specific or cross-resource views, and
something that can be overidden.
+ */
+ protected void dataRetrieved(final PageList<ResourceOperationHistory> result,
final DSResponse response,
+ final DSRequest request) {
+ switch (entityContext.type) {
+
+ // no need to disambiguate the history for a single resource
+ case Resource:
+ response.setData(buildRecords(result));
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize());
+ break;
+
+ // disambiguate as the results could be cross-resource
+ default:
+ HashSet<Integer> typesSet = new HashSet<Integer>();
+ HashSet<String> ancestries = new HashSet<String>();
+ for (ResourceOperationHistory history : result) {
+ Resource resource = history.getResource();
+ typesSet.add(resource.getResourceType().getId());
+ ancestries.add(resource.getAncestry());
+ }
+
+ // In addition to the types of the result resources, get the types of their
ancestry
+ typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
+
+ ResourceTypeRepository typeRepo =
ResourceTypeRepository.Cache.getInstance();
+ typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new
TypesLoadedCallback() {
+ @Override
+ public void onTypesLoaded(Map<Integer, ResourceType> types) {
+ // Smartgwt has issues storing a Map as a ListGridRecord attribute.
Wrap it in a pojo.
+ AncestryUtil.MapWrapper typesWrapper = new
AncestryUtil.MapWrapper(types);
+
+ Record[] records = buildRecords(result);
+ for (Record record : records) {
+ // To avoid a lot of unnecessary String construction, be lazy
about building ancestry hover text.
+ // Store the types map off the records so we can build a detailed
hover string as needed.
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES,
typesWrapper);
+
+ // Build the decoded ancestry Strings now for display
+ record
+ .setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE,
AncestryUtil.getAncestryValue(record));
+ }
+ response.setData(records);
+ // for paging to work we have to specify size of full result set
+ response.setTotalRows(result.getTotalSize());
+ }
+ });
+ }
+ }
+
+ @Override
+ protected ResourceOperationHistoryCriteria getFetchCriteria(DSRequest request) {
+ OperationRequestStatus[] statusFilter = getArrayFilter(request,
Constant.OPERATION_STATUS,
+ OperationRequestStatus.class);
+
+ if (statusFilter == null || statusFilter.length == 0) {
+ return null; // user didn't select any severities - return null to
indicate no data should be displayed
+ }
+
+ ResourceOperationHistoryCriteria criteria = new
ResourceOperationHistoryCriteria();
+
+ criteria.addFilterStatuses(statusFilter);
+
+ switch (entityContext.type) {
+ case Resource:
+ criteria.addFilterResourceIds(entityContext.resourceId);
+ break;
+
+ case ResourceGroup:
+ criteria.addFilterGroupOperationHistoryId(entityContext.groupId);
+ break;
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+
+ @Override
+ protected void executeRemove(Record recordToRemove, DSRequest request, DSResponse
response) {
+ final OperationHistory operationHistoryToRemove = copyValues(recordToRemove);
+ Boolean forceValue = request.getAttributeAsBoolean("force");
+ boolean force = ((forceValue != null) && forceValue);
+ operationService.deleteOperationHistory(operationHistoryToRemove.getId(), force,
new AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ return;
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to delete " +
operationHistoryToRemove + ".", caught);
+ }
+ });
+ }
+
+ @Override
+ public ResourceOperationHistory copyValues(Record from) {
+ return this.currentOperationHistory;
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceOperationHistory from) {
+ this.currentOperationHistory = from;
+
+ ListGridRecord record = new ListGridRecord();
+
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.CREATED_TIME,
convertTimestampToDate(from.getCreatedTime()));
+ record.setAttribute(Field.STARTED_TIME,
convertTimestampToDate(from.getStartedTime()));
+ record.setAttribute(Field.DURATION, from.getDuration());
+ record.setAttribute(Field.SUBJECT, from.getSubjectName());
+ record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
+ record.setAttribute(Field.OPERATION_NAME,
from.getOperationDefinition().getDisplayName());
+ record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
+ record.setAttribute(Field.STATUS, from.getStatus().name());
+ record.setAttribute(Field.PARAMETERS, from.getParameters());
+
+ // for ancestry handling
+ Resource resource = from.getResource();
+ record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
+ record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
+ record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
+ record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID,
resource.getResourceType().getId());
+
+ return record;
+ }
+
+ protected EntityContext getEntityContext() {
+ return entityContext;
+ }
+
+ protected void setEntityContext(EntityContext entityContext) {
+ this.entityContext = entityContext;
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
new file mode 100644
index 0000000..aa02adc
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/OperationHistoryView.java
@@ -0,0 +1,179 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2009 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.operation;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.SortSpecifier;
+import com.smartgwt.client.types.MultipleAppearance;
+import com.smartgwt.client.types.SortDirection;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.PortletConfigurationEditorComponent.Constant;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.AbstractConfigurationHistoryDataSource.Field;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
+
+/**
+ * A view that displays a paginated table of operation history. Support exists of
subsystem and resource contexts.
+ * Group operation history is (currently) handled separately as the view is comprised of
group operation history
+ * entities, not [resource] operation history entities.
+ (
+ * @author Jay Shaughnessy
+ */
+public class OperationHistoryView extends TableSection<OperationHistoryDataSource>
{
+
+ public static final ViewName SUBSYSTEM_VIEW_ID = new
ViewName("RecentOperations", MSG
+ .common_title_recent_operations());
+
+ private static final String HEADER_ICON =
"subsystems/control/Operation_24.png";
+ private static final SortSpecifier DEFAULT_SORT_SPECIFIER = new
SortSpecifier(Field.CREATED_TIME,
+ SortDirection.DESCENDING);
+
+ EntityContext context;
+ boolean hasControlPermission;
+ OperationHistoryDataSource dataSource;
+
+ // for subsystem views
+ public OperationHistoryView(String locatorId) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), EntityContext.forSubsystemView(),
false);
+ }
+
+ public OperationHistoryView(String locatorId, EntityContext entityContext) {
+ this(locatorId, SUBSYSTEM_VIEW_ID.getTitle(), entityContext, false);
+ }
+
+ public OperationHistoryView(String locatorId, String tableTitle, EntityContext
entityContext) {
+ this(locatorId, tableTitle, entityContext, false);
+ }
+
+ protected OperationHistoryView(String locatorId, String tableTitle, EntityContext
context,
+ boolean hasControlPermission) {
+ super(locatorId, tableTitle, new SortSpecifier[] { DEFAULT_SORT_SPECIFIER });
+ this.context = context;
+ this.hasControlPermission = hasControlPermission;
+
+ setDataSource(getDataSource());
+ }
+
+ @Override
+ public OperationHistoryDataSource getDataSource() {
+ if (null == this.dataSource) {
+ this.dataSource = new OperationHistoryDataSource(context);
+ }
+ return this.dataSource;
+ }
+
+ @Override
+ protected void configureTableFilters() {
+ SelectItem statusFilter = new SelectItem(Constant.OPERATION_STATUS,
MSG.common_title_operation_status());
+ statusFilter.setWrapTitle(false);
+ statusFilter.setWidth(325);
+ statusFilter.setMultiple(true);
+ statusFilter.setMultipleAppearance(MultipleAppearance.PICKLIST);
+
+ LinkedHashMap<String, String> stati = new LinkedHashMap<String,
String>(4);
+ stati.put(OperationRequestStatus.SUCCESS.name(), MSG.common_status_success());
+ stati.put(OperationRequestStatus.INPROGRESS.name(),
MSG.common_status_inprogress());
+ stati.put(OperationRequestStatus.CANCELED.name(), MSG.common_status_canceled());
+ stati.put(OperationRequestStatus.FAILURE.name(), MSG.common_status_failed());
+
+ LinkedHashMap<String, String> statusIcons = new LinkedHashMap<String,
String>(3);
+ statusIcons.put(OperationRequestStatus.SUCCESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.SUCCESS));
+ statusIcons.put(OperationRequestStatus.INPROGRESS.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.INPROGRESS));
+ statusIcons.put(OperationRequestStatus.CANCELED.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.CANCELED));
+ statusIcons.put(OperationRequestStatus.FAILURE.name(), ImageManager
+ .getOperationResultsIcon(OperationRequestStatus.FAILURE));
+ statusFilter.setValueMap(stati);
+ statusFilter.setValueIcons(statusIcons);
+ statusFilter.setValues(OperationRequestStatus.SUCCESS.name(),
OperationRequestStatus.INPROGRESS.name(),
+ OperationRequestStatus.FAILURE.name(),
OperationRequestStatus.CANCELED.name());
+
+ if (isShowFilterForm()) {
+ setFilterFormItems(statusFilter);
+ }
+ }
+
+ @Override
+ protected void configureTable() {
+ ArrayList<ListGridField> dataSourceFields =
getDataSource().getListGridFields();
+ getListGrid().setFields(dataSourceFields.toArray(new
ListGridField[dataSourceFields.size()]));
+
+ setupTableInteractions();
+
+ super.configureTable();
+ }
+
+ protected boolean hasControlPermission() {
+ return this.hasControlPermission;
+ }
+
+ protected void setupTableInteractions() {
+
+ addTableAction(extendLocatorId("Delete"), MSG.common_button_delete(),
getDeleteConfirmMessage(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return (count >= 1 && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue)
{
+ deleteSelectedRecords();
+ }
+ });
+
+ addTableAction(extendLocatorId("ForceDelete"),
MSG.view_operationHistoryList_button_forceDelete(),
+ getDeleteConfirmMessage(), new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return (count >= 1 && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue)
{
+ DSRequest requestProperties = new DSRequest();
+ requestProperties.setAttribute("force", true);
+ deleteSelectedRecords(requestProperties);
+ }
+ });
+ }
+
+ public EntityContext getContext() {
+ return context;
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new
ResourceOperationHistoryDetailsView(extendLocatorId("Detail"));
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
deleted file mode 100644
index 1af0364..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/RecentOperationsDataSource.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.operation;
-
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
-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.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.operation.composite.ResourceOperationLastCompletedComposite;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.PageControl;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.LinkManager;
-import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * Responsible for defining and populating the Smart GWT datasource details and
- * translating the deserialized content into specific record entries for display
- *
- * @author Simeon Pinder
- * @author Jay Shaughnessy
- */
-public class RecentOperationsDataSource extends
RPCDataSource<ResourceOperationLastCompletedComposite, Criteria> {
-
- public enum Field {
-
- OPERATION("operationName",
MSG.dataSource_operationSchedule_field_operationName()),
-
- RESOURCE("resource", MSG.common_title_resource()),
-
- STATUS("operationStatus", MSG.common_title_status()),
-
- TIME("operationStartTime", MSG.common_title_timestamp());
-
- /**
- * Corresponds to a property name of Resource (e.g. resourceType.name).
- */
- private String propertyName;
-
- /**
- * The table header for the field or property (e.g. Type).
- */
- private String title;
-
- private Field(String propertyName, String title) {
- this.propertyName = propertyName;
- this.title = title;
- }
-
- public String propertyName() {
- return propertyName;
- }
-
- public String title() {
- return title;
- }
-
- public ListGridField getListGridField() {
- return new ListGridField(propertyName, title);
- }
-
- public ListGridField getListGridField(int width) {
- return new ListGridField(propertyName, title, width);
- }
-
- }
-
- private Portlet portlet;
-
- //config attributes
- private boolean operationsRangeLastEnabled = false;
- private int operationsRangeCompleted = -1;
-
- /** Build list of fields for the datasource and then adds them to it.
- */
- public RecentOperationsDataSource(Portlet portlet) {
- this.portlet = portlet;
-
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- DataSourceTextField resourceField = new
DataSourceTextField(Field.RESOURCE.propertyName, Field.RESOURCE.title);
- fields.add(resourceField);
-
- DataSourceTextField operationField = new
DataSourceTextField(Field.OPERATION.propertyName(), Field.OPERATION
- .title());
- fields.add(operationField);
-
- DataSourceTextField timeField = new
DataSourceTextField(Field.TIME.propertyName(), Field.TIME.title());
- fields.add(timeField);
-
- DataSourceTextField statusField = new
DataSourceTextField(Field.STATUS.propertyName, Field.STATUS.title(), 20);
- fields.add(statusField);
-
- return fields;
- }
-
- /** Fetch the ProblemResource data, and populate the response object appropriately.
- *
- * @param request incoming request
- * @param response outgoing response
- */
- @Override
- public void executeFetch(final DSRequest request, final DSResponse response, final
Criteria unused) {
- PageControl pageControl = new PageControl();
- //retrieve current portlet display settings
- if ((this.portlet != null) && (this.portlet instanceof
OperationsPortlet)) {
- OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
- //populate criteria with portlet preferences defined.
- if (operationsPortlet != null) {
- if (isOperationsRangeCompletedEnabled()) {
- pageControl.setPageSize(getOperationsRangeCompleted());
- operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
- } else {//show the component, return no results and indicate that
you've disabled this display
- pageControl.setPageSize(0);
- operationsPortlet.getCompletedOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE);
- response.setData(null);
- response.setTotalRows(0);
- //pass off for processing
- processResponse(request.getRequestId(), response);
- return;
- }
- }
- }
-
- int resourceId = -1;
-
- GWTServiceLookup.getOperationService().findRecentCompletedOperations(resourceId,
pageControl,
- new
AsyncCallback<PageList<ResourceOperationLastCompletedComposite>>() {
-
- public void onFailure(Throwable throwable) {
-
CoreGUI.getErrorHandler().handleError(MSG.dataSource_recentOperations_error_fetchFailure(),
- throwable);
- }
-
- public void
onSuccess(PageList<ResourceOperationLastCompletedComposite> result) {
- dataRetrieved(result, response, request);
- }
- });
- }
-
- @Override
- protected Criteria getFetchCriteria(DSRequest request) {
- // we don't use criterias for this datasource, just return null
- return null;
- }
-
- protected void dataRetrieved(final
PageList<ResourceOperationLastCompletedComposite> result,
- final DSResponse response, final DSRequest request) {
- HashSet<Integer> typesSet = new HashSet<Integer>();
- HashSet<String> ancestries = new HashSet<String>();
- for (ResourceOperationLastCompletedComposite composite : result) {
- typesSet.add(composite.getResourceTypeId());
- ancestries.add(composite.getAncestry());
- }
-
- // In addition to the types of the result resources, get the types of their
ancestry
- // NOTE: this may be too labor intensive in general, but since this datasource is
a singleton I couldn't
- // make it easily optional.
- typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries));
-
- ResourceTypeRepository typeRepo = ResourceTypeRepository.Cache.getInstance();
- typeRepo.getResourceTypes(typesSet.toArray(new Integer[typesSet.size()]), new
TypesLoadedCallback() {
- @Override
- public void onTypesLoaded(Map<Integer, ResourceType> types) {
- // Smartgwt has issues storing a Map as a ListGridRecord attribute. Wrap
it in a pojo.
- AncestryUtil.MapWrapper typesWrapper = new
AncestryUtil.MapWrapper(types);
-
- Record[] records = buildRecords(result);
- for (Record record : records) {
- // To avoid a lot of unnecessary String construction, be lazy about
building ancestry hover text.
- // Store the types map off the records so we can build a detailed
hover string as needed.
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_TYPES,
typesWrapper);
-
- // Build the decoded ancestry Strings now for display
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY_VALUE,
AncestryUtil.getAncestryValue(record));
- }
- response.setData(records);
-
- // for paging to work we have to specify size of full result set, but if
a limit has been set,
- // respect the limit
- int resultSize = result.getTotalSize();
- int limit = getOperationsRangeCompleted();
- if (limit > 0 && limit < resultSize) {
- resultSize = limit;
- }
- response.setTotalRows(resultSize);
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- public ListGridRecord copyValues(ResourceOperationLastCompletedComposite from) {
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(Field.OPERATION.propertyName, from.getOperationName());
- record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
- record.setAttribute(Field.STATUS.propertyName, getStatusIconLink(from));
- record.setAttribute(Field.TIME.propertyName, new
Date(from.getOperationStartTime()));
-
- // for ancestry handling
- record.setAttribute(AncestryUtil.RESOURCE_ID, from.getResourceId());
- record.setAttribute(AncestryUtil.RESOURCE_NAME, from.getResourceName());
- record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, from.getAncestry());
- record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, from.getResourceTypeId());
-
- record.setAttribute("entity", from);
- return record;
- }
-
- @Override
- public ResourceOperationLastCompletedComposite copyValues(Record from) {
- throw new
UnsupportedOperationException("ResourceOperationLastCompletedComposite data is read
only");
- }
-
- private String getStatusIconLink(ResourceOperationLastCompletedComposite composite)
{
-
- OperationRequestStatus opStatus = composite.getOperationStatus();
- String statusStr = "";
- switch (opStatus) {
- case SUCCESS: {
- statusStr = MSG.common_status_success();
- break;
- }
- case FAILURE: {
- statusStr = MSG.common_status_failed();
- break;
- }
- case INPROGRESS: {
- statusStr = MSG.common_status_inprogress();
- break;
- }
- case CANCELED: {
- statusStr = MSG.common_status_canceled();
- break;
- }
- }
-
- String iconLink = ImageManager.getOperationResultsIcon(opStatus);
- StringBuilder sbImg = new StringBuilder();
- sbImg.append("<img alt='");
- sbImg.append(statusStr);
- sbImg.append("' title='");
- sbImg.append(statusStr);
- sbImg.append("' src='");
- sbImg.append(ImageManager.getFullImagePath(iconLink));
- sbImg.append("'></img>");
-
- String url =
LinkManager.getSubsystemResourceOperationHistoryLink(composite.getResourceId(), composite
- .getOperationHistoryId());
-
- return "<a href='" + url + "'>" +
sbImg.toString() + "</a>";
- }
-
- public boolean isOperationsRangeCompletedEnabled() {
- return operationsRangeLastEnabled;
- }
-
- public void setOperationsRangeCompleteEnabled(boolean operationsRangeLastEnabled) {
- this.operationsRangeLastEnabled = operationsRangeLastEnabled;
- }
-
- public int getOperationsRangeCompleted() {
- return operationsRangeCompleted;
- }
-
- public void setOperationsRangeCompleted(int operationsRangeCompleted) {
- this.operationsRangeCompleted = operationsRangeCompleted;
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
index e9ee1c2..d7bfdad 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/operation/ScheduledOperationsDataSource.java
@@ -38,16 +38,20 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet;
-import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationsPortlet;
+import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.recent.operations.OperationSchedulePortlet;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository.TypesLoadedCallback;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+// Note, there is nothing in this class that requires ResourceOperationScheduleComposite,
it can all be driven
+// off ResourceOperationSchedule. We should improve te scheduled op datamodel/api at
some point and the
+// composite could probably go away.
+
/**
* Responsible for defining and populating the Smart GWT datasource details and
- * translating the deserialized content into specific record entries for display
+ * translating the deserialized content into specific record entries for display.
*
* @author Simeon Pinder
* @author Jay Shaughnessy
@@ -136,18 +140,18 @@ public class ScheduledOperationsDataSource extends
RPCDataSource<ResourceOperati
int pageSize = -1;
//retrieve current portlet display settings
- if ((this.portlet != null) && (this.portlet instanceof
OperationsPortlet)) {
- OperationsPortlet operationsPortlet = (OperationsPortlet) this.portlet;
+ if ((this.portlet != null) && (this.portlet instanceof
OperationSchedulePortlet)) {
+ OperationSchedulePortlet operationsPortlet = (OperationSchedulePortlet)
this.portlet;
//populate criteria with portlet preferences defined.
if (operationsPortlet != null) {
if (isOperationsRangeScheduleEnabled()) {
pageSize = getOperationsRangeScheduled();
operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
+ OperationSchedulePortlet.RANGE_DISABLED_MESSAGE_DEFAULT);
} else {//show the component, return no results and indicate that
you've disabled this display
pageSize = 0;
operationsPortlet.getScheduledOperationsGrid().setEmptyMessage(
- OperationsPortlet.RANGE_DISABLED_MESSAGE);
+ OperationSchedulePortlet.RANGE_DISABLED_MESSAGE);
response.setData(null);
response.setTotalRows(0);
//pass off for processing
@@ -222,6 +226,7 @@ public class ScheduledOperationsDataSource extends
RPCDataSource<ResourceOperati
@Override
public ListGridRecord copyValues(ResourceOperationScheduleComposite from) {
ListGridRecord record = new ListGridRecord();
+ record.setAttribute("id", from.getId());
record.setAttribute(Field.OPERATION.propertyName, from.getOperationName());
record.setAttribute(Field.RESOURCE.propertyName, from.getResourceName());
record.setAttribute(Field.TIME.propertyName, new
Date(from.getOperationNextFireTime()));
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index 186a5b7..90e3ea4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -42,6 +42,7 @@ import
org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import
org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBView;
import
org.rhq.enterprise.gui.coregui.client.report.operation.SubsystemOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
@@ -116,11 +117,11 @@ public class ReportTopView extends
AbstractSectionedLeftNavigationView {
}
});
- NavigationItem recentOperationsItem = new
NavigationItem(SubsystemOperationHistoryListView.VIEW_ID,
+ NavigationItem recentOperationsItem = new
NavigationItem(OperationHistoryView.SUBSYSTEM_VIEW_ID,
"subsystems/control/Operation_16.png", new ViewFactory() {
public Canvas createView() {
- return new SubsystemOperationHistoryListView(
-
extendLocatorId(SubsystemOperationHistoryListView.VIEW_ID.getName()));
+ return new
SubsystemOperationHistoryListView(extendLocatorId(OperationHistoryView.SUBSYSTEM_VIEW_ID
+ .getName()),
getGlobalPermissions().contains(Permission.MANAGE_INVENTORY));
}
});
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
index 0d4e46f..cea9e70 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
@@ -19,81 +19,17 @@
*/
package org.rhq.enterprise.gui.coregui.client.report.operation;
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Set;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.grid.ListGridField;
-
-import org.rhq.core.domain.authz.Permission;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoadedListener;
-import org.rhq.enterprise.gui.coregui.client.PermissionsLoader;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryDataSource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDetailsView;
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.enterprise.gui.coregui.client.operation.OperationHistoryView;
/**
* @author Ian Springer
+ * @author Jay Shaughnessy
*/
-public class SubsystemOperationHistoryListView extends AbstractOperationHistoryListView
{
-
- public static final ViewName VIEW_ID = new ViewName("RecentOperations",
MSG.common_title_recent_operations());
-
- private Set<Permission> globalPermissions;
-
- public SubsystemOperationHistoryListView(String locatorId) {
- super(locatorId, new ResourceOperationHistoryDataSource(), VIEW_ID.getTitle());
-
- this.globalPermissions = EnumSet.noneOf(Permission.class);
- loadGlobalPermissions();
- }
-
- @Override
- protected boolean hasControlPermission() {
- loadGlobalPermissions();
- return this.globalPermissions.contains(Permission.MANAGE_INVENTORY);
- }
+public class SubsystemOperationHistoryListView extends OperationHistoryView {
- private void loadGlobalPermissions() {
- new PermissionsLoader().loadExplicitGlobalPermissions(new
PermissionsLoadedListener() {
- public void onPermissionsLoaded(Set<Permission> permissions) {
- globalPermissions = permissions;
- }
- });
+ public SubsystemOperationHistoryListView(String locatorId, boolean
hasControlPermission) {
+ super(locatorId, OperationHistoryView.SUBSYSTEM_VIEW_ID.getTitle(),
EntityContext.forSubsystemView(),
+ hasControlPermission);
}
-
- @Override
- protected List<ListGridField> createFields() {
- List<ListGridField> fields = super.createFields();
-
- ListGridField resourceField = createResourceField();
- resourceField.setWidth("20%");
- fields.add(1, resourceField);
-
- ListGridField ancestryField = createAncestryField();
- resourceField.setWidth("20%");
- fields.add(2, ancestryField);
-
- for (ListGridField field : fields) {
- String fieldName = field.getName();
- if (fieldName.equals(AbstractOperationHistoryDataSource.Field.SUBJECT)) {
- field.setWidth("10%");
- }
- if
(fieldName.equals(AbstractOperationHistoryDataSource.Field.OPERATION_NAME)
- ||
fieldName.equals(AbstractOperationHistoryDataSource.Field.STARTED_TIME)) {
- field.setWidth("25%");
- }
- }
-
- return fields;
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- return new
ResourceOperationHistoryDetailsView(this.extendLocatorId("DetailsView"), true);
- }
-
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 3fa0171..4e4348e 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -50,6 +50,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.operation.OperationRequestStatus;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
@@ -506,6 +507,8 @@ public abstract class RPCDataSource<T, C extends
org.rhq.core.domain.criteria.Cr
return (S[]) new AlertPriority[size];
} else if (genericEnumType == EventSeverity.class) {
return (S[]) new EventSeverity[size];
+ } else if (genericEnumType == OperationRequestStatus.class) {
+ return (S[]) new OperationRequestStatus[size];
} else if (genericEnumType == ResourceCategory.class) {
return (S[]) new ResourceCategory[size];
} else {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
index 59ad907..ad42c8c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/OperationGWTServiceImpl.java
@@ -38,6 +38,7 @@ import
org.rhq.core.domain.operation.composite.ResourceOperationScheduleComposit
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTService;
import org.rhq.enterprise.gui.coregui.server.util.SerialUtility;
import org.rhq.enterprise.server.operation.OperationManagerLocal;
@@ -196,6 +197,7 @@ public class OperationGWTServiceImpl extends AbstractGWTServiceImpl
implements O
public PageList<ResourceOperationScheduleComposite> findScheduledOperations(int
pageSize) throws RuntimeException {
try {
PageControl pageControl = new PageControl(0, pageSize);
+ pageControl.initDefaultOrderingField("ro.nextFireTime",
PageOrdering.ASC);
PageList<ResourceOperationScheduleComposite> scheduledResourceOps =
operationManager
.findCurrentlyScheduledResourceOperations(getSessionSubject(),
pageControl);
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 4a9cfa4..96ef8cf 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1468,7 +1468,7 @@ view_portlet_defaultName_groupMetric = Resource Group Metric Graph
view_portlet_defaultName_inventorySummary = Inventory Summary
view_portlet_defaultName_mashup = Mashup
view_portlet_defaultName_message = Message
-view_portlet_defaultName_operations = Operations
+view_portlet_defaultName_operations = Recent Operations
view_portlet_defaultName_platformSummary = Platform Utilization
view_portlet_defaultName_problemResources = Alerted or Unavailable Resources
view_portlet_defaultName_recentAlerts = Recent Alerts
@@ -1503,7 +1503,8 @@ view_portlet_help_mashup = This portlet displays the returned
content of a remot
view_portlet_help_metrics = This portlet graphs relevant recent metric data based on
display criteria configured.
view_portlet_help_message = This portlet displays a static HTML message. The
<i>message</i> property must be configured.
view_portlet_help_oobs = This portlet displays OOB(Out of Bound) metric conditions.
-view_portlet_help_operations = This portlet displays executing, completed and scheduled
operations for the current user''s inventory.
+view_portlet_help_operations = This portlet displays the most recently executed
operations for the current user''s inventory.
+view_portlet_help_scheduledOperations = This portlet displays the next scheduled
operations for the current user''s inventory.
view_portlet_help_operations_criteria = This portlet displays Operations consistent with
display criteria configured.
view_portlet_help_pkg_history = This portlet shows relevant package history based on
display criteria configured.
view_portlet_help_platformSummary = This portlet displays utilization data (such as
current CPU and memory usage) for platform resources that are accessible by the current
user.
commit 3266eae064d066c7366c302e05cb1ad6306e184d
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 5 15:41:17 2011 -0400
Fix locatable issue for wizards. Make sure the dialog window is locatable
so tests can access dialog controls.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
index 8713ecc..1a52e12 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/wizard/WizardView.java
@@ -41,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.Messages;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIButton;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
/**
* @author Greg Hinkle
@@ -282,7 +283,7 @@ public class WizardView extends LocatableVLayout {
}
public void displayDialog() {
- wizardWindow = new Window();
+ wizardWindow = new LocatableWindow(extendLocatorId("Wizard"));
wizardWindow.setTitle(wizard.getWindowTitle());
wizardWindow.setWidth(800);
wizardWindow.setHeight(600);
commit 9369a27013749abc46249c66001396cb7e305e64
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Apr 5 15:40:31 2011 -0400
Fix Locatable issue with login dialog box, make it always be the same
regardless of parent widget.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index 865793a..bf4ecf7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -157,7 +157,12 @@ public class LoginView extends LocatableCanvas {
form.setFields(logo, header, new RowSpacerItem(), user, password,
loginButton);
- window = new LocatableWindow(extendLocatorId("LoginWindow"));
+ // we ant the login window to have the same locator regardless of its parent.
It can be
+ // created from at least two different paths (LoginView, UserSessionManager)
but for test purposes
+ // we want a single login script. There will only be one login dialog at any
time, so it is safe
+ // to use a non-extended locator.
+ // is parented by the Login
+ window = new LocatableWindow("Login");
window.setWidth(400);
window.setHeight(275);
window.setTitle(MSG.common_title_welcome());