Compiere 3.1

org.compiere.framework
Class Lookup

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by org.compiere.framework.Lookup
All Implemented Interfaces:
Serializable, ComboBoxModel, ListModel, MutableComboBoxModel
Direct Known Subclasses:
MAccountLookup, MLocationLookup, MLocatorLookup, MLookup, MPAttributeLookup, XLookup

public abstract class Lookup
extends AbstractListModel
implements MutableComboBoxModel, 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
protected  CLogger log
          Logger
protected  int m_WindowNo
          Window No
protected  ArrayList<NamePair> p_data
          The Data List
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
Lookup(Ctx ctx, int windowNo, int displayType)
          Lookup
 
Method Summary
 void addElement(NamePair anObject)
          Add Element at the end
 void addElement(Object anObject)
          Add Element at the end
abstract  boolean containsKey(Object key)
          The Lookup contains the key
 void disableValidation()
          Disable Validation
 void dispose()
          Dispose - clear items w/o firing events
 void fillComboBox(boolean restore)
          Fill ComboBox with old saved data (if exists) or all data available
 void fillComboBox(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary)
          Fill ComboBox with lookup data (async using Worker)
abstract  NamePair get(Object key)
          Get Object of Key Value
abstract  String getColumnName()
          Get underlying fully qualified Table.Column Name.
 Ctx getCtx()
          Get Ctx
abstract  ArrayList<NamePair> getData(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary)
          Fill ComboBox with Data (Value/KeyNamePair)
 NamePair getDirect(Object key, boolean saveInCache, boolean cacheLocal)
          Get Data Direct from Table.
abstract  String getDisplay(Object key)
          Get Display of Key Value
 int getDisplayType()
          Get Display Type
 Object getElementAt(int index)
          Get Element at Index
 int getIndexOf(Object anObject)
          Returns the index-position of the specified object in the list.
 Object getSelectedItem()
          Return previously selected Item
 int getSize()
          Get Size of Model
 String getValidation()
          Get dynamic Validation SQL (none)
 int getWindowNo()
          Get Window No
 Query getZoomQuery()
          Get Zoom Query String - default implementation
 int getZoomWindow()
          Get Zoom - default implementation
 int getZoomWindow(Query query)
          Get Zoom - default implementation
 boolean hasInactive()
          Has Inactive records - default implementation
 void insertElementAt(NamePair anObject, int index)
          Insert Element At
 void insertElementAt(Object anObject, int index)
          Insert Element At
 boolean isValidated()
          Is Validated - default implementation
 boolean isValidationDisabled()
          Is Validation Disabled
 void loadComplete()
          Wait until async Load Complete
 void put(int key, String value)
          Put Value
 void put(String key, String value)
          Put Value
 int refresh()
          Refresh Values - default implementation
 void removeAllElements()
          Empties the list.
 void removeElement(Object anObject)
          Remove Item
 void removeElementAt(int index)
          Remove Item at index
 void setContext(Ctx ctx, int windowNo)
          Set Context
 void setDisplayType(int displayType)
          Set Display Type
 void setSelectedItem(Object anObject)
          Set the value of the selected item.
 void setSelectedItemAlways(Object anObject)
          Set the value of the selected item.
 String toString()
          String Representation
 
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, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Field Detail

p_data

protected volatile ArrayList<NamePair> p_data
The Data List


log

protected CLogger log
Logger


m_WindowNo

protected int m_WindowNo
Window No

Constructor Detail

Lookup

public Lookup(Ctx ctx,
              int windowNo,
              int displayType)
Lookup

Parameters:
ctx - context
windowNo - window no
displayType - display type
Method Detail

setContext

public void setContext(Ctx ctx,
                       int windowNo)
Set Context

Parameters:
ctx - context
windowNo - window

getCtx

public Ctx getCtx()
Get Ctx

Returns:
context

getWindowNo

public int getWindowNo()
Get Window No

