use of org.adempiere.webui.panel.InfoProductPanel in project adempiere by adempiere.
the class WPOSActionPanel method showWindowProduct.
/**
* Show Window Product
*/
private void showWindowProduct(String query) {
// Show Info
//posPanel.getFrame().getContentPane().invalidate();
InfoProductPanel infoProduct = new InfoProductPanel(posPanel.getWindowNo(), true, posPanel.getM_Warehouse_ID(), posPanel.getM_PriceList_ID(), 0, query, true, true, null);
AEnv.showWindow(infoProduct);
Object[] result = infoProduct.getSelectedKeys();
if (result == null)
return;
if (infoProduct.isCancelled())
return;
for (Object item : result) {
int productId = (Integer) item;
if (productId > 0) {
String value = posPanel.getProductValue(productId);
fieldProductName.setText(value);
try {
posPanel.setAddQty(true);
findProduct(true);
} catch (Exception exception) {
FDialog.error(0, this, exception.getLocalizedMessage());
}
fieldProductName.setText("");
//fieldProductName.repaint();
}
}
}
use of org.adempiere.webui.panel.InfoProductPanel 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
}
use of org.adempiere.webui.panel.InfoProductPanel in project adempiere by adempiere.
the class WSearchEditor method actionButton.
// actionBPartner
private void actionButton(String queryValue) {
if (m_lookup == null)
// leave button disabled
return;
// If an infoPanel is already open, close it.
if (infoPanel != null) {
infoPanel.detach();
infoPanel = null;
}
/**
* Three return options:
* - Value Selected & OK pressed => store result => result has value
* - Cancel pressed => store null => result == null && cancelled
* - Window closed -> ignore => result == null && !cancelled
*/
// We're changing something - ignore other events;
m_settingValue = true;
//
Object[] result = null;
boolean cancelled = false;
boolean multipleSelection = false;
boolean modal = true;
boolean saveResults = true;
int record_id = 0;
//
// fully qualified name
String col = m_lookup.getColumnName();
if (col.indexOf('.') != -1)
col = col.substring(col.indexOf('.') + 1);
// Zoom / Validation
String whereClause = getWhereClause();
//
log.fine(col + ", Zoom=" + m_lookup.getZoom() + " (" + whereClause + ")");
// If the record has a value (ID) find the name. The displayed text could be different.
if (queryValue.length() == 0 && getValue() != null && !getValue().equals("")) {
Object currentValue = getValue();
try {
record_id = ((Number) currentValue).intValue();
queryValue = "";
} catch (Exception e) {
// Can't cast the string "" to a number.
}
}
//
String infoPanelFactoryClass = m_lookup.getInfoPanelFactoryClass();
if (infoPanelFactoryClass != null && infoPanelFactoryClass.trim().length() > 0) {
try {
@SuppressWarnings("unchecked") Class<InfoPanelFactory> clazz = (Class<InfoPanelFactory>) this.getClass().getClassLoader().loadClass(infoPanelFactoryClass);
InfoPanelFactory factory = clazz.newInstance();
if (// sets table name & key column
m_tableName == null) {
if (!hasSearchableColumns()) {
// Search should have been disabled for this field.
log.severe("Search enabled on field " + m_columnName + ". Associated table has no standard/identifier columns.");
return;
}
}
// multipleSelection assumed false for custom info windows
infoPanel = factory.create(m_lookup.getWindowNo(), modal, m_tableName, m_keyColumnName, record_id, queryValue, multipleSelection, saveResults, whereClause);
//
} catch (Exception e) {
log.log(Level.SEVERE, "Failed to load custom InfoFactory - " + e.getLocalizedMessage(), e);
}
} else if (col.equals("M_Product_ID")) {
// Reset
resetTabInfo();
//
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_lookup.getWindowNo(), "M_Warehouse_ID");
int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), m_lookup.getWindowNo(), "M_PriceList_ID");
//
if (m_mField != null) {
int AD_Table_ID = MColumn.getTable_ID(Env.getCtx(), m_mField.getAD_Column_ID(), null);
// TODO hard-coded - add to AD_Column?
multipleSelection = (MOrderLine.Table_ID == AD_Table_ID) || (MInvoiceLine.Table_ID == AD_Table_ID) || (I_PP_Product_BOMLine.Table_ID == AD_Table_ID) || (MProductPrice.Table_ID == AD_Table_ID);
}
// Show Info
infoPanel = new InfoProductPanel(m_lookup.getWindowNo(), modal, M_Warehouse_ID, M_PriceList_ID, record_id, queryValue, multipleSelection, saveResults, whereClause);
} else if (col.equals("C_BPartner_ID")) {
resetTabInfo();
//
setIsSOTrx(m_isSOTrxEnvOverride, false);
// If we have a record id, set isSOMatch
if (record_id > 0) {
String trxName = Trx.createTrxName();
MBPartner bp = new MBPartner(Env.getCtx(), record_id, trxName);
m_isSOMatch = (m_isSOTrx && bp.isCustomer()) || (!m_isSOTrx && bp.isVendor());
Trx.get(trxName, false).close();
}
//
infoPanel = new InfoBPartnerPanel(m_lookup.getWindowNo(), modal, record_id, queryValue, m_isSOTrx, m_isSOMatch, multipleSelection, saveResults, whereClause);
} else // General Info
{
if (// sets table name & key column
m_tableName == null)
getDirectAccessSQL("*");
//
infoPanel = InfoPanel.create(m_lookup.getWindowNo(), modal, m_tableName, m_keyColumnName, record_id, queryValue, multipleSelection, saveResults, whereClause);
}
//
if (infoPanel != null) {
infoPanel.addValueChangeListener(this);
AEnv.showWindow(infoPanel);
//
cancelled = infoPanel.isCancelled();
result = infoPanel.getSelectedKeys();
//
infoPanel = null;
}
// Result
if (isReadWrite()) {
if (result != null && result.length > 0) {
//ensure data binding happen
if (result.length > 1)
actionCombo(result);
else
actionCombo(result[0]);
} else if (cancelled) {
log.config(getColumnName() + " - Result = null (cancelled)");
actionCombo(null);
} else {
log.config(getColumnName() + " - Result = null (not cancelled)");
//Reset the combo box to the current value
actionCombo(getValue());
}
} else
m_settingValue = false;
}
Aggregations