@Override protected String validateAction() { String validate = null; DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); BOMLineWrapper line = null; if (!(node.getUserObject() instanceof BOMLineWrapper)) { validate = "'" + node.getUserObject().getClass().getName() + "' isn't a type of 'BOMLineWrapper'(ClassCastException)"; } else { line = (BOMLineWrapper) node.getUserObject(); MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null); if (p.getM_AttributeSet_ID() == 0) { validate = Services.get(IMsgBL.class).getMsg(Env.getCtx(), "PAttributeNoAttributeSet"); } } return validate; }
private void changeBOMLine(BOMLineWrapper line, MProduct p, MAttributeSetInstance asi) { // BigDecimal maxLength = messenger.getLength(p, asi); // BigDecimal neededLength = line.getLength(); // BigDecimal onehundred = new BigDecimal(100); // line.setQtyBatch(neededLength.divide(maxLength, 2, // BigDecimal.ROUND_HALF_UP).multiply(onehundred)); // line.setScrap(onehundred.subtract(line.getQtyBatch()).intValue()); line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID()); savePO(line.get()); }
private int selectASIID(BOMLineWrapper line) { if (line.getM_Product_ID() <= 0) return -1; MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null); PAttributeInstance pai = new PAttributeInstance( (JFrame) null, p.getName(), getParameterValueAsInt("M_Warehouse_ID"), 0, line.getM_Product_ID(), 0); return pai.getM_AttributeSetInstance_ID(); }
private void changeASI(DefaultMutableTreeNode node) { BOMLineWrapper line = (BOMLineWrapper) node.getUserObject(); int selectedASI = selectASIID(line); if (selectedASI == -1) { setIgnoreChange(true); return; } MAttributeSetInstance asi = new MAttributeSetInstance(Env.getCtx(), selectedASI, null); MProduct p = new MProduct(Env.getCtx(), line.getM_Product_ID(), null); changeBOMLine(line, p, asi); }