Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Hiding the Resource Ancestry column in {Alerts|Events} Portlets not t…
Browse files Browse the repository at this point in the history
…o overwhelm user with bazillion columns. It can be shown if necessary. Also fixing a typo that caused to displayed Group Events Portlet instead of Alert Group Portlet.
  • Loading branch information
jkremser committed Apr 17, 2014
1 parent 937cb29 commit 94a3d1e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ protected List<DataSourceField> addDataSourceFields() {
return fields;
}


public ArrayList<ListGridField> getListGridFields() {
return getListGridFields(true);
}

/**
* The view that contains the list grid which will display this datasource's data will call this
* method to get the field information which is used to control the display of the data.
*
* @return list grid fields used to display the datasource data
*/
public ArrayList<ListGridField> getListGridFields() {
public ArrayList<ListGridField> getListGridFields(boolean showResourceAncestry) {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(7);

ListGridField ctimeField = new ListGridField(AlertCriteria.SORT_FIELD_CTIME, MSG.common_title_createTime());
Expand Down Expand Up @@ -219,17 +224,18 @@ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum,
});
fields.add(resourceNameField);

ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);

if (showResourceAncestry) {
ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
ancestryField.setWidth("20%");
}
ctimeField.setWidth(100);
nameField.setWidth("15%");
conditionField.setWidth("15%");
conditionLogField.setWidth("25%");
priorityField.setWidth(50);
statusField.setWidth(80);
resourceNameField.setWidth("20%");
ancestryField.setWidth("20%");
} else {
ctimeField.setWidth(200);
nameField.setWidth("15%");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.rhq.coregui.client.CoreGUI;
import org.rhq.coregui.client.IconEnum;
import org.rhq.coregui.client.ImageManager;
import org.rhq.coregui.client.LinkManager;
import org.rhq.coregui.client.components.form.DateFilterItem;
import org.rhq.coregui.client.components.form.EnumSelectItem;
import org.rhq.coregui.client.components.table.RecordExtractor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public final Portlet getInstance(EntityContext context) {
throw new IllegalArgumentException("Context [" + context + "] not supported by portlet");
}

return new GroupEventsPortlet(context);
return new GroupAlertsPortlet(context);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

import org.rhq.core.domain.alert.Alert;
Expand Down Expand Up @@ -149,6 +150,13 @@ public AlertsPortletDataSource getDataSource() {
public Canvas getHelpCanvas() {
return new HTMLFlow(MSG.view_portlet_help_recentAlerts());
}

@Override
protected void configureTable() {
super.configureTable();
ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields(false);
getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
}

@Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

import org.rhq.core.domain.common.EntityContext;
Expand Down Expand Up @@ -89,6 +90,7 @@ public AbstractRecentEventsPortlet(EntityContext entityContext) {
setOverflow(Overflow.VISIBLE);
setShowFooterRefresh(false); //disable footer refresh button as redundant for portlets
setShowHeader(false);//disable header for portlets
setMinHeight(400);
}

@Override
Expand Down Expand Up @@ -139,6 +141,13 @@ public EventsPortletDataSource getDataSource() {
public Canvas getHelpCanvas() {
return new HTMLFlow(MSG.view_portlet_help_events());
}

@Override
protected void configureTable() {
super.configureTable();
ArrayList<ListGridField> dataSourceFields = getDataSource().getListGridFields(false);
getListGrid().setFields(dataSourceFields.toArray(new ListGridField[dataSourceFields.size()]));
}

@Override
public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;

import org.rhq.core.domain.alert.Alert;
import org.rhq.core.domain.common.EntityContext;
import org.rhq.core.domain.criteria.EventCriteria;
import org.rhq.core.domain.event.EventSeverity;
Expand Down Expand Up @@ -77,13 +76,17 @@ public EventCompositeDatasource(EntityContext context) {
addFields(fields);
}

public ArrayList<ListGridField> getListGridFields() {
return getListGridFields(true);
}

/**
* The view that contains the list grid which will display this datasource's data will call this
* method to get the field information which is used to control the display of the data.
*
* @return list grid fields used to display the datasource data
*/
public ArrayList<ListGridField> getListGridFields() {
public ArrayList<ListGridField> getListGridFields(boolean showResourceAncestry) {
ArrayList<ListGridField> fields = new ArrayList<ListGridField>(6);

ListGridField timestampField = new ListGridField("timestamp", MSG.view_inventory_eventHistory_timestamp());
Expand Down Expand Up @@ -178,15 +181,17 @@ public String hoverHTML(Object value, ListGridRecord listGridRecord, int rowNum,
});
fields.add(resourceNameField);

ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
if (showResourceAncestry) {
ListGridField ancestryField = AncestryUtil.setupAncestryListGridField();
fields.add(ancestryField);
ancestryField.setWidth("25%");
}

timestampField.setWidth(155);
severityField.setWidth(55);
detailField.setWidth("*");
sourceField.setWidth(180);
resourceNameField.setWidth("20%");
ancestryField.setWidth("25%");
} else {
timestampField.setWidth(155);
severityField.setWidth(55);
Expand Down

0 comments on commit 94a3d1e

Please sign in to comment.