use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.
the class IndicatorGridPanel method createColumnModel.
private ColumnModel createColumnModel() {
ColumnConfig icon = new ColumnConfig("icon", 28);
icon.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
if (model instanceof IndicatorDTO) {
int id = ((IndicatorDTO) model).getId();
if (linked.contains(id)) {
return IconImageBundle.ICONS.link().getHTML();
}
}
return "";
}
});
ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.name(), 150);
name.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
StringBuilder html = new StringBuilder();
html.append("<div style=\"margin-left: ").append(indent(model)).append("px;");
if (!(model instanceof IndicatorDTO)) {
html.append(";font-weight: bold;");
}
html.append("\">");
html.append(model.get("name"));
html.append("</div>");
return html.toString();
}
});
return new ColumnModel(Arrays.asList(icon, name));
}
use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addMapColumn.
public ColumnModelBuilder addMapColumn() {
ColumnConfig mapColumn = new ColumnConfig("x", "", 25);
mapColumn.setRenderer(new GridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore listStore, Grid grid) {
if (model instanceof SiteDTO) {
SiteDTO siteModel = (SiteDTO) model;
if (siteModel.hasCoords()) {
return "<div class='mapped'> </div>";
} else {
return "<div class='unmapped'> </div>";
}
}
return " ";
}
});
columns.add(mapColumn);
return this;
}
use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addTreeNameColumn.
public ColumnModelBuilder addTreeNameColumn() {
ColumnConfig name = new ColumnConfig("name", I18N.CONSTANTS.location(), 200);
name.setRenderer(new TreeGridCellRenderer<ModelData>() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid) {
return super.render(model, propertyName(model), config, rowIndex, colIndex, store, grid);
}
private String propertyName(ModelData model) {
if (model instanceof SiteDTO) {
return "locationName";
} else {
return "name";
}
}
});
columns.add(name);
return this;
}
use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addActivityColumn.
public ColumnModelBuilder addActivityColumn(final UserDatabaseDTO database) {
ColumnConfig config = new ColumnConfig("activityId", I18N.CONSTANTS.activity(), 100);
config.setRenderer(new GridCellRenderer<SiteDTO>() {
@Override
public Object render(SiteDTO model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<SiteDTO> store, Grid<SiteDTO> grid) {
ActivityDTO activity = database.getActivityById(model.getActivityId());
return activity == null ? "" : activity.getName();
}
});
columns.add(config);
return this;
}
use of com.extjs.gxt.ui.client.widget.grid.ColumnData in project activityinfo by bedatadriven.
the class ColumnModelBuilder method addIndicatorColumn.
public ColumnConfig addIndicatorColumn(IndicatorDTO indicator, String header) {
NumberField indicatorField = new NumberField();
indicatorField.getPropertyEditor().setFormat(IndicatorNumberFormat.INSTANCE);
ColumnConfig indicatorColumn = new ColumnConfig(indicator.getPropertyName(), SafeHtmlUtils.fromString(header).asString(), 50);
indicatorColumn.setNumberFormat(IndicatorNumberFormat.INSTANCE);
indicatorColumn.setEditor(new CellEditor(indicatorField));
indicatorColumn.setAlignment(Style.HorizontalAlignment.RIGHT);
// (it looks better if we don't)
if (indicator.getAggregation() == IndicatorDTO.AGGREGATE_SUM) {
indicatorColumn.setRenderer(new GridCellRenderer() {
@Override
public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore listStore, Grid grid) {
Double value = model.get(property);
if (value != null && value != 0) {
return IndicatorNumberFormat.INSTANCE.format(value);
} else {
return "";
}
}
});
}
return indicatorColumn;
}
Aggregations