modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java | 26
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java | 336 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java | 106 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java | 189 +++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTitleBar.java | 17
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java | 333 ---------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java | 106 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java | 189 -----
9 files changed, 665 insertions(+), 643 deletions(-)
New commits:
commit fec4fb5d697c886ca6ba8cb03b4686efedcb8815
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Mar 31 16:55:59 2011 -0400
BZ 640396 - when you change the name of a resource or group, the title bar header name also changes now
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
index ba62aa4..fde8d13 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/GeneralProperties.java
@@ -54,10 +54,12 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
public class GeneralProperties extends LocatableVLayout {
private ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService();
private ResourceGroupComposite groupComposite;
+ private final ResourceGroupTitleBar titleBar;
- public GeneralProperties(String locatorId, ResourceGroupComposite groupComposite) {
+ public GeneralProperties(String locatorId, ResourceGroupComposite groupComposite, ResourceGroupTitleBar titleBar) {
super(locatorId);
this.groupComposite = groupComposite;
+ this.titleBar = titleBar;
}
@Override
@@ -108,6 +110,8 @@ public class GeneralProperties extends LocatableVLayout {
}
public void onSuccess(Void result) {
+ titleBar.displayGroupName(newName);
+
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_group_summary_nameUpdateSuccessful(String.valueOf(group
.getId()), oldName, newName), Message.Severity.Info));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
index 26e826c..d8020f3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTitleBar.java
@@ -137,7 +137,8 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
ResourceGroupComposite resultComposite = result.get(0);
setGroupIcons(resultComposite);
- generalProperties = new GeneralProperties(extendLocatorId("genProps"), resultComposite);
+ generalProperties = new GeneralProperties(extendLocatorId("genProps"), resultComposite,
+ ResourceGroupTitleBar.this);
generalProperties.setVisible(false);
ResourceGroupTitleBar.this.addMember(generalProperties);
expandCollapseArrow.addClickHandler(new ClickHandler() {
@@ -234,6 +235,21 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
this.group = groupComposite.getResourceGroup();
update();
+ displayGroupName(group.getName());
+
+ Set<Integer> favorites = UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
+ this.favorite = favorites.contains(group.getId());
+ updateFavoriteButton();
+
+ setGroupIcons(groupComposite);
+ markForRedraw();
+ }
+
+ void displayGroupName(String groupName) {
+ if (!group.getName().equals(groupName)) {
+ group.setName(groupName); // the name must have been changed by the user via the editable field
+ }
+
String catName = null;
switch (group.getGroupCategory()) {
case COMPATIBLE: {
@@ -248,13 +264,7 @@ public class ResourceGroupTitleBar extends LocatableVLayout {
this.title.setContents("<span class=\"SectionHeader\">" + group.getName()
+ "</span> <span class=\"subtitle\">" + catName + "</span>");
-
- Set<Integer> favorites = UserSessionManager.getUserPreferences().getFavoriteResourceGroups();
- this.favorite = favorites.contains(group.getId());
- updateFavoriteButton();
-
- setGroupIcons(groupComposite);
- markForRedraw();
+ this.title.markForRedraw();
}
private void setGroupIcons(ResourceGroupComposite groupComposite) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
new file mode 100644
index 0000000..7547339
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/OverviewForm.java
@@ -0,0 +1,336 @@
+/*
+ * 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.inventory.resource.detail;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.DisplayType;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementDefinition;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
+import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
+import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * The Resource Summary>Overview tab - Resource general properties + summary traits.
+ *
+ * @author Greg Hinkle
+ * @author Ian Springer
+ */
+public class OverviewForm extends EnhancedDynamicForm {
+
+ private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+ private ResourceComposite resourceComposite;
+ private boolean headerEnabled = true;
+ private boolean displayCondensed = false;
+ private final ResourceTitleBar titleBar;
+
+ public OverviewForm(String locatorId, ResourceComposite resourceComposite, ResourceTitleBar titleBar) {
+ super(locatorId);
+ this.resourceComposite = resourceComposite;
+ this.titleBar = titleBar;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ setLeft("10%");
+ setWidth("80%");
+ if (isDisplayCondensed()) {
+ setPadding(5);
+ setColWidths(150, 220, 150, 220);
+ setWidth("45%");
+ }
+
+ if (this.resourceComposite != null) {
+ setResource(this.resourceComposite);
+ }
+ }
+
+ public void setResource(ResourceComposite resourceComposite) {
+
+ this.resourceComposite = resourceComposite;
+ Resource resource = resourceComposite.getResource();
+
+ // Load metric defs.
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ buildForm(type);
+ loadTraitValues();
+ }
+ });
+ }
+
+ private void loadTraitValues() {
+ final Resource resource = resourceComposite.getResource();
+ GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource(resource.getId(),
+ DisplayType.SUMMARY, new AsyncCallback<List<MeasurementDataTrait>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_traitsLoadFailure(resource.toString()), caught);
+ }
+
+ public void onSuccess(List<MeasurementDataTrait> result) {
+ for (MeasurementDataTrait trait : result) {
+ String formItemId = buildFormItemIdFromTraitDisplayName(trait.getName());
+ FormItem item = getItem(formItemId);
+ if (item != null) {
+ setValue(formItemId, trait.getValue());
+ }
+ }
+ markForRedraw();
+ }
+ });
+ }
+
+ private static String buildFormItemIdFromTraitDisplayName(String traitName) {
+ return traitName.replaceAll("\\.", "_").replaceAll(" ", "__");
+ }
+
+ private void buildForm(ResourceType type) {
+ List<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>();
+
+ for (MeasurementDefinition measurement : type.getMetricDefinitions()) {
+ if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) {
+ traits.add(measurement);
+ }
+ }
+
+ StringLengthValidator notEmptyOrNullValidator = new StringLengthValidator(1, null, false);
+ StringLengthValidator notNullValidator = new StringLengthValidator(null, null, false);
+
+ List<FormItem> formItems = new ArrayList<FormItem>();
+
+ if (isHeaderEnabled()) {//conditionally display header
+ HeaderItem headerItem = new HeaderItem("header", MSG.view_summaryOverviewForm_header_summary());
+ headerItem.setValue(MSG.view_summaryOverviewForm_header_summary());
+ formItems.add(headerItem);
+ }
+
+ // Type
+ StaticTextItem typeItem = new StaticTextItem("type", MSG.view_summaryOverviewForm_field_type());
+ typeItem.setTooltip(MSG.view_summaryOverviewForm_label_plugin() + type.getPlugin() + "\n<br>"
+ + MSG.view_summaryOverviewForm_label_type() + type.getName());
+ typeItem.setValue(AncestryUtil.getFormattedType(type));
+ formItems.add(typeItem);
+
+ final Resource resource = this.resourceComposite.getResource();
+ boolean modifiable = this.resourceComposite.getResourcePermission().isInventory();
+
+ // Name
+ final FormItem nameItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
+ nameItem.setName("name");
+ nameItem.setTitle(MSG.view_summaryOverviewForm_field_name());
+ nameItem.setValue(resource.getName());
+ if (nameItem instanceof EditableFormItem) {
+ EditableFormItem togglableNameItem = (EditableFormItem) nameItem;
+ togglableNameItem.setValidators(notEmptyOrNullValidator);
+ togglableNameItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ final String newName = newValue.toString();
+ final String oldName = resource.getName();
+ if (newName.equals(oldName)) {
+ return;
+ }
+ resource.setName(newName);
+ OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_nameChangeFailure(String.valueOf(resource.getId()),
+ oldName, newName), caught);
+ // We failed to update it on the Server, so change back the Resource and the form item to
+ // the original value.
+ resource.setName(oldName);
+ nameItem.setValue(oldName);
+ }
+
+ public void onSuccess(Void result) {
+ titleBar.displayResourceName(newName);
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
+ .valueOf(resource.getId()), oldName, newName), Message.Severity.Info));
+ }
+ });
+ }
+ });
+ }
+ formItems.add(nameItem);
+
+ // Description
+ final FormItem descriptionItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
+ descriptionItem.setName("description");
+ descriptionItem.setTitle(MSG.view_summaryOverviewForm_field_description());
+ descriptionItem.setValue(resource.getDescription());
+ if (descriptionItem instanceof EditableFormItem) {
+ EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
+ togglableDescriptionItem.setValidators(notNullValidator);
+ togglableDescriptionItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ final String newDescription = newValue.toString();
+ final String oldDescription = resource.getDescription();
+ if (newDescription.equals(oldDescription)) {
+ return;
+ }
+ resource.setDescription(newDescription);
+ OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_descriptionChangeFailure(String.valueOf(resource
+ .getId()), oldDescription, newDescription), caught);
+ // We failed to update it on the Server, so change back the Resource and the form item to
+ // the original value.
+ resource.setDescription(oldDescription);
+ descriptionItem.setValue(oldDescription);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter()
+ .notify(
+ new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
+ .valueOf(resource.getId()), oldDescription, newDescription),
+ Message.Severity.Info));
+ }
+ });
+ }
+ });
+ }
+ formItems.add(descriptionItem);
+
+ // Location
+ final FormItem locationItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
+ locationItem.setName("location");
+ locationItem.setTitle(MSG.view_summaryOverviewForm_field_location());
+ locationItem.setValue(resource.getLocation());
+ if (locationItem instanceof EditableFormItem) {
+ EditableFormItem togglableLocationItem = (EditableFormItem) locationItem;
+ togglableLocationItem.setValidators(notNullValidator);
+ togglableLocationItem.setValueEditedHandler(new ValueEditedHandler() {
+ public void editedValue(Object newValue) {
+ final String newLocation = newValue.toString();
+ final String oldLocation = resource.getLocation();
+ if (newLocation.equals(oldLocation)) {
+ return;
+ }
+ resource.setLocation(newLocation);
+ OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.view_summaryOverviewForm_error_locationChangeFailure(String.valueOf(resource
+ .getId()), oldLocation, newLocation), caught);
+ // We failed to update it on the Server, so change back the Resource and the form item to
+ // the original value.
+ resource.setLocation(oldLocation);
+ locationItem.setValue(oldLocation);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(
+ new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
+ .valueOf(resource.getId()), oldLocation, newLocation), Message.Severity.Info));
+ }
+ });
+ }
+ });
+ }
+ formItems.add(locationItem);
+
+ // Version
+ StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
+ versionItem.setValue((resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
+ + "</i>");
+ versionItem.setEndRow(true);
+ formItems.add(versionItem);
+
+ // Traits
+ Collections.sort(traits, new Comparator<MeasurementDefinition>() {
+ public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
+ return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
+ }
+ });
+
+ for (MeasurementDefinition trait : traits) {
+ String formItemId = buildFormItemIdFromTraitDisplayName(trait.getDisplayName());
+ StaticTextItem formItem = new StaticTextItem(formItemId, trait.getDisplayName());
+ formItem.setTooltip(trait.getDescription());
+ formItems.add(formItem);
+ // item.setValue("?");
+ }
+
+ // SectionItem section = new SectionItem("Summary", "Summary");
+ // section.setTitle("Summary");
+ // section.setDefaultValue("Summary");
+ // section.setCanCollapse(true);
+ // section.setCellStyle("HidablePlainSectionHeader");
+ // section.setItemIds(itemIds.toArray(new String[itemIds.size()]));
+ // formItems.add(0, section);
+ if (!isDisplayCondensed()) {
+ formItems.add(new SpacerItem());
+ }
+
+ setItems(formItems.toArray(new FormItem[formItems.size()]));
+ }
+
+ public void loadData() {
+ // TODO: Reload the ResourceComposite too.
+ loadTraitValues();
+ markForRedraw();
+ }
+
+ public boolean isHeaderEnabled() {
+ return headerEnabled;
+ }
+
+ public void setHeaderEnabled(boolean headerEnabled) {
+ this.headerEnabled = headerEnabled;
+ }
+
+ public boolean isDisplayCondensed() {
+ return displayCondensed;
+ }
+
+ public void setDisplayCondensed(boolean displayCondensed) {
+ this.displayCondensed = displayCondensed;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.java
new file mode 100644
index 0000000..0b8f830
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsDataSource.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 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;
+
+import java.util.Date;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.rpc.RPCResponse;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.Criteria;
+import org.rhq.core.domain.resource.ResourceError;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.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";
+ }
+
+ ResourceGWTServiceAsync resourceService;
+ int resourceId;
+
+ public ResourceErrorsDataSource(int resourceId) {
+ resourceService = GWTServiceLookup.getResourceService();
+ this.resourceId = resourceId;
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @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) {
+ CoreGUI.getErrorHandler().handleError(
+ MSG.dataSource_resourceErrors_error_fetchFailure(String.valueOf(resourceId)), caught);
+ response.setStatus(RPCResponse.STATUS_FAILURE);
+ processResponse(request.getRequestId(), response);
+ }
+
+ public void onSuccess(List<ResourceError> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+ @Override
+ protected Criteria getFetchCriteria(DSRequest request) {
+ // we don't use criterias for this datasource, just return null
+ 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.ERROR_TYPE, from.getErrorType().name());
+ record.setAttribute(Field.SUMMARY, from.getSummary());
+ record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred()));
+
+ return record;
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java
new file mode 100644
index 0000000..c881819
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceErrorsView.java
@@ -0,0 +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;
+
+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.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.components.table.TimestampCellFormatter;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.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<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;
+ }
+
+ @Override
+ protected void configureTable() {
+ 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.setAlign(Alignment.CENTER);
+ timeField.setWidth("20%");
+ TimestampCellFormatter.prepareDateField(timeField);
+
+ 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) {
+ String details = event.getRecord().getAttribute(Field.DETAIL);
+ popupDetails(details);
+ }
+ });
+ iconField.setShowHover(true);
+ iconField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ 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.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/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 7bc1cdd..bd86104 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
@@ -49,9 +49,6 @@ import org.rhq.enterprise.gui.coregui.client.UserSessionManager;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagEditorView;
import org.rhq.enterprise.gui.coregui.client.components.tagging.TagsChangedCallback;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.OverviewForm;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsDataSource;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ResourceErrorsView;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout;
import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableImg;
@@ -243,7 +240,7 @@ public class ResourceTitleBar extends LocatableVLayout {
detailsForm.setHeight(10);
detailsForm.setAlign(Alignment.LEFT);
- detailsFormSummary = new OverviewForm(extendLocatorId("Title_Optional_Summary"), resourceComposite);
+ detailsFormSummary = new OverviewForm(extendLocatorId("Title_Optional_Summary"), resourceComposite, this);
detailsFormSummary.setWidth100();
detailsFormSummary.setPadding(3);
detailsFormSummary.setMargin(3);
@@ -294,8 +291,7 @@ public class ResourceTitleBar extends LocatableVLayout {
this.resourceComposite = resourceComposite;
update();
- this.title.setContents("<span class=\"SectionHeader\">" + resource.getName()
- + "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
+ displayResourceName(resource.getName());
Set<Integer> favorites = UserSessionManager.getUserPreferences().getFavoriteResources();
this.favorite = favorites.contains(resource.getId());
@@ -310,6 +306,15 @@ public class ResourceTitleBar extends LocatableVLayout {
}
}
+ void displayResourceName(String resourceName) {
+ if (!resource.getName().equals(resourceName)) {
+ resource.setName(resourceName); // the name must have been changed by the user via the editable field
+ }
+ this.title.setContents("<span class=\"SectionHeader\">" + resource.getName()
+ + "</span> <span class=\"subtitle\">" + resource.getResourceType().getName() + "</span>");
+ this.title.markForRedraw();
+ }
+
private void updateFavoriteButton() {
this.favoriteButton.setSrc(favorite ? FAV_ICON : NOT_FAV_ICON);
if (favorite) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
deleted file mode 100644
index 3cecbe9..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/OverviewForm.java
+++ /dev/null
@@ -1,333 +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.inventory.resource.detail.summary;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.EnumSet;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-
-import org.rhq.core.domain.measurement.DataType;
-import org.rhq.core.domain.measurement.DisplayType;
-import org.rhq.core.domain.measurement.MeasurementDataTrait;
-import org.rhq.core.domain.measurement.MeasurementDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem;
-import org.rhq.enterprise.gui.coregui.client.components.form.EnhancedDynamicForm;
-import org.rhq.enterprise.gui.coregui.client.components.form.StringLengthValidator;
-import org.rhq.enterprise.gui.coregui.client.components.form.EditableFormItem.ValueEditedHandler;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-
-/**
- * The Resource Summary>Overview tab - Resource general properties + summary traits.
- *
- * @author Greg Hinkle
- * @author Ian Springer
- */
-public class OverviewForm extends EnhancedDynamicForm {
-
- private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
- private ResourceComposite resourceComposite;
- private boolean headerEnabled = true;
- private boolean displayCondensed = false;
-
- public OverviewForm(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId);
- this.resourceComposite = resourceComposite;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- setLeft("10%");
- setWidth("80%");
- if (isDisplayCondensed()) {
- setPadding(5);
- setColWidths(150, 220, 150, 220);
- setWidth("45%");
- }
-
- if (this.resourceComposite != null) {
- setResource(this.resourceComposite);
- }
- }
-
- public void setResource(ResourceComposite resourceComposite) {
-
- this.resourceComposite = resourceComposite;
- Resource resource = resourceComposite.getResource();
-
- // Load metric defs.
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
- buildForm(type);
- loadTraitValues();
- }
- });
- }
-
- private void loadTraitValues() {
- final Resource resource = resourceComposite.getResource();
- GWTServiceLookup.getMeasurementDataService().findCurrentTraitsForResource(resource.getId(),
- DisplayType.SUMMARY, new AsyncCallback<List<MeasurementDataTrait>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_traitsLoadFailure(resource.toString()), caught);
- }
-
- public void onSuccess(List<MeasurementDataTrait> result) {
- for (MeasurementDataTrait trait : result) {
- String formItemId = buildFormItemIdFromTraitDisplayName(trait.getName());
- FormItem item = getItem(formItemId);
- if (item != null) {
- setValue(formItemId, trait.getValue());
- }
- }
- markForRedraw();
- }
- });
- }
-
- private static String buildFormItemIdFromTraitDisplayName(String traitName) {
- return traitName.replaceAll("\\.", "_").replaceAll(" ", "__");
- }
-
- private void buildForm(ResourceType type) {
- List<MeasurementDefinition> traits = new ArrayList<MeasurementDefinition>();
-
- for (MeasurementDefinition measurement : type.getMetricDefinitions()) {
- if (measurement.getDataType() == DataType.TRAIT && measurement.getDisplayType() == DisplayType.SUMMARY) {
- traits.add(measurement);
- }
- }
-
- StringLengthValidator notEmptyOrNullValidator = new StringLengthValidator(1, null, false);
- StringLengthValidator notNullValidator = new StringLengthValidator(null, null, false);
-
- List<FormItem> formItems = new ArrayList<FormItem>();
-
- if (isHeaderEnabled()) {//conditionally display header
- HeaderItem headerItem = new HeaderItem("header", MSG.view_summaryOverviewForm_header_summary());
- headerItem.setValue(MSG.view_summaryOverviewForm_header_summary());
- formItems.add(headerItem);
- }
-
- // Type
- StaticTextItem typeItem = new StaticTextItem("type", MSG.view_summaryOverviewForm_field_type());
- typeItem.setTooltip(MSG.view_summaryOverviewForm_label_plugin() + type.getPlugin() + "\n<br>"
- + MSG.view_summaryOverviewForm_label_type() + type.getName());
- typeItem.setValue(AncestryUtil.getFormattedType(type));
- formItems.add(typeItem);
-
- final Resource resource = this.resourceComposite.getResource();
- boolean modifiable = this.resourceComposite.getResourcePermission().isInventory();
-
- // Name
- final FormItem nameItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
- nameItem.setName("name");
- nameItem.setTitle(MSG.view_summaryOverviewForm_field_name());
- nameItem.setValue(resource.getName());
- if (nameItem instanceof EditableFormItem) {
- EditableFormItem togglableNameItem = (EditableFormItem) nameItem;
- togglableNameItem.setValidators(notEmptyOrNullValidator);
- togglableNameItem.setValueEditedHandler(new ValueEditedHandler() {
- public void editedValue(Object newValue) {
- final String newName = newValue.toString();
- final String oldName = resource.getName();
- if (newName.equals(oldName)) {
- return;
- }
- resource.setName(newName);
- OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_nameChangeFailure(String.valueOf(resource.getId()),
- oldName, newName), caught);
- // We failed to update it on the Server, so change back the Resource and the form item to
- // the original value.
- resource.setName(oldName);
- nameItem.setValue(oldName);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
- .valueOf(resource.getId()), oldName, newName), Message.Severity.Info));
- }
- });
- }
- });
- }
- formItems.add(nameItem);
-
- // Description
- final FormItem descriptionItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
- descriptionItem.setName("description");
- descriptionItem.setTitle(MSG.view_summaryOverviewForm_field_description());
- descriptionItem.setValue(resource.getDescription());
- if (descriptionItem instanceof EditableFormItem) {
- EditableFormItem togglableDescriptionItem = (EditableFormItem) descriptionItem;
- togglableDescriptionItem.setValidators(notNullValidator);
- togglableDescriptionItem.setValueEditedHandler(new ValueEditedHandler() {
- public void editedValue(Object newValue) {
- final String newDescription = newValue.toString();
- final String oldDescription = resource.getDescription();
- if (newDescription.equals(oldDescription)) {
- return;
- }
- resource.setDescription(newDescription);
- OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_descriptionChangeFailure(String.valueOf(resource
- .getId()), oldDescription, newDescription), caught);
- // We failed to update it on the Server, so change back the Resource and the form item to
- // the original value.
- resource.setDescription(oldDescription);
- descriptionItem.setValue(oldDescription);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter()
- .notify(
- new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
- .valueOf(resource.getId()), oldDescription, newDescription),
- Message.Severity.Info));
- }
- });
- }
- });
- }
- formItems.add(descriptionItem);
-
- // Location
- final FormItem locationItem = (modifiable) ? new EditableFormItem() : new StaticTextItem();
- locationItem.setName("location");
- locationItem.setTitle(MSG.view_summaryOverviewForm_field_location());
- locationItem.setValue(resource.getLocation());
- if (locationItem instanceof EditableFormItem) {
- EditableFormItem togglableLocationItem = (EditableFormItem) locationItem;
- togglableLocationItem.setValidators(notNullValidator);
- togglableLocationItem.setValueEditedHandler(new ValueEditedHandler() {
- public void editedValue(Object newValue) {
- final String newLocation = newValue.toString();
- final String oldLocation = resource.getLocation();
- if (newLocation.equals(oldLocation)) {
- return;
- }
- resource.setLocation(newLocation);
- OverviewForm.this.resourceService.updateResource(resource, new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(
- MSG.view_summaryOverviewForm_error_locationChangeFailure(String.valueOf(resource
- .getId()), oldLocation, newLocation), caught);
- // We failed to update it on the Server, so change back the Resource and the form item to
- // the original value.
- resource.setLocation(oldLocation);
- locationItem.setValue(oldLocation);
- }
-
- public void onSuccess(Void result) {
- CoreGUI.getMessageCenter().notify(
- new Message(MSG.view_summaryOverviewForm_message_nameChangeSuccess(String
- .valueOf(resource.getId()), oldLocation, newLocation), Message.Severity.Info));
- }
- });
- }
- });
- }
- formItems.add(locationItem);
-
- // Version
- StaticTextItem versionItem = new StaticTextItem("version", MSG.view_summaryOverviewForm_field_version());
- versionItem.setValue((resource.getVersion() != null) ? resource.getVersion() : "<i>" + MSG.common_label_none()
- + "</i>");
- versionItem.setEndRow(true);
- formItems.add(versionItem);
-
- // Traits
- Collections.sort(traits, new Comparator<MeasurementDefinition>() {
- public int compare(MeasurementDefinition o1, MeasurementDefinition o2) {
- return new Integer(o1.getDisplayOrder()).compareTo(o2.getDisplayOrder());
- }
- });
-
- for (MeasurementDefinition trait : traits) {
- String formItemId = buildFormItemIdFromTraitDisplayName(trait.getDisplayName());
- StaticTextItem formItem = new StaticTextItem(formItemId, trait.getDisplayName());
- formItem.setTooltip(trait.getDescription());
- formItems.add(formItem);
- // item.setValue("?");
- }
-
- // SectionItem section = new SectionItem("Summary", "Summary");
- // section.setTitle("Summary");
- // section.setDefaultValue("Summary");
- // section.setCanCollapse(true);
- // section.setCellStyle("HidablePlainSectionHeader");
- // section.setItemIds(itemIds.toArray(new String[itemIds.size()]));
- // formItems.add(0, section);
- if (!isDisplayCondensed()) {
- formItems.add(new SpacerItem());
- }
-
- setItems(formItems.toArray(new FormItem[formItems.size()]));
- }
-
- public void loadData() {
- // TODO: Reload the ResourceComposite too.
- loadTraitValues();
- markForRedraw();
- }
-
- public boolean isHeaderEnabled() {
- return headerEnabled;
- }
-
- public void setHeaderEnabled(boolean headerEnabled) {
- this.headerEnabled = headerEnabled;
- }
-
- public boolean isDisplayCondensed() {
- return displayCondensed;
- }
-
- public void setDisplayCondensed(boolean displayCondensed) {
- this.displayCondensed = displayCondensed;
- }
-
-}
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
deleted file mode 100644
index be76956..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsDataSource.java
+++ /dev/null
@@ -1,106 +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.inventory.resource.detail.summary;
-
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.rpc.RPCResponse;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.Criteria;
-import org.rhq.core.domain.resource.ResourceError;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.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";
- }
-
- ResourceGWTServiceAsync resourceService;
- int resourceId;
-
- public ResourceErrorsDataSource(int resourceId) {
- resourceService = GWTServiceLookup.getResourceService();
- this.resourceId = resourceId;
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @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) {
- CoreGUI.getErrorHandler().handleError(
- MSG.dataSource_resourceErrors_error_fetchFailure(String.valueOf(resourceId)), caught);
- response.setStatus(RPCResponse.STATUS_FAILURE);
- processResponse(request.getRequestId(), response);
- }
-
- public void onSuccess(List<ResourceError> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- protected Criteria getFetchCriteria(DSRequest request) {
- // we don't use criterias for this datasource, just return null
- 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.ERROR_TYPE, from.getErrorType().name());
- record.setAttribute(Field.SUMMARY, from.getSummary());
- record.setAttribute(Field.TIME_OCCURED, new Date(from.getTimeOccurred()));
-
- return record;
- }
-}
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
deleted file mode 100644
index e4e62e8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/summary/ResourceErrorsView.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.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.components.table.TimestampCellFormatter;
-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<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;
- }
-
- @Override
- protected void configureTable() {
- 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.setAlign(Alignment.CENTER);
- timeField.setWidth("20%");
- TimestampCellFormatter.prepareDateField(timeField);
-
- 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) {
- String details = event.getRecord().getAttribute(Field.DETAIL);
- popupDetails(details);
- }
- });
- iconField.setShowHover(true);
- iconField.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- 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.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();
- }
-}