edu.rice.cs.drjava.ui.predictive
Class PredictiveInputFrame<T extends Comparable<? super T>>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by edu.rice.cs.util.swing.SwingFrame
                          extended by edu.rice.cs.drjava.ui.predictive.PredictiveInputFrame<T>
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants

public class PredictiveInputFrame<T extends Comparable<? super T>>
extends SwingFrame

Frame with predictive string input based on a list of strings.

See Also:
Serialized Form

Nested Class Summary
static interface PredictiveInputFrame.CloseAction<X extends Comparable<? super X>>
          Interface for an action to be performed when the user closes the frame, either by using "OK" or "Cancel".
static class PredictiveInputFrame.FrameState
          Class to save the frame state, i.e.
static interface PredictiveInputFrame.InfoSupplier<X>
          Interface that is used to generate additional information about an item.
 
Nested classes/interfaces inherited from class javax.swing.JFrame
JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
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
protected  JComponent[] _optionalComponents
          Optional components for the _optionsPanel.
protected  JPanel _optionsPanel
          Panel for additional options.
protected  Runnable1<WindowEvent> CANCEL
          Runnable that calls _cancel.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PredictiveInputFrame(SwingFrame owner, String title, boolean force, boolean ignoreCase, PredictiveInputFrame.InfoSupplier<? super T> info, List<PredictiveInputModel.MatchingStrategy<T>> strategies, List<PredictiveInputFrame.CloseAction<T>> actions, int cancelIndex, List<T> items)
          Create a new predictive string input frame.
PredictiveInputFrame(SwingFrame owner, String title, boolean force, boolean ignoreCase, PredictiveInputFrame.InfoSupplier<? super T> info, List<PredictiveInputModel.MatchingStrategy<T>> strategies, List<PredictiveInputFrame.CloseAction<T>> actions, int cancelIndex, T... items)
          Create a new predictive string input frame.
 
Method Summary
 String getButtonPressed()
          Return the name for the last button that was pressed.
 PredictiveInputFrame.FrameState getFrameState()
          Returns the last state of the frame, i.e.
 T getItem()
          Return the item that was selected or null the user entered a mask not in the list and force == false.
 List<T> getList()
          Return a copy of the list of items in the model.
 String getMask()
          Return the raw, unforced text in the text field.
 String getText()
          Return the string that was entered in the text field.
protected  JComponent[] makeOptions()
          Creates the optional components.
 void resetFocus()
          Focus back in the text field.
 void selectStrategy()
          Select the strategy for matching.
 void setCurrentItem(T item)
          Set the currently selected item.
 void setFrameState(PredictiveInputFrame.FrameState ds)
          Sets state of the frame, i.e.
 void setFrameState(String s)
          Sets state of the frame, i.e.
 void setItems(boolean ignoreCase, List<T> items)
          Set the items.
 void setItems(boolean ignoreCase, T... items)
          Set the items.
 void setMask(String mask)
          Set the mask in the text field.
 void setModel(boolean ignoreCase, PredictiveInputModel<T> pim)
          Set the predictive input model.
 void setOwnerEnabled(boolean b)
          Enable or disable owner.
 void setVisible(boolean vis)
          Toggle visibility of this frame.
 
Methods inherited from class edu.rice.cs.util.swing.SwingFrame
duringInit, initDone
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

_optionsPanel

protected JPanel _optionsPanel
Panel for additional options.


_optionalComponents

protected JComponent[] _optionalComponents
Optional components for the _optionsPanel.


CANCEL

protected final Runnable1<WindowEvent> CANCEL
Runnable that calls _cancel.

Constructor Detail

PredictiveInputFrame

public PredictiveInputFrame(SwingFrame owner,
                            String title,
                            boolean force,
                            boolean ignoreCase,
                            PredictiveInputFrame.InfoSupplier<? super T> info,
                            List<PredictiveInputModel.MatchingStrategy<T>> strategies,
                            List<PredictiveInputFrame.CloseAction<T>> actions,
                            int cancelIndex,
                            List<T> items)
Create a new predictive string input frame.

Parameters:
owner - owner frame
force - true if the user is forced to select one of the items
ignoreCase - true if case should be ignored
info - information supplier to use for additional information display
strategies - array of matching strategies
actions - actions to be performed when the user closes the frame, e.g. "OK" and "Cancel"; "Cancel" has to be last
items - list of items

PredictiveInputFrame

public PredictiveInputFrame(SwingFrame owner,
                            String title,
                            boolean force,
                            boolean ignoreCase,
                            PredictiveInputFrame.InfoSupplier<? super T> info,
                            List<PredictiveInputModel.MatchingStrategy<T>> strategies,
                            List<PredictiveInputFrame.CloseAction<T>> actions,
                            int cancelIndex,
                            T... items)
Create a new predictive string input frame.

Parameters:
owner - owner frame
force - true if the user is forced to select one of the items
info - information supplier to use for additional information display
strategies - array of matching strategies
actions - actions to be performed when the user closes the frame, e.g. "OK" and "Cancel"; "Cancel" has to be last
items - varargs/array of items
Method Detail

getFrameState

public PredictiveInputFrame.FrameState getFrameState()
Returns the last state of the frame, i.e. the location and dimension.

Returns:
frame state

setFrameState

public void setFrameState(PredictiveInputFrame.FrameState ds)
Sets state of the frame, i.e. the location and dimension of the frame for the next use.

Parameters:
ds - State to update to, or null to reset

setFrameState

public void setFrameState(String s)
Sets state of the frame, i.e. the location and dimension of the frame for the next use.

Parameters:
s - State to update to, or null to reset

getList

public List<T> getList()
Return a copy of the list of items in the model.

Returns:
list of items

setModel

public void setModel(boolean ignoreCase,
                     PredictiveInputModel<T> pim)
Set the predictive input model.

Parameters:
ignoreCase - true if case should be ignored
pim - predictive input model

setItems

public void setItems(boolean ignoreCase,
                     List<T> items)
Set the items.

Parameters:
ignoreCase - true if case should be ignored
items - list of items

setCurrentItem

public void setCurrentItem(T item)
Set the currently selected item.

Parameters:
item - item to select

setItems

public void setItems(boolean ignoreCase,
                     T... items)
Set the items.

Parameters:
ignoreCase - true if case should be ignored
items - varargs/array of items

getButtonPressed

public String getButtonPressed()
Return the name for the last button that was pressed.

Returns:
button name

getMask

public String getMask()
Return the raw, unforced text in the text field.

Returns:
text in text field

setMask

public void setMask(String mask)
Set the mask in the text field.

Parameters:
mask - for text field

getText

public String getText()
Return the string that was entered in the text field. If the user is forced to select an item, then the text of the item will be returned.

Returns:
text in text field

getItem

public T getItem()
Return the item that was selected or null the user entered a mask not in the list and force == false.

Returns:
item that was selected or null

makeOptions

protected JComponent[] makeOptions()
Creates the optional components. Should be overridden.


setOwnerEnabled

public void setOwnerEnabled(boolean b)
Enable or disable owner. Can be overridden to toggle the hourglass, etc.

Parameters:
b - whether the owner should be enabled (true) or disabled

setVisible

public void setVisible(boolean vis)
Toggle visibility of this frame. Warning, it behaves like a modal dialog.

Overrides:
setVisible in class Window

resetFocus

public void resetFocus()
Focus back in the text field.


selectStrategy

public void selectStrategy()
Select the strategy for matching.