use of org.adempiere.webui.panel.InfoPAttributePanel in project adempiere by adempiere.
the class WPAttributeEditor method cmd_dialog.
/**
* Start dialog
*/
private void cmd_dialog() {
//
Integer oldValue = 0;
try {
oldValue = (Integer) getValue();
} catch (Exception npe) {
// 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);
// M_Product.M_AttributeSetInstance_ID = 8418
boolean productWindow = m_AD_Column_ID == MColumn.getColumn_ID(MProduct.Table_Name, MProduct.COLUMNNAME_M_AttributeSetInstance_ID);
// Exclude ability to enter ASI
boolean exclude = true;
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) {
// Determine if the component is associated with the InfoProduct window
Component me = ((Component) this.component.getParent());
while (me != null) {
if (me instanceof InfoProductPanel)
break;
me = me.getParent();
}
//
InfoPAttributePanel ia = new InfoPAttributePanel((Window) me);
m_pAttributeWhere = ia.getWhereClause();
String oldText = getComponent().getText();
getComponent().setText(ia.getDisplay());
String curText = getComponent().getText();
//
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldText, curText);
this.fireValueChange(changeEvent);
} else {
if (!productWindow && (M_Product_ID == 0 || exclude)) {
changed = true;
getComponent().setText(null);
M_AttributeSetInstance_ID = 0;
} else {
WPAttributeDialog vad = new WPAttributeDialog(M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, productWindow, gridField.getAD_Column_ID(), m_WindowNo);
if (vad.isChanged()) {
getComponent().setText(vad.getM_AttributeSetInstanceName());
M_AttributeSetInstance_ID = vad.getM_AttributeSetInstance_ID();
if (m_GridTab != null && !productWindow && vad.getM_Locator_ID() > 0)
m_GridTab.setValue("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);
}
//
String columnName = "M_AttributeSetInstance_ID";
if (m_GridField != null) {
columnName = m_GridField.getColumnName();
}
ValueChangeEvent vce = new ValueChangeEvent(this, columnName, new Object(), getValue());
fireValueChange(vce);
//
if (M_AttributeSetInstance_ID == oldValueInt && m_GridTab != null && gridField != null) {
// force Change - user does not realize that embedded object is already saved.
m_GridTab.processFieldChange(gridField);
}
}
// change
}
Aggregations