Package org.compiere.model
Class Lookup
- java.lang.Object
-
- javax.swing.AbstractListModel<Object>
-
- org.compiere.model.Lookup
-
- All Implemented Interfaces:
Serializable
,ComboBoxModel<Object>
,ListModel<Object>
,MutableComboBoxModel<Object>
- Direct Known Subclasses:
GetListLookup
,MAccountLookup
,MLocationLookup
,MLocatorLookup
,MLookup
,MPAttributeLookup
,MPaymentLookup
,QueryDataLookup
public abstract class Lookup extends AbstractListModel<Object> implements MutableComboBoxModel<Object>, Serializable
Base Class for MLookup, MLocator. as well as for MLocation, MAccount (only single value) Maintains selectable data as NamePairs in ArrayList The objects itself may be shared by the lookup implementation (ususally HashMap)- Version:
- $Id: Lookup.java,v 1.3 2006/07/30 00:58:18 jjanke Exp $
- Author:
- Jorg Janke
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected CLogger
log
Loggerprotected ArrayList<Object>
p_data
The Data List-
Fields inherited from class javax.swing.AbstractListModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description Lookup(int displayType, int windowNo)
Lookup
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addElement(Object anObject)
Add Element at the endabstract boolean
containsKey(Object key)
The Lookup contains the keyabstract boolean
containsKeyNoDirect(Object key)
The Lookup contains the key, do not push directvoid
dispose()
Dispose - clear items w/o firing eventsvoid
fillComboBox(boolean restore)
Fill ComboBox with old saved data (if exists) or all data availablevoid
fillComboBox(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortList)
Fill ComboBox with lookup data (async using Worker)abstract NamePair
get(Object key)
Get Object of Key Valueabstract String
getColumnName()
Get underlying fully qualified Table.Column Name.abstract ArrayList<Object>
getData(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist)
Fill ComboBox with Data (Value/KeyNamePair)NamePair[]
getDirect(Object[] keys)
NamePair
getDirect(Object key, boolean saveInCache, boolean cacheLocal)
NamePair
getDirect(Object key, boolean saveInCache, boolean cacheLocal, String trxName)
Get Data Direct from Table.abstract String
getDisplay(Object key)
Get Display of Key Valueint
getDisplayType()
Get Display TypeObject
getElementAt(int index)
Get Element at Indexint
getIndexOf(Object anObject)
Returns the index-position of the specified object in the list.Object
getSelectedItem()
Return previously selected Itemint
getSize()
Get Size of ModelString
getValidation()
Get dynamic Validation SQL (none)int
getWindowNo()
Get Window Noint
getZoom()
Get Zoom - default implementationint
getZoom(boolean isSOTrx)
int
getZoom(MQuery query)
Get Zoom - default implementationMQuery
getZoomQuery()
Get Zoom Query String - default implementationboolean
hasInactive()
Has Inactive records - default implementationvoid
insertElementAt(Object anObject, int index)
Insert Element Atboolean
isLoaded()
Is this lookup model populatedboolean
isMandatory()
Is lookup model mandatoryboolean
isShortList()
boolean
isValidated()
Is Validated - default implementationvoid
loadComplete()
Wait until async Load Completevoid
put(int key, String value)
Put Valuevoid
put(String key, String value)
Put Valueint
refresh()
Refresh Values - default implementationvoid
removeAllElements()
Empties the list.void
removeElement(Object anObject)
Remove Itemvoid
removeElementAt(int index)
Remove Item at indexvoid
setMandatory(boolean flag)
Set lookup model as mandatory, use in loading datavoid
setSelectedItem(Object anObject)
Set the value of the selected item.void
setShortList(boolean shortlist)
-
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
-
-
-
-
Method Detail
-
getDisplayType
public int getDisplayType()
Get Display Type- Returns:
- display type
-
getWindowNo
public int getWindowNo()
Get Window No- Returns:
- Window No
-
setSelectedItem
public void setSelectedItem(Object anObject)
Set the value of the selected item. The selected item may be null.- Specified by:
setSelectedItem
in interfaceComboBoxModel<Object>
- Parameters:
anObject
- The combo box value or null for no selection.
-
getSelectedItem
public Object getSelectedItem()
Return previously selected Item- Specified by:
getSelectedItem
in interfaceComboBoxModel<Object>
- Returns:
- value
-
getSize
public int getSize()
Get Size of Model
-
getElementAt
public Object getElementAt(int index)
Get Element at Index- Specified by:
getElementAt
in interfaceListModel<Object>
- Parameters:
index
- index- Returns:
- value
-
getIndexOf
public int getIndexOf(Object anObject)
Returns the index-position of the specified object in the list.- Parameters:
anObject
- object- Returns:
- an int representing the index position, where 0 is the first position
-
addElement
public void addElement(Object anObject)
Add Element at the end- Specified by:
addElement
in interfaceMutableComboBoxModel<Object>
- Parameters:
anObject
- object
-
insertElementAt
public void insertElementAt(Object anObject, int index)
Insert Element At- Specified by:
insertElementAt
in interfaceMutableComboBoxModel<Object>
- Parameters:
anObject
- objectindex
- index
-
removeElementAt
public void removeElementAt(int index)
Remove Item at index- Specified by:
removeElementAt
in interfaceMutableComboBoxModel<Object>
- Parameters:
index
- index
-
removeElement
public void removeElement(Object anObject)
Remove Item- Specified by:
removeElement
in interfaceMutableComboBoxModel<Object>
- Parameters:
anObject
- object
-
removeAllElements
public void removeAllElements()
Empties the list.
-
put
public void put(int key, String value)
Put Value- Parameters:
key
- keyvalue
- value
-
fillComboBox
public void fillComboBox(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortList)
Fill ComboBox with lookup data (async using Worker). - try to maintain selected item- Parameters:
mandatory
- has mandatory data only (i.e. no "null" selection)onlyValidated
- only validatedonlyActive
- onlt activetemporary
- save current values - restore via fillComboBox (true)
-
fillComboBox
public void fillComboBox(boolean restore)
Fill ComboBox with old saved data (if exists) or all data available- Parameters:
restore
- if true, use saved data - else fill it with all data
-
getDisplay
public abstract String getDisplay(Object key)
Get Display of Key Value- Parameters:
key
- key- Returns:
- String
-
get
public abstract NamePair get(Object key)
Get Object of Key Value- Parameters:
key
- key- Returns:
- Object or null
-
getData
public abstract ArrayList<Object> getData(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist)
Fill ComboBox with Data (Value/KeyNamePair)- Parameters:
mandatory
- has mandatory data only (i.e. no "null" selection)onlyValidated
- only validatedonlyActive
- only activetemporary
- force load for temporary display- Returns:
- ArrayList
-
getColumnName
public abstract String getColumnName()
Get underlying fully qualified Table.Column Name. Used for VLookup.actionButton (Zoom)- Returns:
- column name
-
containsKey
public abstract boolean containsKey(Object key)
The Lookup contains the key- Parameters:
key
- key- Returns:
- true if contains key
-
containsKeyNoDirect
public abstract boolean containsKeyNoDirect(Object key)
The Lookup contains the key, do not push direct- Parameters:
key
- key- Returns:
- true if contains key
-
refresh
public int refresh()
Refresh Values - default implementation- Returns:
- size
-
isValidated
public boolean isValidated()
Is Validated - default implementation- Returns:
- true if validated
-
getValidation
public String getValidation()
Get dynamic Validation SQL (none)- Returns:
- validation
-
hasInactive
public boolean hasInactive()
Has Inactive records - default implementation- Returns:
- true if inactive
-
getZoom
public int getZoom()
Get Zoom - default implementation- Returns:
- Zoom AD_Window_ID
-
getZoom
public int getZoom(boolean isSOTrx)
- Parameters:
isSOTrx
-- Returns:
- Zoom AD_Window_ID
-
getZoom
public int getZoom(MQuery query)
Get Zoom - default implementation- Parameters:
query
- query- Returns:
- Zoom Window - here 0
-
getZoomQuery
public MQuery getZoomQuery()
Get Zoom Query String - default implementation- Returns:
- Zoom Query
-
getDirect
public NamePair getDirect(Object key, boolean saveInCache, boolean cacheLocal, String trxName)
Get Data Direct from Table. Default implementation - does not requery- Parameters:
key
- keysaveInCache
- save in cache for r/wcacheLocal
- cache locally for r/otrxName
- the transaction name- Returns:
- value
-
dispose
public void dispose()
Dispose - clear items w/o firing events
-
loadComplete
public void loadComplete()
Wait until async Load Complete
-
setMandatory
public void setMandatory(boolean flag)
Set lookup model as mandatory, use in loading data- Parameters:
flag
-
-
isMandatory
public boolean isMandatory()
Is lookup model mandatory- Returns:
- boolean
-
isLoaded
public boolean isLoaded()
Is this lookup model populated- Returns:
- boolean
-
setShortList
public void setShortList(boolean shortlist)
-
isShortList
public boolean isShortList()
-
-