FR2778207 Selectable zoom target window
- Modify to work for both swing and zk client
This commit is contained in:
parent
a94d18dd27
commit
75eaa4c2c9
|
@ -36,7 +36,7 @@ import org.compiere.util.Language;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MLookupFactory.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
|
* @version $Id: MLookupFactory.java,v 1.3 2006/07/30 00:58:04 jjanke Exp $
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
* <li>BF [ 1734394 ] MLookupFactory.getLookup_TableDirEmbed is not translated
|
* <li>BF [ 1734394 ] MLookupFactory.getLookup_TableDirEmbed is not translated
|
||||||
* <li>BF [ 1714261 ] MLookupFactory: TableDirEmbed -> TableEmbed not supported
|
* <li>BF [ 1714261 ] MLookupFactory: TableDirEmbed -> TableEmbed not supported
|
||||||
|
@ -54,7 +54,7 @@ public class MLookupFactory
|
||||||
/** Table Reference Cache */
|
/** Table Reference Cache */
|
||||||
private static CCache<String,MLookupInfo> s_cacheRefTable = new CCache<String,MLookupInfo>("AD_Ref_Table", 30, 60); // 1h
|
private static CCache<String,MLookupInfo> s_cacheRefTable = new CCache<String,MLookupInfo>("AD_Ref_Table", 30, 60); // 1h
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create MLookup
|
* Create MLookup
|
||||||
*
|
*
|
||||||
|
@ -124,10 +124,10 @@ public class MLookupFactory
|
||||||
//
|
//
|
||||||
MLookupInfo info = getLookupInfo (ctx, WindowNo, Column_ID, AD_Reference_ID,
|
MLookupInfo info = getLookupInfo (ctx, WindowNo, Column_ID, AD_Reference_ID,
|
||||||
Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode);
|
Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, IsParent, ValidationCode);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create MLookup
|
* Create MLookup
|
||||||
*
|
*
|
||||||
|
@ -141,7 +141,7 @@ public class MLookupFactory
|
||||||
public static MLookup get (Properties ctx, int WindowNo, int TabNo, int Column_ID, int AD_Reference_ID)
|
public static MLookup get (Properties ctx, int WindowNo, int TabNo, int Column_ID, int AD_Reference_ID)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
MLookupInfo info = getLookupInfo (ctx, WindowNo, Column_ID, AD_Reference_ID);
|
MLookupInfo info = getLookupInfo (ctx, WindowNo, Column_ID, AD_Reference_ID);
|
||||||
return new MLookup(info, TabNo);
|
return new MLookup(info, TabNo);
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ public class MLookupFactory
|
||||||
* @param ValidationCode optional SQL validation
|
* @param ValidationCode optional SQL validation
|
||||||
* @return lookup info structure
|
* @return lookup info structure
|
||||||
*/
|
*/
|
||||||
static public MLookupInfo getLookupInfo (Properties ctx, int WindowNo,
|
static public MLookupInfo getLookupInfo (Properties ctx, int WindowNo,
|
||||||
int Column_ID, int AD_Reference_ID,
|
int Column_ID, int AD_Reference_ID,
|
||||||
Language language, String ColumnName, int AD_Reference_Value_ID,
|
Language language, String ColumnName, int AD_Reference_Value_ID,
|
||||||
boolean IsParent, String ValidationCode)
|
boolean IsParent, String ValidationCode)
|
||||||
|
@ -241,7 +241,7 @@ public class MLookupFactory
|
||||||
//String local_validationCode = "";
|
//String local_validationCode = "";
|
||||||
if (info.ValidationCode.length() == 0)
|
if (info.ValidationCode.length() == 0)
|
||||||
info.IsValidated = true;
|
info.IsValidated = true;
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -266,10 +266,10 @@ public class MLookupFactory
|
||||||
info.Query = info.Query
|
info.Query = info.Query
|
||||||
+ (hasWhere ? " AND " : " WHERE ") + local_validationCode;
|
+ (hasWhere ? " AND " : " WHERE ") + local_validationCode;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// Add Security
|
// Add Security
|
||||||
if (needToAddSecurity)
|
if (needToAddSecurity)
|
||||||
info.Query = MRole.getDefault(ctx, false).addAccessSQL(info.Query,
|
info.Query = MRole.getDefault(ctx, false).addAccessSQL(info.Query,
|
||||||
info.TableName, MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
info.TableName, MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO);
|
||||||
//
|
//
|
||||||
// s_log.finest("Query: " + info.Query);
|
// s_log.finest("Query: " + info.Query);
|
||||||
|
@ -277,7 +277,7 @@ public class MLookupFactory
|
||||||
return info;
|
return info;
|
||||||
} // createLookupInfo
|
} // createLookupInfo
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Get Lookup SQL for Lists
|
* Get Lookup SQL for Lists
|
||||||
* @param language report language
|
* @param language report language
|
||||||
|
@ -299,7 +299,7 @@ public class MLookupFactory
|
||||||
if ("Y".equals(byValue))
|
if ("Y".equals(byValue))
|
||||||
realSQL.append(" ORDER BY 2");
|
realSQL.append(" ORDER BY 2");
|
||||||
else
|
else
|
||||||
realSQL.append(" ORDER BY 3"); // sort by name/translated name - teo_sarca, [ 1672820 ]
|
realSQL.append(" ORDER BY 3"); // sort by name/translated name - teo_sarca, [ 1672820 ]
|
||||||
//
|
//
|
||||||
return new MLookupInfo(realSQL.toString(), "AD_Ref_List", "AD_Ref_List.Value",
|
return new MLookupInfo(realSQL.toString(), "AD_Ref_List", "AD_Ref_List.Value",
|
||||||
101,101, MQuery.getEqualQuery("AD_Reference_ID", AD_Reference_Value_ID)); // Zoom Window+Query
|
101,101, MQuery.getEqualQuery("AD_Reference_ID", AD_Reference_Value_ID)); // Zoom Window+Query
|
||||||
|
@ -312,7 +312,7 @@ public class MLookupFactory
|
||||||
* @param linkColumnName link column name
|
* @param linkColumnName link column name
|
||||||
* @return SELECT Name FROM AD_Ref_List WHERE AD_Reference_ID=x AND Value=linkColumn
|
* @return SELECT Name FROM AD_Ref_List WHERE AD_Reference_ID=x AND Value=linkColumn
|
||||||
*/
|
*/
|
||||||
static public String getLookup_ListEmbed(Language language,
|
static public String getLookup_ListEmbed(Language language,
|
||||||
int AD_Reference_Value_ID, String linkColumnName)
|
int AD_Reference_Value_ID, String linkColumnName)
|
||||||
{
|
{
|
||||||
StringBuffer realSQL = new StringBuffer ("SELECT ");
|
StringBuffer realSQL = new StringBuffer ("SELECT ");
|
||||||
|
@ -325,11 +325,11 @@ public class MLookupFactory
|
||||||
.append(language.getAD_Language()).append("')");
|
.append(language.getAD_Language()).append("')");
|
||||||
realSQL.append(" WHERE AD_Ref_List.AD_Reference_ID=").append(AD_Reference_Value_ID)
|
realSQL.append(" WHERE AD_Ref_List.AD_Reference_ID=").append(AD_Reference_Value_ID)
|
||||||
.append(" AND AD_Ref_List.Value=").append(linkColumnName);
|
.append(" AND AD_Ref_List.Value=").append(linkColumnName);
|
||||||
|
|
||||||
//
|
//
|
||||||
return realSQL.toString();
|
return realSQL.toString();
|
||||||
} // getLookup_ListEmbed
|
} // getLookup_ListEmbed
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Get Lookup SQL for Table Lookup
|
* Get Lookup SQL for Table Lookup
|
||||||
* @param ctx context for access and dynamic access
|
* @param ctx context for access and dynamic access
|
||||||
|
@ -354,7 +354,8 @@ public class MLookupFactory
|
||||||
String sql0 = "SELECT t.TableName,ck.ColumnName AS KeyColumn," // 1..2
|
String sql0 = "SELECT t.TableName,ck.ColumnName AS KeyColumn," // 1..2
|
||||||
+ "cd.ColumnName AS DisplayColumn,rt.IsValueDisplayed,cd.IsTranslated," // 3..5
|
+ "cd.ColumnName AS DisplayColumn,rt.IsValueDisplayed,cd.IsTranslated," // 3..5
|
||||||
+ "rt.WhereClause,rt.OrderByClause,t.AD_Window_ID,t.PO_Window_ID, " // 6..9
|
+ "rt.WhereClause,rt.OrderByClause,t.AD_Window_ID,t.PO_Window_ID, " // 6..9
|
||||||
+ "t.AD_Table_ID, cd.ColumnSQL as DisplayColumnSQL " // 10..11
|
+ "t.AD_Table_ID, cd.ColumnSQL as DisplayColumnSQL, " // 10..11
|
||||||
|
+ "rt.AD_Window_ID as RT_AD_Window_ID " // 12
|
||||||
+ "FROM AD_Ref_Table rt"
|
+ "FROM AD_Ref_Table rt"
|
||||||
+ " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID)"
|
+ " INNER JOIN AD_Table t ON (rt.AD_Table_ID=t.AD_Table_ID)"
|
||||||
+ " INNER JOIN AD_Column ck ON (rt.AD_Key=ck.AD_Column_ID)"
|
+ " INNER JOIN AD_Column ck ON (rt.AD_Key=ck.AD_Column_ID)"
|
||||||
|
@ -368,6 +369,7 @@ public class MLookupFactory
|
||||||
//boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
//boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
||||||
int ZoomWindow = 0;
|
int ZoomWindow = 0;
|
||||||
int ZoomWindowPO = 0;
|
int ZoomWindowPO = 0;
|
||||||
|
int overrideZoomWindow = 0;
|
||||||
//int AD_Table_ID = 0;
|
//int AD_Table_ID = 0;
|
||||||
boolean loaded = false;
|
boolean loaded = false;
|
||||||
|
|
||||||
|
@ -391,6 +393,7 @@ public class MLookupFactory
|
||||||
ZoomWindowPO = rs.getInt(9);
|
ZoomWindowPO = rs.getInt(9);
|
||||||
//AD_Table_ID = rs.getInt(10);
|
//AD_Table_ID = rs.getInt(10);
|
||||||
displayColumnSQL = rs.getString(11);
|
displayColumnSQL = rs.getString(11);
|
||||||
|
overrideZoomWindow = rs.getInt(12);
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,7 +408,7 @@ public class MLookupFactory
|
||||||
rs = null;
|
rs = null;
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loaded)
|
if (!loaded)
|
||||||
{
|
{
|
||||||
s_log.log(Level.SEVERE, "No Table Reference Table ID=" + AD_Reference_Value_ID);
|
s_log.log(Level.SEVERE, "No Table Reference Table ID=" + AD_Reference_Value_ID);
|
||||||
|
@ -486,7 +489,12 @@ public class MLookupFactory
|
||||||
realSQL.append(" ORDER BY 3");
|
realSQL.append(" ORDER BY 3");
|
||||||
|
|
||||||
s_log.finest("AD_Reference_Value_ID=" + AD_Reference_Value_ID + " - " + realSQL);
|
s_log.finest("AD_Reference_Value_ID=" + AD_Reference_Value_ID + " - " + realSQL);
|
||||||
retValue = new MLookupInfo (realSQL.toString(), TableName,
|
if (overrideZoomWindow > 0)
|
||||||
|
{
|
||||||
|
ZoomWindow = overrideZoomWindow;
|
||||||
|
ZoomWindowPO = 0;
|
||||||
|
}
|
||||||
|
retValue = new MLookupInfo (realSQL.toString(), TableName,
|
||||||
TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery);
|
TableName + "." + KeyColumn, ZoomWindow, ZoomWindowPO, zoomQuery);
|
||||||
s_cacheRefTable.put(key, retValue.cloneIt());
|
s_cacheRefTable.put(key, retValue.cloneIt());
|
||||||
return retValue;
|
return retValue;
|
||||||
|
@ -547,7 +555,7 @@ public class MLookupFactory
|
||||||
rs = null;
|
rs = null;
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's self referencing then use other alias - teo_sarca [ 1739544 ]
|
// If it's self referencing then use other alias - teo_sarca [ 1739544 ]
|
||||||
if (TableName.equals(BaseTable)) {
|
if (TableName.equals(BaseTable)) {
|
||||||
TableNameAlias = TableName + "1";
|
TableNameAlias = TableName + "1";
|
||||||
|
@ -605,13 +613,13 @@ public class MLookupFactory
|
||||||
s_log.log(Level.SEVERE, "Key does not end with '_ID': " + ColumnName);
|
s_log.log(Level.SEVERE, "Key does not end with '_ID': " + ColumnName);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String KeyColumn = MQuery.getZoomColumnName(ColumnName);
|
String KeyColumn = MQuery.getZoomColumnName(ColumnName);
|
||||||
String TableName = MQuery.getZoomTableName(ColumnName);
|
String TableName = MQuery.getZoomTableName(ColumnName);
|
||||||
//boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
//boolean isSOTrx = !"N".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));
|
||||||
int ZoomWindow = 0;
|
int ZoomWindow = 0;
|
||||||
int ZoomWindowPO = 0;
|
int ZoomWindowPO = 0;
|
||||||
|
|
||||||
//try cache
|
//try cache
|
||||||
String cacheKey = Env.getAD_Client_ID(ctx) + "|" + TableName + "." + KeyColumn;
|
String cacheKey = Env.getAD_Client_ID(ctx) + "|" + TableName + "." + KeyColumn;
|
||||||
if (s_cacheRefTable.containsKey(cacheKey))
|
if (s_cacheRefTable.containsKey(cacheKey))
|
||||||
|
@ -660,7 +668,7 @@ public class MLookupFactory
|
||||||
rs = null;
|
rs = null;
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we have columns ?
|
// Do we have columns ?
|
||||||
if (list.size() == 0)
|
if (list.size() == 0)
|
||||||
{
|
{
|
||||||
|
@ -713,9 +721,9 @@ public class MLookupFactory
|
||||||
// String
|
// String
|
||||||
else
|
else
|
||||||
displayColumn.append(TableName).append(".").append(ldc.ColumnName);
|
displayColumn.append(TableName).append(".").append(ldc.ColumnName);
|
||||||
|
|
||||||
displayColumn.append(",'-1')");
|
displayColumn.append(",'-1')");
|
||||||
|
|
||||||
}
|
}
|
||||||
realSQL.append(displayColumn.toString());
|
realSQL.append(displayColumn.toString());
|
||||||
realSQL.append(",").append(TableName).append(".IsActive");
|
realSQL.append(",").append(TableName).append(".IsActive");
|
||||||
|
@ -816,7 +824,7 @@ public class MLookupFactory
|
||||||
rs = null;
|
rs = null;
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we have columns ?
|
// Do we have columns ?
|
||||||
if (list.size() == 0)
|
if (list.size() == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,7 +88,7 @@ import org.eevolution.model.X_PP_Product_BOMLine;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @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, SC ARHIPAC SERVICE SRL
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
* <li>BF [ 1740835 ] NPE when closing a window
|
* <li>BF [ 1740835 ] NPE when closing a window
|
||||||
* <li>BF [ 1817768 ] Isolate hardcoded table direct columns
|
* <li>BF [ 1817768 ] Isolate hardcoded table direct columns
|
||||||
|
@ -101,7 +101,7 @@ public class VLookup extends JComponent
|
||||||
implements VEditor, ActionListener, FocusListener
|
implements VEditor, ActionListener, FocusListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -104909868954609498L;
|
private static final long serialVersionUID = -104909868954609498L;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public class VLookup extends JComponent
|
||||||
if (e.getSource() == m_combo || e.getSource() == m_text || e.getSource() == this) {
|
if (e.getSource() == m_combo || e.getSource() == m_text || e.getSource() == this) {
|
||||||
return super.processKeyBinding(ks, e, condition, pressed);
|
return super.processKeyBinding(ks, e, condition, pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
JComponent editorComp = null;
|
JComponent editorComp = null;
|
||||||
if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search)
|
if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search)
|
||||||
editorComp = m_combo;
|
editorComp = m_combo;
|
||||||
|
@ -141,7 +141,7 @@ public class VLookup extends JComponent
|
||||||
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
int AD_Column_ID = 3499; // C_Invoice.C_BPartner_ID
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo,
|
Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo,
|
||||||
0, AD_Column_ID, DisplayType.Search);
|
0, AD_Column_ID, DisplayType.Search);
|
||||||
return new VLookup ("C_BPartner_ID", false, false, true, lookup);
|
return new VLookup ("C_BPartner_ID", false, false, true, lookup);
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ public class VLookup extends JComponent
|
||||||
int AD_Column_ID = 3840; // C_InvoiceLine.M_Product_ID
|
int AD_Column_ID = 3840; // C_InvoiceLine.M_Product_ID
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, 0,
|
Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, 0,
|
||||||
AD_Column_ID, DisplayType.Search);
|
AD_Column_ID, DisplayType.Search);
|
||||||
return new VLookup ("M_Product_ID", false, false, true, lookup);
|
return new VLookup ("M_Product_ID", false, false, true, lookup);
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ public class VLookup extends JComponent
|
||||||
int AD_Column_ID = 10443; // AD_WF_Activity.AD_User_UD
|
int AD_Column_ID = 10443; // AD_WF_Activity.AD_User_UD
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, 0,
|
Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, 0,
|
||||||
AD_Column_ID, DisplayType.Search);
|
AD_Column_ID, DisplayType.Search);
|
||||||
return new VLookup ("AD_User_ID", false, false, true, lookup);
|
return new VLookup ("AD_User_ID", false, false, true, lookup);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ public class VLookup extends JComponent
|
||||||
return null;
|
return null;
|
||||||
} // createProduct
|
} // createProduct
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Detail Constructor
|
* Detail Constructor
|
||||||
*
|
*
|
||||||
|
@ -336,7 +336,7 @@ public class VLookup extends JComponent
|
||||||
private boolean m_comboActive = true;
|
private boolean m_comboActive = true;
|
||||||
/** The Value */
|
/** The Value */
|
||||||
private Object m_value;
|
private Object m_value;
|
||||||
|
|
||||||
private boolean m_stopediting = false;
|
private boolean m_stopediting = false;
|
||||||
|
|
||||||
// Popup
|
// Popup
|
||||||
|
@ -348,7 +348,7 @@ public class VLookup extends JComponent
|
||||||
// Mouse Listener
|
// Mouse Listener
|
||||||
private VLookup_mouseAdapter mouseAdapter;
|
private VLookup_mouseAdapter mouseAdapter;
|
||||||
|
|
||||||
|
|
||||||
// Field for Value Preference
|
// Field for Value Preference
|
||||||
private GridField m_mField = null;
|
private GridField m_mField = null;
|
||||||
/** Logger */
|
/** Logger */
|
||||||
|
@ -497,7 +497,7 @@ public class VLookup extends JComponent
|
||||||
m_text.requestFocus ();
|
m_text.requestFocus ();
|
||||||
} // requestFocus
|
} // requestFocus
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Editor to value
|
* Set Editor to value
|
||||||
* @param value new Value
|
* @param value new Value
|
||||||
|
@ -527,10 +527,10 @@ public class VLookup extends JComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
//must call m_combo.setvalue after m_lookup as
|
//must call m_combo.setvalue after m_lookup as
|
||||||
//loading of combo data might happen in m_lookup.getDisplay
|
//loading of combo data might happen in m_lookup.getDisplay
|
||||||
m_lastDisplay = m_lookup.getDisplay(value);
|
m_lastDisplay = m_lookup.getDisplay(value);
|
||||||
m_combo.setValue (value);
|
m_combo.setValue (value);
|
||||||
|
|
||||||
if (m_lastDisplay.equals("<-1>"))
|
if (m_lastDisplay.equals("<-1>"))
|
||||||
{
|
{
|
||||||
m_lastDisplay = "";
|
m_lastDisplay = "";
|
||||||
|
@ -591,9 +591,9 @@ public class VLookup extends JComponent
|
||||||
*/
|
*/
|
||||||
public void propertyChange (PropertyChangeEvent evt)
|
public void propertyChange (PropertyChangeEvent evt)
|
||||||
{
|
{
|
||||||
if (m_stopediting)
|
if (m_stopediting)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// log.fine( "VLookup.propertyChange", evt);
|
// log.fine( "VLookup.propertyChange", evt);
|
||||||
if (evt.getPropertyName().equals(GridField.PROPERTY))
|
if (evt.getPropertyName().equals(GridField.PROPERTY))
|
||||||
{
|
{
|
||||||
|
@ -644,7 +644,7 @@ public class VLookup extends JComponent
|
||||||
ValuePreference.addMenu (this, popupMenu);
|
ValuePreference.addMenu (this, popupMenu);
|
||||||
} // setField
|
} // setField
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Action Listener - data binding
|
* Action Listener - data binding
|
||||||
* @param e ActionEvent
|
* @param e ActionEvent
|
||||||
|
@ -737,14 +737,14 @@ public class VLookup extends JComponent
|
||||||
}
|
}
|
||||||
// is the value updated ?
|
// is the value updated ?
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
|
|
||||||
Object updatedValue = value;
|
Object updatedValue = value;
|
||||||
|
|
||||||
if (updatedValue instanceof Object[] && ((Object[])updatedValue).length > 0)
|
if (updatedValue instanceof Object[] && ((Object[])updatedValue).length > 0)
|
||||||
{
|
{
|
||||||
updatedValue = ((Object[])updatedValue)[0];
|
updatedValue = ((Object[])updatedValue)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updatedValue == null && m_value == null)
|
if (updatedValue == null && m_value == null)
|
||||||
updated = true;
|
updated = true;
|
||||||
else if (updatedValue != null && value.equals(m_value))
|
else if (updatedValue != null && value.equals(m_value))
|
||||||
|
@ -778,7 +778,7 @@ 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;
|
boolean multipleSelection = false;
|
||||||
|
@ -789,7 +789,7 @@ public class VLookup extends JComponent
|
||||||
// Zoom / Validation
|
// Zoom / Validation
|
||||||
String whereClause = getWhereClause();
|
String whereClause = getWhereClause();
|
||||||
//
|
//
|
||||||
log.fine(col
|
log.fine(col
|
||||||
+ ", Zoom=" + m_lookup.getZoom()
|
+ ", Zoom=" + m_lookup.getZoom()
|
||||||
+ " (" + whereClause + ")");
|
+ " (" + whereClause + ")");
|
||||||
//
|
//
|
||||||
|
@ -802,7 +802,7 @@ public class VLookup extends JComponent
|
||||||
InfoFactory factory = clazz.newInstance();
|
InfoFactory factory = clazz.newInstance();
|
||||||
if (m_tableName == null) // sets table name & key column
|
if (m_tableName == null) // sets table name & key column
|
||||||
getDirectAccessSQL("*");
|
getDirectAccessSQL("*");
|
||||||
Info ig = factory.create (frame, true, m_lookup.getWindowNo(),
|
Info ig = factory.create (frame, true, m_lookup.getWindowNo(),
|
||||||
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();
|
||||||
|
@ -820,11 +820,11 @@ 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");
|
||||||
|
|
||||||
if(m_mField != null)
|
if(m_mField != null)
|
||||||
{
|
{
|
||||||
int AD_Table_ID = MColumn.getTable_ID(Env.getCtx(), m_mField.getAD_Column_ID(), null);
|
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) || (X_PP_Product_BOMLine.Table_ID == AD_Table_ID) || (MProductPrice.Table_ID == AD_Table_ID);
|
multipleSelection = (MOrderLine.Table_ID == AD_Table_ID) || (MInvoiceLine.Table_ID == AD_Table_ID) || (X_PP_Product_BOMLine.Table_ID == AD_Table_ID) || (MProductPrice.Table_ID == AD_Table_ID);
|
||||||
}
|
}
|
||||||
// Show Info
|
// Show Info
|
||||||
|
@ -853,13 +853,13 @@ public class VLookup extends JComponent
|
||||||
{
|
{
|
||||||
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, multipleSelection, whereClause);
|
m_tableName, m_keyColumnName, queryValue, multipleSelection, whereClause);
|
||||||
ig.setVisible(true);
|
ig.setVisible(true);
|
||||||
cancelled = ig.isCancelled();
|
cancelled = ig.isCancelled();
|
||||||
result = ig.getSelectedKeys();
|
result = ig.getSelectedKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
if (result != null && result.length > 0)
|
if (result != null && result.length > 0)
|
||||||
{
|
{
|
||||||
|
@ -873,7 +873,7 @@ public class VLookup extends JComponent
|
||||||
actionCombo (result); // data binding
|
actionCombo (result); // data binding
|
||||||
else
|
else
|
||||||
actionCombo (result[0]);
|
actionCombo (result[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (cancelled)
|
else if (cancelled)
|
||||||
{
|
{
|
||||||
|
@ -925,9 +925,9 @@ public class VLookup extends JComponent
|
||||||
} // getWhereClause
|
} // getWhereClause
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private String getExtraWhereClause (String text)
|
private String getExtraWhereClause (String text)
|
||||||
{
|
{
|
||||||
|
@ -960,7 +960,7 @@ public class VLookup extends JComponent
|
||||||
return MRole.getDefault().addAccessSQL(sql.toString(),
|
return MRole.getDefault().addAccessSQL(sql.toString(),
|
||||||
m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1140,7 +1140,7 @@ public class VLookup extends JComponent
|
||||||
return MRole.getDefault().addAccessSQL(sql.toString(),
|
return MRole.getDefault().addAccessSQL(sql.toString(),
|
||||||
m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
m_tableName, MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if it is a Table Reference
|
// Check if it is a Table Reference
|
||||||
if (m_lookup != null && m_lookup instanceof MLookup)
|
if (m_lookup != null && m_lookup instanceof MLookup)
|
||||||
{
|
{
|
||||||
|
@ -1195,7 +1195,7 @@ public class VLookup extends JComponent
|
||||||
}
|
}
|
||||||
} // Table Reference
|
} // Table Reference
|
||||||
} // MLookup
|
} // MLookup
|
||||||
|
|
||||||
/** Check Well Known Columns of Table - assumes TableDir **/
|
/** Check Well Known Columns of Table - assumes TableDir **/
|
||||||
String query = "SELECT t.TableName, c.ColumnName "
|
String query = "SELECT t.TableName, c.ColumnName "
|
||||||
+ "FROM AD_Column c "
|
+ "FROM AD_Column c "
|
||||||
|
@ -1293,7 +1293,6 @@ public class VLookup extends JComponent
|
||||||
Object value = getValue();
|
Object value = getValue();
|
||||||
if (value == null)
|
if (value == null)
|
||||||
value = selectedItem;
|
value = selectedItem;
|
||||||
int AD_Window_ID = 0;
|
|
||||||
// If not already exist or exact value
|
// If not already exist or exact value
|
||||||
if (zoomQuery == null || value != null)
|
if (zoomQuery == null || value != null)
|
||||||
{
|
{
|
||||||
|
@ -1305,11 +1304,11 @@ public class VLookup extends JComponent
|
||||||
int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID();
|
int AD_Reference_ID = ((MLookup)m_lookup).getAD_Reference_Value_ID();
|
||||||
if (AD_Reference_ID != 0)
|
if (AD_Reference_ID != 0)
|
||||||
{
|
{
|
||||||
String query = "SELECT kc.ColumnName, rt.AD_Window_ID"
|
String query = "SELECT kc.ColumnName"
|
||||||
+ " FROM AD_Ref_Table rt"
|
+ " FROM AD_Ref_Table rt"
|
||||||
+ " INNER JOIN AD_Column kc ON (rt.AD_Key=kc.AD_Column_ID)"
|
+ " INNER JOIN AD_Column kc ON (rt.AD_Key=kc.AD_Column_ID)"
|
||||||
+ "WHERE rt.AD_Reference_ID=?";
|
+ "WHERE rt.AD_Reference_ID=?";
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try
|
try
|
||||||
|
@ -1320,7 +1319,6 @@ public class VLookup extends JComponent
|
||||||
if (rs.next())
|
if (rs.next())
|
||||||
{
|
{
|
||||||
keyColumnName = rs.getString(1);
|
keyColumnName = rs.getString(1);
|
||||||
AD_Window_ID = rs.getInt(2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -1342,10 +1340,10 @@ public class VLookup extends JComponent
|
||||||
|
|
||||||
zoomQuery.setRecordCount(1); // guess
|
zoomQuery.setRecordCount(1); // guess
|
||||||
}
|
}
|
||||||
if ( AD_Window_ID == 0 )
|
|
||||||
AD_Window_ID = m_lookup.getZoom(zoomQuery);
|
int AD_Window_ID = m_lookup.getZoom(zoomQuery);
|
||||||
//
|
//
|
||||||
log.info(m_columnName + " - AD_Window_ID=" + AD_Window_ID
|
log.info(m_columnName + " - AD_Window_ID=" + AD_Window_ID
|
||||||
+ " - Query=" + zoomQuery + " - Value=" + value);
|
+ " - Query=" + zoomQuery + " - Value=" + value);
|
||||||
//
|
//
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
|
@ -1389,7 +1387,7 @@ public class VLookup extends JComponent
|
||||||
Object obj = m_combo.getSelectedItem();
|
Object obj = m_combo.getSelectedItem();
|
||||||
log.info(m_columnName + " #" + m_lookup.getSize() + ", Selected=" + obj);
|
log.info(m_columnName + " #" + m_lookup.getSize() + ", Selected=" + obj);
|
||||||
//no need to refresh readonly lookup, just remove direct cache
|
//no need to refresh readonly lookup, just remove direct cache
|
||||||
if (!isReadWrite())
|
if (!isReadWrite())
|
||||||
{
|
{
|
||||||
m_settingValue = true; // disable actions
|
m_settingValue = true; // disable actions
|
||||||
m_lookup.removeAllElements();
|
m_lookup.removeAllElements();
|
||||||
|
@ -1397,11 +1395,11 @@ public class VLookup extends JComponent
|
||||||
m_text.setText(m_lastDisplay);
|
m_text.setText(m_lastDisplay);
|
||||||
m_text.setCaretPosition(0);
|
m_text.setCaretPosition(0);
|
||||||
m_settingValue = false;
|
m_settingValue = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_lookup.refresh();
|
m_lookup.refresh();
|
||||||
m_lookup.fillComboBox(isMandatory(), true, true, false);
|
m_lookup.fillComboBox(isMandatory(), true, true, false);
|
||||||
m_combo.setSelectedItem(obj);
|
m_combo.setSelectedItem(obj);
|
||||||
//m_combo.revalidate();
|
//m_combo.revalidate();
|
||||||
}
|
}
|
||||||
|
@ -1410,7 +1408,7 @@ public class VLookup extends JComponent
|
||||||
log.info(m_columnName + " #" + m_lookup.getSize() + ", Selected=" + m_combo.getSelectedItem());
|
log.info(m_columnName + " #" + m_lookup.getSize() + ", Selected=" + m_combo.getSelectedItem());
|
||||||
} // actionRefresh
|
} // actionRefresh
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Focus Listener for ComboBoxes with missing Validation or invalid entries
|
* Focus Listener for ComboBoxes with missing Validation or invalid entries
|
||||||
* - Requery listener for updated list
|
* - Requery listener for updated list
|
||||||
|
@ -1420,10 +1418,10 @@ public class VLookup extends JComponent
|
||||||
{
|
{
|
||||||
if (m_combo == null || m_combo.getEditor() == null)
|
if (m_combo == null || m_combo.getEditor() == null)
|
||||||
return;
|
return;
|
||||||
if ((e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent())
|
if ((e.getSource() != m_combo && e.getSource() != m_combo.getEditor().getEditorComponent())
|
||||||
|| e.isTemporary() || m_haveFocus || m_lookup == null)
|
|| e.isTemporary() || m_haveFocus || m_lookup == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//avoid repeated query
|
//avoid repeated query
|
||||||
if (m_lookup.isValidated() && m_lookup.isLoaded())
|
if (m_lookup.isValidated() && m_lookup.isLoaded())
|
||||||
{
|
{
|
||||||
|
@ -1435,21 +1433,21 @@ public class VLookup extends JComponent
|
||||||
m_settingFocus = true; // prevents actionPerformed
|
m_settingFocus = true; // prevents actionPerformed
|
||||||
//
|
//
|
||||||
Object obj = m_lookup.getSelectedItem();
|
Object obj = m_lookup.getSelectedItem();
|
||||||
log.config(m_columnName
|
log.config(m_columnName
|
||||||
+ " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj);
|
+ " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj);
|
||||||
// log.fine( "VLookupHash=" + this.hashCode());
|
// log.fine( "VLookupHash=" + this.hashCode());
|
||||||
boolean popupVisible = m_combo.isPopupVisible();
|
boolean popupVisible = m_combo.isPopupVisible();
|
||||||
m_lookup.fillComboBox(isMandatory(), true, true, false); // only validated & active
|
m_lookup.fillComboBox(isMandatory(), true, true, false); // only validated & active
|
||||||
if (popupVisible)
|
if (popupVisible)
|
||||||
{
|
{
|
||||||
//refresh
|
//refresh
|
||||||
m_combo.hidePopup();
|
m_combo.hidePopup();
|
||||||
m_combo.showPopup();
|
m_combo.showPopup();
|
||||||
}
|
}
|
||||||
log.config(m_columnName
|
log.config(m_columnName
|
||||||
+ " - Update Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem());
|
+ " - Update Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem());
|
||||||
m_lookup.setSelectedItem(obj);
|
m_lookup.setSelectedItem(obj);
|
||||||
log.config(m_columnName
|
log.config(m_columnName
|
||||||
+ " - Selected Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem());
|
+ " - Selected Count=" + m_combo.getItemCount() + ", Selected=" + m_lookup.getSelectedItem());
|
||||||
//
|
//
|
||||||
m_settingFocus = false;
|
m_settingFocus = false;
|
||||||
|
@ -1461,8 +1459,8 @@ public class VLookup extends JComponent
|
||||||
*/
|
*/
|
||||||
public void focusLost(FocusEvent e)
|
public void focusLost(FocusEvent e)
|
||||||
{
|
{
|
||||||
if (e.isTemporary()
|
if (e.isTemporary()
|
||||||
|| m_lookup == null
|
|| m_lookup == null
|
||||||
|| !m_button.isEnabled() ) // set by actionButton
|
|| !m_button.isEnabled() ) // set by actionButton
|
||||||
return;
|
return;
|
||||||
// Text Lost focus
|
// Text Lost focus
|
||||||
|
@ -1472,7 +1470,7 @@ public class VLookup extends JComponent
|
||||||
log.config(m_columnName + " (Text) " + m_columnName + " = " + m_value + " - " + text);
|
log.config(m_columnName + " (Text) " + m_columnName + " = " + m_value + " - " + text);
|
||||||
m_haveFocus = false;
|
m_haveFocus = false;
|
||||||
// Skip if empty
|
// Skip if empty
|
||||||
if ((m_value == null
|
if ((m_value == null
|
||||||
&& m_text.getText().length() == 0))
|
&& m_text.getText().length() == 0))
|
||||||
return;
|
return;
|
||||||
if (m_lastDisplay.equals(text))
|
if (m_lastDisplay.equals(text))
|
||||||
|
@ -1527,7 +1525,7 @@ public class VLookup extends JComponent
|
||||||
m_text.setToolTipText(text);
|
m_text.setToolTipText(text);
|
||||||
m_combo.setToolTipText(text);
|
m_combo.setToolTipText(text);
|
||||||
} // setToolTipText
|
} // setToolTipText
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset Env.TAB_INFO context variables
|
* Reset Env.TAB_INFO context variables
|
||||||
* @param columnName
|
* @param columnName
|
||||||
|
@ -1562,13 +1560,13 @@ public class VLookup extends JComponent
|
||||||
{
|
{
|
||||||
if (m_lookup == null)
|
if (m_lookup == null)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
//no need to refresh readonly lookup, just remove direct cache
|
//no need to refresh readonly lookup, just remove direct cache
|
||||||
if (!isReadWrite()) {
|
if (!isReadWrite()) {
|
||||||
m_lookup.removeAllElements();
|
m_lookup.removeAllElements();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_lookup.refresh();
|
return m_lookup.refresh();
|
||||||
} // refresh
|
} // refresh
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue