IDEMPIERE-3537 Generic Info Window: Rendering of Search, Table Direct and List columns
This commit is contained in:
parent
624b14b51f
commit
c7745182f1
|
@ -38,10 +38,12 @@ import org.adempiere.webui.window.FDialog;
|
||||||
import org.compiere.minigrid.ColumnInfo;
|
import org.compiere.minigrid.ColumnInfo;
|
||||||
import org.compiere.minigrid.IDColumn;
|
import org.compiere.minigrid.IDColumn;
|
||||||
import org.compiere.model.I_C_ElementValue;
|
import org.compiere.model.I_C_ElementValue;
|
||||||
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.compiere.util.Util;
|
import org.compiere.util.Util;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
@ -107,12 +109,28 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
init();
|
init();
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
p_loadedOK = initInfo ();
|
||||||
|
|
||||||
if (queryValue != null && queryValue.length() > 0)
|
if (queryValue != null && queryValue.length() > 0)
|
||||||
|
{
|
||||||
|
Textbox[] txts = new Textbox[] {txt1, txt2, txt3, txt4};
|
||||||
|
for(Textbox t : txts)
|
||||||
|
{
|
||||||
|
if (t != null && t.isVisible())
|
||||||
|
{
|
||||||
|
t.setValue(queryValue);
|
||||||
|
testCount();
|
||||||
|
if (m_count <= 0)
|
||||||
|
t.setValue(null);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_count <= 0)
|
||||||
{
|
{
|
||||||
txt1.setValue(queryValue);
|
txt1.setValue(queryValue);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
p_loadedOK = initInfo ();
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -276,10 +294,10 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
|
|
||||||
// Prepare table
|
// Prepare table
|
||||||
|
|
||||||
StringBuilder where = new StringBuilder("IsActive='Y'");
|
StringBuilder where = new StringBuilder(p_tableName).append(".").append("IsActive='Y'");
|
||||||
|
|
||||||
if (p_whereClause.length() > 0)
|
if (p_whereClause.length() > 0)
|
||||||
where.append(" AND ").append(p_whereClause);
|
where.append(" AND (").append(p_whereClause).append(")");
|
||||||
prepareTable(m_generalLayout, p_tableName, where.toString(), "2");
|
prepareTable(m_generalLayout, p_tableName, where.toString(), "2");
|
||||||
|
|
||||||
// Set & enable Fields
|
// Set & enable Fields
|
||||||
|
@ -348,7 +366,7 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
+ " AND EXISTS (SELECT * FROM AD_Field f "
|
+ " AND EXISTS (SELECT * FROM AD_Field f "
|
||||||
+ "WHERE f.AD_Column_ID=c.AD_Column_ID"
|
+ "WHERE f.AD_Column_ID=c.AD_Column_ID"
|
||||||
+ " AND f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL) "
|
+ " AND f.IsDisplayed='Y' AND f.IsEncrypted='N' AND f.ObscureType IS NULL) "
|
||||||
+ "ORDER BY c.IsIdentifier DESC, c.AD_Reference_ID, c.SeqNo";
|
+ "ORDER BY c.IsIdentifier DESC, c.IsSelectionColumn Desc, c.AD_Reference_ID, c.SeqNoSelection, c.SeqNo";
|
||||||
|
|
||||||
int AD_Table_ID = 0;
|
int AD_Table_ID = 0;
|
||||||
String tableName = null;
|
String tableName = null;
|
||||||
|
@ -367,10 +385,11 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
String columnSql = rs.getString(4);
|
String columnSql = rs.getString(4);
|
||||||
if (columnSql != null && columnSql.contains("@"))
|
if (columnSql != null && columnSql.contains("@"))
|
||||||
columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true);
|
columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true);
|
||||||
|
String qualified = p_tableName+"."+rs.getString(1);
|
||||||
if (columnSql != null && columnSql.length() > 0)
|
if (columnSql != null && columnSql.length() > 0)
|
||||||
m_queryColumnsSql.add(columnSql);
|
m_queryColumnsSql.add(columnSql);
|
||||||
else
|
else
|
||||||
m_queryColumnsSql.add(rs.getString(1));
|
m_queryColumnsSql.add(qualified);
|
||||||
|
|
||||||
if (AD_Table_ID == 0)
|
if (AD_Table_ID == 0)
|
||||||
{
|
{
|
||||||
|
@ -420,7 +439,7 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
// Get Display Columns
|
// Get Display Columns
|
||||||
|
|
||||||
ArrayList<ColumnInfo> list = new ArrayList<ColumnInfo>();
|
ArrayList<ColumnInfo> list = new ArrayList<ColumnInfo>();
|
||||||
sql = "SELECT c.ColumnName, c.AD_Reference_ID, c.IsKey, f.IsDisplayed, c.AD_Reference_Value_ID, c.ColumnSql "
|
sql = "SELECT c.ColumnName, c.AD_Reference_ID, c.IsKey, f.IsDisplayed, c.AD_Reference_Value_ID, c.ColumnSql, c.AD_Column_ID "
|
||||||
+ "FROM AD_Column c"
|
+ "FROM AD_Column c"
|
||||||
+ " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID)"
|
+ " INNER JOIN AD_Table t ON (c.AD_Table_ID=t.AD_Table_ID)"
|
||||||
+ " INNER JOIN AD_Tab tab ON (t.AD_Window_ID=tab.AD_Window_ID)"
|
+ " INNER JOIN AD_Tab tab ON (t.AD_Window_ID=tab.AD_Window_ID)"
|
||||||
|
@ -443,10 +462,11 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
boolean isDisplayed = rs.getString(4).equals("Y");
|
boolean isDisplayed = rs.getString(4).equals("Y");
|
||||||
int AD_Reference_Value_ID = rs.getInt(5);
|
int AD_Reference_Value_ID = rs.getInt(5);
|
||||||
String columnSql = rs.getString(6);
|
String columnSql = rs.getString(6);
|
||||||
|
int AD_Column_ID = rs.getInt(7);
|
||||||
if (columnSql != null && columnSql.contains("@"))
|
if (columnSql != null && columnSql.contains("@"))
|
||||||
columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true);
|
columnSql = Env.parseContext(Env.getCtx(), -1, columnSql, false, true);
|
||||||
if (columnSql == null || columnSql.length() == 0)
|
if (columnSql == null || columnSql.length() == 0)
|
||||||
columnSql = columnName;
|
columnSql = tableName+"."+columnName;
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
StringBuffer colSql = new StringBuffer(columnSql);
|
StringBuffer colSql = new StringBuffer(columnSql);
|
||||||
|
@ -473,12 +493,12 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
{
|
{
|
||||||
if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List"))
|
if (Env.isBaseLanguage(Env.getCtx(), "AD_Ref_List"))
|
||||||
colSql = new StringBuffer("(SELECT l.Name FROM AD_Ref_List l WHERE l.AD_Reference_ID=")
|
colSql = new StringBuffer("(SELECT l.Name FROM AD_Ref_List l WHERE l.AD_Reference_ID=")
|
||||||
.append(AD_Reference_Value_ID).append(" AND l.Value=").append(tableName).append(".").append(columnSql)
|
.append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql)
|
||||||
.append(") AS ").append(columnName);
|
.append(") AS ").append(columnName);
|
||||||
else
|
else
|
||||||
colSql = new StringBuffer("(SELECT t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t "
|
colSql = new StringBuffer("(SELECT t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t "
|
||||||
+ "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.AD_Reference_ID=")
|
+ "WHERE l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.AD_Reference_ID=")
|
||||||
.append(AD_Reference_Value_ID).append(" AND l.Value=").append(tableName).append(".").append(columnSql)
|
.append(AD_Reference_Value_ID).append(" AND l.Value=").append(columnSql)
|
||||||
.append(" AND t.AD_Language='").append(Env.getAD_Language(Env.getCtx()))
|
.append(" AND t.AD_Language='").append(Env.getAD_Language(Env.getCtx()))
|
||||||
.append("') AS ").append(columnName);
|
.append("') AS ").append(columnName);
|
||||||
colClass = String.class;
|
colClass = String.class;
|
||||||
|
@ -489,6 +509,19 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
list.add(new ColumnInfo(Msg.translate(Env.getCtx(), columnName), colSql.toString(), colClass));
|
list.add(new ColumnInfo(Msg.translate(Env.getCtx(), columnName), colSql.toString(), colClass));
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest("Added Column=" + columnName);
|
if (log.isLoggable(Level.FINEST)) log.finest("Added Column=" + columnName);
|
||||||
}
|
}
|
||||||
|
else if (DisplayType.isLookup(displayType))
|
||||||
|
{
|
||||||
|
ColumnInfo colInfo = createLookupColumnInfo(Msg.translate(Env.getCtx(), columnName), columnName, displayType, AD_Reference_Value_ID, AD_Column_ID);
|
||||||
|
if (colInfo != null)
|
||||||
|
{
|
||||||
|
list.add(colInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (log.isLoggable(Level.FINEST)) log.finest("Not Added Column=" + columnName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if (log.isLoggable(Level.FINEST)) log.finest("Not Added Column=" + columnName);
|
if (log.isLoggable(Level.FINEST)) log.finest("Not Added Column=" + columnName);
|
||||||
}
|
}
|
||||||
|
@ -592,4 +625,22 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ColumnInfo createLookupColumnInfo(String name, String columnName, int AD_Reference_ID, int AD_Reference_Value_ID, int AD_Column_ID) {
|
||||||
|
// MLookupInfo lookupInfo = MLookupFactory.getLookupInfo(Env.getCtx(), p_WindowNo, AD_Column_ID, AD_Reference_ID, Env.getLanguage(Env.getCtx()), columnName,
|
||||||
|
// AD_Reference_Value_ID, false, null);
|
||||||
|
// String displayColumn = lookupInfo.DisplayColumn;
|
||||||
|
// String keyColumn = lookupInfo.KeyColumn;
|
||||||
|
|
||||||
|
String embedded = AD_Reference_Value_ID > 0 ? MLookupFactory.getLookup_TableEmbed(Env.getLanguage(Env.getCtx()), columnName, p_tableName, AD_Reference_Value_ID)
|
||||||
|
: MLookupFactory.getLookup_TableDirEmbed(Env.getLanguage(Env.getCtx()), columnName, p_tableName);
|
||||||
|
embedded = "(" + embedded + ")";
|
||||||
|
|
||||||
|
ColumnInfo columnInfo = null;
|
||||||
|
if (columnName.endsWith("_ID"))
|
||||||
|
columnInfo = new ColumnInfo(name, embedded, KeyNamePair.class, p_tableName+"."+columnName);
|
||||||
|
else
|
||||||
|
columnInfo = new ColumnInfo(name, embedded, String.class, null);
|
||||||
|
return columnInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue