From afb50f10e00a94358ac283049ede72092bc5b4b0 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 23 Oct 2012 06:48:06 +0800 Subject: [PATCH] IDEMPIERE-377 Improve current search dialog box. Fixed can't search using invisible lookup field ( for e.g, CreatedBy and UpdatedBy ). --- .../src/org/compiere/model/GridField.java | 19 ++++++++-- .../src/org/compiere/model/GridFieldVO.java | 38 +++++++++++-------- .../adempiere/webui/window/FindWindow.java | 10 +++-- 3 files changed, 46 insertions(+), 21 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridField.java b/org.adempiere.base/src/org/compiere/model/GridField.java index a0ada2cd8f..f9a2f2ed30 100644 --- a/org.adempiere.base/src/org/compiere/model/GridField.java +++ b/org.adempiere.base/src/org/compiere/model/GridField.java @@ -178,9 +178,7 @@ public class GridField m_vo.lookupInfo.DisplayType = DisplayType.Search; } // - m_vo.lookupInfo.IsKey = isKey(); - MLookup ml = new MLookup (m_vo.lookupInfo, m_vo.TabNo); - m_lookup = ml; + loadLookupNoValidate(); } else if (m_vo.displayType == DisplayType.Location) // not cached { @@ -209,6 +207,21 @@ public class GridField } } // m_lookup + /*** + * bypass isdisplay validation, used by findwindow + */ + public void loadLookupNoValidate() { + if (m_vo.lookupInfo == null) { + m_vo.loadLookupInfo(); + } + if (m_vo.lookupInfo == null) { + return; + } + m_vo.lookupInfo.IsKey = isKey(); + MLookup ml = new MLookup (m_vo.lookupInfo, m_vo.TabNo); + m_lookup = ml; + } + /** * Wait until Load is complete */ diff --git a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java index 3c62928b06..2363a51ac8 100644 --- a/org.adempiere.base/src/org/compiere/model/GridFieldVO.java +++ b/org.adempiere.base/src/org/compiere/model/GridFieldVO.java @@ -582,24 +582,32 @@ public class GridFieldVO implements Serializable // Create Lookup, if not ID if (DisplayType.isLookup(displayType) && IsDisplayed) { - try - { - lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, AD_Column_ID, displayType, - Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, - IsParent, ValidationCode); - if (lookupInfo == null) - displayType = DisplayType.ID; - else - lookupInfo.InfoFactoryClass = this.InfoFactoryClass; - } - catch (Exception e) // Cannot create Lookup - { - CLogger.get().log(Level.SEVERE, "No LookupInfo for " + ColumnName, e); - displayType = DisplayType.ID; - } + loadLookupInfo(); } } // initFinish + /** + * load lookup info. + * used by findwindow to loadlookupinfo for invisible field + */ + public void loadLookupInfo() { + try + { + lookupInfo = MLookupFactory.getLookupInfo (ctx, WindowNo, AD_Column_ID, displayType, + Env.getLanguage(ctx), ColumnName, AD_Reference_Value_ID, + IsParent, ValidationCode); + if (lookupInfo == null) + displayType = DisplayType.ID; + else + lookupInfo.InfoFactoryClass = this.InfoFactoryClass; + } + catch (Exception e) // Cannot create Lookup + { + CLogger.get().log(Level.SEVERE, "No LookupInfo for " + ColumnName, e); + displayType = DisplayType.ID; + } + } + /** * Clone Field. * @param Ctx ctx diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index 2f33c99abd..fb31455f3c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -1626,7 +1626,11 @@ public class FindWindow extends Window implements EventListener, ValueCha } else { - editor = WebEditorFactory.getEditor(field, true); + //lookupinfo is null for invisible field + if (DisplayType.isLookup(field.getDisplayType()) && field.getLookup() == null) { + field.loadLookupNoValidate(); + } + editor = WebEditorFactory.getEditor(field, true); } if (editor == null) editor = new WStringEditor(field); @@ -1634,8 +1638,8 @@ public class FindWindow extends Window implements EventListener, ValueCha field.addPropertyChangeListener(editor); editor.addValueChangeListener(this); editor.setValue(null); - editor.setReadWrite(enabled); - editor.setVisible(enabled); + editor.setReadWrite(true); + editor.setVisible(true); editor.dynamicDisplay(); // return editor.getComponent();