Specify exactly which are the search fields
Implemented as discussed in forum thread. Sponsored by Metas GmbH. Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3016592
This commit is contained in:
parent
79764d2942
commit
7a4ad64e8e
|
@ -0,0 +1,25 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.compiere.model;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.adempiere.model.GridTabWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author teo_sarca
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Callout_AD_Column extends CalloutEngine
|
||||||
|
{
|
||||||
|
public String columnName (Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
|
||||||
|
{
|
||||||
|
I_AD_Column column = GridTabWrapper.create(mTab, I_AD_Column.class);
|
||||||
|
if (MColumn.isSuggestSelectionColumn(column.getColumnName(), true))
|
||||||
|
column.setIsSelectionColumn(true);
|
||||||
|
//
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ 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.Msg;
|
import org.compiere.util.Msg;
|
||||||
|
import org.compiere.util.Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persistent Column Model
|
* Persistent Column Model
|
||||||
|
@ -566,5 +567,24 @@ public class MColumn extends X_AD_Column
|
||||||
return DB.getSQLValue(trxName, sqlStmt, AD_Column_ID);
|
return DB.getSQLValue(trxName, sqlStmt, AD_Column_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean isSuggestSelectionColumn(String columnName, boolean caseSensitive)
|
||||||
|
{
|
||||||
|
if (Util.isEmpty(columnName, true))
|
||||||
|
return false;
|
||||||
|
//
|
||||||
|
if (columnName.equals("Value") || (!caseSensitive && columnName.equalsIgnoreCase("Value")))
|
||||||
|
return true;
|
||||||
|
else if (columnName.equals("Name") || (!caseSensitive && columnName.equalsIgnoreCase("Name")))
|
||||||
|
return true;
|
||||||
|
else if (columnName.equals("DocumentNo") || (!caseSensitive && columnName.equalsIgnoreCase("DocumentNo")))
|
||||||
|
return true;
|
||||||
|
else if (columnName.equals("Description") || (!caseSensitive && columnName.equalsIgnoreCase("Description")))
|
||||||
|
return true;
|
||||||
|
else if (columnName.indexOf("Name") != -1
|
||||||
|
|| (!caseSensitive && columnName.toUpperCase().indexOf("Name".toUpperCase()) != -1) )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // MColumn
|
} // MColumn
|
||||||
|
|
|
@ -77,6 +77,7 @@ import org.compiere.model.DataStatusListener;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridFieldVO;
|
import org.compiere.model.GridFieldVO;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
|
@ -512,6 +513,7 @@ public final class Find extends CDialog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
|
||||||
if (columnName.equals("Value"))
|
if (columnName.equals("Value"))
|
||||||
hasValue = true;
|
hasValue = true;
|
||||||
else if (columnName.equals("Name"))
|
else if (columnName.equals("Name"))
|
||||||
|
@ -520,10 +522,14 @@ public final class Find extends CDialog
|
||||||
hasDocNo = true;
|
hasDocNo = true;
|
||||||
else if (columnName.equals("Description"))
|
else if (columnName.equals("Description"))
|
||||||
hasDescription = true;
|
hasDescription = true;
|
||||||
else if (mField.isSelectionColumn())
|
else
|
||||||
|
/**/
|
||||||
|
if (mField.isSelectionColumn())
|
||||||
addSelectionColumn (mField);
|
addSelectionColumn (mField);
|
||||||
|
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
|
||||||
else if (columnName.indexOf("Name") != -1)
|
else if (columnName.indexOf("Name") != -1)
|
||||||
addSelectionColumn (mField);
|
addSelectionColumn (mField);
|
||||||
|
/**/
|
||||||
|
|
||||||
// TargetFields
|
// TargetFields
|
||||||
m_targetFields.put (new Integer(mField.getAD_Column_ID()), mField);
|
m_targetFields.put (new Integer(mField.getAD_Column_ID()), mField);
|
||||||
|
@ -1041,6 +1047,18 @@ public final class Find extends CDialog
|
||||||
GridField field = getTargetMField(ColumnName);
|
GridField field = getTargetMField(ColumnName);
|
||||||
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
||||||
String ColumnSQL = field.getColumnSQL(false);
|
String ColumnSQL = field.getColumnSQL(false);
|
||||||
|
//
|
||||||
|
// Be more permissive for String columns
|
||||||
|
if (isSearchLike(field))
|
||||||
|
{
|
||||||
|
String valueStr = value.toString().toUpperCase();
|
||||||
|
if (!valueStr.endsWith("%"))
|
||||||
|
valueStr += "%";
|
||||||
|
//
|
||||||
|
ColumnSQL = "UPPER("+ColumnSQL+")";
|
||||||
|
value = valueStr;
|
||||||
|
}
|
||||||
|
//
|
||||||
if (value.toString().indexOf('%') != -1)
|
if (value.toString().indexOf('%') != -1)
|
||||||
m_query.addRestriction(ColumnSQL, MQuery.LIKE, value, ColumnName, ved.getDisplay());
|
m_query.addRestriction(ColumnSQL, MQuery.LIKE, value, ColumnName, ved.getDisplay());
|
||||||
else if (isProductCategoryField && value instanceof Integer)
|
else if (isProductCategoryField && value instanceof Integer)
|
||||||
|
@ -1682,6 +1700,12 @@ public final class Find extends CDialog
|
||||||
return null;
|
return null;
|
||||||
} // getTargetMField
|
} // getTargetMField
|
||||||
|
|
||||||
|
private boolean isSearchLike(GridField field)
|
||||||
|
{
|
||||||
|
return DisplayType.isText(field.getDisplayType())
|
||||||
|
&& MColumn.isSuggestSelectionColumn(field.getColumnName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
private class ProxyRenderer implements TableCellRenderer
|
private class ProxyRenderer implements TableCellRenderer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
-- Jun 15, 2010 7:27:00 PM EEST
|
||||||
|
-- Disable automatic field selection in Find windows
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.Callout_AD_Column.columnName',Updated=TO_DATE('2010-06-15 19:27:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=116
|
||||||
|
;
|
||||||
|
|
||||||
|
UPDATE AD_Column SET IsSelectionColumn='Y'
|
||||||
|
WHERE IsSelectionColumn='N' AND (ColumnName IN ('Value', 'Name', 'Description') OR ColumnName LIKE '%Name%')
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
-- Jun 15, 2010 7:27:00 PM EEST
|
||||||
|
-- Disable automatic field selection in Find windows
|
||||||
|
UPDATE AD_Column SET Callout='org.compiere.model.Callout_AD_Column.columnName',Updated=TO_TIMESTAMP('2010-06-15 19:27:00','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Column_ID=116
|
||||||
|
;
|
||||||
|
|
||||||
|
UPDATE AD_Column SET IsSelectionColumn='Y'
|
||||||
|
WHERE IsSelectionColumn='N' AND (ColumnName IN ('Value', 'Name', 'Description') OR ColumnName LIKE '%Name%')
|
||||||
|
;
|
||||||
|
|
|
@ -61,6 +61,7 @@ import org.adempiere.webui.part.MultiTabPart;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.model.GridFieldVO;
|
import org.compiere.model.GridFieldVO;
|
||||||
import org.compiere.model.GridTab;
|
import org.compiere.model.GridTab;
|
||||||
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MLookupFactory;
|
import org.compiere.model.MLookupFactory;
|
||||||
import org.compiere.model.MProduct;
|
import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
|
@ -537,6 +538,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
|
||||||
if (columnName.equals("Value"))
|
if (columnName.equals("Value"))
|
||||||
hasValue = true;
|
hasValue = true;
|
||||||
else if (columnName.equals("Name"))
|
else if (columnName.equals("Name"))
|
||||||
|
@ -545,10 +547,14 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
hasDocNo = true;
|
hasDocNo = true;
|
||||||
else if (columnName.equals("Description"))
|
else if (columnName.equals("Description"))
|
||||||
hasDescription = true;
|
hasDescription = true;
|
||||||
else if (mField.isSelectionColumn())
|
else
|
||||||
|
/**/
|
||||||
|
if (mField.isSelectionColumn())
|
||||||
addSelectionColumn (mField);
|
addSelectionColumn (mField);
|
||||||
|
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
|
||||||
else if (columnName.indexOf("Name") != -1)
|
else if (columnName.indexOf("Name") != -1)
|
||||||
addSelectionColumn (mField);
|
addSelectionColumn (mField);
|
||||||
|
/**/
|
||||||
|
|
||||||
// TargetFields
|
// TargetFields
|
||||||
m_targetFields.put (new Integer(mField.getAD_Column_ID()), mField);
|
m_targetFields.put (new Integer(mField.getAD_Column_ID()), mField);
|
||||||
|
@ -745,6 +751,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
contentSimpleRows.appendChild(panel);
|
contentSimpleRows.appendChild(panel);
|
||||||
m_sEditors.add(editor);
|
m_sEditors.add(editor);
|
||||||
|
|
||||||
|
fieldLabel.addEventListener(Events.ON_OK,this);
|
||||||
} // addSelectionColumn
|
} // addSelectionColumn
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception
|
public void onEvent(Event event) throws Exception
|
||||||
|
@ -845,6 +852,15 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
cmd_ok_Advanced();
|
cmd_ok_Advanced();
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
// Check simple panel fields
|
||||||
|
for (WEditor editor : m_sEditors)
|
||||||
|
{
|
||||||
|
if (editor.getComponent() == event.getTarget())
|
||||||
|
{
|
||||||
|
cmd_ok_Simple();
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // onEvent
|
} // onEvent
|
||||||
|
@ -1339,9 +1355,21 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
if (field.isEncryptedColumn()) {
|
if (field.isEncryptedColumn()) {
|
||||||
value = SecureEngine.encrypt(value);
|
value = SecureEngine.encrypt(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
||||||
String ColumnSQL = field.getColumnSQL(false);
|
String ColumnSQL = field.getColumnSQL(false);
|
||||||
|
//
|
||||||
|
// Be more permissive for String columns
|
||||||
|
if (isSearchLike(field))
|
||||||
|
{
|
||||||
|
String valueStr = value.toString().toUpperCase();
|
||||||
|
if (!valueStr.endsWith("%"))
|
||||||
|
valueStr += "%";
|
||||||
|
//
|
||||||
|
ColumnSQL = "UPPER("+ColumnSQL+")";
|
||||||
|
value = valueStr;
|
||||||
|
}
|
||||||
|
//
|
||||||
if (value.toString().indexOf('%') != -1)
|
if (value.toString().indexOf('%') != -1)
|
||||||
m_query.addRestriction(ColumnSQL, MQuery.LIKE, value, ColumnName, wed.getDisplay());
|
m_query.addRestriction(ColumnSQL, MQuery.LIKE, value, ColumnName, wed.getDisplay());
|
||||||
else if (isProductCategoryField && value instanceof Integer)
|
else if (isProductCategoryField && value instanceof Integer)
|
||||||
|
@ -1782,5 +1810,11 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSearchLike(GridField field)
|
||||||
|
{
|
||||||
|
return DisplayType.isText(field.getDisplayType())
|
||||||
|
&& MColumn.isSuggestSelectionColumn(field.getColumnName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
} // FindPanel
|
} // FindPanel
|
Loading…
Reference in New Issue