org.jminor.framework.client.model
Class DefaultEntityLookupModel

java.lang.Object
  extended by org.jminor.framework.client.model.DefaultEntityLookupModel
All Implemented Interfaces:
EntityDataProvider, EntityLookupModel

public class DefaultEntityLookupModel
extends Object
implements EntityLookupModel

A default EntityLookupModel implementation


Constructor Summary
DefaultEntityLookupModel(String entityID, EntityConnectionProvider connectionProvider, List<Property.ColumnProperty> lookupProperties)
          Instantiates a new EntityLookupModel
 
Method Summary
 void addSearchStringListener(ActionListener listener)
          
 void addSelectedEntitiesListener(ActionListener listener)
          
 EntityConnectionProvider getConnectionProvider()
          
 String getDescription()
          
 String getEntityID()
          
 List<Property.ColumnProperty> getLookupProperties()
          
 String getMultipleValueSeparator()
          
 String getSearchString()
          
 List<Entity> getSelectedEntities()
          
 String getWildcard()
          
 boolean isCaseSensitive()
          
 boolean isMultipleSelectionAllowed()
          
 boolean isWildcardPostfix()
          
 boolean isWildcardPrefix()
          
 List<Entity> performQuery()
          Performs a query based on the select criteria
 void refreshSearchText()
          Refreshes the search text so that is represents the selected entities
 void removeSearchStringListener(ActionListener listener)
          
 void removeSelectedEntitiesListener(ActionListener listener)
          
 EventObserver searchStringObserver()
          
 boolean searchStringRepresentsSelected()
          
 EntityLookupModel setAdditionalLookupCriteria(Criteria additionalLookupCriteria)
          Sets the additional lookup criteria to use when performing the lookup.
 EntityLookupModel setCaseSensitive(boolean caseSensitive)
          Specifies whether or not this lookup model should be case sensitive
 void setDescription(String description)
          
 void setMultipleSelectionAllowed(boolean multipleSelectionAllowed)
          Specifies whether or not this lookup model should allow selection of multiple entities
 EntityLookupModel setMultipleValueSeparator(String multipleValueSeparator)
          Sets the string to use to separate multiple values when shown as a string
 void setSearchString(String searchString)
          Sets the search string to use when performing the next lookup
 void setSelectedEntities(List<Entity> entities)
          Sets the selected entities
 void setSelectedEntity(Entity entity)
          Sets the given entity as the selected entity
 EntityLookupModel setWildcard(String wildcard)
          Sets the wildcard to use
 EntityLookupModel setWildcardPostfix(boolean wildcardPostfix)
          Specifies whether or not to automatically append a wildcard to the search string
 EntityLookupModel setWildcardPrefix(boolean wildcardPrefix)
          Specifies whether or not to automatically prefix the search string with a wildcard
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEntityLookupModel

public DefaultEntityLookupModel(String entityID,
                                EntityConnectionProvider connectionProvider,
                                List<Property.ColumnProperty> lookupProperties)
Instantiates a new EntityLookupModel

Parameters:
entityID - the ID of the entity to lookup
connectionProvider - the EntityConnectionProvider to use when performing the lookup
lookupProperties - the properties to search by, these must be string based
Method Detail

getEntityID

public final String getEntityID()

Specified by:
getEntityID in interface EntityDataProvider
Returns:
the ID of the entity this data provider is based on

getConnectionProvider

public final EntityConnectionProvider getConnectionProvider()

Specified by:
getConnectionProvider in interface EntityDataProvider
Returns:
the db provider this data provider uses

getLookupProperties

public final List<Property.ColumnProperty> getLookupProperties()

Specified by:
getLookupProperties in interface EntityLookupModel
Returns:
a list containing the properties used when performing a lookup

isMultipleSelectionAllowed

public final boolean isMultipleSelectionAllowed()

Specified by:
isMultipleSelectionAllowed in interface EntityLookupModel
Returns:
true if this lookup model allows selection of multiple entities

setMultipleSelectionAllowed

public final void setMultipleSelectionAllowed(boolean multipleSelectionAllowed)
Specifies whether or not this lookup model should allow selection of multiple entities

Specified by:
setMultipleSelectionAllowed in interface EntityLookupModel
Parameters:
multipleSelectionAllowed - if true then selection of multiple entities is allowed

getDescription

public final String getDescription()

Specified by:
getDescription in interface EntityLookupModel
Returns:
a string describing this lookup model, by default a comma separated list of search property names

setDescription

public final void setDescription(String description)

Specified by:
setDescription in interface EntityLookupModel
Parameters:
description - a string describing this lookup model

setSelectedEntity

public final void setSelectedEntity(Entity entity)
Sets the given entity as the selected entity

Specified by:
setSelectedEntity in interface EntityLookupModel
Parameters:
entity - the entity to set as the selected entity

setSelectedEntities

public final void setSelectedEntities(List<Entity> entities)
Sets the selected entities

Specified by:
setSelectedEntities in interface EntityLookupModel
Parameters:
entities - the entities to set as selected

getSelectedEntities

public final List<Entity> getSelectedEntities()

Specified by:
getSelectedEntities in interface EntityLookupModel
Returns:
an unmodifiable view of the selected entities

isCaseSensitive

public final boolean isCaseSensitive()

Specified by:
isCaseSensitive in interface EntityLookupModel
Returns:
true if this lookup model is case sensitive

setCaseSensitive

public final EntityLookupModel setCaseSensitive(boolean caseSensitive)
Specifies whether or not this lookup model should be case sensitive

Specified by:
setCaseSensitive in interface EntityLookupModel
Parameters:
caseSensitive - if true then this lookup model is case sensitive
Returns:
this EntityLookupModel instance

isWildcardPostfix

public final boolean isWildcardPostfix()

Specified by:
isWildcardPostfix in interface EntityLookupModel
Returns:
whether or not to automatically append a wildcard to the search string

setWildcardPostfix

public final EntityLookupModel setWildcardPostfix(boolean wildcardPostfix)
Specifies whether or not to automatically append a wildcard to the search string

Specified by:
setWildcardPostfix in interface EntityLookupModel
Parameters:
wildcardPostfix - if true then a wildcard is automatically appended to the search string
Returns:
this EntityLookupModel instance

isWildcardPrefix

public final boolean isWildcardPrefix()

Specified by:
isWildcardPrefix in interface EntityLookupModel
Returns:
whether or not to automatically prefix the the search string with a wildcard

setWildcardPrefix

public final EntityLookupModel setWildcardPrefix(boolean wildcardPrefix)
Specifies whether or not to automatically prefix the search string with a wildcard

Specified by:
setWildcardPrefix in interface EntityLookupModel
Parameters:
wildcardPrefix - if true then a wildcard is automatically prefixed to the search string
Returns:
this EntityLookupModel instance

getWildcard

public final String getWildcard()

Specified by:
getWildcard in interface EntityLookupModel
Returns:
the wildcard being used by this model

setWildcard

public final EntityLookupModel setWildcard(String wildcard)
Sets the wildcard to use

Specified by:
setWildcard in interface EntityLookupModel
Parameters:
wildcard - the wildcard
Returns:
this EntityLookupModel instance

getMultipleValueSeparator

public final String getMultipleValueSeparator()

Specified by:
getMultipleValueSeparator in interface EntityLookupModel
Returns:
the string used to separate multiple values when shown as a string

setMultipleValueSeparator

public final EntityLookupModel setMultipleValueSeparator(String multipleValueSeparator)
Sets the string to use to separate multiple values when shown as a string

Specified by:
setMultipleValueSeparator in interface EntityLookupModel
Parameters:
multipleValueSeparator - the separator string
Returns:
this EntityLookupModel instance

setAdditionalLookupCriteria

public final EntityLookupModel setAdditionalLookupCriteria(Criteria additionalLookupCriteria)
Sets the additional lookup criteria to use when performing the lookup. This criteria is AND'ed to the actual lookup criteria.

Specified by:
setAdditionalLookupCriteria in interface EntityLookupModel
Parameters:
additionalLookupCriteria - the additional lookup criteria
Returns:
this EntityLookupModel instance

refreshSearchText

public final void refreshSearchText()
Refreshes the search text so that is represents the selected entities

Specified by:
refreshSearchText in interface EntityLookupModel

setSearchString

public final void setSearchString(String searchString)
Sets the search string to use when performing the next lookup

Specified by:
setSearchString in interface EntityLookupModel
Parameters:
searchString - the search string

getSearchString

public final String getSearchString()

Specified by:
getSearchString in interface EntityLookupModel
Returns:
the current search string value

searchStringRepresentsSelected

public final boolean searchStringRepresentsSelected()

Specified by:
searchStringRepresentsSelected in interface EntityLookupModel
Returns:
true if the current search string represents the selected entities

performQuery

public final List<Entity> performQuery()
Performs a query based on the select criteria

Specified by:
performQuery in interface EntityLookupModel
Returns:
a list containing the entities fulfilling the current criteria

searchStringObserver

public final EventObserver searchStringObserver()

Specified by:
searchStringObserver in interface EntityLookupModel
Returns:
an Event fired each time the search string changes

addSearchStringListener

public final void addSearchStringListener(ActionListener listener)

Specified by:
addSearchStringListener in interface EntityLookupModel
Parameters:
listener - a listener to be notified each time the search string changes

addSelectedEntitiesListener

public final void addSelectedEntitiesListener(ActionListener listener)

Specified by:
addSelectedEntitiesListener in interface EntityLookupModel
Parameters:
listener - a listener to be notified each time the selected entities are changed

removeSearchStringListener

public final void removeSearchStringListener(ActionListener listener)

Specified by:
removeSearchStringListener in interface EntityLookupModel
Parameters:
listener - the listener to remove

removeSelectedEntitiesListener

public final void removeSelectedEntitiesListener(ActionListener listener)

Specified by:
removeSelectedEntitiesListener in interface EntityLookupModel
Parameters:
listener - the listener to remove