Returns:
Window No

getDisplayType

public int getDisplayType()
Get Display Type

Returns:
display type

setDisplayType

public void setDisplayType(int displayType)
Set Display Type

Parameters:
displayType - display type

setSelectedItem

public void setSelectedItem(Object anObject)
Set the value of the selected item. Checks, if value has changed first. The selected item may be null. If it is not valid, set to null.

Specified by:
setSelectedItem in interface ComboBoxModel
Parameters:
anObject - The combo box value or null for no selection.

setSelectedItemAlways

public void setSelectedItemAlways(Object anObject)
Set the value of the selected item. The selected item may be null. If it is not valid, set to null.

Parameters:
anObject - The combo box value or null for no selection.

getSelectedItem

public Object getSelectedItem()
Return previously selected Item

Specified by:
getSelectedItem in interface ComboBoxModel
Returns:
value

getSize

public int getSize()
Get Size of Model

Specified by:
getSize in interface ListModel
Returns:
size

getElementAt

public Object getElementAt(int index)
Get Element at Index

Specified by:
getElementAt in interface ListModel
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(NamePair anObject)
Add Element at the end

Parameters:
anObject - object

addElement

public void addElement(Object anObject)
Add Element at the end

Specified by:
addElement in interface MutableComboBoxModel
Parameters:
anObject - object

insertElementAt

public void insertElementAt(NamePair anObject,
                            int index)
Insert Element At

Parameters:
anObject - object
index - index

insertElementAt

public void insertElementAt(Object anObject,
                            int index)
Insert Element At

Specified by:
insertElementAt in interface MutableComboBoxModel
Parameters:
anObject - object
index - index

removeElementAt

public void removeElementAt(int index)
Remove Item at index

Specified by:
removeElementAt in interface MutableComboBoxModel
Parameters:
index - index

removeElement

public void removeElement(Object anObject)
Remove Item

Specified by:
removeElement in interface MutableComboBoxModel
Parameters:
anObject - object

removeAllElements

public void removeAllElements()
Empties the list.


put

public void put(String key,
                String value)
Put Value

Parameters:
key - key
value - value

put

public void put(int key,
                String value)
Put Value

Parameters:
key - key
value - value

fillComboBox

public void fillComboBox(boolean mandatory,
                         boolean onlyValidated,
                         boolean onlyActive,
                         boolean temporary)
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 validated
onlyActive - onlt active
temporary - 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<NamePair> getData(boolean mandatory,
                                            boolean onlyValidated,
                                            boolean onlyActive,
                                            boolean temporary)
Fill ComboBox with Data (Value/KeyNamePair)

Parameters:
mandatory - has mandatory data only (i.e. no "null" selection)
onlyValidated - only validated
onlyActive - only active
temporary - 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

refresh

public int refresh()
Refresh Values - default implementation

Returns:
size

disableValidation

public void disableValidation()
Disable Validation


isValidationDisabled

public boolean isValidationDisabled()
Is Validation Disabled

Returns:
true if disabled

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

getZoomWindow

public int getZoomWindow()
Get Zoom - default implementation

Returns:
Zoom AD_Window_ID

getZoomWindow

public int getZoomWindow(Query query)
Get Zoom - default implementation

Parameters:
query - query
Returns:
Zoom Window - here 0

getZoomQuery

public Query getZoomQuery()
Get Zoom Query String - default implementation

Returns:
Zoom Query

getDirect

public NamePair getDirect(Object key,
                          boolean saveInCache,
                          boolean cacheLocal)
Get Data Direct from Table. Default implementation - does not requery

Parameters:
key - key
saveInCache - save in cache for r/w
cacheLocal - cache locally for r/o
Returns:
value

dispose

public void dispose()
Dispose - clear items w/o firing events


loadComplete

public void loadComplete()
Wait until async Load Complete


toString

public String toString()
String Representation

Overrides:
toString in class Object
Returns:
info

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.