modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
| 284 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
| 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
| 284 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
| 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
| 105 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
| 16
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
| 54 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
| 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
| 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
| 20
10 files changed, 515 insertions(+), 289 deletions(-)
New commits:
commit aeac14f0fd67d08b39b33d6feeccb453a7ad5aa5
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Mon Jan 24 22:35:38 2011 -0500
partial impl of group Operations>Schedule subtab
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
new file mode 100644
index 0000000..db32a81
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/AbstractOperationScheduleDetailsView.java
@@ -0,0 +1,284 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextAreaItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.rhq.core.domain.auth.Subject;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.form.AbstractRecordEditor;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class AbstractOperationScheduleDetailsView extends AbstractRecordEditor
{
+
+ private static final String FIELD_OPERATION_DESCRIPTION =
"operationDescription";
+ private static final String FIELD_OPERATION_PARAMETERS =
"operationParameters";
+
+ private Map<String, String> operationNameToDescriptionMap = new
HashMap<String, String>();
+ private Map<String, ConfigurationDefinition>
operationNameToParametersDefinitionMap =
+ new HashMap<String, ConfigurationDefinition>();
+ private StaticTextItem operationDescriptionItem;
+ private StaticTextItem operationParametersItem;
+ private LocatableHLayout operationParametersConfigurationHolder;
+ private JobTriggerEditor triggerEditor;
+ private Configuration parameters;
+ private EnhancedDynamicForm notesForm;
+
+ public AbstractOperationScheduleDetailsView(String locatorId,
OperationScheduleDataSource dataSource,
+ ResourceType resourceType, int
scheduleId) {
+ super(locatorId, dataSource, scheduleId, "Scheduled Operation", null);
+
+ Set<OperationDefinition> operationDefinitions =
resourceType.getOperationDefinitions();
+ for (OperationDefinition operationDefinition : operationDefinitions) {
+ this.operationNameToDescriptionMap.put(operationDefinition.getName(),
operationDefinition.getDescription());
+
this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
+ operationDefinition.getParametersConfigurationDefinition());
+ }
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ super.renderView(viewPath);
+
+ // Existing schedules are not editable. This may change in the future.
+ boolean isReadOnly = (getRecordId() != 0);
+ init(isReadOnly);
+ }
+
+ @Override
+ protected List<FormItem> createFormItems(EnhancedDynamicForm form) {
+ List<FormItem> items = new ArrayList<FormItem>();
+
+ SelectItem operationNameItem = new
SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ items.add(operationNameItem);
+ operationNameItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+ }
+ });
+
+ this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION,
"Operation Description");
+ items.add(this.operationDescriptionItem);
+
+ this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS,
"Operation Parameters");
+ items.add(this.operationParametersItem);
+
+ return items;
+ }
+
+ @Override
+ protected LocatableVLayout buildContentPane() {
+ LocatableVLayout contentPane = super.buildContentPane();
+
+ this.operationParametersConfigurationHolder = new
LocatableHLayout(extendLocatorId("ConfigHolder"));
+ this.operationParametersConfigurationHolder.setVisible(false);
+ contentPane.addMember(this.operationParametersConfigurationHolder);
+
+ HTMLFlow hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
+
+ if (isNewRecord()) {
+ this.triggerEditor = new
JobTriggerEditor(extendLocatorId("TriggerEditor"));
+ contentPane.addMember(this.triggerEditor);
+ hr = new HTMLFlow("<p/><hr/><p/>");
+ contentPane.addMember(hr);
+ }
+
+ this.notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"),
isReadOnly(),
+ isNewRecord());
+ this.notesForm.setWidth100();
+
+ List<FormItem> notesFields = new ArrayList<FormItem>();
+
+ if (!isNewRecord()) {
+ StaticTextItem nextFireTimeItem = new
StaticTextItem(OperationScheduleDataSource.Field.NEXT_FIRE_TIME);
+ notesFields.add(nextFireTimeItem);
+ }
+
+ TextItem timeoutItem = new TextItem(OperationScheduleDataSource.Field.TIMEOUT,
"Timeout (in seconds)");
+ notesFields.add(timeoutItem);
+
+ TextAreaItem notesItem = new
TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
+ notesItem.setWidth(450);
+ notesItem.setHeight(150);
+ notesFields.add(notesItem);
+
+ this.notesForm.setFields(notesFields.toArray(new FormItem[notesFields.size()]));
+
+ contentPane.addMember(this.notesForm);
+
+ return contentPane;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+ }
+
+ @Override
+ protected String getTitleFieldName() {
+ return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
+ }
+
+ @Override
+ protected Record createNewRecord() {
+ Record record = super.createNewRecord();
+ Subject sessionSubject = UserSessionManager.getSessionSubject();
+ OperationScheduleDataSource.SubjectRecord subjectRecord =
+ new OperationScheduleDataSource.SubjectRecord(sessionSubject);
+ record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT,
subjectRecord);
+ return record;
+ }
+
+ @Override
+ protected void editRecord(Record record) {
+ refreshOperationDescriptionItem();
+ refreshOperationParametersItem();
+
+ if (!isNewRecord()) {
+ FormItem nextFireTimeItem =
this.notesForm.getField(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
+
nextFireTimeItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
+ }
+
+ FormItem notesItem =
this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+
notesItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION));
+
+ super.editRecord(record);
+ }
+
+ @Override
+ protected void save(DSRequest requestProperties) {
+ requestProperties.setAttribute("parameters", this.parameters);
+
+ if (!this.triggerEditor.validate()) {
+ // TODO: print error Message
+ return;
+ }
+ EnhancedDynamicForm form = getForm();
+
+ Record jobTriggerRecord = new ListGridRecord();
+
+ Date startTime = this.triggerEditor.getStartTime();
+
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.START_TIME,
startTime);
+
+ Date endTime = this.triggerEditor.getEndTime();
+ jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.END_TIME,
endTime);
+
+ Integer repeatCount = this.triggerEditor.getRepeatCount();
+
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_COUNT,
repeatCount);
+
+ Long repeatInterval = this.triggerEditor.getRepeatInterval();
+
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_INTERVAL,
repeatInterval);
+
+ String cronExpression = this.triggerEditor.getCronExpression();
+
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.CRON_EXPRESSION,
cronExpression);
+
+ form.setValue("jobTrigger", jobTriggerRecord);
+
+ FormItem notesItem =
this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
+ form.setValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION,
(String)notesItem.getValue());
+
+ super.save(requestProperties);
+ }
+
+ private void refreshOperationDescriptionItem() {
+ String operationName = getSelectedOperationName();
+ String value;
+ if (operationName == null) {
+ value = "<i>Select an operation.</i>";
+ } else {
+ value = this.operationNameToDescriptionMap.get(operationName);
+ }
+ this.operationDescriptionItem.setValue(value);
+ }
+
+ private void refreshOperationParametersItem() {
+ String operationName = getSelectedOperationName();
+ String value;
+ if (operationName == null) {
+ value = "<i>Select an operation.</i>";
+ } else {
+ ConfigurationDefinition parametersDefinition =
this.operationNameToParametersDefinitionMap.get(operationName);
+ if (parametersDefinition == null ||
parametersDefinition.getPropertyDefinitions().isEmpty()) {
+ value = "<i>" +
MSG.view_operationCreateWizard_parametersStep_noParameters() + "</i>";
+
+ for (Canvas child :
this.operationParametersConfigurationHolder.getChildren()) {
+ child.destroy();
+ }
+ this.operationParametersConfigurationHolder.hide();
+ } else {
+ value = isNewRecord() ? "<i>Enter parameters
below...</i>" : "";
+
+ for (Canvas child :
this.operationParametersConfigurationHolder.getChildren()) {
+ child.destroy();
+ }
+ Configuration defaultConfiguration =
(parametersDefinition.getDefaultTemplate() != null) ?
+ parametersDefinition.getDefaultTemplate().createConfiguration() : new
Configuration();
+ ConfigurationEditor configurationEditor = new
ConfigurationEditor("ParametersEditor", parametersDefinition,
+ defaultConfiguration);
+ configurationEditor.setReadOnly(isReadOnly());
+ this.parameters = configurationEditor.getConfiguration();
+
this.operationParametersConfigurationHolder.addMember(configurationEditor);
+ this.operationParametersConfigurationHolder.show();
+ }
+ }
+ this.operationParametersItem.setValue(value);
+ }
+
+ private String getSelectedOperationName() {
+ FormItem operationNameItem =
getForm().getField(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
+ return (String)operationNameItem.getValue();
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
index ec95731..3813b98 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleDataSource.java
@@ -35,6 +35,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.common.JobTrigger;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.operation.OperationDefinition;
import org.rhq.core.domain.operation.bean.OperationSchedule;
import org.rhq.core.domain.resource.ResourceType;
@@ -57,6 +58,7 @@ public abstract class OperationScheduleDataSource<T extends
OperationSchedule> e
public static final String SUBJECT = "subject";
public static final String DESCRIPTION = "description";
public static final String NEXT_FIRE_TIME = "nextFireTime";
+ public static final String TIMEOUT = "timeout";
// job trigger fields
public static final String START_TIME = "startTime";
@@ -112,6 +114,10 @@ public abstract class OperationScheduleDataSource<T extends
OperationSchedule> e
DataSourceDateTimeField nextFireTimeField = new
DataSourceDateTimeField(Field.NEXT_FIRE_TIME,
"Next Scheduled Execution");
nextFireTimeField.setCanEdit(false);
+ fields.add(nextFireTimeField);
+
+ DataSourceIntegerField timeoutField = createIntegerField(Field.TIMEOUT,
"Timeout (in seconds)", 30, null, false);
+ fields.add(timeoutField);
return fields;
}
@@ -127,11 +133,15 @@ public abstract class OperationScheduleDataSource<T extends
OperationSchedule> e
to.setJobGroup(from.getAttribute(Field.JOB_GROUP));
SubjectRecord subjectRecord = (SubjectRecord)
from.getAttributeAsRecord(Field.SUBJECT);
to.setSubject(subjectRecord.toSubject());
- to.setParameters((Configuration)from.getAttributeAsObject(Field.PARAMETERS));
+ Configuration parameters = (Configuration)
from.getAttributeAsObject(Field.PARAMETERS);
+ to.setParameters(parameters);
to.setOperationName(from.getAttribute(Field.OPERATION_NAME));
to.setOperationDisplayName(from.getAttribute(Field.OPERATION_DISPLAY_NAME));
to.setDescription(from.getAttribute(Field.DESCRIPTION));
to.setNextFireTime(from.getAttributeAsDate(Field.NEXT_FIRE_TIME));
+ if (parameters != null) {
+ parameters.put(new PropertySimple(OperationDefinition.TIMEOUT_PARAM_NAME,
from.getAttributeAsInt(Field.TIMEOUT)));
+ }
to.setJobTrigger(createJobTrigger(from.getAttributeAsRecord("jobTrigger")));
@@ -152,6 +162,7 @@ public abstract class OperationScheduleDataSource<T extends
OperationSchedule> e
to.setAttribute(Field.OPERATION_DISPLAY_NAME, from.getOperationDisplayName());
to.setAttribute(Field.DESCRIPTION, from.getDescription());
to.setAttribute(Field.NEXT_FIRE_TIME, from.getNextFireTime());
+ to.setAttribute(Field.TIMEOUT,
from.getParameters().getSimpleValue(OperationDefinition.TIMEOUT_PARAM_NAME, null));
JobTrigger jobTrigger = from.getJobTrigger();
Record jobTriggerRecord = new ListGridRecord();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
deleted file mode 100644
index bc405b1..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-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 org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import
org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.form.AbstractRecordEditor;
-import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.components.trigger.JobTriggerEditor;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-
-/**
- * @author Ian Springer
- */
-public class ResourceOperationScheduleDetailsView extends AbstractRecordEditor {
-
- private static final String FIELD_OPERATION_DESCRIPTION =
"operationDescription";
- private static final String FIELD_OPERATION_PARAMETERS =
"operationParameters";
-
- private ResourceComposite resourceComposite;
- private Map<String, String> operationNameToDescriptionMap = new
HashMap<String, String>();
- private Map<String, ConfigurationDefinition>
operationNameToParametersDefinitionMap =
- new HashMap<String, ConfigurationDefinition>();
- private StaticTextItem operationDescriptionItem;
- private StaticTextItem operationParametersItem;
- private LocatableHLayout operationParametersConfigurationHolder;
- private JobTriggerEditor triggerEditor;
- private Configuration parameters;
- private EnhancedDynamicForm notesForm;
-
- public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite
resourceComposite, int scheduleId) {
- super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite),
scheduleId, "Scheduled Operation", null);
-
- this.resourceComposite = resourceComposite;
- ResourceType resourceType =
this.resourceComposite.getResource().getResourceType();
- Set<OperationDefinition> operationDefinitions =
resourceType.getOperationDefinitions();
- for (OperationDefinition operationDefinition : operationDefinitions) {
- this.operationNameToDescriptionMap.put(operationDefinition.getName(),
operationDefinition.getDescription());
-
this.operationNameToParametersDefinitionMap.put(operationDefinition.getName(),
- operationDefinition.getParametersConfigurationDefinition());
- }
- }
-
- @Override
- public void renderView(ViewPath viewPath) {
- super.renderView(viewPath);
-
- // Existing schedules are not editable. This may change in the future.
- boolean isReadOnly = (getRecordId() != 0);
- init(isReadOnly);
- }
-
- @Override
- protected List<FormItem> createFormItems(EnhancedDynamicForm form) {
- List<FormItem> items = new ArrayList<FormItem>();
-
- SelectItem operationNameItem = new
SelectItem(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
- items.add(operationNameItem);
- operationNameItem.addChangedHandler(new ChangedHandler() {
- public void onChanged(ChangedEvent event) {
- refreshOperationDescriptionItem();
- refreshOperationParametersItem();
- }
- });
-
- this.operationDescriptionItem = new StaticTextItem(FIELD_OPERATION_DESCRIPTION,
"Operation Description");
- items.add(this.operationDescriptionItem);
-
- this.operationParametersItem = new StaticTextItem(FIELD_OPERATION_PARAMETERS,
"Operation Parameters");
- items.add(this.operationParametersItem);
-
- return items;
- }
-
- @Override
- protected LocatableVLayout buildContentPane() {
- LocatableVLayout contentPane = super.buildContentPane();
-
- this.operationParametersConfigurationHolder = new
LocatableHLayout(extendLocatorId("ConfigHolder"));
- this.operationParametersConfigurationHolder.setVisible(false);
- contentPane.addMember(this.operationParametersConfigurationHolder);
-
- HTMLFlow hr = new HTMLFlow("<p/><hr/><p/>");
- contentPane.addMember(hr);
-
- if (isNewRecord()) {
- this.triggerEditor = new
JobTriggerEditor(extendLocatorId("TriggerEditor"));
- contentPane.addMember(this.triggerEditor);
- hr = new HTMLFlow("<p/><hr/><p/>");
- contentPane.addMember(hr);
- }
-
- this.notesForm = new EnhancedDynamicForm(extendLocatorId("NotesForm"),
isReadOnly(),
- isNewRecord());
- this.notesForm.setWidth100();
-
- List<FormItem> notesFields = new ArrayList<FormItem>();
-
- if (!isNewRecord()) {
- StaticTextItem nextFireTimeItem = new
StaticTextItem(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME,
- "Next Scheduled Execution");
- notesFields.add(nextFireTimeItem);
- }
-
- TextAreaItem notesItem = new
TextAreaItem(ResourceOperationScheduleDataSource.Field.DESCRIPTION, "Notes");
- notesItem.setWidth(450);
- notesItem.setHeight(150);
- notesFields.add(notesItem);
-
- this.notesForm.setFields(notesFields.toArray(new FormItem[notesFields.size()]));
-
- contentPane.addMember(this.notesForm);
-
- return contentPane;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
- refreshOperationDescriptionItem();
- refreshOperationParametersItem();
- }
-
- @Override
- protected String getTitleFieldName() {
- return ResourceOperationScheduleDataSource.Field.OPERATION_DISPLAY_NAME;
- }
-
- @Override
- protected Record createNewRecord() {
- Record record = super.createNewRecord();
- Subject sessionSubject = UserSessionManager.getSessionSubject();
- OperationScheduleDataSource.SubjectRecord subjectRecord =
- new OperationScheduleDataSource.SubjectRecord(sessionSubject);
- record.setAttribute(ResourceOperationScheduleDataSource.Field.SUBJECT,
subjectRecord);
- return record;
- }
-
- @Override
- protected void editRecord(Record record) {
- refreshOperationDescriptionItem();
- refreshOperationParametersItem();
-
- if (!isNewRecord()) {
- FormItem nextFireTimeItem =
this.notesForm.getField(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME);
-
nextFireTimeItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.NEXT_FIRE_TIME));
- }
-
- FormItem notesItem =
this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
-
notesItem.setValue(getForm().getValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION));
-
- super.editRecord(record);
- }
-
- @Override
- protected void save(DSRequest requestProperties) {
- requestProperties.setAttribute("parameters", this.parameters);
-
- if (!this.triggerEditor.validate()) {
- // TODO: print error Message
- return;
- }
- EnhancedDynamicForm form = getForm();
-
- Record jobTriggerRecord = new ListGridRecord();
-
- Date startTime = this.triggerEditor.getStartTime();
-
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.START_TIME,
startTime);
-
- Date endTime = this.triggerEditor.getEndTime();
- jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.END_TIME,
endTime);
-
- Integer repeatCount = this.triggerEditor.getRepeatCount();
-
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_COUNT,
repeatCount);
-
- Long repeatInterval = this.triggerEditor.getRepeatInterval();
-
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.REPEAT_INTERVAL,
repeatInterval);
-
- String cronExpression = this.triggerEditor.getCronExpression();
-
jobTriggerRecord.setAttribute(ResourceOperationScheduleDataSource.Field.CRON_EXPRESSION,
cronExpression);
-
- form.setValue("jobTrigger", jobTriggerRecord);
-
- FormItem notesItem =
this.notesForm.getField(ResourceOperationScheduleDataSource.Field.DESCRIPTION);
- form.setValue(ResourceOperationScheduleDataSource.Field.DESCRIPTION,
(String)notesItem.getValue());
-
- super.save(requestProperties);
- }
-
- private void refreshOperationDescriptionItem() {
- String operationName = getSelectedOperationName();
- String value;
- if (operationName == null) {
- value = "<i>Select an operation.</i>";
- } else {
- value = this.operationNameToDescriptionMap.get(operationName);
- }
- this.operationDescriptionItem.setValue(value);
- }
-
- private void refreshOperationParametersItem() {
- String operationName = getSelectedOperationName();
- String value;
- if (operationName == null) {
- value = "<i>Select an operation.</i>";
- } else {
- ConfigurationDefinition parametersDefinition =
this.operationNameToParametersDefinitionMap.get(operationName);
- if (parametersDefinition == null ||
parametersDefinition.getPropertyDefinitions().isEmpty()) {
- value = "<i>" +
MSG.view_operationCreateWizard_parametersStep_noParameters() + "</i>";
-
- for (Canvas child :
this.operationParametersConfigurationHolder.getChildren()) {
- child.destroy();
- }
- this.operationParametersConfigurationHolder.hide();
- } else {
- value = isNewRecord() ? "<i>Enter parameters
below...</i>" : "";
-
- for (Canvas child :
this.operationParametersConfigurationHolder.getChildren()) {
- child.destroy();
- }
- Configuration defaultConfiguration =
(parametersDefinition.getDefaultTemplate() != null) ?
- parametersDefinition.getDefaultTemplate().createConfiguration() : new
Configuration();
- ConfigurationEditor configurationEditor = new
ConfigurationEditor("ParametersEditor", parametersDefinition,
- defaultConfiguration);
- configurationEditor.setReadOnly(isReadOnly());
- this.parameters = configurationEditor.getConfiguration();
-
this.operationParametersConfigurationHolder.addMember(configurationEditor);
- this.operationParametersConfigurationHolder.show();
- }
- }
- this.operationParametersItem.setValue(value);
- }
-
- private String getSelectedOperationName() {
- FormItem operationNameItem =
getForm().getField(ResourceOperationScheduleDataSource.Field.OPERATION_NAME);
- return (String)operationNameItem.getValue();
- }
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 8c4d6a2..9b18b47 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -57,6 +57,7 @@ import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.H
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.MembersView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule.GroupOperationScheduleListView;
import
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
import
org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -295,8 +296,9 @@ public class ResourceGroupDetailView extends
AbstractTwoLevelTabSetView<Resource
private void updateOperationsTab(int groupId, GroupCategory groupCategory,
Set<ResourceTypeFacet> facets) {
if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.OPERATION), true)) {
- updateSubTab(this.operationsTab, this.operationsSchedule, new
FullHTMLPane(this.operationsSchedule.extendLocatorId("View"),
-
"/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId),
true, true);
+ updateSubTab(this.operationsTab, this.operationsSchedule,
+ new
GroupOperationScheduleListView(this.operationsSchedule.extendLocatorId("View"),
+ this.groupComposite), true, true);
updateSubTab(this.operationsTab, this.operationsHistory, new
FullHTMLPane(this.operationsHistory.extendLocatorId("View"),
"/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId),
true, true);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
new file mode 100644
index 0000000..d104eb2
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDataSource.java
@@ -0,0 +1,105 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.Record;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.operation.bean.GroupOperationSchedule;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+
+import java.util.List;
+
+/**
+ * A DataSource for {@link org.rhq.core.domain.operation.bean.GroupOperationSchedule}s
for a given
+ * {@link org.rhq.core.domain.resource.group.ResourceGroup}.
+ *
+ * @author Ian Springer
+ */
+public class GroupOperationScheduleDataSource extends
OperationScheduleDataSource<GroupOperationSchedule> {
+
+ private ResourceGroupComposite groupComposite;
+
+ public GroupOperationScheduleDataSource(ResourceGroupComposite groupComposite) {
+ super(groupComposite.getResourceGroup().getResourceType());
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected GroupOperationSchedule createOperationSchedule() {
+ GroupOperationSchedule groupOperationSchedule = new GroupOperationSchedule();
+ groupOperationSchedule.setGroup(this.groupComposite.getResourceGroup());
+ return groupOperationSchedule;
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+
operationService.findScheduledGroupOperations(this.groupComposite.getResourceGroup().getId(),
+ new AsyncCallback<List<GroupOperationSchedule>>() {
+ public void onSuccess(List<GroupOperationSchedule> result) {
+ Record[] records = buildRecords(result);
+ response.setData(records);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to find scheduled operations
for "
+ + groupComposite.getResourceGroup() + ".", caught);
+ }
+ });
+ }
+
+ @Override
+ protected void executeAdd(Record recordToAdd, final DSRequest request, final
DSResponse response) {
+ Configuration parameters = (Configuration)
request.getAttributeAsObject("parameters");
+ recordToAdd.setAttribute(Field.PARAMETERS, parameters);
+ final GroupOperationSchedule scheduleToAdd = copyValues(recordToAdd);
+ // TODO
+ /*operationService.scheduleResourceOperation(scheduleToAdd, new
AsyncCallback<Integer>() {
+ public void onSuccess(Integer scheduleId) {
+ scheduleToAdd.setId(scheduleId);
+ sendSuccessResponse(request, response, scheduleToAdd);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException("Failed to add " + scheduleToAdd,
caught);
+ }
+ });*/
+ }
+
+ @Override
+ protected void executeRemove(Record recordToRemove, final DSRequest request, final
DSResponse response) {
+ final GroupOperationSchedule scheduleToRemove = copyValues(recordToRemove);
+ // TODO
+ /*operationService.unscheduleResourceOperation(scheduleToRemove, new
AsyncCallback<Void>() {
+ public void onSuccess(Void result) {
+ sendSuccessResponse(request, response, scheduleToRemove);
+ }
+
+ public void onFailure(Throwable caught) {
+ throw new RuntimeException(caught);
+ }
+ });*/
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
new file mode 100644
index 0000000..b6a37bf
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleDetailsView.java
@@ -0,0 +1,16 @@
+package
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+
+/**
+ *
+ */
+public class GroupOperationScheduleDetailsView extends
AbstractOperationScheduleDetailsView {
+
+ public GroupOperationScheduleDetailsView(String locatorId, ResourceGroupComposite
groupComposite, int scheduleId) {
+ super(locatorId, new GroupOperationScheduleDataSource(groupComposite),
+ groupComposite.getResourceGroup().getResourceType(), scheduleId);
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
new file mode 100644
index 0000000..f3b376b
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/operation/schedule/GroupOperationScheduleListView.java
@@ -0,0 +1,54 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package
org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.operation.schedule;
+
+import com.smartgwt.client.widgets.Canvas;
+import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule.ResourceOperationScheduleDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class GroupOperationScheduleListView extends OperationScheduleListView {
+
+ private static final String TITLE = null;
+
+ private ResourceGroupComposite groupComposite;
+
+ public GroupOperationScheduleListView(String locatorId, ResourceGroupComposite
groupComposite) {
+ super(locatorId, new GroupOperationScheduleDataSource(groupComposite), TITLE);
+ this.groupComposite = groupComposite;
+ }
+
+ @Override
+ protected boolean hasControlPermission() {
+ return this.groupComposite.getResourcePermission().isControl();
+ }
+
+ @Override
+ public Canvas getDetailsView(int scheduleId) {
+ return new
GroupOperationScheduleDetailsView(extendLocatorId("DetailsView"),
+ this.groupComposite, scheduleId);
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
new file mode 100644
index 0000000..70f2c18
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleDetailsView.java
@@ -0,0 +1,18 @@
+package
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.schedule;
+
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleDataSource;
+
+/**
+ *
+ */
+public class ResourceOperationScheduleDetailsView extends
AbstractOperationScheduleDetailsView {
+
+ public ResourceOperationScheduleDetailsView(String locatorId, ResourceComposite
resourceComposite, int scheduleId) {
+ super(locatorId, new ResourceOperationScheduleDataSource(resourceComposite),
+ resourceComposite.getResource().getResourceType(), scheduleId);
+ }
+
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
index 14bb294..0e362f0 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/schedule/ResourceOperationScheduleListView.java
@@ -23,7 +23,7 @@ import com.smartgwt.client.widgets.Canvas;
import org.rhq.core.domain.resource.composite.ResourceComposite;
import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationScheduleListView;
-import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.ResourceOperationScheduleDetailsView;
+import
org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.AbstractOperationScheduleDetailsView;
/**
* @author Ian Springer
@@ -46,7 +46,7 @@ public class ResourceOperationScheduleListView extends
OperationScheduleListView
@Override
public Canvas getDetailsView(int scheduleId) {
- return new
ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
+ return new
ResourceOperationScheduleDetailsView(extendLocatorId("DetailsView"),
this.resourceComposite, scheduleId);
}
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 f43417f..47d9d49 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
@@ -36,14 +36,17 @@ import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.DSProtocol;
import com.smartgwt.client.util.JSOHelper;
+import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.grid.ListGridRecord;
+import org.hibernate.validator.RangeValidator;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
import org.rhq.core.domain.resource.ResourceCategory;
@@ -553,4 +556,21 @@ public abstract class RPCDataSource<T> extends DataSource {
return textField;
}
+ protected DataSourceIntegerField createIntegerField(String name, String title,
Integer minValue, Integer maxValue,
+ Boolean required) {
+ DataSourceIntegerField textField = new DataSourceIntegerField(name, title);
+ textField.setRequired(required);
+ if (minValue != null || maxValue != null) {
+ IntegerRangeValidator integerRangeValidator = new IntegerRangeValidator();
+ if (minValue != null) {
+ integerRangeValidator.setMin(minValue);
+ }
+ if (maxValue != null) {
+ integerRangeValidator.setMax(maxValue);
+ }
+ textField.setValidators(integerRangeValidator);
+ }
+ return textField;
+ }
+
}