public void forceValidate() {}
});
Response res = ClientUtils.getData("loadItemTypes",new GridParams());
final Domain d = new Domain("ITEM_TYPES");
if (!res.isError()) {
ItemTypeVO vo = null;
java.util.List list = ((VOListResponse)res).getRows();
for(int i=0;i<list.size();i++) {
vo = (ItemTypeVO)list.get(i);
d.addDomainPair(vo.getProgressiveHie02ITM02(),vo.getDescriptionSYS10());
}
}
controlItemType.setDomain(d);
controlItemType.getComboBox().addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange()==e.SELECTED && detailPanel.getMode()!=Consts.READONLY) {
DetailSaleDocRowVO vo = (DetailSaleDocRowVO)detailPanel.getVOModel().getValueObject();
vo.setItemCodeItm01DOC02(null);
vo.setDescriptionSYS10(null);
vo.setMinSellingQtyUmCodeReg02DOC02(null);
vo.setVatCodeItm01DOC02(null);
vo.setVatDescriptionDOC02(null);
vo.setDeductibleReg01DOC02(null);
vo.setValueReg01DOC02(null);
vo.setValueSal02DOC02(null);
vo.setQtyDOC02(null);
int selIndex = ((JComboBox)e.getSource()).getSelectedIndex();
Object selValue = d.getDomainPairList()[selIndex].getCode();
treeLevelDataLocator.getTreeNodeParams().put(ApplicationConsts.COMPANY_CODE_SYS01,vo.getCompanyCodeSys01DOC02());
treeLevelDataLocator.getTreeNodeParams().put(ApplicationConsts.PROGRESSIVE_HIE02,selValue);
detailPanel.pull(controlItemCode.getAttributeName());
try {
controlItemCode.validateCode(null);
}
catch (Exception ex) {
}
}
}
});
// set buttons disabilitation...
HashSet buttonsToDisable = new HashSet();
buttonsToDisable.add(insertButton1);
buttonsToDisable.add(editButton1);
buttonsToDisable.add(deleteButton1);
buttonsToDisable.add(copyButton1);
detailPanel.addButtonsNotEnabled(buttonsToDisable,frame);
grid.addButtonsNotEnabled(buttonsToDisable,frame);
variantsPanel.setVariantsPanelController(new ProductVariantsPanelController() {
public boolean validateCell(int rowNumber,int colNumber,String attributeName,Number oldValue,Number newValue) {
if (newValue==null)
return true;
if (pricesMatrix!=null) {
CustomValueObject vo = (CustomValueObject)pricesMatrix.get(rowNumber);
Object lastPrice = null;
Object currentPrice = null;
try {
lastPrice = CustomValueObject.class.getMethod("getAttributeNameN"+(colNumber-1),new Class[0]).invoke(vo,new Object[0]);
}
catch (Exception ex) {
}
Object[][] cells = variantsPanel.getCells();
for(int i=0;i<cells.length;i++) {
vo = (CustomValueObject)pricesMatrix.get(i);
for(int j=0;j<cells[i].length;j++) {
if (i==rowNumber && colNumber-1==j)
continue;
if (cells[i][j]==null)
continue;
try {
currentPrice = CustomValueObject.class.getMethod("getAttributeNameN"+j,new Class[0]).invoke(vo,new Object[0]);
}
catch (Exception ex) {
}
if (currentPrice!=null && lastPrice==null ||
currentPrice==null && lastPrice!=null ||
currentPrice!=null && !currentPrice.equals(lastPrice)) {
JOptionPane.showMessageDialog(
ClientUtils.getParentFrame(variantsPanel),
ClientSettings.getInstance().getResources().getResource("it is not allowed to insert variants having different unit prices"),
ClientSettings.getInstance().getResources().getResource("Attention"),
JOptionPane.WARNING_MESSAGE
);
return false;
}
} // end innner for
} // end outer for
if(lastPrice!=null) {
controlPriceUnit.setValue(lastPrice);
variantsPanel.getForm().getVOModel().setValue(controlPriceUnit.getAttributeName(),lastPrice);
}
else {
lastPrice = ((PriceItemVO)variantsPanel.getLookupController().getLookupVO()).getValueSAL02();
controlPriceUnit.setValue(lastPrice);
variantsPanel.getForm().getVOModel().setValue(controlPriceUnit.getAttributeName(),lastPrice);
}
}
return true;
}
public void loadDataCompleted(boolean error) {
if (!error) {
// load also variants prices, if available...
GridParams gridParams = new GridParams();
gridParams.getOtherGridParams().put(ApplicationConsts.VARIANTS_MATRIX_VO,variantsPanel.getVariantsMatrixVO());
// gridParams.getOtherGridParams().put(ApplicationConsts.PRICELIST,parentVO.getPricelistCodeSal01DOC01());
gridParams.getOtherGridParams().put(ApplicationConsts.PRICELIST,controlPricelistCode.getValue());
Response res = ClientUtils.getData("loadVariantsPrices",gridParams);
if (!res.isError()) {
pricesMatrix = ((VOListResponse)res).getRows();
}
else