};
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
@SuppressWarnings("unused")
GridCellRenderer<AbstractDto> comboBoxRenderer = createComboBoxRenderer();
GridCellRenderer<LigTransfertppModel> deleteBtn = deleteButton(user, role);
column = new ColumnConfig();
column.setFixed(true);
column.setAlignment(HorizontalAlignment.CENTER);
column.setSortable(false);
column.setMenuDisabled(true);
column.setResizable(false);
column.setId("supprimer");
column.setHeader("Supprimer");
column.setWidth(66);
column.setRenderer(deleteBtn);
configs.add(column);
column = new ColumnConfig();
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(100);
column.setFixed(true);
column.setSortable(false);
column.setMenuDisabled(true);
column.setResizable(false);
column.setId(LigTransfertppModel.TYPE);
column.setHeader("Type");
column.setEditor(editor);
column.setRenderer(new GridCellRenderer<AbstractDto>() {
@Override
public Object render(AbstractDto model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<AbstractDto> store, Grid<AbstractDto> grid) {
SimpleDto value = (SimpleDto) model.get(property);
if (value == null) {
return null;
} else {
return value.getLabel();
}
}
});
configs.add(column);
column = new ColumnConfig();
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(225);
column.setId(LigTransfertppModel.LOT1);
column.setEditor(new CellEditor(textLot1));
column.setHeader("Lot1");
column.setSortable(false);
column.setMenuDisabled(true);
column.setResizable(true);
configs.add(column);
column = new ColumnConfig();
column.setAlignment(HorizontalAlignment.CENTER);
column.setWidth(80);
column.setId(LigTransfertppModel.DEVERS);
column.setHeader("De/Vers");
column.setFixed(true);
column.setSortable(false);
column.setMenuDisabled(true);
column.setResizable(true);
column.setEditor(editor1);
configs.add(column);
column = new ColumnConfig();
column.setAlignment(HorizontalAlignment.CENTER);
column.setId(LigTransfertppModel.LOT2);
column.setEditor(new CellEditor(textLot2));
column.setAlignment(HorizontalAlignment.CENTER);
column.setHeader("Lot2");
column.setSortable(false);
column.setMenuDisabled(true);
column.setResizable(true);
column.setWidth(225);
configs.add(column);
column = new ColumnConfig();
column.setId("montant");
column.setHeader("Montant");
column.setAlignment(HorizontalAlignment.CENTER);
column.setSortable(false);
column.setMenuDisabled(true);
column.setResizable(true);
column.setWidth(150);
SummaryColumnConfig<Double> montant = new SummaryColumnConfig<Double>("montant", "Montant", 100);
montant.setMenuDisabled(true);
montant.setAlignment(HorizontalAlignment.CENTER);
montant.setSummaryFormat(NumberFormat.getCurrencyFormat());
montant.setSummaryType(new SummaryType<Double>() {
@Override
public Double render(Object v, ModelData m, String field, Map<String, Object> data) {
if (v == null) {
v = 0d;
}
LigTransfertppModel lig = (LigTransfertppModel) m;
return ((Double) v).doubleValue() + (lig.getQuantite() * lig.getPu());
}
});
montant.setRenderer(new GridCellRenderer<LigTransfertppModel>() {
@Override
public String render(LigTransfertppModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<LigTransfertppModel> store, Grid<LigTransfertppModel> grid) {
LigTransfertppModel lig = model;
if (lig.getDeVers().equalsIgnoreCase("vers")) {
return NumberFormat.getCurrencyFormat().format(lig.getPu() * lig.getQuantite() * (-1));
} else {
return NumberFormat.getCurrencyFormat().format(lig.getPu() * lig.getQuantite());
}
}
});
configs.add(montant);
SummaryColumnConfig<Integer> quantity = new SummaryColumnConfig<Integer>(LigTransfertppModel.QUANTITY, "Quantite", 100);
NumberField nfQuantity = createIntegerField(null, true);
nfQuantity.setAutoValidate(true);
nfQuantity.setAllowNegative(false);
nfQuantity.setAllowDecimals(false);
quantity.setSummaryType(new SummaryType<Integer>() {
@Override
public Integer render(Object v, ModelData m, String field, Map<String, Object> data) {
if (v == null) {
v = 1;
}
return ((Integer) v).intValue();
}
});
CellEditor ce1 = new CellEditor(nfQuantity);
ce1.setCancelOnEsc(true);
quantity.setMenuDisabled(true);
quantity.setAlignment(HorizontalAlignment.CENTER);
quantity.setSortable(false);
quantity.setEditor(ce1);
quantity.setSummaryType(SummaryType.COUNT);
configs.add(quantity);
SummaryColumnConfig<Double> pu = new SummaryColumnConfig<Double>(LigTransfertppModel.PU, "Pu", 100);
pu.setSortable(false);
pu.setMenuDisabled(true);
pu.setAlignment(HorizontalAlignment.CENTER);
pu.setSummaryFormat(NumberFormat.getCurrencyFormat());
pu.setNumberFormat(NumberFormat.getCurrencyFormat());
pu.setSummaryType(new SummaryType<Double>() {
@Override
public Double render(Object v, ModelData m, String field, Map<String, Object> data) {
if (v == null) {
v = 0d;
}
return ((Double) v).doubleValue();
}
});
/* pu.setAlignment(HorizontalAlignment.RIGHT); */
NumberField nf = new NumberField();
nf.setAutoValidate(true);
CellEditor ce = new CellEditor(nf);
ce.setCancelOnEsc(true);
pu.setEditor(ce);
pu.setAlignment(HorizontalAlignment.CENTER);
configs.add(pu);
column = new ColumnConfig();
/* column.setWidth(300); */
column.setId(LigTransfertppModel.COMMENTAIRES);
column.setHeader("Commentaire");
column.setAlignment(HorizontalAlignment.LEFT);
column.setFixed(true);