IDEMPIERE-1105 The find advanced, automatically replaces the current record values / fix init window - refactoring for performance
This commit is contained in:
parent
f36853a3d7
commit
b91f9e76bf
|
@ -30,7 +30,6 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
@ -80,7 +79,6 @@ import org.compiere.model.MQuery;
|
||||||
import org.compiere.model.MRole;
|
import org.compiere.model.MRole;
|
||||||
import org.compiere.model.MTable;
|
import org.compiere.model.MTable;
|
||||||
import org.compiere.model.MUserQuery;
|
import org.compiere.model.MUserQuery;
|
||||||
import org.compiere.model.X_AD_Column;
|
|
||||||
import org.compiere.util.AdempiereSystemError;
|
import org.compiere.util.AdempiereSystemError;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
|
@ -120,7 +118,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5019862772740854656L;
|
private static final long serialVersionUID = 3901459797939709594L;
|
||||||
|
|
||||||
// values and label for history combo
|
// values and label for history combo
|
||||||
private static final String HISTORY_DAY_ALL = "All";
|
private static final String HISTORY_DAY_ALL = "All";
|
||||||
|
@ -163,14 +161,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
//
|
//
|
||||||
/** List of WEditors */
|
/** List of WEditors */
|
||||||
private ArrayList<WEditor> m_sEditors = new ArrayList<WEditor>();
|
private ArrayList<WEditor> m_sEditors = new ArrayList<WEditor>();
|
||||||
/** Target Fields with AD_Column_ID as key */
|
|
||||||
private Hashtable<Integer,GridField> m_targetFields = new Hashtable<Integer,GridField>();
|
|
||||||
/** For Grid Controller */
|
/** For Grid Controller */
|
||||||
public static final int TABNO = 99;
|
public static final int TABNO = 99;
|
||||||
/** Length of Fields on first tab */
|
/** Length of Fields on first tab */
|
||||||
public static final int FIELDLENGTH = 20;
|
public static final int FIELDLENGTH = 20;
|
||||||
/** Reference ID for Yes/No */
|
|
||||||
public static final int AD_REFERENCE_ID_YESNO = REFERENCE_YESNO;
|
|
||||||
|
|
||||||
private int m_AD_Tab_ID = 0;
|
private int m_AD_Tab_ID = 0;
|
||||||
private MUserQuery[] userQueries;
|
private MUserQuery[] userQueries;
|
||||||
|
@ -615,53 +609,53 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
{
|
{
|
||||||
GridField mField = m_findFields[i];
|
GridField mField = m_findFields[i];
|
||||||
|
|
||||||
// Make Yes-No searchable as list
|
if (mField.isSelectionColumn()) {
|
||||||
if (mField.getVO().displayType == DisplayType.YesNo)
|
if (mField.getVO().displayType == DisplayType.YesNo) {
|
||||||
{
|
// Make Yes-No searchable as list
|
||||||
GridFieldVO vo = mField.getVO();
|
GridFieldVO vo = mField.getVO();
|
||||||
GridFieldVO ynvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
|
GridFieldVO ynvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
|
||||||
ynvo.IsDisplayed = true;
|
ynvo.IsDisplayed = true;
|
||||||
ynvo.displayType = DisplayType.List;
|
ynvo.displayType = DisplayType.List;
|
||||||
ynvo.AD_Reference_Value_ID = AD_REFERENCE_ID_YESNO;
|
ynvo.AD_Reference_Value_ID = REFERENCE_YESNO;
|
||||||
|
|
||||||
ynvo.lookupInfo = MLookupFactory.getLookupInfo (ynvo.ctx, ynvo.WindowNo, ynvo.AD_Column_ID, ynvo.displayType,
|
ynvo.lookupInfo = MLookupFactory.getLookupInfo (ynvo.ctx, ynvo.WindowNo, ynvo.AD_Column_ID, ynvo.displayType,
|
||||||
Env.getLanguage(ynvo.ctx), ynvo.ColumnName, ynvo.AD_Reference_Value_ID,
|
Env.getLanguage(ynvo.ctx), ynvo.ColumnName, ynvo.AD_Reference_Value_ID,
|
||||||
ynvo.IsParent, ynvo.ValidationCode);
|
ynvo.IsParent, ynvo.ValidationCode);
|
||||||
|
|
||||||
GridField ynfield = new GridField(ynvo);
|
GridField ynfield = new GridField(ynvo);
|
||||||
|
|
||||||
// replace the original field by the YN List field
|
// replace the original field by the YN List field
|
||||||
m_findFields[i] = ynfield;
|
m_findFields[i] = ynfield;
|
||||||
mField = ynfield;
|
mField = ynfield;
|
||||||
}
|
} else if ( mField.getVO().displayType == DisplayType.Button ) {
|
||||||
|
// Make Buttons searchable
|
||||||
|
GridFieldVO vo = mField.getVO();
|
||||||
|
if ( vo.AD_Reference_Value_ID > 0 )
|
||||||
|
{
|
||||||
|
GridFieldVO postedvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
|
||||||
|
postedvo.IsDisplayed = true;
|
||||||
|
postedvo.displayType = DisplayType.List;
|
||||||
|
|
||||||
// Make Buttons searchable
|
postedvo.lookupInfo = MLookupFactory.getLookupInfo (postedvo.ctx, postedvo.WindowNo, postedvo.AD_Column_ID, postedvo.displayType,
|
||||||
if ( mField.getVO().displayType == DisplayType.Button )
|
Env.getLanguage(postedvo.ctx), postedvo.ColumnName, postedvo.AD_Reference_Value_ID,
|
||||||
{
|
postedvo.IsParent, postedvo.ValidationCode);
|
||||||
GridFieldVO vo = mField.getVO();
|
|
||||||
if ( vo.AD_Reference_Value_ID > 0 )
|
|
||||||
{
|
|
||||||
GridFieldVO postedvo = vo.clone(vo.ctx, vo.WindowNo, vo.TabNo, vo.AD_Window_ID, vo.AD_Tab_ID, vo.tabReadOnly);
|
|
||||||
postedvo.IsDisplayed = true;
|
|
||||||
postedvo.displayType = DisplayType.List;
|
|
||||||
|
|
||||||
postedvo.lookupInfo = MLookupFactory.getLookupInfo (postedvo.ctx, postedvo.WindowNo, postedvo.AD_Column_ID, postedvo.displayType,
|
GridField postedfield = new GridField(postedvo);
|
||||||
Env.getLanguage(postedvo.ctx), postedvo.ColumnName, postedvo.AD_Reference_Value_ID,
|
|
||||||
postedvo.IsParent, postedvo.ValidationCode);
|
|
||||||
|
|
||||||
GridField postedfield = new GridField(postedvo);
|
// replace the original field by the Posted List field
|
||||||
|
m_findFields[i] = postedfield;
|
||||||
// replace the original field by the Posted List field
|
mField = postedfield;
|
||||||
m_findFields[i] = postedfield;
|
}
|
||||||
mField = postedfield;
|
} else {
|
||||||
}
|
// clone the field and clean gridtab - IDEMPIERE-1105
|
||||||
}
|
GridField findField = (GridField) mField.clone(m_findCtx);
|
||||||
|
findField.setGridTab(null);
|
||||||
if (mField.isSelectionColumn())
|
m_findFields[i] = findField;
|
||||||
|
mField = findField;
|
||||||
|
}
|
||||||
gridFieldList.add(mField);
|
gridFieldList.add(mField);
|
||||||
|
} // isSelectionColumn
|
||||||
|
|
||||||
// TargetFields
|
|
||||||
m_targetFields.put (new Integer(mField.getAD_Column_ID()), mField);
|
|
||||||
} // for all target tab fields
|
} // for all target tab fields
|
||||||
|
|
||||||
|
|
||||||
|
@ -1324,7 +1318,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
//
|
//
|
||||||
GridField field = getTargetMField(ColumnName);
|
GridField field = getTargetMField(ColumnName);
|
||||||
if(field == null) continue; // Elaine 2008/07/29
|
if(field == null) continue; // Elaine 2008/07/29
|
||||||
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
boolean isProductCategoryField = isProductCategoryField(field.getColumnName());
|
||||||
String ColumnSQL = field.getColumnSQL(false);
|
String ColumnSQL = field.getColumnSQL(false);
|
||||||
// Left brackets
|
// Left brackets
|
||||||
Listbox listLeftBracket = (Listbox)row.getFellow("listLeftBracket"+row.getId());
|
Listbox listLeftBracket = (Listbox)row.getFellow("listLeftBracket"+row.getId());
|
||||||
|
@ -1755,7 +1749,7 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
value = SecureEngine.encrypt(value, Env.getAD_Client_ID(Env.getCtx()));
|
value = SecureEngine.encrypt(value, Env.getAD_Client_ID(Env.getCtx()));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID());
|
boolean isProductCategoryField = isProductCategoryField(field.getColumnName());
|
||||||
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
|
StringBuilder ColumnSQL = new StringBuilder(field.getColumnSQL(false));
|
||||||
//
|
//
|
||||||
// Be more permissive for String columns
|
// Be more permissive for String columns
|
||||||
|
@ -1847,10 +1841,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
DB.close(m_pstmt);
|
DB.close(m_pstmt);
|
||||||
m_pstmt = null;
|
m_pstmt = null;
|
||||||
|
|
||||||
// TargetFields
|
|
||||||
if (m_targetFields != null)
|
|
||||||
m_targetFields.clear();
|
|
||||||
m_targetFields = null;
|
|
||||||
//
|
//
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
||||||
|
@ -1951,16 +1941,11 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the given column.
|
* Checks the given column.
|
||||||
* @param columnId
|
* @param columnName
|
||||||
* @return true if the column is a product category column
|
* @return true if the column is a product category column
|
||||||
**/
|
**/
|
||||||
private boolean isProductCategoryField(int columnId) {
|
private boolean isProductCategoryField(String columnName) {
|
||||||
X_AD_Column col = new X_AD_Column(Env.getCtx(), columnId, null);
|
return MProduct.COLUMNNAME_M_Product_Category_ID.equals(columnName);
|
||||||
if (col.get_ID() == 0) {
|
|
||||||
return false; // column not found...
|
|
||||||
}
|
|
||||||
return MProduct.COLUMNNAME_M_Product_Category_ID.equals(col.getColumnName());
|
|
||||||
|
|
||||||
} // isProductCategoryField
|
} // isProductCategoryField
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1973,15 +1958,16 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
//if a node with this id is found later in the search we have a loop in the tree
|
//if a node with this id is found later in the search we have a loop in the tree
|
||||||
int subTreeRootParentId = 0;
|
int subTreeRootParentId = 0;
|
||||||
StringBuilder retString = new StringBuilder(" M_Product_Category_ID IN (");
|
StringBuilder retString = new StringBuilder(" M_Product_Category_ID IN (");
|
||||||
String sql = " SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category";
|
String sql = "SELECT M_Product_Category_ID, M_Product_Category_Parent_ID FROM M_Product_Category WHERE AD_Client_ID=? AND IsActive='Y'";
|
||||||
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
|
final Vector<SimpleTreeNode> categories = new Vector<SimpleTreeNode>(100);
|
||||||
Statement stmt = null;
|
PreparedStatement pstmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
stmt = DB.createStatement();
|
pstmt = DB.prepareStatement(sql, null);
|
||||||
rs = stmt.executeQuery(sql);
|
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
|
||||||
|
rs = pstmt.executeQuery();
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
if(rs.getInt(1)==productCategoryId) {
|
if (rs.getInt(1) == productCategoryId) {
|
||||||
subTreeRootParentId = rs.getInt(2);
|
subTreeRootParentId = rs.getInt(2);
|
||||||
}
|
}
|
||||||
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
|
categories.add(new SimpleTreeNode(rs.getInt(1), rs.getInt(2)));
|
||||||
|
@ -1996,9 +1982,8 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
|
||||||
retString = new StringBuilder();
|
retString = new StringBuilder();
|
||||||
}
|
}
|
||||||
finally{
|
finally{
|
||||||
DB.close(rs,stmt);
|
DB.close(rs, pstmt);
|
||||||
rs = null;
|
rs = null; pstmt = null;
|
||||||
stmt = null;
|
|
||||||
}
|
}
|
||||||
return retString.toString();
|
return retString.toString();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue