transferPpFieldSet.setHeight("430");
transfertPpGrid.addListener(Events.BeforeEdit, new Listener<GridEvent<TransfertPpSummaryDto>>() {
@Override
public void handleEvent(GridEvent<TransfertPpSummaryDto> be) {
@SuppressWarnings("unused")
TransfertPpSummaryDto transfertPpSummaryDto = transfertPpGrid.getSelectionModel().getSelectedItem();
if(isAdminOrContributor(role, user)) {
be.setCancelled(false);
}
else {
be.setCancelled(true);
}
}
});
transfertPpGrid.addListener(Events.AfterEdit, new Listener<GridEvent<TransfertPpSummaryDto>>() {
@Override
public void handleEvent(GridEvent<TransfertPpSummaryDto> be) {
saveLayout2.setEnabled(true);
isEdit = true;
bus.fireEvent(new IsEditEvent(isEdit));
}
});
FieldSet fldstNewFieldset_3 = new CustomFieldSet();
fldstNewFieldset_3.setHeading("TOTAL CHANTIER");
fldstNewFieldset_3.setLayout(new BorderLayout());
fldstNewFieldset_3.setHeight(175);
add(fldstNewFieldset_3);
createFicheStSummaryGrid();
fldstNewFieldset_3.add(ficheStSummaryGrid);
buttons = new SyntheseButtonsPanel(bus, role, user);
add(buttons);
bindModel(formPanel, this.chantier);
bus.fireEvent(new IsEditEvent(isEdit));
bus.addHandler(SyntheseEvent.TYPE, new SyntheseHandler() {
@Override
public void onEvent(SyntheseEvent event) {
if( !isValid() ) {
return;
}
showSaving(SyntheseMainPanel.this);
AsyncCallbackWithErrorResolution<Void> callback = new AsyncCallbackWithErrorResolution<Void>() {
@Override
public void onFailure(Throwable caught) {
unmaskAll();
super.onFailure(caught);
}
@Override
public void onSuccess(Void result) {
unmaskAll();
SyntheseMainPanel.this.commitDataChange();
GuiUtil.showSuccessInfo();
saveLayout.setEnabled(false);
saveLayout2.setEnabled(false);
}
private void unmaskAll() {
SyntheseMainPanel.this.unmask();
}
};
updateSynthese(callback);
}
private void updateSynthese(AsyncCallbackWithErrorResolution<Void> callback) {
List<FicheStDto> ficheStList = new ArrayList<FicheStDto>();
ficheStList.addAll(ficheStGrid1.getStore().getModels());
ficheStList.addAll(ficheStGrid2.getStore().getModels());
List<TransfertPpSummaryDto> transfertPpSummaryList = transfertPpGrid.getStore().getModels();
List<FicheTransfertppDto> ficheTransfertppDtoList = new ArrayList<FicheTransfertppDto>();
for( TransfertPpSummaryDto transfertPpSummary : transfertPpSummaryList ) {
FicheTransfertppDto ficheTransfertppDto = new FicheTransfertppDto();
ficheTransfertppDto.setObjectif(transfertPpSummary.getObjective());
ficheTransfertppDto.setChantier(SyntheseMainPanel.this.chantier);
SimpleDto refTransfertPp = new SimpleDto();
refTransfertPp.setId(transfertPpSummary.getRefTransfertPpId());
ficheTransfertppDto.setRefTransfertPp(refTransfertPp);
ficheTransfertppDtoList.add(ficheTransfertppDto);
}
clientFicheStService.updateSynthese(chantier, ficheStList, ficheTransfertppDtoList, callback);
}
});
bus.addHandler(ExportSyntheseEcranEvent.TYPE, new ExportSyntheseEcranHandler() {
@Override
public void onExportSyntheseEcran(ExportSyntheseEcranEvent event) {
List<NameValuePair> params = new ArrayList<NameValuePair>();
// Information Chantier
String chantier = chatierName.getValue();
params.add(new NameValuePair("paramChantier", chantier));
if( prorataTheorique.getValue() != null ) {
Double prorata = prorataTheorique.getValue().doubleValue();
params.add(new NameValuePair("paramProrata", prorata + ""));
}
// Synthese des fiches st
// + Grid 1
List<FicheStDto> fichestGrid1 = ficheStGrid1.getStore().getModels();
List<String> lstKeyGrid1 = new ArrayList<String>();
String keyGrid1 = "";
for( int i = 0 ; i < fichestGrid1.size() ; i++ ) {
if( fichestGrid1.get(i).getLotType() != null && !lstKeyGrid1.contains(fichestGrid1.get(i).getLotType().getName()) ) {
lstKeyGrid1.add(fichestGrid1.get(i).getLotType().getName());
keyGrid1 += fichestGrid1.get(i).getLotType().getName() + Constants.SEPRATE;
}
}
if( keyGrid1 != null && keyGrid1.length() > 0 ) {
keyGrid1 = keyGrid1.substring(0, keyGrid1.length() - Constants.SEPRATE.length());
params.add(new NameValuePair("paramKeyGrid1", keyGrid1));
}
Map<String, String> mapGrid1 = new HashMap<String, String>();
Map<String, String> mapTotalGroupGrid1 = new HashMap<String, String>();
String totalSumGrid1 = createGridReport(fichestGrid1, lstKeyGrid1, mapGrid1, mapTotalGroupGrid1);
params.add(new NameValuePair("paramMapGrid1", mapGrid1.toString()));
params.add(new NameValuePair("paramMapTotalGroupGrid1", mapTotalGroupGrid1.toString()));
params.add(new NameValuePair("paramTotalSumGrid1", totalSumGrid1));
// +Grid 2
List<FicheStDto> fichestGrid2 = ficheStGrid2.getStore().getModels();
Map<String, String> mapGrid2 = new HashMap<String, String>();
Map<String, String> mapTotalGroupGrid2 = new HashMap<String, String>();
List<String> lstKeyGrid2 = new ArrayList<String>();
String keyGrid2 = "";
for( int i = 0 ; i < fichestGrid2.size() ; i++ ) {
if( fichestGrid2.get(i).getLotType() != null && !lstKeyGrid2.contains(fichestGrid2.get(i).getLotType().getName()) ) {
lstKeyGrid2.add(fichestGrid2.get(i).getLotType().getName());
keyGrid2 += fichestGrid2.get(i).getLotType().getName() + Constants.SEPRATE;
}
}
if( keyGrid2 != null && keyGrid2.length() > 0 ) {
keyGrid2 = keyGrid2.substring(0, keyGrid2.length() - Constants.SEPRATE.length());
params.add(new NameValuePair("paramKeyGrid2", keyGrid2));
}
String totalSumGrid2 = createGridReport(fichestGrid2, lstKeyGrid2, mapGrid2, mapTotalGroupGrid2);
params.add(new NameValuePair("paramMapGrid2", mapGrid2.toString()));
params.add(new NameValuePair("paramMapTotalGroupGrid2", mapTotalGroupGrid2.toString()));
params.add(new NameValuePair("paramTotalSumGrid2", totalSumGrid2));
// Synthese des transpert pp
List<TransfertPpSummaryDto> listTransfertPpGrid = transfertPpGrid.getStore().getModels();
TransfertPpSummaryDto transfertPpSummaryDto = null;
String grid3 = "";
double sumColumnObjectif = 0.0;
double sumColumnObj = 0.0;
double sumColumnTransfert = 0.0;
double sumColumnRd = 0.0;
double sumColumnTs = 0.0;
double sumRow = 0.0;
double sumSumRow = 0.0;
NumberFormat numberFormat = NumberFormat.getFormat(Constants.NUMBER_FORMAT);
for( int i = 0 ; i < listTransfertPpGrid.size() ; i++ ) {
transfertPpSummaryDto = listTransfertPpGrid.get(i);
sumColumnObjectif += transfertPpSummaryDto.getObjective();
sumColumnObj += transfertPpSummaryDto.getObj();
sumColumnTransfert += transfertPpSummaryDto.getDevers();
sumColumnRd += transfertPpSummaryDto.getRd();
sumColumnTs += transfertPpSummaryDto.getTs();
sumRow = transfertPpSummaryDto.getObj() + transfertPpSummaryDto.getDevers() + transfertPpSummaryDto.getRd() + transfertPpSummaryDto.getTs();
sumSumRow += sumRow;
grid3 += createTotalSumReport(
numberFormat, transfertPpSummaryDto.getLabel(), transfertPpSummaryDto.getObjective(),
transfertPpSummaryDto.getObj(), transfertPpSummaryDto.getDevers(),
transfertPpSummaryDto.getRd(), transfertPpSummaryDto.getTs(), sumRow);
}
params.add(new NameValuePair("paramGrid3", grid3));
String totalSumGrid3 = createTotalSumReport(
numberFormat, "Total PP", sumColumnObjectif, sumColumnObj, sumColumnTransfert, sumColumnRd,