use of org.compiere.model.MProductBOM in project adempiere by adempiere.
the class myJTree method addChild.
// action_fillTree
public void addChild(MProductBOM bomline, DefaultMutableTreeNode parent) {
//System.out.println("-------------------------Parent:" + bom.getName());
MProduct M_Product = MProduct.get(getCtx(), bomline.getM_ProductBOM_ID());
Vector<Object> line = new Vector<Object>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(bomline.isActive()));
// 2 Line
line.add(new Integer(bomline.getLine()));
KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getValue().concat("_").concat(M_Product.getName()));
// 3 M_Product_ID
line.add(pp);
MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName());
KeyNamePair uom = new KeyNamePair(M_Product.getC_UOM_ID(), u.getUOMSymbol());
// 4 C_UOM_ID
line.add(uom);
// 5 QtyBOM
line.add((BigDecimal) ((bomline.getBOMQty() != null) ? bomline.getBOMQty() : new BigDecimal(0)));
DefaultMutableTreeNode child = new DefaultMutableTreeNode(line);
parent.add(child);
if (m_selected_id == bomline.getM_Product_ID() || getM_Product_ID() == bomline.getM_Product_ID())
dataBOM.add(line);
if (reload)
return;
for (MProductBOM bom : getChildBOMs(bomline.getM_ProductBOM_ID(), false)) {
addChild(bom, child);
}
}
use of org.compiere.model.MProductBOM in project adempiere by adempiere.
the class myJTree method addParent.
public void addParent(MProductBOM bom, DefaultMutableTreeNode parent) {
MProduct M_Product = MProduct.get(getCtx(), bom.getM_Product_ID());
Vector<Object> line = new Vector<Object>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(M_Product.isActive()));
// 2 Line
line.add(new Integer(bom.getLine()));
KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getValue().concat("_").concat(M_Product.getName()));
// 3 M_Product_ID
line.add(pp);
MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName());
KeyNamePair uom = new KeyNamePair(M_Product.getC_UOM_ID(), u.getUOMSymbol());
// 6 C_UOM_ID
line.add(uom);
// 9 QtyBOM
line.add((BigDecimal) ((bom.getBOMQty() != null) ? bom.getBOMQty() : new BigDecimal(0)));
dataBOM.add(line);
DefaultMutableTreeNode child = new DefaultMutableTreeNode(line);
parent.add(child);
if (reload)
return;
for (MProductBOM bomline : getParentBOMs(bom.getM_Product_ID())) {
addParent(bomline, child);
}
//dataBOM.add(line);
}
use of org.compiere.model.MProductBOM in project adempiere by adempiere.
the class myJTree method action_loadBOM.
// actionPerformed
/**
* Action: Fill Tree with all nodes
*/
private void action_loadBOM() {
//m_frame.setBusy(true);
m_frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
reload = false;
int M_Product_ID = getM_Product_ID();
if (M_Product_ID == 0)
return;
MProduct M_Product = MProduct.get(getCtx(), M_Product_ID);
treeInfo.setText(" Current Selection: " + M_Product.getValue());
Vector<Object> line = new Vector<Object>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(M_Product.isActive()));
// 2 Line
line.add(new Integer(0));
KeyNamePair pp = new KeyNamePair(M_Product.getM_Product_ID(), M_Product.getValue().concat("_").concat(M_Product.getName()));
// 3 M_Product_ID
line.add(pp);
MUOM u = new MUOM(M_Product.getCtx(), M_Product.getC_UOM_ID(), M_Product.get_TrxName());
KeyNamePair uom = new KeyNamePair(M_Product.getC_UOM_ID(), u.getUOMSymbol());
// 4 C_UOM_ID
line.add(uom);
// 5 QtyBOM
line.add(Env.ONE);
DefaultMutableTreeNode parent = new DefaultMutableTreeNode(line);
m_root = (DefaultMutableTreeNode) parent.getRoot();
dataBOM.clear();
if (isImplosion()) {
for (MProductBOM bomline : getParentBOMs(M_Product_ID)) {
addParent(bomline, parent);
}
m_tree = new myJTree(parent);
m_tree.addMouseListener(mouseListener);
} else {
for (MProductBOM bom : getChildBOMs(M_Product_ID, true)) {
addChild(bom, parent);
}
m_tree = new myJTree(parent);
m_tree.addMouseListener(mouseListener);
}
/* MouseListener ml = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int selRow = m_tree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = m_tree.getPathForLocation(e.getX(), e.getY());
if(selRow != -1) {
if(e.getClickCount() == 1) {
mySingleClick(selRow, selPath);
}
// else if(e.getClickCount() == 2) {
// myDoubleClick(selRow, selPath);
// }
}
}
private void mySingleClick(int selRow, TreePath selPath) {
// TODO Auto-generated method stub
}
};
m_tree.addMouseListener(ml);
*/
m_tree.addTreeSelectionListener(this);
treePane.getViewport().add(m_tree, null);
loadTableBOM();
dataPane.getViewport().add(tableBOM, null);
// 4Layers - Set divider location
splitPane.setDividerLocation(DIVIDER_LOCATION);
// 4Layers - end
// Popup
// if (m_selected_id != 0)
// {
// }
//m_frame.setBusy(false);
m_frame.setCursor(Cursor.getDefaultCursor());
}
use of org.compiere.model.MProductBOM in project adempiere by adempiere.
the class WBOMDrop method addBOMLines.
// createMainPanel
/**
* Add BOM Lines to this.
* Called recursively
* @param product product
* @param qty quantity
*/
private void addBOMLines(MProduct product, BigDecimal qty) {
MProductBOM[] bomLines = MProductBOM.getBOMLines(product);
for (int i = 0; i < bomLines.length; i++) {
grpSelectProd.appendChild(new Separator());
addBOMLine(bomLines[i], qty);
grpSelectProd.appendChild(new Separator());
}
log.fine("#" + bomLines.length);
}
use of org.compiere.model.MProductBOM in project adempiere by adempiere.
the class BOMValidate method validateOldProduct.
// validateProduct
/**
* Validate Old BOM Product structure
* @param product product
* @return true if valid
*/
private boolean validateOldProduct(MProduct product) {
if (!product.isBOM())
return true;
//
if (m_products.contains(product)) {
log.warning(m_product.getName() + " recursively includes " + product.getName());
return false;
}
m_products.add(product);
log.fine(product.getName());
//
MProductBOM[] productsBOMs = MProductBOM.getBOMLines(product);
for (int i = 0; i < productsBOMs.length; i++) {
MProductBOM productsBOM = productsBOMs[i];
MProduct pp = new MProduct(getCtx(), productsBOM.getM_ProductBOM_ID(), get_TrxName());
if (!pp.isBOM())
log.finer(pp.getName());
else if (!validateOldProduct(pp))
return false;
}
return true;
}
Aggregations