use of org.compiere.model.MProduct in project adempiere by adempiere.
the class VPAttribute method actionPerformed.
// addActionListener
/**
* Action Listener - start dialog
* @param e Event
*/
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(RecordInfo.CHANGE_LOG_COMMAND)) {
RecordInfo.start(m_GridField);
return;
}
if (!m_button.isEnabled())
return;
m_button.setEnabled(false);
//
Integer oldValue = 0;
try {
oldValue = (Integer) getValue();
} catch (ClassCastException cce) {
// Possible Invalid Cast exception if getValue() return new instance of Object.
}
int oldValueInt = oldValue == null ? 0 : oldValue.intValue();
int M_AttributeSetInstance_ID = oldValueInt;
int M_Product_ID = 0;
int M_ProductBOM_ID = 0;
if (m_GridTab != null) {
M_Product_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_GridTab.getTabNo(), "M_Product_ID");
M_ProductBOM_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_GridTab.getTabNo(), "M_ProductBOM_ID");
} else {
M_Product_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_Product_ID");
M_ProductBOM_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductBOM_ID");
}
int M_Locator_ID = -1;
log.config("M_Product_ID=" + M_Product_ID + "/" + M_ProductBOM_ID + ",M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID + ", AD_Column_ID=" + m_AD_Column_ID);
// M_Product.M_AttributeSetInstance_ID = 8418
// HARDCODED
boolean productWindow = m_AD_Column_ID == 8418;
// Exclude ability to enter ASI
boolean exclude = false;
if (M_Product_ID != 0) {
MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
int M_AttributeSet_ID = product.getM_AttributeSet_ID();
if (M_AttributeSet_ID != 0) {
MAttributeSet mas = MAttributeSet.get(Env.getCtx(), M_AttributeSet_ID);
exclude = mas.excludeEntry(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNo));
}
}
boolean changed = false;
if (// Use BOM Component
M_ProductBOM_ID != 0)
M_Product_ID = M_ProductBOM_ID;
// If the VPAttribute component is in a dialog, use the search
if (m_searchOnly) {
// The component is an element in a CPanel, which is part of a JPanel
// which is in a JLayeredPane which is in ... the InfoProduct window
Container me = ((Container) this).getParent();
while (me != null) {
if (me instanceof InfoProduct)
break;
me = me.getParent();
}
InfoPAttribute ia = new InfoPAttribute((CDialog) me);
m_pAttributeWhere = ia.getWhereClause();
String oldText = m_text.getText();
m_text.setText(ia.getDisplay());
// The text can be long. Use the tooltip to help display the info.
m_text.setToolTipText(m_text.getText());
ActionEvent ae = new ActionEvent(m_text, 1001, "updated");
// TODO not the generally correct way to fire an event
((InfoProduct) me).actionPerformed(ae);
} else if (!productWindow && (M_Product_ID == 0 || exclude)) {
changed = true;
m_text.setText(null);
M_AttributeSetInstance_ID = 0;
} else {
VPAttributeDialog vad = new VPAttributeDialog(Env.getFrame(this), M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, productWindow, m_AD_Column_ID, m_WindowNo, isReadWrite());
if (vad.isChanged()) {
m_text.setText(vad.getM_AttributeSetInstanceName());
// The text can be long. Use the tooltip to help display the info.
m_text.setToolTipText(vad.getM_AttributeSetInstanceName());
M_AttributeSetInstance_ID = vad.getM_AttributeSetInstance_ID();
if (!productWindow && vad.getM_Locator_ID() > 0) {
M_Locator_ID = vad.getM_Locator_ID();
}
changed = true;
}
}
// Set Value
if (changed) {
log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID);
// force re-query display
m_value = new Object();
if (M_AttributeSetInstance_ID == 0)
setValue(null);
else
setValue(new Integer(M_AttributeSetInstance_ID));
// Change Locator
if (m_GridTab != null && M_Locator_ID > 0) {
log.finest("Change M_Locator_ID=" + M_Locator_ID);
m_GridTab.setValue("M_Locator_ID", M_Locator_ID);
}
//
try {
String columnName = "M_AttributeSetInstance_ID";
if (m_GridField != null) {
columnName = m_GridField.getColumnName();
}
fireVetoableChange(columnName, new Object(), getValue());
} catch (PropertyVetoException pve) {
log.log(Level.SEVERE, "", pve);
}
if (M_AttributeSetInstance_ID == oldValueInt && m_GridTab != null && m_GridField != null) {
// force Change - user does not realize that embedded object is already saved.
m_GridTab.processFieldChange(m_GridField);
}
}
// change
m_button.setEnabled(true);
requestFocus();
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class WOrderReceiptIssue method valueChange.
// executeQuery
@Override
public void valueChange(ValueChangeEvent e) {
String name = e.getPropertyName();
Object value = e.getNewValue();
if (value == null)
return;
// PP_Order_ID
if (name.equals("PP_Order_ID")) {
orderField.setValue(value);
MPPOrder pp_order = getPP_Order();
if (pp_order != null) {
setS_Resource_ID(pp_order.getS_Resource_ID());
setM_Warehouse_ID(pp_order.getM_Warehouse_ID());
setDeliveredQty(pp_order.getQtyDelivered());
setOrderedQty(pp_order.getQtyOrdered());
//m_PP_order.getQtyOrdered().subtract(m_PP_order.getQtyDelivered());
setQtyBatchs(pp_order.getQtyBatchs());
setQtyBatchSize(pp_order.getQtyBatchSize());
setOpenQty(pp_order.getQtyOrdered().subtract(pp_order.getQtyDelivered()));
setToDeliverQty(getOpenQty());
setM_Product_ID(pp_order.getM_Product_ID());
MProduct m_product = MProduct.get(Env.getCtx(), pp_order.getM_Product_ID());
setC_UOM_ID(m_product.getC_UOM_ID());
setOrder_UOM_ID(pp_order.getC_UOM_ID());
//Default ASI defined from the Parent BOM Order
setM_AttributeSetInstance_ID(pp_order.getMPPOrderBOM().getM_AttributeSetInstance_ID());
//default to first entry - isBackflush
pickcombo.setSelectedIndex(0);
Event ev = new Event(Events.ON_CHANGE, pickcombo);
try {
onEvent(ev);
} catch (Exception e1) {
throw new AdempiereException(e1);
}
}
}
if (name.equals(toDeliverQty.getColumnName()) || name.equals(scrapQtyField.getColumnName())) {
if (getPP_Order_ID() > 0 && isBackflush()) {
executeQuery();
}
}
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class WTreeBOM method parent.
public DefaultTreeNode parent(MPPProductBOM bom) {
DefaultTreeNode parent = new DefaultTreeNode(productSummary(bom), new ArrayList());
for (MPPProductBOMLine bomline : bom.getLines()) {
MProduct component = MProduct.get(getCtx(), bomline.getM_Product_ID());
Vector<Object> line = new Vector<Object>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(true));
// 2 Line
line.add(new Integer(bomline.getLine()));
// 3 ValidDrom
line.add((Timestamp) bomline.getValidFrom());
// 4 ValidTo
line.add((Timestamp) bomline.getValidTo());
KeyNamePair pp = new KeyNamePair(component.getM_Product_ID(), component.getName());
// 5 M_Product_ID
line.add(pp);
KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), bomline.getC_UOM().getUOMSymbol());
// 6 C_UOM_ID
line.add(uom);
// 7 IsQtyPercentage
line.add(new Boolean(bomline.isQtyPercentage()));
// 8 BatchPercent
line.add((BigDecimal) bomline.getQtyBatch());
// 9 QtyBom
line.add((BigDecimal) bomline.getQtyBOM());
// 10 IsCritical
line.add(new Boolean(bomline.isCritical()));
// 11 LTOffSet
line.add((Integer) bomline.getLeadTimeOffset());
// 12 Assay
line.add((BigDecimal) bomline.getAssay());
// 13 Scrap
line.add((BigDecimal) (bomline.getScrap()));
// 14 IssueMethod
line.add((String) bomline.getIssueMethod());
// 15 BackflushGroup
line.add((String) bomline.getBackflushGroup());
// 16 Forecast
line.add((BigDecimal) bomline.getForecast());
dataBOM.add(line);
parent.getChildren().add(component(component));
}
return parent;
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class RadioButtonTreeCellRenderer method parent.
public DefaultMutableTreeNode parent(MPPProductBOM bom) {
log.fine("Parent:" + bom.getName());
MProduct product = MProduct.get(Env.getCtx(), bom.getM_Product_ID());
//vparent.setValue(m_product_id);
String data = Msg.translate(Env.getCtx(), "PP_Product_BOM_ID") + " " + Msg.translate(Env.getCtx(), "Value") + ":" + bom.getValue() + " " + Msg.translate(Env.getCtx(), "Name") + ": " + bom.getName();
DefaultMutableTreeNode parent = new DefaultMutableTreeNode(new nodeUserObject(data, product, bom, null));
String whereClause = "PP_Product_BOM_ID=?";
List<MPPProductBOMLine> bomlines = new Query(Env.getCtx(), MPPProductBOMLine.Table_Name, whereClause, null).setParameters(new Object[] { bom.getPP_Product_BOM_ID() }).list();
for (MPPProductBOMLine bomline : bomlines) {
MProduct component = MProduct.get(Env.getCtx(), bomline.getM_Product_ID());
//System.out.println("Componente :" + component.getValue() + "[" + component.getName() + "]");
//component(component);
Vector<Comparable<?>> line = new Vector<Comparable<?>>(17);
// 0 Select
line.add(new Boolean(false));
// 1 IsActive
line.add(new Boolean(true));
// 2 Line
line.add(new Integer(bomline.getLine()));
// 3 ValidDrom
line.add((Timestamp) bomline.getValidFrom());
// 4 ValidTo
line.add((Timestamp) bomline.getValidTo());
KeyNamePair pp = new KeyNamePair(component.getM_Product_ID(), component.getName());
// 5 M_Product_ID
line.add(pp);
KeyNamePair uom = new KeyNamePair(bomline.getC_UOM_ID(), "");
// 6 C_UOM_ID
line.add(uom);
// 7 IsQtyPercentage
line.add(new Boolean(bomline.isQtyPercentage()));
// 8 BatchPercent
line.add((BigDecimal) bomline.getQtyBatch());
// 9 QtyBom
line.add((BigDecimal) bomline.getQtyBOM());
// 10 IsCritical
line.add(new Boolean(bomline.isCritical()));
// 11 LTOffSet
line.add((Integer) bomline.getLeadTimeOffset());
// 12 Assay
line.add((BigDecimal) bomline.getAssay());
// 13 Scrap
line.add((BigDecimal) (bomline.getScrap()));
// 14 IssueMethod
line.add((String) bomline.getIssueMethod());
// 15 BackflushGroup
line.add((String) bomline.getBackflushGroup());
// 16 Forecast
line.add((BigDecimal) bomline.getForecast());
//line.add(this.);
dataBOM.add(line);
parent.add(component(component, bom, bomline));
}
return parent;
}
use of org.compiere.model.MProduct in project adempiere by adempiere.
the class RadioButtonTreeCellRenderer method action_loadBOM.
/**
* Action: Fill Tree with all nodes
*/
public DefaultMutableTreeNode action_loadBOM(MProduct Product, boolean setRoot) {
int M_Product_ID = Product.get_ID();
MProduct M_Product = MProduct.get(Env.getCtx(), M_Product_ID);
MUOM UOM = new MUOM(Env.getCtx(), M_Product.getC_UOM_ID(), null);
DefaultMutableTreeNode root = new DefaultMutableTreeNode(new nodeUserObject(Msg.translate(Env.getCtx(), "M_Product_ID") + Msg.translate(Env.getCtx(), "Value") + ": " + M_Product.getValue() + " " + Msg.translate(Env.getCtx(), "Name") + ": " + M_Product.getName() + " " + Msg.translate(Env.getCtx(), "C_UOM_ID") + ": " + UOM.getName(), M_Product, null, null));
if (setRoot) {
this.root = root;
}
dataBOM.clear();
if (false) {
String whereClause = "M_Product_ID=?";
List<MPPProductBOMLine> bomlines = new Query(Env.getCtx(), MPPProductBOMLine.Table_Name, whereClause, null).setParameters(new Object[] { M_Product_ID }).list();
for (MPPProductBOMLine bomline : bomlines) {
root.add(parent(bomline));
}
} else {
String whereClause = "M_Product_ID=?";
List<MPPProductBOM> boms = new Query(Env.getCtx(), MPPProductBOM.Table_Name, whereClause, null).setParameters(new Object[] { M_Product_ID }).setOnlyActiveRecords(true).list();
for (MPPProductBOM bom : boms) {
DefaultMutableTreeNode child = parent(bom);
root.add(child);
}
}
log.fine("root.getChildCount: " + root.getChildCount());
if (root.getChildCount() > 0) {
root = (DefaultMutableTreeNode) root.getFirstChild();
}
if (setRoot)
this.root = root;
return root;
}
Aggregations