Package adams.gui.core
Class SearchableBaseList
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JList
-
- adams.gui.core.BaseList
-
- adams.gui.core.SearchableBaseList
-
- All Implemented Interfaces:
SearchableList,ImageObserver,MenuContainer,Serializable,Accessible,Scrollable
public class SearchableBaseList extends BaseList implements SearchableList
Extended BaseList class that allows searching in its elements.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JList
JList.AccessibleJList, JList.DropLocation
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_SEARCHREGEXPthe key for the regular expression search flag.static StringKEY_SEARCHSTRINGthe key for the search string.protected SearchableWrapperListModelm_Modelthe searchable model.-
Fields inherited from class adams.gui.core.BaseList
m_RemoveItemsListeners
-
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description SearchableBaseList()Constructs aSearchableBaseListwith an empty, read-only, model.SearchableBaseList(Object[] listData)Constructs aSearchableBaseListthat displays the elements in the specified array.SearchableBaseList(Vector<?> listData)Constructs aSearchableBaseListthat displays the elements in the specifiedVector.SearchableBaseList(ListModel dataModel)Constructs aSearchableBaseListthat displays elements from the specified,non-null, model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Hashtable<String,Object>backupModelSettings(ListModel model)Backs up the settings from the old model.intgetActualIndex(int index)Returns the actual index in the model.ListModelgetActualModel()returns the underlying model, can be null.intgetActualSize()Returns the actual size of the model.protected ClassgetListModelClass()Returns the class of the list model that the models need to be derived from.StringgetSeachString()Returns the current search string.booleanisRegExpSearch()Returns whether the last search was a regular expression based one.protected voidrestoreModelSettings(ListModel model, Hashtable<String,Object> settings)Restores the settings previously backed up.voidsearch(String searchString, boolean regexp)Performs a search for the given string.voidsetActualModel(ListModel value)Sets the model to use.voidsetModel(ListModel model)Sets the model to display - onlygetListModelClass().-
Methods inherited from class adams.gui.core.BaseList
addRemoveItemsListener, canMoveDown, canMoveUp, initGUI, invertSelection, moveBottom, moveDown, moveTop, moveUp, notifyRemoveItemsListeners, removeRemoveItemsListener, selectAll, selectNone
-
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectedValuesList, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
KEY_SEARCHSTRING
public static final String KEY_SEARCHSTRING
the key for the search string.- See Also:
- Constant Field Values
-
KEY_SEARCHREGEXP
public static final String KEY_SEARCHREGEXP
the key for the regular expression search flag.- See Also:
- Constant Field Values
-
m_Model
protected SearchableWrapperListModel m_Model
the searchable model.
-
-
Constructor Detail
-
SearchableBaseList
public SearchableBaseList()
Constructs aSearchableBaseListwith an empty, read-only, model.
-
SearchableBaseList
public SearchableBaseList(Object[] listData)
Constructs aSearchableBaseListthat displays the elements in the specified array. This constructor creates a read-only model for the given array, and then delegates to the constructor that takes aListModel.Attempts to pass a
nullvalue to this method results in undefined behavior and, most likely, exceptions. The created model references the given array directly. Attempts to modify the array after constructing the list results in undefined behavior.- Parameters:
listData- the array of Objects to be loaded into the data model,non-null
-
SearchableBaseList
public SearchableBaseList(Vector<?> listData)
Constructs aSearchableBaseListthat displays the elements in the specifiedVector. This constructor creates a read-only model for the givenVector, and then delegates to the constructor that takes aListModel.Attempts to pass a
nullvalue to this method results in undefined behavior and, most likely, exceptions. The created model references the givenVectordirectly. Attempts to modify theVectorafter constructing the list results in undefined behavior.- Parameters:
listData- theVectorto be loaded into the data model,non-null
-
SearchableBaseList
public SearchableBaseList(ListModel dataModel)
Constructs aSearchableBaseListthat displays elements from the specified,non-null, model. AllSearchableBaseListconstructors delegate to this one.This constructor registers the list with the
ToolTipManager, allowing for tooltips to be provided by the cell renderers.- Parameters:
dataModel- the model for the list- Throws:
IllegalArgumentException- if the model isnull
-
-
Method Detail
-
getListModelClass
protected Class getListModelClass()
Returns the class of the list model that the models need to be derived from. The default implementation just returns ListModel.class- Returns:
- the class the models must be derived from
-
backupModelSettings
protected Hashtable<String,Object> backupModelSettings(ListModel model)
Backs up the settings from the old model.- Parameters:
model- the old model (the model stored within the SortedModel)- Returns:
- the backed up settings
-
restoreModelSettings
protected void restoreModelSettings(ListModel model, Hashtable<String,Object> settings)
Restores the settings previously backed up.- Parameters:
model- the new model (the model stored within the SortedModel)settings- the old settings, null if no settings were available
-
setModel
public void setModel(ListModel model)
Sets the model to display - onlygetListModelClass().
-
setActualModel
public void setActualModel(ListModel value)
Sets the model to use.- Parameters:
value- the model to use
-
getActualModel
public ListModel getActualModel()
returns the underlying model, can be null.- Returns:
- the current model
-
getActualIndex
public int getActualIndex(int index)
Returns the actual index in the model.- Specified by:
getActualIndexin interfaceSearchableList- Parameters:
index- the index of the currently displayed data- Returns:
- the index in the underlying data
-
getActualSize
public int getActualSize()
Returns the actual size of the model.- Specified by:
getActualSizein interfaceSearchableList- Returns:
- the size in the underlying data
-
search
public void search(String searchString, boolean regexp)
Performs a search for the given string. Limits the display of rows to ones containing the search string.- Specified by:
searchin interfaceSearchableList- Parameters:
searchString- the string to search forregexp- whether to perform regular expression matching or just plain string comparison
-
getSeachString
public String getSeachString()
Returns the current search string.- Specified by:
getSeachStringin interfaceSearchableList- Returns:
- the search string, null if not filtered
-
isRegExpSearch
public boolean isRegExpSearch()
Returns whether the last search was a regular expression based one.- Specified by:
isRegExpSearchin interfaceSearchableList- Returns:
- true if last search was a reg exp one
-
-