modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
| 18
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
| 33 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
| 187 +++++++---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
| 10
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 6
6 files changed, 178 insertions(+), 78 deletions(-)
New commits:
commit 3e764d153948be8b0d7b9d25e58947caa14295ca
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri Mar 25 18:23:16 2011 -0400
be able to clear out ResourcErrors for a particular resource.
This is needed because I'm seeing instances where I get ResourcErrors in the
database that never go away, even after the plugin can later successfully connect and
monitor the resource.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
index 72be13d..921b82d 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ResourceGWTService.java
@@ -59,6 +59,8 @@ public interface ResourceGWTService extends RemoteService {
List<ResourceError> findResourceErrors(int resourceId) throws
RuntimeException;
+ void deleteResourceErrors(int[] resourceErrorIds) throws RuntimeException;
+
PageList<ProblemResourceComposite> findProblemResources(long ctime, int
maxItems) throws RuntimeException;
Resource getPlatformForResource(int resourceId) throws RuntimeException;
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
index 1046f31..7bc1cdd 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java
@@ -204,25 +204,25 @@ public class ResourceTitleBar extends LocatableVLayout {
winModal.setWidth("70%");
winModal.setHeight("70%");
winModal.setIsModal(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
winModal.centerInPage();
- winModal.setTitle(MSG.common_title_component_errors() + ":");
+ winModal.setTitle(MSG.common_title_component_errors());
LocatableVLayout form = new
LocatableVLayout(extendLocatorId("_Modal_Form"));
form.setAlign(VerticalAlignment.CENTER);
- form.setLayoutMargin(20);
+ form.setLayoutMargin(10);
form.setWidth100();
- form.setHeight("40%");
- ResourceErrorsView errorsGrid = new
ResourceErrorsView(extendLocatorId("errors"), MSG
- .view_summaryOverview_header_detectedErrors(), null, null,
- new String[] { ResourceErrorsDataSource.Field.DETAIL });
- errorsGrid.setWidth100();
- errorsGrid.setHeight("400");
+ form.setHeight100();
Resource resource = resourceComposite.getResource();
ResourceErrorsDataSource errors = new
ResourceErrorsDataSource(resource.getId());
- errorsGrid.setShowFooter(false);
+ ResourceErrorsView errorsGrid = new
ResourceErrorsView(extendLocatorId("errors"), MSG
+ .view_summaryOverview_header_detectedErrors(), null, null,
+ new String[] { ResourceErrorsDataSource.Field.DETAIL });
errorsGrid.setDataSource(errors);
+
form.addMember(errorsGrid);
winModal.addItem(form);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
index 5999e14..be76956 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
@@ -27,10 +27,6 @@ import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceDateTimeField;
-import com.smartgwt.client.data.fields.DataSourceEnumField;
-import com.smartgwt.client.data.fields.DataSourceImageField;
-import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.rpc.RPCResponse;
import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -42,22 +38,20 @@ import
org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
/**
- *
* @author Lukas Krejci
* @author Simeon Pinder
+ * @author John Mazzitelli
*/
public class ResourceErrorsDataSource extends RPCDataSource<ResourceError,
Criteria> {
public static abstract class Field {
+ public static final String ID = "id";
public static final String SUMMARY = "summary";
public static final String DETAIL = "detail";
public static final String ERROR_TYPE = "errorType";
public static final String TIME_OCCURED = "timeOccured";
- public static final String ICON = "icon";
}
- private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png";
-
ResourceGWTServiceAsync resourceService;
int resourceId;
@@ -69,25 +63,6 @@ public class ResourceErrorsDataSource extends
RPCDataSource<ResourceError, Crite
}
@Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- fields.add(new DataSourceEnumField(Field.ERROR_TYPE,
MSG.dataSource_resourceErrors_field_errorType()));
- fields.add(new DataSourceDateTimeField(Field.TIME_OCCURED,
MSG.dataSource_resourceErrors_field_timeOccured()));
- fields.add(new DataSourceTextField(Field.SUMMARY,
MSG.dataSource_resourceErrors_field_summary()));
- DataSourceTextField details = new DataSourceTextField(Field.DETAIL, MSG
- .dataSource_resourceErrors_field_detail());
- details.setHidden(true);//won't be displaying this value directly in the
listgrid
- fields.add(details);
- fields.add(new DataSourceImageField(Field.ICON,
MSG.dataSource_resourceErrors_field_detail()));
-
- return fields;
- }
-
- /* (non-Javadoc)
- * @see
org.rhq.enterprise.gui.coregui.client.util.RPCDataSource#executeFetch(com.smartgwt.client.data.DSRequest,
com.smartgwt.client.data.DSResponse)
- */
- @Override
protected void executeFetch(final DSRequest request, final DSResponse response, final
Criteria unused) {
resourceService.findResourceErrors(resourceId, new
AsyncCallback<List<ResourceError>>() {
public void onFailure(Throwable caught) {
@@ -110,16 +85,18 @@ public class ResourceErrorsDataSource extends
RPCDataSource<ResourceError, Crite
return null;
}
+ @Override
public ResourceError copyValues(Record from) {
//This is read-only datasource, so no need to implement this.
return null;
}
+ @Override
public ListGridRecord copyValues(ResourceError from) {
ListGridRecord record = new ListGridRecord();
+ record.setAttribute(Field.ID, from.getId());
record.setAttribute(Field.DETAIL, from.getDetail());
- record.setAttribute(Field.ICON, ERROR_ICON);
record.setAttribute(Field.ERROR_TYPE, from.getErrorType().name());
record.setAttribute(Field.SUMMARY, from.getSummary());
record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred()));
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
index 0309602..1c75bcc 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
@@ -1,80 +1,189 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.AutoFitWidthApproach;
+import com.smartgwt.client.types.DateDisplayFormat;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.types.SelectionStyle;
import com.smartgwt.client.widgets.Window;
import com.smartgwt.client.widgets.events.CloseClickHandler;
import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.events.DoubleClickEvent;
+import com.smartgwt.client.widgets.events.DoubleClickHandler;
import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.table.AbstractTableAction;
import org.rhq.enterprise.gui.coregui.client.components.table.Table;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablement;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import
org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource.Field;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-public class ResourceErrorsView extends Table {
+public class ResourceErrorsView extends Table<ResourceErrorsDataSource> {
+ private static final String ERROR_ICON = "[SKIN]/Dialog/warn.png";
+
public ResourceErrorsView(String locatorId, String string, Criteria criteria, Object
object, String[] strings) {
super(locatorId, MSG.common_title_component_errors(), criteria);
+ setWidth100();
+ setHeight100();
+ setShowHeader(false);
+ }
+
+ @Override
+ protected SelectionStyle getDefaultSelectionStyle() {
+ return SelectionStyle.MULTIPLE;
}
- /** Set order and width of table display
- */
@Override
protected void configureTable() {
-
getListGrid().getField(ResourceErrorsDataSource.Field.ERROR_TYPE).setWidth("20%");
-
getListGrid().getField(ResourceErrorsDataSource.Field.TIME_OCCURED).setWidth("15%");
-
getListGrid().getField(ResourceErrorsDataSource.Field.SUMMARY).setWidth("30%");
- //modify icon display listgrid element
- ListGridField iconField =
getListGrid().getField(ResourceErrorsDataSource.Field.ICON);
- iconField.setWidth("35%");
- //add action on click of cell
+ ListGridField errorTypeField = new ListGridField(Field.ERROR_TYPE, MSG
+ .dataSource_resourceErrors_field_errorType());
+ errorTypeField.setAlign(Alignment.CENTER);
+ errorTypeField.setAutoFitWidth(true);
+ errorTypeField.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
+
+ ListGridField timeField = new ListGridField(Field.TIME_OCCURED, MSG
+ .dataSource_resourceErrors_field_timeOccured());
+ timeField.setType(ListGridFieldType.DATE);
+ timeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ timeField.setAlign(Alignment.CENTER);
+ timeField.setWidth("20%");
+
+ ListGridField summaryField = new ListGridField(Field.SUMMARY,
MSG.dataSource_resourceErrors_field_summary());
+ summaryField.setAlign(Alignment.CENTER);
+ summaryField.setCellAlign(Alignment.LEFT);
+ summaryField.setWidth("*");
+
+ ListGridField iconField = new ListGridField("icon");
+ iconField.setType(ListGridFieldType.ICON);
+ iconField.setAlign(Alignment.CENTER);
+ iconField.setIcon(ERROR_ICON);
+ iconField.setCellIcon(ERROR_ICON);
+ iconField.setWidth("50");
+ iconField.setCanSort(false);
iconField.addRecordClickHandler(new RecordClickHandler() {
@Override
public void onRecordClick(RecordClickEvent event) {
- final Window winModal = new
LocatableWindow(extendLocatorId("errorDetailsWin"));
- winModal.setTitle(MSG.common_title_component_errors());
- winModal.setOverflow(Overflow.VISIBLE);
- winModal.setShowMinimizeButton(false);
- winModal.setShowMaximizeButton(true);
- winModal.setIsModal(true);
- winModal.setShowModalMask(true);
- winModal.setAutoSize(true);
- winModal.setAutoCenter(true);
- winModal.setShowResizer(true);
- winModal.setCanDragResize(true);
- winModal.centerInPage();
- winModal.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
- }
- });
-
- LocatableHTMLPane htmlPane = new
LocatableHTMLPane(extendLocatorId("errorDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(550);
- htmlPane.setDefaultHeight(550);
-
htmlPane.setContents((event.getRecord().getAttribute(ResourceErrorsDataSource.Field.DETAIL)));
- winModal.addItem(htmlPane);
- winModal.show();
+ String details = event.getRecord().getAttribute(Field.DETAIL);
+ popupDetails(details);
}
});
iconField.setShowHover(true);
- //show some details in mouseOver
iconField.setHoverCustomizer(new HoverCustomizer() {
@Override
public String hoverHTML(Object value, ListGridRecord record, int rowNum, int
colNum) {
- String html =
record.getAttribute(ResourceErrorsDataSource.Field.DETAIL);
+ String html = record.getAttribute(Field.DETAIL);
if (html.length() > 80) {
// this was probably an error stack trace, snip it so the tooltip
isn't too big
html = "<pre>" + html.substring(0, 80) +
"...</pre><p>"
- + MSG.view_group_pluginConfig_table_clickStatusIcon() +
"</p>";
+ + MSG.dataSource_resourceErrors_clickStatusIcon() +
"</p>";
}
return html;
}
});
+
+ setListGridDoubleClickHandler(new DoubleClickHandler() {
+ @Override
+ public void onDoubleClick(DoubleClickEvent event) {
+ ListGrid listGrid = (ListGrid) event.getSource();
+ ListGridRecord[] selectedRows = listGrid.getSelection();
+ if (selectedRows != null && selectedRows.length > 0) {
+ String details = selectedRows[0].getAttribute(Field.DETAIL);
+ popupDetails(details);
+ }
+ }
+ });
+
+ setListGridFields(errorTypeField, timeField, summaryField, iconField);
+
+ addTableAction(extendLocatorId("delete"), MSG.common_button_delete(),
MSG.common_msg_areYouSure(),
+ new AbstractTableAction(TableActionEnablement.ANY) {
+ @Override
+ public void executeAction(final ListGridRecord[] selection, Object
actionValue) {
+ if (selection == null || selection.length == 0) {
+ return;
+ }
+ int[] resourceErrorIds = new int[selection.length];
+ int i = 0;
+ for (ListGridRecord record : selection) {
+ resourceErrorIds[i++] = record.getAttributeAsInt(Field.ID);
+ }
+
GWTServiceLookup.getResourceService().deleteResourceErrors(resourceErrorIds,
+ new AsyncCallback<Void>() {
+ @Override
+ public void onSuccess(Void result) {
+ Message msg = new
Message(MSG.dataSource_resourceErrors_deleteSuccess(String
+ .valueOf(selection.length)), Severity.Info);
+ CoreGUI.getMessageCenter().notify(msg);
+ refresh();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+
CoreGUI.getErrorHandler().handleError(MSG.dataSource_resourceErrors_deleteFailure(),
+ caught);
+ }
+ });
+ }
+ });
+ }
+
+ private void popupDetails(String details) {
+ final Window winModal = new
LocatableWindow(extendLocatorId("errorDetailsWin"));
+ winModal.setTitle(MSG.common_title_component_errors());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new
LocatableHTMLPane(extendLocatorId("errorDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(700);
+ htmlPane.setDefaultHeight(500);
+ htmlPane.setContents("<pre>" + details +
"</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
}
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
index 7b32034..13fc75a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ResourceGWTServiceImpl.java
@@ -314,6 +314,16 @@ public class ResourceGWTServiceImpl extends AbstractGWTServiceImpl
implements Re
}
}
+ public void deleteResourceErrors(int[] resourceErrorIds) throws RuntimeException {
+ try {
+ for (int doomedId : resourceErrorIds) {
+ resourceManager.deleteResourceError(getSessionSubject(), doomedId);
+ }
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
public Resource manuallyAddResource(int resourceTypeId, int parentResourceId,
Configuration pluginConfiguration)
throws RuntimeException {
try {
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 8317263..35ff92d 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -108,7 +108,7 @@ common_title_columns = Columns
common_title_configuration = Configuration
common_title_compatibleGroups = Compatible Groups
common_title_compatibleGroups_total = Compatible Group Total
-common_title_component_errors = Component errors
+common_title_component_errors = Component Errors
common_title_count = Count
common_title_custom = Custom
common_title_dashboard_name = Dashboard Name
@@ -563,10 +563,12 @@ dataSource_configurationHistory_error_fetchFailure = Unable to load
configuratio
# Resource Errors
#-------------------------
dataSource_resourceErrors_field_summary = Summary
-dataSource_resourceErrors_field_detail = Detailed Message
dataSource_resourceErrors_field_errorType = Error Type
dataSource_resourceErrors_field_timeOccured = Time
dataSource_resourceErrors_error_fetchFailure = Failed to find Resource errors for
Resource with id [{0}].
+dataSource_resourceErrors_clickStatusIcon = Click the icon for more details
+dataSource_resourceErrors_deleteSuccess = You have successfully deleted [{0}] resource
error messages.
+dataSource_resourceErrors_deleteFailure = Failed to delete resource errors
# Template Schedules
#-------------------------