[FR 1913527] - http://sourceforge.net/tracker/index.php?func=detail&aid=1913527&group_id=176962&atid=879335
Thanks goes to Michael Judd for developing this awesome functionality! I just backported it from trunk into stable. Regards, Fernando
This commit is contained in:
parent
061de127b3
commit
18071c1e3b
|
|
@ -520,7 +520,18 @@ public class MColumn extends X_AD_Column
|
||||||
}
|
}
|
||||||
//end vpj-cd e-evolution
|
//end vpj-cd e-evolution
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Table Id for a column
|
||||||
|
* @param ctx context
|
||||||
|
* @param AD_Column_ID id
|
||||||
|
* @param trxName transaction
|
||||||
|
* @return MColumn
|
||||||
|
*/
|
||||||
|
public static int getTable_ID(Properties ctx, int AD_Column_ID, String trxName)
|
||||||
|
{
|
||||||
|
String sqlStmt = "SELECT AD_Table_ID FROM AD_Column WHERE AD_Column_ID=?";
|
||||||
|
return DB.getSQLValue(trxName, sqlStmt, AD_Column_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // MColumn
|
} // MColumn
|
||||||
|
|
|
||||||
|
|
@ -418,6 +418,12 @@ public abstract class Info extends CDialog
|
||||||
if (layout[i].getColClass() == IDColumn.class)
|
if (layout[i].getColClass() == IDColumn.class)
|
||||||
m_keyColumnIndex = i;
|
m_keyColumnIndex = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Table Selection (Invoked before setting column class so that row selection is enabled)
|
||||||
|
p_table.setRowSelectionAllowed(true);
|
||||||
|
p_table.addMouseListener(this);
|
||||||
|
p_table.setMultiSelection(p_multiSelection);
|
||||||
|
|
||||||
// set editors (two steps)
|
// set editors (two steps)
|
||||||
for (int i = 0; i < layout.length; i++)
|
for (int i = 0; i < layout.length; i++)
|
||||||
p_table.setColumnClass(i, layout[i].getColClass(), layout[i].isReadOnly(), layout[i].getColHeader());
|
p_table.setColumnClass(i, layout[i].getColClass(), layout[i].isReadOnly(), layout[i].getColHeader());
|
||||||
|
|
@ -435,11 +441,6 @@ public abstract class Info extends CDialog
|
||||||
if (m_keyColumnIndex == -1)
|
if (m_keyColumnIndex == -1)
|
||||||
log.log(Level.SEVERE, "No KeyColumn - " + sql);
|
log.log(Level.SEVERE, "No KeyColumn - " + sql);
|
||||||
|
|
||||||
// Table Selection
|
|
||||||
p_table.setRowSelectionAllowed(true);
|
|
||||||
p_table.addMouseListener(this);
|
|
||||||
p_table.setMultiSelection(p_multiSelection);
|
|
||||||
|
|
||||||
// Window Sizing
|
// Window Sizing
|
||||||
parameterPanel.setPreferredSize(new Dimension (INFO_WIDTH, parameterPanel.getPreferredSize().height));
|
parameterPanel.setPreferredSize(new Dimension (INFO_WIDTH, parameterPanel.getPreferredSize().height));
|
||||||
//Begin - [FR 1823612 ] Product Info Screen Improvements
|
//Begin - [FR 1823612 ] Product Info Screen Improvements
|
||||||
|
|
@ -527,6 +528,7 @@ public abstract class Info extends CDialog
|
||||||
// Multi Selection
|
// Multi Selection
|
||||||
if (p_multiSelection)
|
if (p_multiSelection)
|
||||||
{
|
{
|
||||||
|
m_results.addAll(getSelectedRowKeys());
|
||||||
}
|
}
|
||||||
else // singleSelection
|
else // singleSelection
|
||||||
{
|
{
|
||||||
|
|
@ -548,18 +550,68 @@ public abstract class Info extends CDialog
|
||||||
* @return selected key
|
* @return selected key
|
||||||
*/
|
*/
|
||||||
protected Integer getSelectedRowKey()
|
protected Integer getSelectedRowKey()
|
||||||
|
{
|
||||||
|
ArrayList<Integer> selectedDataList = getSelectedRowKeys();
|
||||||
|
if (selectedDataList.size() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return selectedDataList.get(0);
|
||||||
|
}
|
||||||
|
} // getSelectedRowKey
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the keys of selected row/s based on layout defined in prepareTable
|
||||||
|
* @return IDs if selection present
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
protected ArrayList<Integer> getSelectedRowKeys()
|
||||||
|
{
|
||||||
|
ArrayList<Integer> selectedDataList = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
if (m_keyColumnIndex == -1)
|
||||||
|
{
|
||||||
|
return selectedDataList;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p_multiSelection)
|
||||||
|
{
|
||||||
|
int rows = p_table.getRowCount();
|
||||||
|
for (int row = 0; row < rows; row++)
|
||||||
|
{
|
||||||
|
Object data = p_table.getModel().getValueAt(row, m_keyColumnIndex);
|
||||||
|
if (data instanceof IDColumn)
|
||||||
|
{
|
||||||
|
IDColumn dataColumn = (IDColumn)data;
|
||||||
|
if (dataColumn.isSelected())
|
||||||
|
{
|
||||||
|
selectedDataList.add(dataColumn.getRecord_ID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.severe("For multiple selection, IDColumn should be key column for selection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDataList.size() == 0)
|
||||||
{
|
{
|
||||||
int row = p_table.getSelectedRow();
|
int row = p_table.getSelectedRow();
|
||||||
if (row != -1 && m_keyColumnIndex != -1)
|
if (row != -1 && m_keyColumnIndex != -1)
|
||||||
{
|
{
|
||||||
Object data = p_table.getModel().getValueAt(row, m_keyColumnIndex);
|
Object data = p_table.getModel().getValueAt(row, m_keyColumnIndex);
|
||||||
if (data instanceof IDColumn)
|
if (data instanceof IDColumn)
|
||||||
data = ((IDColumn)data).getRecord_ID();
|
selectedDataList.add(((IDColumn)data).getRecord_ID());
|
||||||
if (data instanceof Integer)
|
if (data instanceof Integer)
|
||||||
return (Integer)data;
|
selectedDataList.add((Integer)data);
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
} // getSelectedRowKey
|
|
||||||
|
return selectedDataList;
|
||||||
|
} // getSelectedRowKeys
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get selected Keys
|
* Get selected Keys
|
||||||
|
|
@ -569,7 +621,9 @@ public abstract class Info extends CDialog
|
||||||
{
|
{
|
||||||
if (!m_ok || m_results.size() == 0)
|
if (!m_ok || m_results.size() == 0)
|
||||||
return null;
|
return null;
|
||||||
return m_results.toArray();
|
Integer values[] = new Integer[m_results.size()];
|
||||||
|
m_results.toArray(values);
|
||||||
|
return values;
|
||||||
} // getSelectedKeys;
|
} // getSelectedKeys;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -786,12 +840,15 @@ public abstract class Info extends CDialog
|
||||||
} // calueChanged
|
} // calueChanged
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable OK, History, Zoom if row selected
|
* Enable OK, History, Zoom if row/s selected
|
||||||
|
* ---
|
||||||
|
* Changes: Changed the logic for accomodating multiple selection
|
||||||
|
* @author ashley
|
||||||
*/
|
*/
|
||||||
protected void enableButtons ()
|
protected void enableButtons ()
|
||||||
{
|
{
|
||||||
boolean enable = p_table.getSelectedRow() != -1;
|
boolean enable = (p_table.getSelectedRowCount() == 1);
|
||||||
confirmPanel.getOKButton().setEnabled(enable);
|
confirmPanel.getOKButton().setEnabled(p_table.getSelectedRowCount() > 0);
|
||||||
|
|
||||||
if (hasHistory())
|
if (hasHistory())
|
||||||
confirmPanel.getHistoryButton().setEnabled(enable);
|
confirmPanel.getHistoryButton().setEnabled(enable);
|
||||||
|
|
|
||||||
|
|
@ -936,7 +936,7 @@ public final class InfoProduct extends Info implements ActionListener
|
||||||
if (s_productLayout == null)
|
if (s_productLayout == null)
|
||||||
{
|
{
|
||||||
ArrayList<Info_Column> list = new ArrayList<Info_Column>();
|
ArrayList<Info_Column> list = new ArrayList<Info_Column>();
|
||||||
list.add(new Info_Column(" ", "p.M_Product_ID", IDColumn.class));
|
list.add(new Info_Column(" ", "p.M_Product_ID", IDColumn.class, !p_multiSelection));
|
||||||
list.add(new Info_Column(Msg.translate(Env.getCtx(), "Discontinued").substring(0, 1), "p.Discontinued", Boolean.class));
|
list.add(new Info_Column(Msg.translate(Env.getCtx(), "Discontinued").substring(0, 1), "p.Discontinued", Boolean.class));
|
||||||
list.add(new Info_Column(Msg.translate(Env.getCtx(), "Value"), "p.Value", String.class));
|
list.add(new Info_Column(Msg.translate(Env.getCtx(), "Value"), "p.Value", String.class));
|
||||||
list.add(new Info_Column(Msg.translate(Env.getCtx(), "Name"), "p.Name", String.class));
|
list.add(new Info_Column(Msg.translate(Env.getCtx(), "Name"), "p.Name", String.class));
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,20 @@ public class Info_Column
|
||||||
this(colHeader, colSQL, colClass, true, false, IDcolSQL);
|
this(colHeader, colSQL, colClass, true, false, IDcolSQL);
|
||||||
} // Info_Column
|
} // Info_Column
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Info Column (not color column)
|
||||||
|
*
|
||||||
|
* @param colHeader Column Header
|
||||||
|
* @param colSQL SQL select code for column
|
||||||
|
* @param colClass class of column - determines display
|
||||||
|
* @param readOnly column is read only
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
public Info_Column (String colHeader, String colSQL, Class colClass, boolean readOnly)
|
||||||
|
{
|
||||||
|
this(colHeader, colSQL, colClass, readOnly, false, null);
|
||||||
|
} // Info_Column
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Info Column
|
* Create Info Column
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1037,6 +1037,53 @@ public class GridController extends CPanel
|
||||||
} // rowChanged
|
} // rowChanged
|
||||||
|
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Save Multiple records - Clone a record and assign new values to each
|
||||||
|
* clone for a specific column.
|
||||||
|
* @param ctx context
|
||||||
|
* @param tableName Table Name
|
||||||
|
* @param columnName Column for which value need to be changed
|
||||||
|
* @param recordId Record to clone
|
||||||
|
* @param values Values to be assigned to clones for the specified column
|
||||||
|
* @param trxName Transaction
|
||||||
|
* @throws Exception If error is occured when loading the PO or saving clones
|
||||||
|
*
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
protected void saveMultipleRecords(Properties ctx, String tableName,
|
||||||
|
String columnName, int recordId, Integer[] values,
|
||||||
|
String trxName) throws Exception
|
||||||
|
{
|
||||||
|
if (values == null)
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int oldRow = m_mTab.getCurrentRow();
|
||||||
|
GridField lineField = m_mTab.getField("Line");
|
||||||
|
|
||||||
|
for (int i = 0; i < values.length; i++)
|
||||||
|
{
|
||||||
|
if (!m_mTab.dataNew(true))
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Could not clone tab");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mTab.setValue(columnName, values[i]);
|
||||||
|
|
||||||
|
if (lineField != null)
|
||||||
|
{
|
||||||
|
m_mTab.setValue(lineField, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!m_mTab.dataSave(false))
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Could not update tab");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_mTab.setCurrentRow(oldRow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Vetoable Change Listener.
|
* Vetoable Change Listener.
|
||||||
|
|
@ -1104,7 +1151,38 @@ public class GridController extends CPanel
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// mTable.setValueAt (e.getNewValue(), row, col, true);
|
// mTable.setValueAt (e.getNewValue(), row, col, true);
|
||||||
mTable.setValueAt (e.getNewValue(), row, col); // -> dataStatusChanged -> dynamicDisplay
|
/*
|
||||||
|
* Changes: Added the logic below to handle multiple values for a single field
|
||||||
|
* due to multiple selection in Lookup (Info).
|
||||||
|
* @author ashley
|
||||||
|
*/
|
||||||
|
Object newValue = e.getNewValue();
|
||||||
|
Integer newValues[] = null;
|
||||||
|
|
||||||
|
if (newValue instanceof Integer[])
|
||||||
|
{
|
||||||
|
newValues = ((Integer[])newValue);
|
||||||
|
newValue = newValues[0];
|
||||||
|
|
||||||
|
if (newValues.length > 1)
|
||||||
|
{
|
||||||
|
Integer valuesCopy[] = new Integer[newValues.length - 1];
|
||||||
|
System.arraycopy(newValues, 1, valuesCopy, 0, valuesCopy.length);
|
||||||
|
newValues = valuesCopy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newValues = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (newValue instanceof Object[])
|
||||||
|
{
|
||||||
|
log.severe("Multiple values can only be processed for IDs (Integer)");
|
||||||
|
throw new PropertyVetoException("Multiple Selection values not available for this field", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
mTable.setValueAt (newValue, row, col); // -> dataStatusChanged -> dynamicDisplay
|
||||||
|
|
||||||
// Force Callout
|
// Force Callout
|
||||||
if (e.getPropertyName().equals("S_ResourceAssignment_ID"))
|
if (e.getPropertyName().equals("S_ResourceAssignment_ID"))
|
||||||
{
|
{
|
||||||
|
|
@ -1112,6 +1190,37 @@ public class GridController extends CPanel
|
||||||
if (mField != null && mField.getCallout().length() > 0)
|
if (mField != null && mField.getCallout().length() > 0)
|
||||||
m_mTab.processFieldChange(mField); // Dependencies & Callout
|
m_mTab.processFieldChange(mField); // Dependencies & Callout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newValues != null && newValues.length > 0)
|
||||||
|
{
|
||||||
|
// Save data, since record need to be used for generating clones.
|
||||||
|
if (!m_mTab.dataSave(false))
|
||||||
|
{
|
||||||
|
throw new PropertyVetoException("SaveError", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve the current record ID
|
||||||
|
int recordId = m_mTab.getKeyID(m_mTab.getCurrentRow());
|
||||||
|
|
||||||
|
Trx trx = Trx.get(Trx.createTrxName(), true);
|
||||||
|
trx.start();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
saveMultipleRecords(Env.getCtx(), mTable.getTableName(), e.getPropertyName(), recordId, newValues, trx.getTrxName());
|
||||||
|
trx.commit();
|
||||||
|
m_mTab.dataRefreshAll();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
trx.rollback();
|
||||||
|
log.severe(ex.getMessage());
|
||||||
|
throw new PropertyVetoException("SaveError", e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
trx.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// log.config( "GridController.vetoableChange (" + m_mTab.toString() + ") - fini", e.getPropertyName() + "=" + e.getNewValue());
|
// log.config( "GridController.vetoableChange (" + m_mTab.toString() + ") - fini", e.getPropertyName() + "=" + e.getNewValue());
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ import org.compiere.util.*;
|
||||||
* @version $Id: VLookup.java,v 1.5 2006/10/06 00:42:38 jjanke Exp $
|
* @version $Id: VLookup.java,v 1.5 2006/10/06 00:42:38 jjanke Exp $
|
||||||
*
|
*
|
||||||
* @author Teo Sarca - BF [ 1740835 ]
|
* @author Teo Sarca - BF [ 1740835 ]
|
||||||
|
* @author Michael Judd (MultiSelect)
|
||||||
*/
|
*/
|
||||||
public class VLookup extends JComponent
|
public class VLookup extends JComponent
|
||||||
implements VEditor, ActionListener, FocusListener
|
implements VEditor, ActionListener, FocusListener
|
||||||
|
|
@ -678,16 +679,24 @@ public class VLookup extends JComponent
|
||||||
}
|
}
|
||||||
// is the value updated ?
|
// is the value updated ?
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
if (value == null && m_value == null)
|
|
||||||
|
Object updatedValue = value;
|
||||||
|
|
||||||
|
if (updatedValue instanceof Object[] && ((Object[])updatedValue).length > 0)
|
||||||
|
{
|
||||||
|
updatedValue = ((Object[])updatedValue)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updatedValue == null && m_value == null)
|
||||||
updated = true;
|
updated = true;
|
||||||
else if (value != null && value.equals(m_value))
|
else if (updatedValue != null && value.equals(m_value))
|
||||||
updated = true;
|
updated = true;
|
||||||
if (!updated)
|
if (!updated)
|
||||||
{
|
{
|
||||||
// happens if VLookup is used outside of APanel/GridController (no property listener)
|
// happens if VLookup is used outside of APanel/GridController (no property listener)
|
||||||
log.fine(m_columnName + " - Value explicitly set - new=" + value + ", old=" + m_value);
|
log.fine(m_columnName + " - Value explicitly set - new=" + updatedValue + ", old=" + m_value);
|
||||||
if (getListeners(PropertyChangeListener.class).length <= 0)
|
if (getListeners(PropertyChangeListener.class).length <= 0)
|
||||||
setValue(value);
|
setValue(updatedValue);
|
||||||
}
|
}
|
||||||
} // actionCombo
|
} // actionCombo
|
||||||
|
|
||||||
|
|
@ -711,8 +720,10 @@ public class VLookup extends JComponent
|
||||||
* - Cancel pressed => store null => result == null && cancelled
|
* - Cancel pressed => store null => result == null && cancelled
|
||||||
* - Window closed -> ignore => result == null && !cancalled
|
* - Window closed -> ignore => result == null && !cancalled
|
||||||
*/
|
*/
|
||||||
Object result = null;
|
|
||||||
|
Object result[] = null;
|
||||||
boolean cancelled = false;
|
boolean cancelled = false;
|
||||||
|
boolean multipleSelection = false;
|
||||||
//
|
//
|
||||||
String col = m_lookup.getColumnName(); // fully qualified name
|
String col = m_lookup.getColumnName(); // fully qualified name
|
||||||
if (col.indexOf('.') != -1)
|
if (col.indexOf('.') != -1)
|
||||||
|
|
@ -737,7 +748,7 @@ public class VLookup extends JComponent
|
||||||
m_tableName, m_keyColumnName, queryValue, false, whereClause);
|
m_tableName, m_keyColumnName, queryValue, false, whereClause);
|
||||||
ig.setVisible(true);
|
ig.setVisible(true);
|
||||||
cancelled = ig.isCancelled();
|
cancelled = ig.isCancelled();
|
||||||
result = ig.getSelectedKey();
|
result = ig.getSelectedKeys();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.log(Level.SEVERE, "Failed to load custom InfoFactory - " + e.getLocalizedMessage(), e);
|
log.log(Level.SEVERE, "Failed to load custom InfoFactory - " + e.getLocalizedMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
@ -753,12 +764,16 @@ public class VLookup extends JComponent
|
||||||
queryValue = "@" + m_text.getText() + "@"; // Name indicator - otherwise Value
|
queryValue = "@" + m_text.getText() + "@"; // Name indicator - otherwise Value
|
||||||
int M_Warehouse_ID = Env.getContextAsInt(Env.getCtx(), m_lookup.getWindowNo(), "M_Warehouse_ID");
|
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");
|
int M_PriceList_ID = Env.getContextAsInt(Env.getCtx(), m_lookup.getWindowNo(), "M_PriceList_ID");
|
||||||
|
|
||||||
|
int AD_Table_ID = MColumn.getTable_ID(Env.getCtx(), m_mField.getAD_Column_ID(), null);
|
||||||
|
multipleSelection = (MOrderLine.Table_ID == AD_Table_ID) || (MInvoiceLine.Table_ID == AD_Table_ID);
|
||||||
|
|
||||||
// Show Info
|
// Show Info
|
||||||
InfoProduct ip = new InfoProduct (frame, true, m_lookup.getWindowNo(),
|
InfoProduct ip = new InfoProduct (frame, true, m_lookup.getWindowNo(),
|
||||||
M_Warehouse_ID, M_PriceList_ID, queryValue, false, whereClause);
|
M_Warehouse_ID, M_PriceList_ID, queryValue, multipleSelection, whereClause);
|
||||||
ip.setVisible(true);
|
ip.setVisible(true);
|
||||||
cancelled = ip.isCancelled();
|
cancelled = ip.isCancelled();
|
||||||
result = ip.getSelectedKey();
|
result = ip.getSelectedKeys();
|
||||||
resetValue = true;
|
resetValue = true;
|
||||||
}
|
}
|
||||||
else if (col.equals("C_BPartner_ID"))
|
else if (col.equals("C_BPartner_ID"))
|
||||||
|
|
@ -770,31 +785,36 @@ public class VLookup extends JComponent
|
||||||
if (Env.getContext(Env.getCtx(), m_lookup.getWindowNo(), "IsSOTrx").equals("N"))
|
if (Env.getContext(Env.getCtx(), m_lookup.getWindowNo(), "IsSOTrx").equals("N"))
|
||||||
isSOTrx = false;
|
isSOTrx = false;
|
||||||
InfoBPartner ip = new InfoBPartner (frame, true, m_lookup.getWindowNo(),
|
InfoBPartner ip = new InfoBPartner (frame, true, m_lookup.getWindowNo(),
|
||||||
queryValue, isSOTrx, false, whereClause);
|
queryValue, isSOTrx, multipleSelection, whereClause);
|
||||||
ip.setVisible(true);
|
ip.setVisible(true);
|
||||||
cancelled = ip.isCancelled();
|
cancelled = ip.isCancelled();
|
||||||
result = ip.getSelectedKey();
|
result = ip.getSelectedKeys();
|
||||||
}
|
}
|
||||||
else // General Info
|
else // General Info
|
||||||
{
|
{
|
||||||
if (m_tableName == null) // sets table name & key column
|
if (m_tableName == null) // sets table name & key column
|
||||||
getDirectAccessSQL("*");
|
getDirectAccessSQL("*");
|
||||||
Info ig = Info.create (frame, true, m_lookup.getWindowNo(),
|
Info ig = Info.create (frame, true, m_lookup.getWindowNo(),
|
||||||
m_tableName, m_keyColumnName, queryValue, false, whereClause);
|
m_tableName, m_keyColumnName, queryValue, multipleSelection, whereClause);
|
||||||
ig.setVisible(true);
|
ig.setVisible(true);
|
||||||
cancelled = ig.isCancelled();
|
cancelled = ig.isCancelled();
|
||||||
result = ig.getSelectedKey();
|
result = ig.getSelectedKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
if (result != null)
|
if (result != null && result.length > 0)
|
||||||
{
|
{
|
||||||
log.config(m_columnName + " - Result = " + result.toString() + " (" + result.getClass().getName() + ")");
|
log.config(m_columnName + " - Result = " + result.toString() + " (" + result.getClass().getName() + ")");
|
||||||
// make sure that value is in cache
|
// make sure that value is in cache
|
||||||
m_lookup.getDirect(result, false, true);
|
m_lookup.getDirect(result[0], false, true);
|
||||||
if (resetValue)
|
if (resetValue)
|
||||||
actionCombo (null);
|
actionCombo (null);
|
||||||
|
// juddm added logic for multi-select handling
|
||||||
|
if (result.length > 1)
|
||||||
actionCombo (result); // data binding
|
actionCombo (result); // data binding
|
||||||
|
else
|
||||||
|
actionCombo (result[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (cancelled)
|
else if (cancelled)
|
||||||
{
|
{
|
||||||
|
|
@ -845,6 +865,47 @@ public class VLookup extends JComponent
|
||||||
return whereClause;
|
return whereClause;
|
||||||
} // getWhereClause
|
} // getWhereClause
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private String getExtraWhereClause (String text)
|
||||||
|
{
|
||||||
|
StringBuffer sql = new StringBuffer();
|
||||||
|
m_tableName = m_columnName.substring(0, m_columnName.length()-3);
|
||||||
|
m_keyColumnName = m_columnName;
|
||||||
|
//
|
||||||
|
if (m_columnName.equals("M_Product_ID"))
|
||||||
|
{
|
||||||
|
// Reset
|
||||||
|
Env.setContext(Env.getCtx(), Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID", "0");
|
||||||
|
Env.setContext(Env.getCtx(), Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID", "0");
|
||||||
|
Env.setContext(Env.getCtx(), Env.WINDOW_INFO, Env.TAB_INFO, "M_Locator_ID", "0");
|
||||||
|
//
|
||||||
|
sql.append(" AND (UPPER(p.Value) LIKE ")
|
||||||
|
.append(DB.TO_STRING(text))
|
||||||
|
.append(" OR UPPER(p.Name) LIKE ").append(DB.TO_STRING(text))
|
||||||
|
.append(" OR p.SKU LIKE ").append(DB.TO_STRING(text)).append(")");
|
||||||
|
//.append(" OR p.SKU LIKE ").append(DB.TO_STRING(text))
|
||||||
|
//.append(" OR p.UPC LIKE ").append(DB.TO_STRING(text)).append(")");
|
||||||
|
}
|
||||||
|
// Predefined
|
||||||
|
/*
|
||||||
|
if (sql.length() > 0)
|
||||||
|
{
|
||||||
|
String wc = getWhereClause();
|
||||||
|
if (wc != null && wc.length() > 0)
|
||||||
|
sql.append(" AND ").append(wc);
|
||||||
|
sql.append(" AND IsActive='Y'");
|
||||||
|
// ***
|
||||||
|
log.finest(m_columnName + " (predefined) " + sql.toString());
|
||||||
|
return MRole.getDefault().addAccessSQL(sql.toString(),
|
||||||
|
m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return sql.toString();
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Check, if data returns unique entry, otherwise involve Info via Button
|
* Check, if data returns unique entry, otherwise involve Info via Button
|
||||||
*/
|
*/
|
||||||
|
|
@ -961,6 +1022,7 @@ public class VLookup extends JComponent
|
||||||
sql.append("SELECT M_Product_ID FROM M_Product WHERE (UPPER(Value) LIKE ")
|
sql.append("SELECT M_Product_ID FROM M_Product WHERE (UPPER(Value) LIKE ")
|
||||||
.append(DB.TO_STRING(text))
|
.append(DB.TO_STRING(text))
|
||||||
.append(" OR UPPER(Name) LIKE ").append(DB.TO_STRING(text))
|
.append(" OR UPPER(Name) LIKE ").append(DB.TO_STRING(text))
|
||||||
|
.append(" OR SKU LIKE ").append(DB.TO_STRING(text))
|
||||||
.append(" OR UPC LIKE ").append(DB.TO_STRING(text)).append(")");
|
.append(" OR UPC LIKE ").append(DB.TO_STRING(text)).append(")");
|
||||||
}
|
}
|
||||||
else if (m_columnName.equals("C_BPartner_ID"))
|
else if (m_columnName.equals("C_BPartner_ID"))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue