modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
| 8
modules/core/domain/src/main/java/org/rhq/core/domain/alert/BooleanExpression.java
| 46 +-
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
| 11
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
| 133 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
| 149 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsDataSource.java
| 194 --------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
| 69 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
| 106 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
| 99 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
| 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
| 221 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
| 57 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
| 108 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
| 99 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
| 119 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
| 132 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
| 108 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
| 175 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
| 57 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
| 108 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
| 55 +-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
| 9
22 files changed, 1758 insertions(+), 326 deletions(-)
New commits:
commit 5e99a1a17683741a4fc7f92376e6269a7a73ddf3
Merge: 602b409... 9964a96...
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Aug 13 03:04:34 2010 -0400
Merge branch 'master' into alert-def-gwt
commit 602b40901e514a475854f00219e790cb5d6d0f47
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Aug 13 03:02:06 2010 -0400
the start of the GWT resource alert definition tab
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
index 23ecc44..807d3d3 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/AlertDefinition.java
@@ -475,6 +475,10 @@ public class AlertDefinition implements Serializable {
return this.ctime;
}
+ public void setCtime(long ctime) {
+ this.ctime = ctime;
+ }
+
@PrePersist
void onPersist() {
this.mtime = this.ctime = System.currentTimeMillis();
@@ -484,6 +488,10 @@ public class AlertDefinition implements Serializable {
return this.mtime;
}
+ public void setMtime(long mtime) {
+ this.mtime = mtime;
+ }
+
@PreUpdate
void onUpdate() {
this.mtime = System.currentTimeMillis();
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/BooleanExpression.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/BooleanExpression.java
index 62c9a92..87ebf60 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/alert/BooleanExpression.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/alert/BooleanExpression.java
@@ -1,25 +1,25 @@
- /*
- * RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License and the GNU Lesser General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
package org.rhq.core.domain.alert;
public enum BooleanExpression {
@@ -38,4 +38,4 @@ public enum BooleanExpression {
* processing
*/
COMPLEX; // <-- not currently supported
-}
\ No newline at end of file
+}; // gwt compiler wants semicolon
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
index 9ddf148..298a6e5 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/AlertDefinitionCriteria.java
@@ -52,10 +52,10 @@ public class AlertDefinitionCriteria extends Criteria {
private List<Integer> filterResourceIds; // requires overrides
private List<Integer> filterResourceGroupIds; // requires overrides
private Boolean filterEnabled;
- private String filterOperationName; // requires overrides
private Boolean filterDeleted = false; // find enabled definitions by default
private boolean fetchAlerts;
+ private boolean fetchGroupAlertDefinition;
private boolean fetchConditions;
private boolean fetchAlertNotifications;
@@ -68,7 +68,6 @@ public class AlertDefinitionCriteria extends Criteria {
filterOverrides.put("alertTemplateResourceTypeName",
"resourceType.name like ?");
filterOverrides.put("resourceIds", "resource.id IN ( ? )");
filterOverrides.put("resourceGroupIds", "resourceGroup.id IN ( ?
)");
- filterOverrides.put("operationName", "operationDefinition.name
like ?");
}
@Override
@@ -116,10 +115,6 @@ public class AlertDefinitionCriteria extends Criteria {
this.filterEnabled = filterEnabled;
}
- public void addFilterOperationName(String filterOperationName) {
- this.filterOperationName = filterOperationName;
- }
-
public void addFilterDeleted(Boolean filterDeleted) {
this.filterDeleted = filterDeleted;
}
@@ -128,6 +123,10 @@ public class AlertDefinitionCriteria extends Criteria {
this.fetchAlerts = fetchAlerts;
}
+ public void fetchGroupAlertDefinition(boolean fetchGroupAlertDefinition) {
+ this.fetchGroupAlertDefinition = fetchGroupAlertDefinition;
+ }
+
public void fetchConditions(boolean fetchConditions) {
this.fetchConditions = fetchConditions;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
new file mode 100644
index 0000000..c3c6660
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsDataSource.java
@@ -0,0 +1,133 @@
+/*
+ * 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.alert.definitions;
+
+import java.util.Date;
+
+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.fields.DataSourceTextField;
+import com.smartgwt.client.types.FieldType;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.AlertPriority;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class AbstractAlertDefinitionsDataSource extends
RPCDataSource<AlertDefinition> {
+
+ protected static final String FIELD_ID = "id";
+ protected static final String FIELD_NAME = "name";
+ protected static final String FIELD_DESCRIPTION = "description";
+ protected static final String FIELD_CTIME = "ctime";
+ protected static final String FIELD_MTIME = "mtime";
+ protected static final String FIELD_ENABLED = "enabled";
+ protected static final String FIELD_DELETED = "deleted";
+ protected static final String FIELD_PRIORITY = "priority"; // not the
actual object; a string for the UI
+ protected static final String FIELD_PRIORITY_ENUM = "priority_enum"; // the
actual enum name
+
+ public AbstractAlertDefinitionsDataSource() {
+ setupFields();
+ }
+
+ @Override
+ public AlertDefinition copyValues(ListGridRecord from) {
+ AlertDefinition alertDef = new AlertDefinition();
+ alertDef.setId(from.getAttributeAsInt(FIELD_ID));
+ alertDef.setName(from.getAttributeAsString(FIELD_NAME));
+ alertDef.setDescription(from.getAttributeAsString(FIELD_DESCRIPTION));
+ alertDef.setCtime(from.getAttributeAsDate(FIELD_CTIME).getTime());
+ alertDef.setMtime(from.getAttributeAsDate(FIELD_MTIME).getTime());
+ alertDef.setEnabled(from.getAttributeAsBoolean(FIELD_ENABLED));
+
alertDef.setPriority(AlertPriority.valueOf(from.getAttributeAsString(FIELD_PRIORITY_ENUM)));
+ return alertDef;
+ }
+
+ @Override
+ public ListGridRecord copyValues(AlertDefinition from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(FIELD_ID, from.getId());
+ record.setAttribute(FIELD_NAME, from.getName());
+ record.setAttribute(FIELD_DESCRIPTION, from.getDescription());
+ record.setAttribute(FIELD_CTIME, new Date(from.getCtime()));
+ record.setAttribute(FIELD_MTIME, new Date(from.getMtime()));
+ record.setAttribute(FIELD_ENABLED, from.getEnabled());
+ record.setAttribute(FIELD_DELETED, from.getDeleted());
+ record.setAttribute(FIELD_PRIORITY, from.getPriority().getDisplayName());
+ record.setAttribute(FIELD_PRIORITY_ENUM, from.getPriority().name());
+ return record;
+ }
+
+ /**
+ * Sets up some basic alert definition fields for this data source. Subclasses are
+ * free to call this method and then add more, or add their own custom set and not
+ * call this method at all (if they don't want some of these basic fields or want
to reorder them).
+ */
+ protected void setupFields() {
+ DataSourceTextField nameField = new DataSourceTextField(FIELD_NAME,
"Name");
+ addField(nameField);
+
+ DataSourceTextField descriptionField = new DataSourceTextField(FIELD_DESCRIPTION,
"Description");
+ addField(descriptionField);
+
+ DataSourceTextField ctimeField = new DataSourceTextField(FIELD_CTIME,
"Created Time");
+ ctimeField.setType(FieldType.DATETIME);
+ addField(ctimeField);
+
+ DataSourceTextField mtimeField = new DataSourceTextField(FIELD_MTIME,
"Modified Time");
+ mtimeField.setType(FieldType.DATETIME);
+ addField(mtimeField);
+
+ DataSourceTextField enabledField = new DataSourceTextField(FIELD_ENABLED,
"Enabled");
+ enabledField.setType(FieldType.BOOLEAN);
+ addField(enabledField);
+
+ DataSourceTextField priorityField = new DataSourceTextField(FIELD_PRIORITY,
"Priority");
+ addField(priorityField);
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ AlertDefinitionCriteria criteria = getCriteria(request);
+ GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(criteria,
+ new AsyncCallback<PageList<AlertDefinition>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("Failed to load alert
definition data", caught);
+ response.setStatus(DSResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(PageList<AlertDefinition> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ protected abstract AlertDefinitionCriteria getCriteria(DSRequest request);
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
new file mode 100644
index 0000000..6c6aa9f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AbstractAlertDefinitionsView.java
@@ -0,0 +1,149 @@
+/*
+ * 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.alert.definitions;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
+import com.smartgwt.client.widgets.grid.events.SelectionEvent;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.Table.SelectionEnablement;
+
+/**
+ * Superclass to the different alert definition views. This should be subclassed
+ * to obtain resource, group, and template alert definition views.
+ *
+ * @author John Mazzitelli
+ */
+public abstract class AbstractAlertDefinitionsView extends VLayout {
+
+ private SingleAlertDefinitionView singleAlertDefinitionView;
+
+ public AbstractAlertDefinitionsView() {
+ setWidth100();
+ setHeight100();
+ setMembersMargin(10);
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ Criteria criteria = getCriteria();
+ final Table table = new Table(getTableTitle(), criteria);
+ table.setDataSource(getAlertDefinitionDataSource());
+ table.getListGrid().setUseAllDataSourceFields(true);
+
+ table.getListGrid().addSelectionChangedHandler(new SelectionChangedHandler() {
+ public void onSelectionChanged(SelectionEvent selectionEvent) {
+ AlertDefinition alertDef = null;
+ ListGridRecord selectedRecord = null;
+ ListGridRecord[] allSelections = selectionEvent.getSelection();
+ if (allSelections != null && allSelections.length == 1) {
+ selectedRecord = allSelections[0];
+ }
+ if (selectedRecord != null) {
+ alertDef = ((AbstractAlertDefinitionsDataSource)
table.getDataSource()).copyValues(selectedRecord);
+ table.setHeight("33%");
+ table.setShowResizeBar(true);
+ singleAlertDefinitionView.setHeight("67%");
+ singleAlertDefinitionView.show();
+ singleAlertDefinitionView.setAlertDefinition(alertDef);
+ } else {
+ table.setHeight100();
+ table.setShowResizeBar(false);
+ singleAlertDefinitionView.hide();
+ }
+ markForRedraw();
+ }
+ });
+
+ boolean permitted = isAllowedToModifyAlerts();
+
+ table.addTableAction("New", (permitted) ? SelectionEnablement.ALWAYS :
SelectionEnablement.NEVER, null,
+ new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ newButtonPressed(selection);
+ CoreGUI.refresh();
+ }
+ });
+
+ table.addTableAction("Enable", (permitted) ? SelectionEnablement.ANY :
SelectionEnablement.NEVER,
+ "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ enableButtonPressed(selection);
+ CoreGUI.refresh();
+ }
+ });
+
+ table.addTableAction("Disable", (permitted) ? SelectionEnablement.ANY :
SelectionEnablement.NEVER,
+ "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ disableButtonPressed(selection);
+ }
+ });
+
+ table.addTableAction("Delete", (permitted) ? SelectionEnablement.ANY :
SelectionEnablement.NEVER,
+ "Are You Sure?", new TableAction() {
+ public void executeAction(ListGridRecord[] selection) {
+ deleteButtonPressed(selection);
+ CoreGUI.refresh();
+ }
+ });
+
+ addMember(table);
+
+ this.singleAlertDefinitionView = buildSingleAlertDefinitionView();
+ this.singleAlertDefinitionView.hide();
+ this.singleAlertDefinitionView.setWidth100();
+ this.singleAlertDefinitionView.setHeight100();
+ this.singleAlertDefinitionView.setMargin(10);
+ addMember(this.singleAlertDefinitionView);
+ }
+
+ protected SingleAlertDefinitionView getSingleAlertDefinitionView() {
+ return this.singleAlertDefinitionView;
+ }
+
+ protected SingleAlertDefinitionView buildSingleAlertDefinitionView() {
+ SingleAlertDefinitionView singleAlertDefinitionView = new
SingleAlertDefinitionView();
+ return singleAlertDefinitionView;
+ }
+
+ protected abstract String getTableTitle();
+
+ protected abstract Criteria getCriteria();
+
+ protected abstract AbstractAlertDefinitionsDataSource
getAlertDefinitionDataSource();
+
+ protected abstract boolean isAllowedToModifyAlerts();
+
+ protected abstract void newButtonPressed(ListGridRecord[] selection);
+
+ protected abstract void deleteButtonPressed(ListGridRecord[] selection);
+
+ protected abstract void enableButtonPressed(ListGridRecord[] selection);
+
+ protected abstract void disableButtonPressed(ListGridRecord[] selection);
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsDataSource.java
deleted file mode 100644
index e8ec455..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsDataSource.java
+++ /dev/null
@@ -1,194 +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.alert.definitions;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Embedded;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.OrderBy;
-import javax.xml.bind.annotation.XmlTransient;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.fields.DataSourceIntegerField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.types.FieldType;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.alert.Alert;
-import org.rhq.core.domain.alert.AlertCondition;
-import org.rhq.core.domain.alert.AlertDampening;
-import org.rhq.core.domain.alert.AlertDampeningEvent;
-import org.rhq.core.domain.alert.AlertDefinition;
-import org.rhq.core.domain.alert.AlertDefinitionContext;
-import org.rhq.core.domain.alert.AlertPriority;
-import org.rhq.core.domain.alert.BooleanExpression;
-import org.rhq.core.domain.alert.notification.AlertNotification;
-import org.rhq.core.domain.criteria.AlertCriteria;
-import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.group.ResourceGroup;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author Greg Hinkle
- */
-public class AlertDefinitionsDataSource extends RPCDataSource<AlertDefinition> {
-
-
- public AlertDefinitionsDataSource() {
-
- DataSourceIntegerField idField = new
DataSourceIntegerField("id","ID");
- idField.setPrimaryKey(true);
- addField(idField);
-
- DataSourceTextField nameField = new
DataSourceTextField("name","Name");
- addField(nameField);
-
- DataSourceTextField ctimeField = new
DataSourceTextField("ctime","Created Time");
- ctimeField.setType(FieldType.DATETIME);
- addField(ctimeField);
-
- DataSourceTextField mtimeField = new DataSourceTextField("mtime",
"Modified Time");
- mtimeField.setType(FieldType.DATETIME);
- addField(mtimeField);
-
- DataSourceTextField descriptionField = new
DataSourceTextField("description","Description");
- addField(descriptionField);
-
- DataSourceTextField priorityField = new
DataSourceTextField("priority","Priority");
- addField(priorityField);
-
- DataSourceTextField enabledField = new
DataSourceTextField("enabled","Enabled");
- enabledField.setType(FieldType.BOOLEAN);
- addField(enabledField);
-
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
-
- AlertDefinitionCriteria criteria = getCriteria(request);
-
- GWTServiceLookup.getAlertService().findAlertDefinitionsByCriteria(
- criteria,
- new AsyncCallback<PageList<AlertDefinition>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError("Failed to load alert
definition data", caught);
- response.setStatus(DSResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(PageList<AlertDefinition> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- }
- );
- }
-
-
- protected AlertDefinitionCriteria getCriteria(DSRequest request) {
- AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
- criteria.fetchConditions(true);
-
- Criteria requestCriteria = request.getCriteria();
- if (requestCriteria != null) {
- Map values = requestCriteria.getValues();
- for (Object key : values.keySet()) {
- String fieldName = (String) key;
- if (fieldName.equals("resourceId")) {
- Integer resourceId = (Integer) values.get(fieldName);
- criteria.addFilterResourceIds(resourceId);
- }
- // TODO: Add support for other fields we need to filter by (e.g.
resourceGroupId).
- }
- }
-
- criteria.setPageControl(getPageControl(request));
- return criteria;
- }
-
-
- @Override
- public AlertDefinition copyValues(ListGridRecord from) {
- return null; // TODO: Implement this method.
- }
-
- @Override
- public ListGridRecord copyValues(AlertDefinition from) {
- ListGridRecord record = new ListGridRecord();
-
- record.setAttribute("id", from.getId());
- record.setAttribute("name", from.getName());
- record.setAttribute("ctime", new Date(from.getCtime()));
- record.setAttribute("mtime", new Date(from.getMtime()));
- record.setAttribute("parentId", from.getParentId());
- record.setAttribute("description", from.getDescription());
- record.setAttribute("priority", from.getPriority().getDisplayName());
- record.setAttribute("enabled", from.getEnabled());
-
- record.setAttribute("recoveryId", from.getRecoveryId());
- record.setAttribute("willRecover", from.getWillRecover());
- record.setAttribute("notifyFiltered", from.getNotifyFiltered());
- record.setAttribute("controlFiltered", from.getControlFiltered());
- record.setAttribute("deleted", from.getDeleted());
- record.setAttribute("readOnly", from.isReadOnly());
- record.setAttribute("conditionExpression",
from.getConditionExpression());
-
-
- return record;
- }
-
-
-/*
-The following is not yet translated into the record
- private AlertDefinition groupAlertDefinition;
- private Set<AlertDefinition> groupAlertDefinitionChildren = new
LinkedHashSet<AlertDefinition>();
- private AlertDampening alertDampening;
- private BooleanExpression conditionExpression;
- private Set<AlertCondition> conditions = new
LinkedHashSet<AlertCondition>(1); // Most alerts will only have one condition.
- private List<AlertNotification> alertNotifications = new
ArrayList<AlertNotification>();
- private OperationDefinition operationDefinition;
- private Set<AlertDampeningEvent> alertDampeningEvents = new
HashSet<AlertDampeningEvent>();
- private Set<Alert> alerts = new LinkedHashSet<Alert>();
-*/
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
deleted file mode 100644
index 0e35a55..0000000
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/AlertDefinitionsView.java
+++ /dev/null
@@ -1,69 +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.alert.definitions;
-
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.gui.coregui.client.components.table.Table;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
-import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.alert.AlertEditView;
-
-/**
- * @author Greg Hinkle
- */
-public class AlertDefinitionsView extends VLayout {
-
- private Resource resource;
-
- public AlertDefinitionsView(Resource resource) {
- setWidth100();
- this.resource = resource;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- Criteria criteria = new Criteria();
- criteria.addCriteria("resourceId",resource.getId());
-
- Table table = new Table("Alert Definitions", criteria);
- table.setDataSource(new AlertDefinitionsDataSource());
- table.getListGrid().setUseAllDataSourceFields(true);
-
-
- table.addTableAction("New", new TableAction() {
- public void executeAction(ListGridRecord[] selection) {
- new AlertEditView(resource).displayAsDialog();
- }
- });
-
- addMember(table);
- }
-
-
- public static AlertDefinitionsView getResourceView(Resource resource) {
- return new AlertDefinitionsView(resource);
- }
-
-
-}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
new file mode 100644
index 0000000..3f91844
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsAlertDefinitionForm.java
@@ -0,0 +1,106 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.BooleanExpression;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ConditionsAlertDefinitionForm extends DynamicForm implements
EditAlertDefinitionForm {
+
+ private AlertDefinition alertDefinition;
+
+ private SelectItem conditionExpression;
+
+ public ConditionsAlertDefinitionForm() {
+ this(null);
+ }
+
+ public ConditionsAlertDefinitionForm(AlertDefinition alertDefinition) {
+ this.alertDefinition = alertDefinition;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ if (conditionExpression == null) {
+ buildForm();
+ setAlertDefinition(alertDefinition);
+ makeViewOnly();
+ }
+ }
+
+ @Override
+ public AlertDefinition getAlertDefinition() {
+ return this.alertDefinition;
+ }
+
+ @Override
+ public void setAlertDefinition(AlertDefinition alertDef) {
+ this.alertDefinition = alertDef;
+
+ if (alertDef == null) {
+ clearFormValues();
+ } else {
+ // TODO: why is cond expression always null????
+
//conditionExpression.setValue(alertDef.getConditionExpression().toString());
+ }
+
+ markForRedraw();
+ }
+
+ @Override
+ public void makeEditable() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void makeViewOnly() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void saveAlertDefinition() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void clearFormValues() {
+ conditionExpression.clearValue();
+ }
+
+ private void buildForm() {
+ conditionExpression = new SelectItem("conditionExpression", "Fire
alert when");
+ conditionExpression.setValueMap(BooleanExpression.ALL.toString(),
BooleanExpression.ANY.toString());
+ conditionExpression.setDefaultValue(BooleanExpression.ALL.toString());
+
+ setFields(conditionExpression);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
new file mode 100644
index 0000000..adf2173
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/DampeningAlertDefinitionForm.java
@@ -0,0 +1,99 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+/**
+ * @author John Mazzitelli
+ */
+public class DampeningAlertDefinitionForm extends DynamicForm implements
EditAlertDefinitionForm {
+
+ private AlertDefinition alertDefinition;
+
+ public DampeningAlertDefinitionForm() {
+ this(null);
+ }
+
+ public DampeningAlertDefinitionForm(AlertDefinition alertDefinition) {
+ this.alertDefinition = alertDefinition;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ // TODO only build form if we didn't do it yet
+ if (true) {
+ buildForm();
+ setAlertDefinition(alertDefinition);
+ makeViewOnly();
+ }
+ }
+
+ @Override
+ public AlertDefinition getAlertDefinition() {
+ return this.alertDefinition;
+ }
+
+ @Override
+ public void setAlertDefinition(AlertDefinition alertDef) {
+ this.alertDefinition = alertDef;
+
+ if (alertDef == null) {
+ clearFormValues();
+ } else {
+ // TODO set values of the components
+ }
+
+ markForRedraw();
+ }
+
+ @Override
+ public void makeEditable() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void makeViewOnly() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void saveAlertDefinition() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void clearFormValues() {
+ // TODO component.clearValue();
+ }
+
+ private void buildForm() {
+ // TODO build components
+ // TODO setFields(components);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
new file mode 100644
index 0000000..439ed3e
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
@@ -0,0 +1,21 @@
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+/**
+ * @author John Mazzitelli
+ */
+public interface EditAlertDefinitionForm {
+
+ AlertDefinition getAlertDefinition();
+
+ void setAlertDefinition(AlertDefinition alertDef);
+
+ void makeEditable();
+
+ void makeViewOnly();
+
+ void saveAlertDefinition();
+
+ void clearFormValues();
+}
\ No newline at end of file
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
new file mode 100644
index 0000000..712013c
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GeneralPropertiesAlertDefinitionForm.java
@@ -0,0 +1,221 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+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 org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.alert.AlertPriority;
+
+/**
+ * @author John Mazzitelli
+ */
+public class GeneralPropertiesAlertDefinitionForm extends DynamicForm implements
EditAlertDefinitionForm {
+
+ private AlertDefinition alertDefinition;
+
+ private TextItem nameTextField;
+ private TextAreaItem descriptionTextField;
+ private SelectItem prioritySelection;
+ private RadioGroupItem enabledSelection;
+ private RadioGroupItem readOnlySelection;
+
+ private StaticTextItem nameStatic;
+ private StaticTextItem descriptionStatic;
+ private StaticTextItem priorityStatic;
+ private StaticTextItem enabledStatic;
+ private StaticTextItem readOnlyStatic;
+
+ private boolean formBuilt = false;
+
+ public GeneralPropertiesAlertDefinitionForm() {
+ this(null);
+ }
+
+ public GeneralPropertiesAlertDefinitionForm(AlertDefinition alertDefinition) {
+ this.alertDefinition = alertDefinition;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ if (!formBuilt) {
+ buildForm();
+ setAlertDefinition(alertDefinition);
+ makeViewOnly();
+ }
+ }
+
+ @Override
+ public AlertDefinition getAlertDefinition() {
+ return this.alertDefinition;
+ }
+
+ @Override
+ public void setAlertDefinition(AlertDefinition alertDef) {
+ this.alertDefinition = alertDef;
+
+ buildForm();
+
+ if (alertDef == null) {
+ clearFormValues();
+ } else {
+ nameTextField.setValue(alertDef.getName());
+ nameStatic.setValue(alertDef.getName());
+
+ descriptionTextField.setValue(alertDef.getDescription());
+ descriptionStatic.setValue(alertDef.getDescription());
+
+ prioritySelection.setValue(alertDef.getPriority().getDisplayName());
+ priorityStatic.setValue(alertDef.getPriority().getDisplayName());
+
+ enabledSelection.setValue(alertDef.getEnabled() ? "Yes" :
"No");
+ enabledStatic.setValue(alertDef.getEnabled() ? "Yes" :
"No");
+
+ readOnlySelection.setValue(alertDef.isReadOnly() ? "Yes" :
"No");
+ readOnlyStatic.setValue(alertDef.isReadOnly() ? "Yes" :
"No");
+ }
+
+ markForRedraw();
+ }
+
+ @Override
+ public void makeEditable() {
+ nameTextField.show();
+ nameStatic.hide();
+
+ descriptionTextField.show();
+ descriptionStatic.hide();
+
+ prioritySelection.show();
+ priorityStatic.hide();
+
+ enabledSelection.show();
+ enabledStatic.hide();
+
+ readOnlySelection.show();
+ readOnlyStatic.hide();
+
+ Integer parentId = this.alertDefinition.getParentId();
+ if ((parentId == null || parentId.intValue() == 0) &&
(this.alertDefinition.getGroupAlertDefinition() == null)) {
+ readOnlySelection.hide();
+ } else {
+ readOnlySelection.show();
+ }
+ readOnlyStatic.hide();
+
+ markForRedraw();
+ }
+
+ @Override
+ public void makeViewOnly() {
+ nameTextField.hide();
+ nameStatic.show();
+
+ descriptionTextField.hide();
+ descriptionStatic.show();
+
+ prioritySelection.hide();
+ priorityStatic.show();
+
+ enabledSelection.hide();
+ enabledStatic.show();
+
+ readOnlySelection.hide();
+ readOnlyStatic.show();
+
+ Integer parentId = this.alertDefinition.getParentId();
+ if ((parentId == null || parentId.intValue() == 0) &&
(this.alertDefinition.getGroupAlertDefinition() == null)) {
+ readOnlyStatic.hide();
+ } else {
+ readOnlyStatic.show();
+ }
+ readOnlySelection.hide();
+
+ markForRedraw();
+ }
+
+ @Override
+ public void saveAlertDefinition() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void clearFormValues() {
+ nameTextField.clearValue();
+ descriptionTextField.clearValue();
+ prioritySelection.clearValue();
+ enabledSelection.clearValue();
+ readOnlySelection.clearValue();
+
+ nameStatic.clearValue();
+ descriptionStatic.clearValue();
+ priorityStatic.clearValue();
+ enabledStatic.clearValue();
+ readOnlyStatic.clearValue();
+
+ markForRedraw();
+ }
+
+ private void buildForm() {
+ if (!formBuilt) {
+ nameTextField = new TextItem("name", "Name");
+ nameTextField.setWidth(300);
+ nameStatic = new StaticTextItem("nameStatic", "Name");
+
+ descriptionTextField = new TextAreaItem("description",
"Description");
+ descriptionTextField.setWidth(300);
+ descriptionStatic = new StaticTextItem("descriptionStatic",
"Description");
+
+ prioritySelection = new SelectItem("priority",
"Priority");
+ prioritySelection.setValueMap(AlertPriority.HIGH.getDisplayName(),
AlertPriority.MEDIUM.getDisplayName(),
+ AlertPriority.LOW.getDisplayName());
+ prioritySelection.setDefaultValue(AlertPriority.MEDIUM.getDisplayName());
+ priorityStatic = new StaticTextItem("priorityStatic",
"Priority");
+
+ enabledSelection = new RadioGroupItem("enabled",
"Enabled");
+ enabledSelection.setValueMap("Yes", "No");
+ enabledSelection.setDefaultValue("Yes");
+ enabledStatic = new StaticTextItem("enabledStatic",
"Enabled");
+
+ readOnlySelection = new RadioGroupItem("readOnly", "Read
Only");
+ readOnlySelection.setValueMap("Yes", "No");
+ readOnlySelection.setDefaultValue("Yes");
+ readOnlySelection.setPrompt("If true, the parent definition will not
override this alert definition");
+ readOnlyStatic = new StaticTextItem("readOnlyStatic", "Read
Only");
+
+ setFields(nameTextField, nameStatic, descriptionTextField, descriptionStatic,
prioritySelection,
+ priorityStatic, enabledSelection, enabledStatic, readOnlySelection,
readOnlyStatic);
+
+ formBuilt = true;
+ }
+
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
new file mode 100644
index 0000000..90f9490
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsDataSource.java
@@ -0,0 +1,57 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import java.util.Map;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+
+/**
+ * @author John Mazzitelli
+ */
+public class GroupAlertDefinitionsDataSource extends AbstractAlertDefinitionsDataSource
{
+
+ @Override
+ protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+
+ Criteria requestCriteria = request.getCriteria();
+ if (requestCriteria != null) {
+ Map values = requestCriteria.getValues();
+ for (Object key : values.keySet()) {
+ String fieldName = (String) key;
+ if (fieldName.equals(GroupAlertDefinitionsView.CRITERIA_GROUP_ID)) {
+ Integer resourceId = (Integer) values.get(fieldName);
+ criteria.addFilterResourceGroupIds(resourceId);
+ }
+ }
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
new file mode 100644
index 0000000..7283f8f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/GroupAlertDefinitionsView.java
@@ -0,0 +1,108 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.group.ResourceGroup;
+
+/**
+ * @author John Mazzitelli
+ */
+public class GroupAlertDefinitionsView extends AbstractAlertDefinitionsView {
+
+ public static final String CRITERIA_GROUP_ID = "groupId";
+
+ private ResourceGroup group;
+
+ public GroupAlertDefinitionsView(ResourceGroup group) {
+ super();
+ this.group = group;
+ }
+
+ @Override
+ protected Criteria getCriteria() {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(CRITERIA_GROUP_ID, group.getId());
+ return criteria;
+ }
+
+ @Override
+ protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() {
+ return new GroupAlertDefinitionsDataSource();
+ }
+
+ @Override
+ protected String getTableTitle() {
+ return "Group Alert Definitions";
+ }
+
+ @Override
+ protected boolean isAllowedToModifyAlerts() {
+ // TODO: see if user can modify group alerts on this group
+ return true;
+ }
+
+ @Override
+ protected void newButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void enableButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void disableButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void deleteButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
new file mode 100644
index 0000000..948656a
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/NotificationsAlertDefinitionForm.java
@@ -0,0 +1,99 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+/**
+ * @author John Mazzitelli
+ */
+public class NotificationsAlertDefinitionForm extends DynamicForm implements
EditAlertDefinitionForm {
+
+ private AlertDefinition alertDefinition;
+
+ public NotificationsAlertDefinitionForm() {
+ this(null);
+ }
+
+ public NotificationsAlertDefinitionForm(AlertDefinition alertDefinition) {
+ this.alertDefinition = alertDefinition;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ // TODO only build form if we didn't do it yet
+ if (true) {
+ buildForm();
+ setAlertDefinition(alertDefinition);
+ makeViewOnly();
+ }
+ }
+
+ @Override
+ public AlertDefinition getAlertDefinition() {
+ return this.alertDefinition;
+ }
+
+ @Override
+ public void setAlertDefinition(AlertDefinition alertDef) {
+ this.alertDefinition = alertDef;
+
+ if (alertDef == null) {
+ clearFormValues();
+ } else {
+ // TODO set values of the components
+ }
+
+ markForRedraw();
+ }
+
+ @Override
+ public void makeEditable() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void makeViewOnly() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void saveAlertDefinition() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void clearFormValues() {
+ // TODO component.clearValue();
+ }
+
+ private void buildForm() {
+ // TODO build components
+ // TODO setFields(components);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
new file mode 100644
index 0000000..e95c771
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/RecoveryAlertDefinitionForm.java
@@ -0,0 +1,119 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+/**
+ * @author John Mazzitelli
+ */
+public class RecoveryAlertDefinitionForm extends DynamicForm implements
EditAlertDefinitionForm {
+
+ private AlertDefinition alertDefinition;
+
+ private SelectItem recoverAlertSelection;
+ private RadioGroupItem disableWhenFiredSelection;
+
+ private boolean formBuilt = false;
+
+ public RecoveryAlertDefinitionForm() {
+ this(null);
+ }
+
+ public RecoveryAlertDefinitionForm(AlertDefinition alertDefinition) {
+ this.alertDefinition = alertDefinition;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ if (!formBuilt) {
+ buildForm();
+ setAlertDefinition(alertDefinition);
+ makeViewOnly();
+ }
+ }
+
+ @Override
+ public AlertDefinition getAlertDefinition() {
+ return this.alertDefinition;
+ }
+
+ @Override
+ public void setAlertDefinition(AlertDefinition alertDef) {
+ this.alertDefinition = alertDef;
+
+ buildForm();
+
+ if (alertDef == null) {
+ clearFormValues();
+ } else {
+ disableWhenFiredSelection.setValue(alertDef.getWillRecover() ?
"Yes" : "No");
+ }
+
+ markForRedraw();
+ }
+
+ @Override
+ public void makeEditable() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void makeViewOnly() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void saveAlertDefinition() {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void clearFormValues() {
+ recoverAlertSelection.clearValue();
+ disableWhenFiredSelection.clearValue();
+ }
+
+ private void buildForm() {
+ if (!formBuilt) {
+ recoverAlertSelection = new SelectItem("recoveryAlert",
"Recover Alert");
+ recoverAlertSelection.setValueMap("Select...");
+ recoverAlertSelection.setDefaultValue("Select...");
+ // TODO: call into server and get the menu list of all alerts that we can
recover
+
+ disableWhenFiredSelection = new RadioGroupItem("disableWhenFired",
"Disable When Fired");
+ disableWhenFiredSelection.setValueMap("Yes", "No");
+ disableWhenFiredSelection.setDefaultValue("Yes");
+
+ setFields(recoverAlertSelection, disableWhenFiredSelection);
+ formBuilt = true;
+ }
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
new file mode 100644
index 0000000..ed19a24
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsDataSource.java
@@ -0,0 +1,132 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import java.util.Map;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.fields.DataSourceLinkField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceAlertDefinitionsDataSource extends
AbstractAlertDefinitionsDataSource {
+
+ protected static final String FIELD_PARENT = "parent"; // the column field
- may be template or group alert def parent
+ protected static final String FIELD_PARENT_TEMPLATEID = "parent_tid"; //
the actual integer (may be 0) of template ID
+ protected static final String FIELD_PARENT_GROUPALERTDEF = "parentId_gad";
// the actual group alert def parent (may be null)
+ protected static final String FIELD_READONLY = "readOnly"; // not
necessarily the actual boolean; sometimes we display "N/A"
+ protected static final String FIELD_READONLY_BOOLEAN = "readOnly_boolean";
// the actual boolean value
+
+ private Resource resource;
+
+ public ResourceAlertDefinitionsDataSource(Resource resource) {
+ super();
+ this.resource = resource;
+ }
+
+ @Override
+ public AlertDefinition copyValues(ListGridRecord from) {
+ AlertDefinition alertDef = super.copyValues(from);
+ alertDef.setParentId(from.getAttributeAsInt(FIELD_PARENT_TEMPLATEID));
+ alertDef.setGroupAlertDefinition((AlertDefinition)
from.getAttributeAsObject(FIELD_PARENT_GROUPALERTDEF));
+ alertDef.setReadOnly(from.getAttributeAsBoolean(FIELD_READONLY_BOOLEAN));
+ return alertDef;
+ }
+
+ @Override
+ public ListGridRecord copyValues(AlertDefinition from) {
+ ListGridRecord record = super.copyValues(from);
+
+ Integer parentId = from.getParentId(); // a valid non-zero number means the alert
def came from a template
+ AlertDefinition groupAlertDefinition = from.getGroupAlertDefinition();
+ boolean readOnly = from.isReadOnly();
+
+ record.setAttribute(FIELD_PARENT_TEMPLATEID, parentId);
+ record.setAttribute(FIELD_PARENT_GROUPALERTDEF, groupAlertDefinition);
+ record.setAttribute(FIELD_READONLY_BOOLEAN, readOnly);
+
+ if ((parentId == null || parentId.intValue() == 0) &&
(groupAlertDefinition == null)) {
+ record.setAttribute(FIELD_PARENT, "");
+ record.setLinkText("");
+ record.setAttribute(FIELD_READONLY, "N/A");
+ } else {
+ // TODO: fix the URLs so they point to the new GWT pages when they are
implemented
+ if (parentId != null && parentId.intValue() != 0) {
+ record.setAttribute(FIELD_PARENT,
"/alerts/Config.do?mode=viewRoles&type="
+ + this.resource.getResourceType().getId() + "&from=" +
from.getId() + "&ad=" + parentId);
+ record.setLinkText("View Template");
+ } else {
+ record.setAttribute(FIELD_PARENT,
"/alerts/Config.do?mode=viewRoles&groupId="
+ + groupAlertDefinition.getResourceGroup().getId() +
"&from=" + from.getId() + "&ad="
+ + groupAlertDefinition.getId());
+ record.setLinkText("View Group Definition");
+ }
+ record.setAttribute(FIELD_READONLY, readOnly);
+ }
+
+ return record;
+ }
+
+ @Override
+ protected void setupFields() {
+ super.setupFields();
+
+ // add two more columns
+ DataSourceLinkField parentIdField = new DataSourceLinkField(FIELD_PARENT,
"Parent");
+ addField(parentIdField);
+
+ DataSourceTextField readOnlyField = new DataSourceTextField(FIELD_READONLY,
"Read Only");
+ addField(readOnlyField);
+ }
+
+ @Override
+ protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+
+ criteria.fetchGroupAlertDefinition(true);
+
+ Criteria requestCriteria = request.getCriteria();
+ if (requestCriteria != null) {
+ Map values = requestCriteria.getValues();
+ for (Object key : values.keySet()) {
+ String fieldName = (String) key;
+ if (fieldName.equals(ResourceAlertDefinitionsView.CRITERIA_RESOURCE_ID))
{
+ Integer resourceId = (Integer) values.get(fieldName);
+ criteria.addFilterResourceIds(resourceId);
+ }
+ }
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
new file mode 100644
index 0000000..36c146c
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -0,0 +1,108 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.Resource;
+
+/**
+ * @author John Mazzitelli
+ */
+public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
+
+ public static final String CRITERIA_RESOURCE_ID = "resourceId";
+
+ private Resource resource;
+
+ public ResourceAlertDefinitionsView(Resource resource) {
+ super();
+ this.resource = resource;
+ }
+
+ @Override
+ protected Criteria getCriteria() {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(CRITERIA_RESOURCE_ID, resource.getId());
+ return criteria;
+ }
+
+ @Override
+ protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() {
+ return new ResourceAlertDefinitionsDataSource(this.resource);
+ }
+
+ @Override
+ protected String getTableTitle() {
+ return "Alert Definitions";
+ }
+
+ @Override
+ protected boolean isAllowedToModifyAlerts() {
+ // TODO: see if user can modify alerts on this resource
+ return true;
+ }
+
+ @Override
+ protected void newButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void enableButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void disableButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void deleteButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
new file mode 100644
index 0000000..eff934f
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -0,0 +1,175 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.widgets.Button;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
+
+import org.rhq.core.domain.alert.AlertDefinition;
+
+/**
+ * @author John Mazzitelli
+ */
+public class SingleAlertDefinitionView extends VLayout {
+
+ private AlertDefinition alertDefinition;
+ private GeneralPropertiesAlertDefinitionForm generalProperties;
+ private ConditionsAlertDefinitionForm conditions;
+ private NotificationsAlertDefinitionForm notifications;
+ private RecoveryAlertDefinitionForm recovery;
+ private DampeningAlertDefinitionForm dampening;
+
+ private Button editButton;
+ private Button saveButton;
+ private Button cancelButton;
+
+ public SingleAlertDefinitionView() {
+ this(null);
+ }
+
+ public SingleAlertDefinitionView(AlertDefinition alertDefinition) {
+ this.alertDefinition = alertDefinition;
+
+ TabSet tabSet = new TabSet();
+ tabSet.setHeight100();
+
+ Tab generalPropertiesTab = new Tab("General Properties");
+ generalProperties = new GeneralPropertiesAlertDefinitionForm(alertDefinition);
+ generalPropertiesTab.setPane(generalProperties);
+
+ Tab conditionsTab = new Tab("Conditions");
+ conditions = new ConditionsAlertDefinitionForm(alertDefinition);
+ conditionsTab.setPane(conditions);
+
+ Tab notificationsTab = new Tab("Notifications");
+ notifications = new NotificationsAlertDefinitionForm(alertDefinition);
+ notificationsTab.setPane(notifications);
+
+ Tab recoveryTab = new Tab("Recovery");
+ recovery = new RecoveryAlertDefinitionForm(alertDefinition);
+ recoveryTab.setPane(recovery);
+
+ Tab dampeningTab = new Tab("Dampening");
+ dampening = new DampeningAlertDefinitionForm(alertDefinition);
+ dampeningTab.setPane(dampening);
+
+ tabSet.setTabs(generalPropertiesTab, conditionsTab, notificationsTab,
recoveryTab, dampeningTab);
+
+ final HLayout buttons = new HLayout();
+ buttons.setMembersMargin(20);
+
+ editButton = new Button("Edit");
+ saveButton = new Button("Save");
+ cancelButton = new Button("Cancel");
+
+ editButton.show();
+ saveButton.hide();
+ cancelButton.hide();
+
+ buttons.addMember(editButton);
+ buttons.addMember(saveButton);
+ buttons.addMember(cancelButton);
+
+ editButton.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ makeEditable();
+ }
+ });
+
+ saveButton.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ saveAlertDefinition();
+ makeViewOnly();
+
+ // TODO getAlertDefinition() should now have the new user data - commit
it to DB
+ }
+ });
+
+ cancelButton.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ makeViewOnly();
+ }
+ });
+
+ setMembersMargin(10);
+ addMember(tabSet);
+ addMember(buttons);
+ }
+
+ public AlertDefinition getAlertDefinition() {
+ return alertDefinition;
+ }
+
+ public void setAlertDefinition(AlertDefinition alertDef) {
+ alertDefinition = alertDef;
+
+ generalProperties.setAlertDefinition(alertDef);
+ conditions.setAlertDefinition(alertDef);
+ notifications.setAlertDefinition(alertDef);
+ recovery.setAlertDefinition(alertDef);
+ dampening.setAlertDefinition(alertDef);
+
+ makeViewOnly();
+ }
+
+ public void makeEditable() {
+ saveButton.show();
+ cancelButton.show();
+ editButton.hide();
+
+ generalProperties.makeEditable();
+ conditions.makeEditable();
+ notifications.makeEditable();
+ recovery.makeEditable();
+ dampening.makeEditable();
+ }
+
+ public void makeViewOnly() {
+ saveButton.hide();
+ cancelButton.hide();
+ editButton.show();
+
+ generalProperties.makeViewOnly();
+ conditions.makeViewOnly();
+ notifications.makeViewOnly();
+ recovery.makeViewOnly();
+ dampening.makeViewOnly();
+ }
+
+ public void saveAlertDefinition() {
+ generalProperties.saveAlertDefinition();
+ conditions.saveAlertDefinition();
+ notifications.saveAlertDefinition();
+ recovery.saveAlertDefinition();
+ dampening.saveAlertDefinition();
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
new file mode 100644
index 0000000..9a96db8
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsDataSource.java
@@ -0,0 +1,57 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import java.util.Map;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.DSRequest;
+
+import org.rhq.core.domain.criteria.AlertDefinitionCriteria;
+
+/**
+ * @author John Mazzitelli
+ */
+public class TemplateAlertDefinitionsDataSource extends
AbstractAlertDefinitionsDataSource {
+
+ @Override
+ protected AlertDefinitionCriteria getCriteria(DSRequest request) {
+ AlertDefinitionCriteria criteria = new AlertDefinitionCriteria();
+
+ Criteria requestCriteria = request.getCriteria();
+ if (requestCriteria != null) {
+ Map values = requestCriteria.getValues();
+ for (Object key : values.keySet()) {
+ String fieldName = (String) key;
+ if
(fieldName.equals(TemplateAlertDefinitionsView.CRITERIA_RESOURCE_TYPE_ID)) {
+ Integer resourceId = (Integer) values.get(fieldName);
+ criteria.addFilterAlertTemplateResourceTypeId(resourceId);
+ }
+ }
+ }
+
+ criteria.setPageControl(getPageControl(request));
+ return criteria;
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
new file mode 100644
index 0000000..e9674ad
--- /dev/null
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/TemplateAlertDefinitionsView.java
@@ -0,0 +1,108 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.enterprise.gui.coregui.client.alert.definitions;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.ResourceType;
+
+/**
+ * @author John Mazzitelli
+ */
+public class TemplateAlertDefinitionsView extends AbstractAlertDefinitionsView {
+
+ public static final String CRITERIA_RESOURCE_TYPE_ID = "resourceTypeId";
+
+ private ResourceType resourceType;
+
+ public TemplateAlertDefinitionsView(ResourceType resourceType) {
+ super();
+ this.resourceType = resourceType;
+ }
+
+ @Override
+ protected Criteria getCriteria() {
+ Criteria criteria = new Criteria();
+ criteria.addCriteria(CRITERIA_RESOURCE_TYPE_ID, resourceType.getId());
+ return criteria;
+ }
+
+ @Override
+ protected AbstractAlertDefinitionsDataSource getAlertDefinitionDataSource() {
+ return new TemplateAlertDefinitionsDataSource();
+ }
+
+ @Override
+ protected String getTableTitle() {
+ return "Alert Templates";
+ }
+
+ @Override
+ protected boolean isAllowedToModifyAlerts() {
+ // TODO: see if user can modify template alerts
+ return true;
+ }
+
+ @Override
+ protected void newButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void enableButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void disableButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+
+ @Override
+ protected void deleteButtonPressed(ListGridRecord[] selection) {
+ // TODO Auto-generated method stub
+ String str = "this is not implemented yet but you selected";
+ for (ListGridRecord record : selection) {
+ str += ": " + record.getAttribute("name");
+ }
+ SC.say(str);
+ }
+}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index 2418783..ee29754 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -34,11 +34,8 @@ import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.events.DataArrivedEvent;
import com.smartgwt.client.widgets.grid.events.DataArrivedHandler;
-import com.smartgwt.client.widgets.grid.events.FieldStateChangedEvent;
-import com.smartgwt.client.widgets.grid.events.FieldStateChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionChangedHandler;
import com.smartgwt.client.widgets.grid.events.SelectionEvent;
import com.smartgwt.client.widgets.layout.HLayout;
@@ -68,7 +65,6 @@ public class Table extends VLayout {
private String headerIcon;
-
private boolean showHeader = true;
private boolean showFooter = true;
@@ -91,7 +87,11 @@ public class Table extends VLayout {
/**
* Two or more rows are selected.
*/
- MULTIPLE
+ MULTIPLE,
+ /**
+ * Never enabled - usually due to the user having a lack of permissions
+ */
+ NEVER
}
;
@@ -124,7 +124,7 @@ public class Table extends VLayout {
}
public Table(String tableTitle, Criteria criteria, SortSpecifier[] sortSpecifiers,
String[] excludedFieldNames,
- boolean autoFetchData) {
+ boolean autoFetchData) {
super();
setWidth100();
@@ -164,7 +164,6 @@ public class Table extends VLayout {
protected void onInit() {
super.onInit();
-
// NOTE: It is essential that we wait to hide any excluded fields until after
super.onDraw() is called, since
// super.onDraw() is what actually adds the fields to the ListGrid (based
on what fields are defined in
// the underlying datasource).
@@ -174,13 +173,10 @@ public class Table extends VLayout {
}
}
-
tableInfo.setWrap(false);
-
}
-
@Override
protected void onDraw() {
super.onDraw();
@@ -222,7 +218,7 @@ public class Table extends VLayout {
if (tableAction.confirmMessage != null) {
String message =
tableAction.confirmMessage.replaceAll("\\#", String.valueOf(listGrid
- .getSelection().length));
+ .getSelection().length));
SC.ask(message, new BooleanCallback() {
public void execute(Boolean confirmed) {
@@ -244,7 +240,6 @@ public class Table extends VLayout {
footer.addMember(extraWidgetCanvas);
}
-
footer.addMember(new LayoutSpacer());
IButton refreshButton = new IButton("Refresh");
@@ -268,11 +263,9 @@ public class Table extends VLayout {
public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
refreshTableInfo();
fieldSizes.clear();
- totalWidth = 0;
}
});
-
addMember(footer);
}
}
@@ -297,9 +290,7 @@ public class Table extends VLayout {
this.showFooter = showFooter;
}
- private int totalWidth;
private ArrayList<Integer> fieldSizes = new ArrayList<Integer>();
- private boolean autoSizing = false;
public void refresh(Criteria criteria) {
this.listGrid.invalidateCache();
@@ -311,7 +302,6 @@ public class Table extends VLayout {
this.listGrid.invalidateCache();
this.listGrid.markForRedraw();
}
-
public void setTableTitle(String titleString) {
if (titleString == null) {
@@ -346,7 +336,6 @@ public class Table extends VLayout {
return listGrid;
}
-
public void setTitleComponent(Canvas canvas) {
this.titleComponent = canvas;
}
@@ -356,7 +345,7 @@ public class Table extends VLayout {
}
public void addTableAction(String title, SelectionEnablement enablement, String
confirmation,
- TableAction tableAction) {
+ TableAction tableAction) {
if (enablement == null) {
enablement = DEFAULT_SELECTION_ENABLEMENT;
}
@@ -383,20 +372,23 @@ public class Table extends VLayout {
for (TableActionInfo tableAction : tableActions) {
boolean enabled;
switch (tableAction.enablement) {
- case ALWAYS:
- enabled = true;
- break;
- case ANY:
- enabled = (count >= 1);
- break;
- case SINGLE:
- enabled = (count == 1);
- break;
- case MULTIPLE:
- enabled = (count > 1);
- break;
- default:
- throw new IllegalStateException("Unhandled
SelectionEnablement: " + tableAction.enablement.name());
+ case ALWAYS:
+ enabled = true;
+ break;
+ case NEVER:
+ enabled = false;
+ break;
+ case ANY:
+ enabled = (count >= 1);
+ break;
+ case SINGLE:
+ enabled = (count == 1);
+ break;
+ case MULTIPLE:
+ enabled = (count > 1);
+ break;
+ default:
+ throw new IllegalStateException("Unhandled SelectionEnablement:
" + tableAction.enablement.name());
}
tableAction.actionButton.setDisabled(!enabled);
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index ea7b88e..5da123b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -33,6 +33,7 @@ import org.rhq.core.domain.resource.composite.ResourcePermission;
import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
import org.rhq.enterprise.gui.coregui.client.CoreGUI;
import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import
org.rhq.enterprise.gui.coregui.client.alert.definitions.ResourceAlertDefinitionsView;
import org.rhq.enterprise.gui.coregui.client.components.FullHTMLPane;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTab;
import org.rhq.enterprise.gui.coregui.client.components.tab.TwoLevelTabSelectedEvent;
@@ -108,7 +109,7 @@ public class ResourceDetailView extends VLayout implements
BookmarkableView, Res
operationsTab.registerSubTabs("History", "Scheduled");
alertsTab = new TwoLevelTab("Alerts",
"/images/icons/Alert_grey_16.png");
- alertsTab.registerSubTabs("History", "Definitions");
+ alertsTab.registerSubTabs("History", "Definitions",
"DELETEME");
configurationTab = new TwoLevelTab("Configuration",
"/images/icons/Configure_grey_16.png");
configurationTab.registerSubTabs("Current", "History");
@@ -178,11 +179,11 @@ public class ResourceDetailView extends VLayout implements
BookmarkableView, Res
// 3) user can enable/disable/delete alert definitions if they possess the
appropriate permissions
// 4) user can search alert history by: date alert was fired, alert priority,
or alert definition
//alertsTab.updateSubTab("History", new
ResourceAlertHistoryView(resource.getId()));
- //alertsTab.updateSubTab("Definitions",
AlertDefinitionsView.getResourceView(resource));
alertsTab.updateSubTab("History", new
FullHTMLPane("/rhq/resource/alert/listAlertHistory-plain.xhtml?id="
+ resource.getId()));
- alertsTab.updateSubTab("Definitions", new FullHTMLPane(
- "/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id=" +
resource.getId()));
+ alertsTab.updateSubTab("Definitions", new
ResourceAlertDefinitionsView(resource));
+ alertsTab.updateSubTab("DELETEME", new
FullHTMLPane("/rhq/resource/alert/listAlertDefinitions-plain.xhtml?id="
+ + resource.getId()));
// comment out GWT-based view until...
// 1) user can search event history by: metric display range, event source,
event details, event severity