use of org.geosdi.geoplatform.gui.client.widget.grid.renderer.GPGridCellRenderer in project geo-platform by geosdi.
the class ManageRolesWidget method prepareColumnModel.
private ColumnModel prepareColumnModel() {
List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayList();
ColumnConfig iconColumn = new ColumnConfig();
iconColumn.setId("icon");
iconColumn.setHeaderHtml(UserModuleConstants.INSTANCE.ManageRolesWidget_iconText());
iconColumn.setWidth(35);
iconColumn.setFixed(true);
iconColumn.setResizable(false);
iconColumn.setSortable(false);
iconColumn.setRenderer(new GPGridCellRenderer<GuiComponentDetail>() {
@Override
public Object render(GuiComponentDetail model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GuiComponentDetail> store, Grid<GuiComponentDetail> grid) {
Button button = new Button();
button.setIcon(model.getImage());
button.setAutoWidth(true);
return button;
}
});
configs.add(iconColumn);
ColumnConfig idColumn = new ColumnConfig();
idColumn.setId(GuiComponentDetailKeyValue.COMPONENT_ID.toString());
idColumn.setHeaderHtml(UserModuleConstants.INSTANCE.ManageRolesWidget_componentIDText());
idColumn.setFixed(true);
configs.add(idColumn);
final SimpleComboBox<GuiPermission> permissionComboBox = new SimpleComboBox<GuiPermission>();
permissionComboBox.setEditable(false);
permissionComboBox.setTriggerAction(ComboBox.TriggerAction.ALL);
permissionComboBox.add(Arrays.asList(GuiPermission.values()));
CellEditor comboEditor = new CellEditor(permissionComboBox) {
@Override
public Object preProcessValue(Object value) {
if (value == null) {
return value;
}
return permissionComboBox.findModel((GuiPermission) value);
}
@Override
public Object postProcessValue(Object value) {
if (value == null) {
return value;
}
return ((SimpleComboValue<GuiPermission>) value).getValue();
}
};
GridCellRenderer<GuiComponentDetail> rendererPermission = new GridCellRenderer<GuiComponentDetail>() {
@Override
public Object render(GuiComponentDetail model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<GuiComponentDetail> store, Grid<GuiComponentDetail> grid) {
GuiPermission permission = model.getPermission();
return "<span style='color:" + permission.toStringColor() + "'>" + permission + "</span>";
}
};
ColumnConfig permissionColumn = new ColumnConfig();
permissionColumn.setId(GuiComponentDetailKeyValue.PERMISSION.toString());
permissionColumn.setHeaderHtml(UserModuleConstants.INSTANCE.ManageRolesWidget_permissionsText());
permissionColumn.setWidth(150);
permissionColumn.setFixed(true);
permissionColumn.setEditor(comboEditor);
permissionColumn.setRenderer(rendererPermission);
configs.add(permissionColumn);
return new ColumnModel(configs);
}
Aggregations