IDEMPIERE-1540 Autocomplete for field type "Search" (#88)
Fix search column for auto complete
This commit is contained in:
parent
ed7952945a
commit
fc56a2a205
|
@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -618,7 +619,12 @@ public class MLookupFactory
|
||||||
retValue.DisplayColumn = lookupDisplayColumn;
|
retValue.DisplayColumn = lookupDisplayColumn;
|
||||||
retValue.InfoWindowId = infoWindowId;
|
retValue.InfoWindowId = infoWindowId;
|
||||||
retValue.QueryDirect = MRole.getDefault().addAccessSQL(directQuery, TableName, true, false);
|
retValue.QueryDirect = MRole.getDefault().addAccessSQL(directQuery, TableName, true, false);
|
||||||
|
List<String> lookupDisplayColumns = new ArrayList<String>();
|
||||||
|
if (isValueDisplayed)
|
||||||
|
lookupDisplayColumns.add("Value");
|
||||||
|
lookupDisplayColumns.add(lookupDisplayColumn != null ? lookupDisplayColumn : DisplayColumn);
|
||||||
s_cacheRefTable.put(key.toString(), retValue.cloneIt());
|
s_cacheRefTable.put(key.toString(), retValue.cloneIt());
|
||||||
|
retValue.lookupDisplayColumns = lookupDisplayColumns;
|
||||||
return retValue;
|
return retValue;
|
||||||
} // getLookup_Table
|
} // getLookup_Table
|
||||||
|
|
||||||
|
@ -850,6 +856,11 @@ public class MLookupFactory
|
||||||
msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery);
|
msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery);
|
||||||
lInfo.DisplayColumn = displayColumn.toString();
|
lInfo.DisplayColumn = displayColumn.toString();
|
||||||
lInfo.QueryDirect = MRole.getDefault().addAccessSQL(directQuery, TableName, true, false);
|
lInfo.QueryDirect = MRole.getDefault().addAccessSQL(directQuery, TableName, true, false);
|
||||||
|
List<String> lookupDisplayColumns = new ArrayList<String>();
|
||||||
|
for (LookupDisplayColumn ldc : list) {
|
||||||
|
lookupDisplayColumns.add(ldc.ColumnName);
|
||||||
|
}
|
||||||
|
lInfo.lookupDisplayColumns = lookupDisplayColumns;
|
||||||
s_cacheRefTable.put(cacheKey.toString(), lInfo.cloneIt());
|
s_cacheRefTable.put(cacheKey.toString(), lInfo.cloneIt());
|
||||||
return lInfo;
|
return lInfo;
|
||||||
} // getLookup_TableDir
|
} // getLookup_TableDir
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.io.Serializable;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -208,6 +209,8 @@ public class MLookupInfo implements Serializable, Cloneable
|
||||||
|
|
||||||
public int InfoWindowId;
|
public int InfoWindowId;
|
||||||
|
|
||||||
|
public List<String> lookupDisplayColumns = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
* @return info
|
* @return info
|
||||||
|
|
|
@ -21,6 +21,7 @@ import static org.compiere.model.SystemIDs.COLUMN_C_INVOICELINE_M_PRODUCT_ID;
|
||||||
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID;
|
import static org.compiere.model.SystemIDs.COLUMN_C_INVOICE_C_BPARTNER_ID;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -226,6 +227,15 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
|
||||||
.append(",")
|
.append(",")
|
||||||
.append("pagesize:")
|
.append("pagesize:")
|
||||||
.append(MAX_AUTO_COMPLETE_ROWS);
|
.append(MAX_AUTO_COMPLETE_ROWS);
|
||||||
|
if (lookup instanceof MLookup) {
|
||||||
|
MLookup mlookup = (MLookup) lookup;
|
||||||
|
List<String> displayColumns = mlookup.getLookupInfo().lookupDisplayColumns;
|
||||||
|
if (displayColumns != null && displayColumns.size() > 0) {
|
||||||
|
query.append(",")
|
||||||
|
.append("searchcolumn:")
|
||||||
|
.append(displayColumns.get(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
query.append("}");
|
query.append("}");
|
||||||
s = query.toString();
|
s = query.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -506,8 +506,11 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
||||||
isQueryByUser = true;
|
isQueryByUser = true;
|
||||||
for (int i = 0; i < identifiers.size(); i++) {
|
for (int i = 0; i < identifiers.size(); i++) {
|
||||||
WEditor editor = identifiers.get(i);
|
WEditor editor = identifiers.get(i);
|
||||||
if (isAutoComplete && i > 0) {
|
if (isAutoComplete) {
|
||||||
break;
|
if (!Util.isEmpty(autoCompleteSearchColumn)) {
|
||||||
|
if (!editor.getColumnName().equals(autoCompleteSearchColumn))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
editor.setValue(queryValue);
|
editor.setValue(queryValue);
|
||||||
|
@ -516,6 +519,8 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
||||||
}
|
}
|
||||||
|
|
||||||
testCount(false);
|
testCount(false);
|
||||||
|
if (isAutoComplete)
|
||||||
|
break;
|
||||||
if (m_count > 0) {
|
if (m_count > 0) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1452,8 +1457,7 @@ public class InfoWindow extends InfoPanel implements ValueChangeListener, EventL
|
||||||
row.appendChild(checkAND);
|
row.appendChild(checkAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isAutoComplete)
|
evalDisplayLogic();
|
||||||
evalDisplayLogic();
|
|
||||||
if (!update)
|
if (!update)
|
||||||
initParameters();
|
initParameters();
|
||||||
if (!isAutoComplete)
|
if (!isAutoComplete)
|
||||||
|
|
|
@ -160,22 +160,32 @@ public class InfoGeneralPanel extends InfoPanel implements EventListener<Event>
|
||||||
if (queryValue != null && queryValue.length() > 0)
|
if (queryValue != null && queryValue.length() > 0)
|
||||||
{
|
{
|
||||||
Textbox[] txts = new Textbox[] {txt1, txt2, txt3, txt4};
|
Textbox[] txts = new Textbox[] {txt1, txt2, txt3, txt4};
|
||||||
|
int i = 0;
|
||||||
for(Textbox t : txts)
|
for(Textbox t : txts)
|
||||||
{
|
{
|
||||||
if (t != null && t.isVisible())
|
if (t != null && t.isVisible())
|
||||||
{
|
{
|
||||||
|
if (isAutoComplete)
|
||||||
|
{
|
||||||
|
if (!Util.isEmpty(autoCompleteSearchColumn))
|
||||||
|
{
|
||||||
|
if (!autoCompleteSearchColumn.equals(m_queryColumns.get(i)))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
t.setValue(queryValue);
|
t.setValue(queryValue);
|
||||||
testCount();
|
testCount();
|
||||||
if (m_count <= 0)
|
if (m_count <= 0)
|
||||||
t.setValue(null);
|
t.setValue(null);
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
if (isAutoComplete)
|
if (isAutoComplete)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
if (m_count <= 0)
|
if (m_count <= 0 && !isAutoComplete)
|
||||||
{
|
{
|
||||||
txt1.setValue(queryValue);
|
txt1.setValue(queryValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,6 +318,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
if (t > 0)
|
if (t > 0)
|
||||||
this.pageSize = t;
|
this.pageSize = t;
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
} else if (pair[0].equalsIgnoreCase("searchcolumn")) {
|
||||||
|
this.autoCompleteSearchColumn = pair[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -462,6 +464,8 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
|
||||||
|
|
||||||
protected int queryTimeout = 0;
|
protected int queryTimeout = 0;
|
||||||
|
|
||||||
|
protected String autoCompleteSearchColumn = null;
|
||||||
|
|
||||||
protected String queryValue;
|
protected String queryValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue