com.ibm.commons.iloader.node.lookups
Class SortedLookup

java.lang.Object
  extended by com.ibm.commons.iloader.node.lookups.api.AbstractLookup
      extended by com.ibm.commons.iloader.node.lookups.SortedLookup
All Implemented Interfaces:
ILookup

public class SortedLookup
extends com.ibm.commons.iloader.node.lookups.api.AbstractLookup

Creates a sorted lookup.


Field Summary
static java.util.Comparator<java.lang.String> sortAsc
           
static java.util.Comparator<java.lang.String> sortDesc
           
 
Constructor Summary
SortedLookup(ILookup wrapped, java.util.Comparator<java.lang.String> comparator)
          Creates a new instance of this class.
 
Method Summary
 java.lang.String getCode(int index)
          Return the code or model value for this index.
 java.util.Comparator<java.lang.String> getComparator()
           
 org.eclipse.swt.graphics.Image getImage(int index)
          Return the image for the given index.
 java.lang.String getLabel(int index)
          Return the label displayed to the user for this index.
 java.lang.String getLabelFromCode(java.lang.String code)
          Return the label for the given model value code.
 void refresh()
          Refresh the lookup based on the comparator.
 void setComparator(java.util.Comparator<java.lang.String> comparator)
          Sets the comparator to use to sort the lookup
 int size()
          Return the number of items in this lookup.
 
Methods inherited from class com.ibm.commons.iloader.node.lookups.api.AbstractLookup
addLookupListener, addNotify, getLabelFromCodeIgnoreCase, notifyLookupChanged, removeLookupListener, removeNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sortAsc

public static final java.util.Comparator<java.lang.String> sortAsc

sortDesc

public static final java.util.Comparator<java.lang.String> sortDesc
Constructor Detail

SortedLookup

public SortedLookup(ILookup wrapped,
                    java.util.Comparator<java.lang.String> comparator)
Creates a new instance of this class.

Parameters:
wrapped -
comparator -
Method Detail

getComparator

public java.util.Comparator<java.lang.String> getComparator()

setComparator

public void setComparator(java.util.Comparator<java.lang.String> comparator)
Sets the comparator to use to sort the lookup

Parameters:
comparator -

refresh

public void refresh()
Refresh the lookup based on the comparator.


size

public int size()
Description copied from interface: ILookup
Return the number of items in this lookup.


getCode

public java.lang.String getCode(int index)
Description copied from interface: ILookup
Return the code or model value for this index.


getLabel

public java.lang.String getLabel(int index)
Description copied from interface: ILookup
Return the label displayed to the user for this index.


getLabelFromCode

public java.lang.String getLabelFromCode(java.lang.String code)
Description copied from interface: ILookup
Return the label for the given model value code.

Specified by:
getLabelFromCode in interface ILookup
Overrides:
getLabelFromCode in class com.ibm.commons.iloader.node.lookups.api.AbstractLookup

getImage

public org.eclipse.swt.graphics.Image getImage(int index)
Description copied from interface: ILookup
Return the image for the given index.

Specified by:
getImage in interface ILookup
Overrides:
getImage in class com.ibm.commons.iloader.node.lookups.api.AbstractLookup