modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 53 +++++++-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java | 58 +++------- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java | 39 +++++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java | 9 + modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java | 1 6 files changed, 104 insertions(+), 60 deletions(-)
New commits: commit a34e6bd43d4f7613b02b0112eadfb99a3adf322a Merge: 67a558f 057e6b1 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 17:02:18 2011 -0500
Merge branch 'group-fixes'
commit 057e6b1c5b011affd525da40cb27cc76115acea9 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 16:41:36 2011 -0500
do not allow user to sort on cpu/memory/swap columns.. though it would be nice, the way the data is collected and stored client side means we have some work to get sorting to properly function
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java index ac24e68..a58c909 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java @@ -28,7 +28,6 @@ import com.smartgwt.client.types.Autofit; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.HTMLFlow; import com.smartgwt.client.widgets.Img; -import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; @@ -61,6 +60,7 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableListGrid; * @author Greg Hinkle */ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet { + public static final ViewName VIEW_ID = new ViewName("CpuAndMemoryUtilization", MSG.view_reports_platforms());
// A non-displayed, persisted identifier for the portlet @@ -68,6 +68,10 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet // A default displayed, persisted name for the portlet public static final String NAME = MSG.view_portlet_defaultName_platformSummary();
+ private static final String FIELD_CPU = "cpu"; + private static final String FIELD_MEMORY = "memory"; + private static final String FIELD_SWAP = "swap"; + private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(); private ResourceTypeGWTServiceAsync typeService = GWTServiceLookup.getResourceTypeGWTService();
@@ -123,12 +127,21 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet + "</a>"; } }); - nameField.setWidth("25%"); + nameField.setWidth("20%"); setFields(nameField);
- getField("cpu").setWidth("25%"); - getField("memory").setWidth("25%"); - getField("swap").setWidth("25%"); + ListGridField cpuField = getField(FIELD_CPU); + ListGridField memoryField = getField(FIELD_MEMORY); + ListGridField swapField = getField(FIELD_SWAP); + + cpuField.setWidth("20%"); + memoryField.setWidth("20%"); + swapField.setWidth("20%"); + + // the way the field data is calculated, we can't sort on the graph columns + cpuField.setCanSort(false); + memoryField.setCanSort(false); + swapField.setCanSort(false);
hideField("id"); hideField(ResourceDataSourceField.TYPE.propertyName()); // we could show this, do we want to indicate the kind of platform? @@ -146,9 +159,9 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet new AsyncCallback<Set<MeasurementData>>() { public void onFailure(Throwable caught) { // this can happen if the agent is down, don't crash out of the entire portlet - record.setAttribute("cpu", MSG.common_val_na()); - record.setAttribute("memory", MSG.common_val_na()); - record.setAttribute("swap", MSG.common_val_na()); + record.setAttribute(FIELD_CPU, MSG.common_val_na()); + record.setAttribute(FIELD_MEMORY, MSG.common_val_na()); + record.setAttribute(FIELD_SWAP, MSG.common_val_na());
setSortField(1); refreshFields(); @@ -210,17 +223,13 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet return new HTMLFlow(MSG.view_portlet_help_platformSummary()); }
- public DynamicForm getCustomSettingsForm() { - return null; // TODO: Implement this method. - } - @Override protected Canvas createRecordComponent(ListGridRecord listGridRecord, Integer colNum) {
String fieldName = this.getFieldName(colNum);
try { - if (fieldName.equals("cpu")) { + if (fieldName.equals(FIELD_CPU)) { if (listGridRecord.getAttribute(CPUMetric.Idle.property) != null) { HLayout bar = new HLayout(); bar.setHeight(18); @@ -247,7 +256,7 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet return bar; }
- } else if (fieldName.equals("memory")) { + } else if (fieldName.equals(FIELD_MEMORY)) { if (listGridRecord.getAttribute(MemoryMetric.Total.property) != null) { HLayout bar = new HLayout(); bar.setHeight(18); @@ -274,7 +283,7 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet
return bar; } - } else if (fieldName.equals("swap")) { + } else if (fieldName.equals(FIELD_SWAP)) { if (listGridRecord.getAttribute(SwapMetric.Total.property) != null) { HLayout bar = new HLayout(); bar.setHeight(18);
commit 657a356a0ebc1e1c65fc7be3c1880302fa776178 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 16:07:54 2011 -0500
this field is hidden, avoid NPE by not setting cell formatter
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java index 4b28abc..ac24e68 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/platform/PlatformSummaryPortlet.java @@ -126,27 +126,6 @@ public class PlatformSummaryPortlet extends LocatableListGrid implements Portlet nameField.setWidth("25%"); setFields(nameField);
- // even though we hide this by default, a user could unhide it, so at least i18n in that case - getField(ResourceDataSourceField.CATEGORY.propertyName()).setCellFormatter(new CellFormatter() { - @Override - public String format(Object value, ListGridRecord record, int rowNum, int colNum) { - String catStr = record.getAttribute(ResourceDataSourceField.CATEGORY.propertyName()); - if (catStr == null) { - return "?"; - } - ResourceCategory cat = ResourceCategory.valueOf(catStr); - switch (cat) { - case PLATFORM: - return MSG.common_title_platform(); - case SERVER: - return MSG.common_title_server(); - case SERVICE: - return MSG.common_title_service(); - } - return "???"; - } - }); - getField("cpu").setWidth("25%"); getField("memory").setWidth("25%"); getField("swap").setWidth("25%");
commit 0b07e0b15b701710e7fee4a4e83703f3f09acb96 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 15:55:43 2011 -0500
fix problem that has to do with copying criteria. need to be careful when criteria includes primitive attribute types as well as Object
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 ce0754e..93d31d7 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 @@ -20,6 +20,8 @@ package org.rhq.enterprise.gui.coregui.client.components.table;
import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; +import java.util.Iterator; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -554,7 +556,9 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements */ protected void refresh(Criteria criteria) { if (null != this.listGrid) { - this.listGrid.setCriteria(criteria); + if (criteria != null) { + this.listGrid.setCriteria(criteria); + } this.listGrid.invalidateCache(); this.listGrid.markForRedraw(); } @@ -576,17 +580,9 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements } else { // there is both initial criteria and filters. We need criteria that combines both. Criteria fullCriteria = new Criteria(); - String[] criteriaAttribs = this.criteria.getAttributes(); // the initial criteria attributes - for (String attribName : criteriaAttribs) { - Object attribValue = this.criteria.getAttributeAsObject(attribName); - fullCriteria.setAttribute(attribName, attribValue); - } + addCriteria(fullCriteria, this.criteria); if (filterFormCriteria != null) { - criteriaAttribs = filterFormCriteria.getAttributes(); // the filter form criteria attributes (like the search bar) - for (String attribName : criteriaAttribs) { - Object attribValue = filterFormCriteria.getAttributeAsObject(attribName); - fullCriteria.setAttribute(attribName, attribValue); - } + addCriteria(fullCriteria, filterFormCriteria); } refresh(fullCriteria); } @@ -599,6 +595,41 @@ public class Table<DS extends RPCDataSource> extends LocatableHLayout implements } }
+ // Smartgwt 2.4's version of Criteria.addCriteria for some reason doesn't have else clauses for the array types + // and it doesn't handle Object types properly (seeing odd behavior because of this), so this method explicitly + // supports adding array types and Objects. + // This method takes the src criteria and adds it to the dest criteria. + @SuppressWarnings("unchecked") + private static void addCriteria(Criteria dest, Criteria src) { + Map otherMap = src.getValues(); + Set otherKeys = otherMap.keySet(); + for (Iterator i = otherKeys.iterator(); i.hasNext();) { + String field = (String) i.next(); + Object value = otherMap.get(field); + + if (value instanceof Integer) { + dest.addCriteria(field, (Integer) value); + } else if (value instanceof Float) { + dest.addCriteria(field, (Float) value); + } else if (value instanceof String) { + dest.addCriteria(field, (String) value); + } else if (value instanceof Date) { + dest.addCriteria(field, (Date) value); + } else if (value instanceof Boolean) { + dest.addCriteria(field, (Boolean) value); + } else if (value instanceof Integer[]) { + dest.addCriteria(field, (Integer[]) value); + } else if (value instanceof Double[]) { + dest.addCriteria(field, (Double[]) value); + } else if (value instanceof String[]) { + dest.addCriteria(field, (String[]) value); + } else { + // this is the magic piece - we need to get attrib as an object and set that value + dest.setAttribute(field, src.getAttributeAsObject(field)); + } + } + } + public void setTableTitle(String titleString) { if (titleString == null) { titleString = ""; diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java index 0ad0278..442fefd 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ResourceInstallReport.java @@ -91,7 +91,6 @@ public class ResourceInstallReport extends LocatableVLayout implements Bookmarka private void showResourceList(Criteria criteria) { hideResourceList(); resourceList = new ResourceSearchView(extendLocatorId("resourceList"), criteria); - resourceList.setHideSearchBar(true); // we don't want to enable search - the contents of this table are very specific addMember(resourceList); markForRedraw(); }
commit c6cce83caf754d82fc7b1576a2227d45162e7ca7 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 15:18:29 2011 -0500
double clicking row now goes to the resource alert def page
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java index 4a736e1..5d05431 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java @@ -55,6 +55,13 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D public void onDoubleClick(DoubleClickEvent event) { ListGrid lg = (ListGrid) event.getSource(); ListGridRecord selected = lg.getSelectedRecord(); + if (selected != null) { + AlertDefinition alertDef = getDataSource().copyValues(selected); + int resourceId = alertDef.getResource().getId(); + int alertDefId = alertDef.getId(); + String link = LinkManager.getSubsystemAlertDefinitionLink(resourceId, alertDefId); + CoreGUI.goToView(link); + } } }); }
commit d54f3e5c808fc472dc532996dea83ecf3045cd0a Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 15:06:19 2011 -0500
forgot to remove this debug statement
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java index 6396acd..4a736e1 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/AlertDefinitionReportView.java @@ -8,7 +8,6 @@ import com.smartgwt.client.data.DSRequest; import com.smartgwt.client.data.DataSourceField; import com.smartgwt.client.data.Record; import com.smartgwt.client.data.fields.DataSourceTextField; -import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.events.DoubleClickEvent; import com.smartgwt.client.widgets.events.DoubleClickHandler; import com.smartgwt.client.widgets.grid.CellFormatter; @@ -56,7 +55,6 @@ public class AlertDefinitionReportView extends Table<AlertDefinitionReportView.D public void onDoubleClick(DoubleClickEvent event) { ListGrid lg = (ListGrid) event.getSource(); ListGridRecord selected = lg.getSelectedRecord(); - SC.say(selected.getAttribute("name")); // TODO deleteme } }); }
commit 7abc32d2dbe65f5fb2cdf6c0174ae5860b2ebf84 Author: John Mazzitelli mazz@redhat.com Date: Thu Mar 10 14:26:35 2011 -0500
ignore right mouse clicks on nodes that don't have a context menu
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java index 2ef1ecf..27cf7d6 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeContextMenu.java @@ -23,7 +23,6 @@ package org.rhq.enterprise.gui.coregui.client.inventory.groups.detail;
import com.google.gwt.user.client.rpc.AsyncCallback; -import com.smartgwt.client.widgets.tree.TreeNode;
import org.rhq.core.domain.criteria.ResourceGroupCriteria; import org.rhq.core.domain.resource.group.ClusterKey; @@ -31,6 +30,7 @@ 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.inventory.groups.detail.ResourceGroupTreeView.ResourceGroupEnhancedTreeNode;
/** * @author Greg Hinkle @@ -41,7 +41,7 @@ public class ResourceGroupTreeContextMenu extends ResourceGroupContextMenu { super(locatorId); }
- public void showContextMenu(TreeNode node) { + public void showContextMenu(ResourceGroupEnhancedTreeNode node) {
final ClusterKey clusterKey = (ClusterKey) node.getAttributeAsObject("key"); if (clusterKey != null) { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java index d65d400..9853c7f 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupTreeView.java @@ -55,6 +55,7 @@ import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.BookmarkableView; import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.ImageManager; +import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.ViewId; import org.rhq.enterprise.gui.coregui.client.ViewPath; import org.rhq.enterprise.gui.coregui.client.components.tree.EnhancedTreeNode; @@ -65,8 +66,24 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; import org.rhq.enterprise.gui.coregui.client.util.selenium.SeleniumUtility;
/** + * This is the view that renders the left hand tree for groups. + * There are three main types of nodes in the group tree: + * 1. Cluster Node - This represents a single aggregate resource that is of a specific resource type. + * If a group has members with one or more resources with an identical resource key and type, + * those identical resources are represented with one cluster node. Each cluster node + * is associated with a resource type and an unique cluster key. + * 2. Auto Type Group Node - This is a folder node whose children are all of a specific resource type. + * The children are typically cluster nodes. An example of this kind of node is + * "WARs", where there can be many different WARs deployed on an individual member resource + * but a WAR can be clustered (copied) across many member resources. Each auto type group node + * is associated with a resource type but they do not have cluster keys. + * 3. Subcategory Node these are simply nodes that group other kinds of nodes. Plugin developers define subcategories + * in plugin descriptors to organize resource types. Subcategories are not associated with any + * particular resource type and do not have cluster keys. + * * @author Greg Hinkle * @author Ian Springer + * @author John Mazzitelli */ public class ResourceGroupTreeView extends LocatableVLayout implements BookmarkableView {
@@ -142,6 +159,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka @Override public void onSelectionChanged(SelectionEvent selectionEvent) { if (!selectionEvent.isRightButtonDown() && selectionEvent.getState()) { + selectedNodeId = null; // if user selected a valid node, we'll set this later ResourceGroupEnhancedTreeNode selectedNode = (ResourceGroupEnhancedTreeNode) selectionEvent .getRecord(); com.allen_sauer.gwt.log.client.Log.info("Node selected in tree: " + selectedNode); @@ -160,11 +178,8 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka selectedNodeId = selectedNode.getID(); String groupId = selectedNodeId; com.allen_sauer.gwt.log.client.Log.debug("Selecting group [" + groupId + "]..."); - String viewPath = ResourceGroupTopView.VIEW_ID + "/" + groupId; - String currentViewPath = History.getToken(); - if (!currentViewPath.startsWith(viewPath)) { - CoreGUI.goToView(viewPath); - } + String viewPath = LinkManager.getResourceGroupLink(Integer.parseInt(groupId)); + CoreGUI.goToView(viewPath, true); } else { // the user selected a auto type group node; we have got nothing to show, so cancel the selection of this node treeGrid.deselectRecord(selectedNode); @@ -185,12 +200,18 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka event.cancel();
// don't select the node on a right click, since we're not navigating to it - treeGrid.deselectRecord(event.getNode()); + ResourceGroupEnhancedTreeNode node = (ResourceGroupEnhancedTreeNode) event.getNode(); + treeGrid.deselectRecord(node); if (null != selectedNodeId) { - treeGrid.selectRecord(treeGrid.getTree().findById(SeleniumUtility.getSafeId(selectedNodeId))); + treeGrid.selectRecord(treeGrid.getTree().findById(selectedNodeId)); }
- contextMenu.showContextMenu(event.getNode()); + // only show the context menu for cluster nodes and our top root node + ResourceType type = node.getResourceType(); + ClusterKey key = node.getClusterKey(); + if (type != null && (key != null || node.getParentID().equals(FAKE_ROOT_ID))) { + contextMenu.showContextMenu(node); + } } });
@@ -264,7 +285,7 @@ public class ResourceGroupTreeView extends LocatableVLayout implements Bookmarka } else { // TODO not sure when this else would happen, why would a group's cluster key be null? selectedNode = (ResourceGroupEnhancedTreeNode) treeGrid.getTree().findById( - SeleniumUtility.getSafeId(String.valueOf(this.selectedGroup.getId()))); + String.valueOf(this.selectedGroup.getId())); }
if (selectedNode != null) {