Mercurial > dive4elements > river
diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java @ 9237:972e10522ed6
salix.supraregional ui
author | gernotbelger |
---|---|
date | Tue, 10 Jul 2018 11:24:12 +0200 |
parents | 431f1c269be5 |
children | d89976700474 |
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java Fri Jul 06 17:56:18 2018 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java Tue Jul 10 11:24:12 2018 +0200 @@ -9,10 +9,18 @@ */ package org.dive4elements.river.client.client.ui; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.form.fields.IntegerItem; import com.smartgwt.client.widgets.form.fields.TextItem; +import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator; import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; import com.smartgwt.client.widgets.form.validator.Validator; +import com.smartgwt.client.widgets.grid.ListGrid; +import com.smartgwt.client.widgets.grid.ListGridField; +import com.smartgwt.client.widgets.grid.SortNormalizer; +import com.smartgwt.client.widgets.grid.events.RecordClickEvent; +import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.VLayout; /** @@ -63,4 +71,48 @@ return inputItem; } + + public static final ListGridField createRemoveField(final ListGrid table, final String icon) { + final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") { + { + setType(ListGridFieldType.ICON); + setIcon(icon); + setCanEdit(false); + setCanFilter(false); + setCanSort(false); + setCanGroupBy(false); + setCanFreeze(false); + setWidth(25); + setCanDragResize(false); + super.setCanToggle(false); + } + }; + table.addRecordClickHandler(new RecordClickHandler() { + @Override + public void onRecordClick(final RecordClickEvent event) { + // Just handle remove-clicks + if (!event.getField().getName().equals(removeField.getName())) { + return; + } + event.getViewer().removeData(event.getRecord()); + } + }); + + return removeField; + } + + public static final ListGridField createIntTableField(final String key, final String msg, final boolean canSort, final SortNormalizer normalizer, + final IntegerRangeValidator validators) { + final ListGridField intField = new ListGridField(key, msg); + intField.setType(ListGridFieldType.INTEGER); + intField.setValidators(validators); + intField.setWidth(90); + intField.setAlign(Alignment.RIGHT); + intField.setSortNormalizer(normalizer); + intField.setCanSort(canSort); + intField.setCanDragResize(false); + + return intField; + } + }