diff --git a/migration/i1.0a-release/oracle/2013012430719_IDEMPIERE-90.sql b/migration/i1.0a-release/oracle/2013012430719_IDEMPIERE-90.sql new file mode 100644 index 0000000000..eab6751c50 --- /dev/null +++ b/migration/i1.0a-release/oracle/2013012430719_IDEMPIERE-90.sql @@ -0,0 +1,40 @@ +-- Jan 24, 2013 12:10:51 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Element_UU,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,202202,'7d389ba2-a5c9-4a9f-a93c-a42588b6e62d',0,'IsShortList',TO_DATE('2013-01-24 12:10:49','YYYY-MM-DD HH24:MI:SS'),100,'This record is in the short list','D','The most used records could be set into the short list in order to be selected faster','Y','Short list','Short list',TO_DATE('2013-01-24 12:10:49','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Jan 24, 2013 12:10:51 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=202202 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Jan 24, 2013 12:11:24 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200136,'a8e26155-174f-4fdb-b575-ba4bd3fe0523',0,TO_DATE('2013-01-24 12:11:23','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','All records','I',TO_DATE('2013-01-24 12:11:23','YYYY-MM-DD HH24:MI:SS'),100,'ShortListListAllItems') +; + +-- Jan 24, 2013 12:11:24 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200136 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Jan 24, 2013 12:11:32 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200137,'eb83b9c3-95c6-4324-870b-975965aa033f',0,TO_DATE('2013-01-24 12:11:32','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Short list items','I',TO_DATE('2013-01-24 12:11:32','YYYY-MM-DD HH24:MI:SS'),100,'ShortListShortListItems') +; + +-- Jan 24, 2013 12:11:32 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200137 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Jan 24, 2013 12:11:41 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200138,'ac962f08-3465-4be3-b330-ba0b4e8e388f',0,TO_DATE('2013-01-24 12:11:40','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Short list / All','I',TO_DATE('2013-01-24 12:11:40','YYYY-MM-DD HH24:MI:SS'),100,'ShortListSwitchSearchMode') +; + +-- Jan 24, 2013 12:11:41 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200138 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + diff --git a/migration/i1.0a-release/postgresql/2013012430719_IDEMPIERE-90.sql b/migration/i1.0a-release/postgresql/2013012430719_IDEMPIERE-90.sql new file mode 100644 index 0000000000..6ace886f75 --- /dev/null +++ b/migration/i1.0a-release/postgresql/2013012430719_IDEMPIERE-90.sql @@ -0,0 +1,40 @@ +-- Jan 24, 2013 12:10:51 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Element_UU,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,202202,'7d389ba2-a5c9-4a9f-a93c-a42588b6e62d',0,'IsShortList',TO_TIMESTAMP('2013-01-24 12:10:49','YYYY-MM-DD HH24:MI:SS'),100,'This record is in the short list','D','The most used records could be set into the short list in order to be selected faster','Y','Short list','Short list',TO_TIMESTAMP('2013-01-24 12:10:49','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Jan 24, 2013 12:10:51 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=202202 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID) +; + +-- Jan 24, 2013 12:11:24 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200136,'a8e26155-174f-4fdb-b575-ba4bd3fe0523',0,TO_TIMESTAMP('2013-01-24 12:11:23','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','All records','I',TO_TIMESTAMP('2013-01-24 12:11:23','YYYY-MM-DD HH24:MI:SS'),100,'ShortListListAllItems') +; + +-- Jan 24, 2013 12:11:24 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200136 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Jan 24, 2013 12:11:32 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200137,'eb83b9c3-95c6-4324-870b-975965aa033f',0,TO_TIMESTAMP('2013-01-24 12:11:32','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Short list items','I',TO_TIMESTAMP('2013-01-24 12:11:32','YYYY-MM-DD HH24:MI:SS'),100,'ShortListShortListItems') +; + +-- Jan 24, 2013 12:11:32 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200137 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + +-- Jan 24, 2013 12:11:41 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200138,'ac962f08-3465-4be3-b330-ba0b4e8e388f',0,TO_TIMESTAMP('2013-01-24 12:11:40','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Short list / All','I',TO_TIMESTAMP('2013-01-24 12:11:40','YYYY-MM-DD HH24:MI:SS'),100,'ShortListSwitchSearchMode') +; + +-- Jan 24, 2013 12:11:41 PM CET +-- IDEMPIERE 90 +INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200138 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID) +; + diff --git a/org.adempiere.base/src/org/compiere/model/Lookup.java b/org.adempiere.base/src/org/compiere/model/Lookup.java index e3bafc583e..b74d8a15f0 100644 --- a/org.adempiere.base/src/org/compiere/model/Lookup.java +++ b/org.adempiere.base/src/org/compiere/model/Lookup.java @@ -76,6 +76,8 @@ public abstract class Lookup extends AbstractListModel private boolean m_loaded; + private boolean m_shortList; // IDEMPIERE 90 + /** * Get Display Type * @return display type @@ -259,7 +261,7 @@ public abstract class Lookup extends AbstractListModel * @param temporary save current values - restore via fillComboBox (true) */ public void fillComboBox (boolean mandatory, boolean onlyValidated, - boolean onlyActive, boolean temporary) + boolean onlyActive, boolean temporary, boolean shortList) // IDEMPIERE 90 { long startTime = System.currentTimeMillis(); m_loaded = false; @@ -279,7 +281,7 @@ public abstract class Lookup extends AbstractListModel p_data.clear(); // may cause delay *** The Actual Work *** - p_data = getData (mandatory, onlyValidated, onlyActive, temporary); + p_data = getData (mandatory, onlyValidated, onlyActive, temporary, shortList); // IDEMPIERE 90 // Selected Object changed if (obj != m_selectedObject) @@ -335,7 +337,7 @@ public abstract class Lookup extends AbstractListModel return; } if (p_data != null) - fillComboBox(isMandatory(), true, true, false); + fillComboBox(isMandatory(), true, true, false, false); // IDEMPIERE 90 } // fillComboBox @@ -363,7 +365,7 @@ public abstract class Lookup extends AbstractListModel * @return ArrayList */ public abstract ArrayList getData (boolean mandatory, - boolean onlyValidated, boolean onlyActive, boolean temporary); + boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist); // IDEMPIERE 90 /** * Get underlying fully qualified Table.Column Name. @@ -503,5 +505,16 @@ public abstract class Lookup extends AbstractListModel { return m_loaded; } - + + // IDEMPIERE 90 + public void setShortList(boolean shortlist) + { + m_shortList = shortlist; + } + + public boolean isShortList() + { + return m_shortList; + } + // IDEMPIERE 90 } // Lookup diff --git a/org.adempiere.base/src/org/compiere/model/MAccountLookup.java b/org.adempiere.base/src/org/compiere/model/MAccountLookup.java index 1f08b62883..4ee55f2d48 100644 --- a/org.adempiere.base/src/org/compiere/model/MAccountLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MAccountLookup.java @@ -173,7 +173,7 @@ public final class MAccountLookup extends Lookup implements Serializable * @return ArrayList with KeyNamePair */ public ArrayList getData (boolean mandatory, boolean onlyValidated, - boolean onlyActive, boolean temporary) + boolean onlyActive, boolean temporary, boolean isshortlist) // IDEMPIERE 90 { ArrayList list = new ArrayList(); if (!mandatory) diff --git a/org.adempiere.base/src/org/compiere/model/MLocationLookup.java b/org.adempiere.base/src/org/compiere/model/MLocationLookup.java index 85f3b3286d..91c8d8747b 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocationLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLocationLookup.java @@ -144,7 +144,7 @@ public final class MLocationLookup extends Lookup * @param temporary force load for temporary display * @return null */ - public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary) + public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) // IDEMPIERE 90 { log.log(Level.SEVERE, "not implemented"); return null; diff --git a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java index 26c2b17a36..9bddcbeac2 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLocatorLookup.java @@ -414,7 +414,7 @@ public final class MLocatorLookup extends Lookup implements Serializable * @param temporary force load for temporary display * @return ArrayList of lookup values */ - public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary) + public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) // IDEMPIERE 90 { // create list Collection collection = getData(); diff --git a/org.adempiere.base/src/org/compiere/model/MLookup.java b/org.adempiere.base/src/org/compiere/model/MLookup.java index 7fb3a8331b..4af0858f21 100644 --- a/org.adempiere.base/src/org/compiere/model/MLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MLookup.java @@ -103,7 +103,6 @@ public final class MLookup extends Lookup implements Serializable /** Indicator for Null */ private static Integer MINUS_ONE = new Integer(-1); - /** The Lookup Info Value Object */ private MLookupInfo m_info = null; @@ -122,7 +121,14 @@ public final class MLookup extends Lookup implements Serializable private boolean m_refreshing = false; /** Next Read for Parent */ private long m_nextRead = 0; - + + /** Not in short List item Marker Start IDEMPIERE 90 */ + public static final String SHORTLIST_S = "*"; + /** Not in short List item Marker End IDEMPIERE 90 */ + public static final String SHORTLIST_E = "*"; + + private boolean m_hasShortListItems = false; // IDEMPIERE 90 + /** * Dispose */ @@ -391,9 +397,10 @@ public final class MLookup extends Lookup implements Serializable * @param onlyValidated only validated * @param onlyActive only active * @param temporary force load for temporary display + * @param isshortlist * @return list */ - public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary) + public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) // idempiere 90 { // create list ArrayList list = getData (onlyValidated, true); @@ -414,6 +421,23 @@ public final class MLookup extends Lookup implements Serializable } } + // Remove non short list items IDEMPIERE 90 + if (shortlist && m_hasShortListItems) + { + // list from the back + for (int i = list.size(); i > 0; i--) + { + Object o = list.get(i-1); + if (o != null) + { + String s = o.toString(); + if (s.startsWith(SHORTLIST_S) && s.endsWith(SHORTLIST_E)) + list.remove(i-1); + } + } + } + // End Remove non short list items IDEMPIERE 90 + // Add Optional (empty) selection if (!mandatory) { @@ -597,7 +621,7 @@ public final class MLookup extends Lookup implements Serializable m_refreshing = true; //force refresh m_lookup.clear(); - fillComboBox(isMandatory(), true, true, false); + fillComboBox(isMandatory(), true, true, false, isShortList()); // idempiere 90 m_refreshing = false; return m_lookup.size(); } // refresh @@ -677,6 +701,17 @@ public final class MLookup extends Lookup implements Serializable MLookupCache.loadStart (m_info); StringBuilder sql = new StringBuilder().append(m_info.Query); + // IDEMPIERE 90 + if (isShortList()) + { + // Adding ", IsShortList" to the sql SELECT clause + int posFirstPoint = sql.indexOf("."); + String tableName = sql.substring(7, posFirstPoint); + int posFirstFrom = sql.indexOf(tableName+".IsActive FROM "+tableName) + tableName.length() + 9 ; // 9 = .IsActive + String ClauseFromWhereOrder = sql.substring(posFirstFrom, sql.length()); + sql = new StringBuilder(sql.substring(0, posFirstFrom) + ", " + tableName + ".IsShortList" + ClauseFromWhereOrder); + } // IDEMPIERE 90 + // not validated if (!m_info.IsValidated) { @@ -768,6 +803,17 @@ public final class MLookup extends Lookup implements Serializable name = new StringBuilder(INACTIVE_S).append(name).append(INACTIVE_E); m_hasInactive = true; } + // IDEMPIERE 90 + if (isShortList()) + { + boolean isShortListItem = rs.getString(5).equals("Y"); + if (!isShortListItem) + { + name = new StringBuilder(SHORTLIST_S).append(name).append(SHORTLIST_S); + m_hasShortListItems = true; + } + } + // IDEMPIERE 90 if (isNumber) { int key = rs.getInt(1); diff --git a/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java b/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java index 08471716b7..2f0b4556d2 100644 --- a/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MPAttributeLookup.java @@ -168,7 +168,7 @@ public class MPAttributeLookup extends Lookup * @param temporary force load for temporary display * @return null */ - public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary) + public ArrayList getData (boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) // IDEMPIERE 90 { log.log(Level.SEVERE, "Not implemented"); return null; diff --git a/org.adempiere.base/src/org/compiere/model/MPaymentLookup.java b/org.adempiere.base/src/org/compiere/model/MPaymentLookup.java index 1aad341ce0..9d0610145b 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaymentLookup.java +++ b/org.adempiere.base/src/org/compiere/model/MPaymentLookup.java @@ -199,7 +199,7 @@ public class MPaymentLookup extends Lookup implements Serializable { @Override public ArrayList getData(boolean mandatory, boolean onlyValidated, - boolean onlyActive, boolean temporary) { + boolean onlyActive, boolean temporary, boolean shortlist) { // IDEMPIERE 90 ArrayList list = new ArrayList(); ValueNamePair[] values = getData(); @@ -220,7 +220,7 @@ public class MPaymentLookup extends Lookup implements Serializable { @Override public int refresh() { - fillComboBox(isMandatory(), true, true, false); + fillComboBox(isMandatory(), true, true, false, false); // IDEMPIERE 90 return super.getSize(); } } diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java b/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java index 478648521b..b9b32f5e3c 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/XLookup.java @@ -125,7 +125,7 @@ public class XLookup extends Lookup * @return list of data */ public ArrayList getData (boolean mandatory, - boolean onlyValidated, boolean onlyActive, boolean temporary) + boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) // IDEMPIERE 90 { ArrayList list = new ArrayList(p_data); diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java index 7811783123..736c3cd8fb 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLocatorDialog.java @@ -243,7 +243,7 @@ public class VLocatorDialog extends CDialog log.fine("Warehouses=" + fWarehouse.getItemCount()); // Load existing Locators - m_mLocator.fillComboBox(m_mandatory, true, true, false); + m_mLocator.fillComboBox(m_mandatory, true, true, false, false); // IDEMPIERE 90 log.fine(m_mLocator.toString()); fLocator.setModel(m_mLocator); fLocator.setValue(m_M_Locator_ID); diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java index fd65f8c548..8c7406b950 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VLookup.java @@ -64,6 +64,7 @@ import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; import org.compiere.model.MQuery; import org.compiere.model.MRole; +import org.compiere.model.MTable; import org.compiere.swing.CButton; import org.compiere.swing.CMenuItem; import org.compiere.swing.CTextField; @@ -272,12 +273,39 @@ public class VLookup extends JComponent else m_button.setIcon(Env.getImageIcon("PickOpen10.gif")); + // IDEMPIERE 90 + boolean isShortListAvailable = false; // Short List available for this lookup + if (m_lookup != null && (m_lookup.getDisplayType() == DisplayType.TableDir || m_lookup.getDisplayType() == DisplayType.Table)) // only for Table & TableDir + { + String tableName_temp = m_lookup.getColumnName(); // Returns AD_Org.AD_Org_ID + int posPoint = tableName_temp.indexOf("."); + String tableName = tableName_temp.substring(0, posPoint); + int table_id = MTable.getTable_ID(tableName); // now we got the ad_table_id + + String sql = "SELECT COUNT(*) FROM AD_Column WHERE ColumnName = 'IsShortList' AND IsActive='Y' AND AD_Table_ID = " + table_id; + isShortListAvailable = DB.getSQLValue(null, sql) == 1; // if the table has an active IsShortList column, we could use the restrict search ! + + if (isShortListAvailable) + { + setComboShortList(true); + m_lookup.setShortList(true); + + m_buttonSL.addActionListener(this); + m_buttonSL.addMouseListener(mouseAdapter); + m_buttonSL.setFocusable(false); // don't focus when tabbing + m_buttonSL.setMargin(new Insets(0, 0, 0, 0)); + m_buttonSL.setIcon(Env.getImageIcon("LockX16.gif")); + m_buttonSL.setToolTipText(Msg.getMsg(Env.getCtx(), "ShortListShortListItems")); + } + } + // IDEMPIERE 90 + // *** VComboBox *** if (m_lookup != null && m_lookup.getDisplayType() != DisplayType.Search) // No Search { // Don't have to fill up combobox if it is readonly if (!isReadOnly && isUpdateable) - m_lookup.fillComboBox (isMandatory(), true, true, false); + m_lookup.fillComboBox (isMandatory(), true, true, false, isShortListAvailable); // IDEMPIERE 90 m_combo.setModel(m_lookup); // // AutoCompletion.enable(m_combo); @@ -342,6 +370,7 @@ public class VLookup extends JComponent m_button = null; m_lookup = null; m_mField = null; + m_buttonSL = null; // IDEMPIERE 90 // m_combo.getEditor().getEditorComponent().removeFocusListener(this); m_combo.getEditor().getEditorComponent().removeMouseListener(mouseAdapter); @@ -394,6 +423,11 @@ public class VLookup extends JComponent // Mouse Listener private VLookup_mouseAdapter mouseAdapter; + /** ShortList button IDEMPIERE 90 */ + private CButton m_buttonSL = new CButton(); + + /** All items or only those of the short list ?*/ + boolean onlyShortListItems = false; // Field for Value Preference private GridField m_mField = null; @@ -417,11 +451,13 @@ public class VLookup extends JComponent m_text.setBorder(null); Dimension bSize = new Dimension(size.height, size.height); m_button.setPreferredSize (bSize); + m_buttonSL.setPreferredSize (bSize); // IDEMPIERE 90 } // What to show this.remove(m_combo); this.remove(m_button); + this.remove(m_buttonSL); // IDEMPIERE 90 this.remove(m_text); // if (!isReadWrite()) // r/o - show text only @@ -437,6 +473,9 @@ public class VLookup extends JComponent this.setBorder(null); this.add(m_combo, BorderLayout.CENTER); m_comboActive = true; + // IDEMPIERE 90 + if (isComboShortList()) + this.add(m_buttonSL, BorderLayout.EAST); // add a button for short list items <-> all items } else // Search or unstable - show text & button { @@ -761,6 +800,8 @@ public class VLookup extends JComponent actionBPartner(false); else if (e.getSource() == m_location) actionLocation(); + else if (e.getSource() == m_buttonSL) // IDEMPIERE 90 + actionShortList(); } // actionPerformed /** @@ -1463,7 +1504,7 @@ public class VLookup extends JComponent else { m_lookup.refresh(); - m_lookup.fillComboBox(isMandatory(), true, true, false); + m_lookup.fillComboBox(isMandatory(), true, true, false, isComboShortList()); // IDEMPIERE 90 m_combo.setSelectedItem(obj); //m_combo.revalidate(); } @@ -1501,7 +1542,7 @@ public class VLookup extends JComponent + " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj); // log.fine( "VLookupHash=" + this.hashCode()); boolean popupVisible = m_combo.isPopupVisible(); - m_lookup.fillComboBox(isMandatory(), true, true, false); // only validated & active + m_lookup.fillComboBox(isMandatory(), true, true, false, isComboShortList()); // only validated & active + IDEMPIERE 90 if (popupVisible) { //refresh @@ -1525,6 +1566,7 @@ public class VLookup extends JComponent { if (e.isTemporary() || m_lookup == null + || !m_buttonSL.isEnabled() // IDEMPIERE 90 || !m_button.isEnabled() ) // set by actionButton return; // Text Lost focus @@ -1642,5 +1684,36 @@ public class VLookup extends JComponent m_stopediting = stopediting; } + // IDEMPIERE 90 + private void actionShortList () + { + if (onlyShortListItems) + { + onlyShortListItems = false; + m_lookup.setShortList(true); + refresh(); + m_lookup.fillComboBox(isMandatory(), true, true, false, isComboShortList()); + m_buttonSL.setIcon(Env.getImageIcon("LockX16.gif")); + m_buttonSL.setToolTipText(Msg.getMsg(Env.getCtx(), "ShortListOnlyShortListItems")); + }else{ + onlyShortListItems = true; + m_lookup.setShortList(false); + m_buttonSL.setIcon(Env.getImageIcon("Lock16.gif")); + m_buttonSL.setToolTipText(Msg.getMsg(Env.getCtx(), "ShortListAllItems")); + } + + actionRefresh(); + } // actionShortList + + public void setComboShortList (boolean shortList) + { + m_combo.setShortListSearch(shortList); + } // setComboShortList + + public boolean isComboShortList() + { + return m_combo.isShortListSearch(); + } // isComboShortList + // IDEMPIERE 90 } // VLookup \ No newline at end of file diff --git a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java index c9cbfc06e3..842d2a073a 100644 --- a/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java +++ b/org.adempiere.ui.swing/src/org/compiere/grid/ed/VPaymentEditor.java @@ -104,7 +104,7 @@ public class VPaymentEditor extends JComponent implements VEditor, ActionListene { // Don't have to fill up combobox if it is readonly if (!isReadOnly && isUpdateable) - m_lookup.fillComboBox (isMandatory(), true, true, false); + m_lookup.fillComboBox (isMandatory(), true, true, false, false); // IDEMPIERE 90 m_combo.setModel(m_lookup); // // AutoCompletion.enable(m_combo); @@ -472,7 +472,7 @@ public class VPaymentEditor extends JComponent implements VEditor, ActionListene + " - Start Count=" + m_combo.getItemCount() + ", Selected=" + obj); // log.fine( "VLookupHash=" + this.hashCode()); boolean popupVisible = m_combo.isPopupVisible(); - m_lookup.fillComboBox(isMandatory(), true, true, false); // only validated & active + m_lookup.fillComboBox(isMandatory(), true, true, false, false); // only validated & active + IDEMPIERE 90 if (popupVisible) { //refresh diff --git a/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java b/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java index 7c0279aa41..71d2169968 100644 --- a/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java +++ b/org.adempiere.ui.swing/src/org/compiere/pos/PosPayment.java @@ -250,7 +250,7 @@ public class PosPayment extends CDialog implements PosKeyListener, VetoableChang // Payment type selection int AD_Column_ID = COLUMN_C_PAYMENT_V_TENDERTYPE; //C_Payment_v.TenderType MLookup lookup = MLookupFactory.get(Env.getCtx(), 0, 0, AD_Column_ID, DisplayType.List); - ArrayList types = lookup.getData(true, false, true, true); + ArrayList types = lookup.getData(true, false, true, true, false); // IDEMPIERE 90 DefaultComboBoxModel typeModel = new DefaultComboBoxModel(types.toArray()); tenderTypePick.setModel(typeModel); diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java b/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java index 53b712308f..1e98c2ff60 100644 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java +++ b/org.adempiere.ui.swing/src/org/compiere/swing/CComboBox.java @@ -984,4 +984,21 @@ public class CComboBox extends JComboBox } } // ReducibleKeyListener + // IDEMPIERE 90 + /** show only short list items or all ? */ + private boolean m_ShortListSearch = false; + + /** set the editor to return only short list items */ + public void setShortListSearch (boolean shortList) + { + m_ShortListSearch = shortList; + } // setShortListSearch + + /** does the search should return only short list items ? */ + public boolean isShortListSearch() + { + return m_ShortListSearch; + } // isShortListSearch + + // IDEMPIERE 90 } // CComboBox diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java index 555e1a1acd..4cc2770b49 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/AEnv.java @@ -407,16 +407,16 @@ public final class AEnv } // canAccessInfo - public static void actionRefresh(Lookup lookup, Object value, boolean mandatory) + public static void actionRefresh(Lookup lookup, Object value, boolean mandatory, boolean shortList) // IDEMPIERE 90 { if (lookup == null) return; lookup.refresh(); if (lookup.isValidated()) - lookup.fillComboBox(mandatory, false, false, false); + lookup.fillComboBox(mandatory, false, false, false, shortList); // IDEMPIERE 90 else - lookup.fillComboBox(mandatory, true, false, false); + lookup.fillComboBox(mandatory, true, false, false, shortList); // IDEMPIERE 90 } /** * diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java index 4a5a12eece..ded84de208 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WTableDirEditor.java @@ -36,7 +36,9 @@ import org.compiere.model.GridField; import org.compiere.model.Lookup; import org.compiere.model.MBPartnerLocation; import org.compiere.model.MLocation; +import org.compiere.model.MTable; import org.compiere.util.CLogger; +import org.compiere.util.DB; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.KeyNamePair; @@ -47,6 +49,7 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zul.Comboitem; +import org.zkoss.zul.Menuitem; /** * @@ -69,7 +72,10 @@ ContextMenuListener, IZoomableEditor private Lookup lookup; private Object oldValue; - + + public static final String SHORT_LIST_EVENT = "SHORT_LIST"; // IDEMPIERE 90 + protected boolean onlyShortListItems; // IDEMPIERE 90 + public WTableDirEditor(GridField gridField) { super(new Combobox(), gridField); @@ -159,6 +165,37 @@ ContextMenuListener, IZoomableEditor popupMenu = new WEditorPopupMenu(zoom, true, isShowPreference(), false, false, false, lookup); } addChangeLogMenu(popupMenu); + + // IDEMPIERE 90 + boolean isShortListAvailable = false; // Short List available for this lookup + if (lookup != null && (lookup.getDisplayType() == DisplayType.TableDir || lookup.getDisplayType() == DisplayType.Table)) // only for Table & TableDir + { + String tableName_temp = lookup.getColumnName(); // Returns AD_Org.AD_Org_ID + int posPoint = tableName_temp.indexOf("."); + String tableName = tableName_temp.substring(0, posPoint); + int table_id = MTable.getTable_ID(tableName); // now we got the ad_table_id + + String sql = "SELECT COUNT(*) FROM AD_Column WHERE ColumnName = 'IsShortList' AND IsActive='Y' AND AD_Table_ID = " + table_id; + isShortListAvailable = DB.getSQLValue(null, sql) == 1; // if the table has an active isShortList column, we could use the restrict search ! + + if (isShortListAvailable) + { + onlyShortListItems=true; + lookup.setShortList(true); + getLabel().setText(">" + getGridField().getHeader() + "<"); + actionRefresh(); + + // add in popup menu + Menuitem searchMode; + searchMode = new Menuitem(); + searchMode.setAttribute(WEditorPopupMenu.EVENT_ATTRIBUTE, SHORT_LIST_EVENT); + searchMode.setLabel(Msg.getMsg(Env.getCtx(), "ShortListSwitchSearchMode")); + searchMode.setImage("/images/Lock16.png"); + searchMode.addEventListener(Events.ON_CLICK, popupMenu); + popupMenu.appendChild(searchMode); + } + } + // IDEMPIERE 90 } } @@ -493,6 +530,25 @@ ContextMenuListener, IZoomableEditor { actionLocation(); } + // IDEMPIERE 90 + else if (SHORT_LIST_EVENT.equals(evt.getContextEvent())) + { + String champ = getGridField().getHeader(); + + if(onlyShortListItems) + { + onlyShortListItems=false; + lookup.setShortList(false); + actionRefresh(); + getLabel().setText(champ); + }else{ + onlyShortListItems=true; + lookup.setShortList(true); + actionRefresh(); + getLabel().setText(">" + champ + "<"); + } + } + // IDEMPIERE 90 } public void propertyChange(PropertyChangeEvent evt) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java index 454e89d211..79ee5c72e7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java @@ -328,7 +328,7 @@ public class WLocatorDialog extends Window implements EventListener // Load existing Locators - m_mLocator.fillComboBox(m_mandatory, true, true, false); + m_mLocator.fillComboBox(m_mandatory, true, true, false, false); // IDEMPIERE 90 log.fine(m_mLocator.toString()); diff --git a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ADLookup.java b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ADLookup.java index c0b11ae5c3..ac7a96b4cf 100644 --- a/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ADLookup.java +++ b/org.idempiere.webservices/WEB-INF/src/org/idempiere/adinterface/ADLookup.java @@ -19,12 +19,12 @@ public class ADLookup { protected static CLogger log = CLogger.getCLogger(ADLookup.class); - public static void fillLookupValues( LookupValues lvs, Lookup lookup, boolean isMandatory, boolean isReadOnly ) + public static void fillLookupValues( LookupValues lvs, Lookup lookup, boolean isMandatory, boolean isReadOnly, boolean isShortList) // IDEMPIERE 90 { if(lookup.getSize() == 0) lookup.refresh(); - Object[] list = lookup.getData(isMandatory, true, !isReadOnly, false).toArray(); + Object[] list = lookup.getData(isMandatory, true, !isReadOnly, false, isShortList).toArray(); // IDEMPIERE 90 for (int i=0; i