lemurproject.indri.ui
Class IndexUI

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by lemurproject.indri.ui.IndexUI
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CaretListener, javax.swing.event.TableModelListener

public class IndexUI
extends javax.swing.JPanel
implements java.awt.event.ActionListener, java.awt.event.ItemListener, javax.swing.event.CaretListener, javax.swing.event.TableModelListener

User interface for building Indri indexes.

Version:
1.1 12/3/07 - added fields tab (MJH)
Author:
David Fisher, Mark J. Hoy
See Also:
Serialized Form

Nested Class Summary
(package private)  class IndexUI.UIIndexStatus
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static java.lang.String aboutText
          About the indexer.
private static java.lang.String[] annotationsColumnTooltips
           
(package private)  boolean appendIndex
          are we appending?
private  boolean blinking
          Is the blinker running?
private  javax.swing.JButton browse
          Action Buttons
private  javax.swing.JButton btnAddField
           
private  javax.swing.JButton btnHarvestLinks
           
private  javax.swing.JButton btnRemoveField
           
private  javax.swing.JButton cfbrowse
          Action Buttons
private  javax.swing.DefaultListModel cfModel
          hold the file names
private  javax.swing.JButton cfRemove
          Action Buttons
private  javax.swing.JTextField colFields
          field names
private  javax.swing.JList collectionFiles
          browse multiple filenames
private  java.util.Vector dataFilesOffsetFiles
           
private  javax.swing.JComboBox docFormat
          Multiple choices
private  javax.swing.JCheckBox doRecurse
          Single choice
private  javax.swing.JCheckBox doStem
          Single choice
private  javax.swing.JFileChooser fc
          File chooser starting in current directory
private static java.lang.String[] fieldColumnTooltips
           
private  javax.swing.JTable fieldTable
           
private  FieldTableModel fieldTableModel
           
private  javax.swing.JMenu fileMenu
          Menus
private  javax.swing.JTextField filterString
          filename filter
private  javax.swing.JMenuItem fOpen
          Menu Items
private static java.lang.String[] formats
          Indri FileClassEnvironments
private  javax.swing.JMenuItem fPrefs
          Menu Items
private  javax.swing.JMenuItem fQuit
          Menu Items
private  javax.swing.JMenuItem fSave
          Menu Items
private  javax.swing.JButton go
          Action Buttons
private  javax.swing.JMenuItem hAbout
          Menu Items
private static java.lang.String helpFile
          Help file for the application
private  javax.swing.JFrame helpFrame
          Frame for help window
private  javax.swing.JMenu helpMenu
          Menus
private  javax.swing.JMenuItem hHelp
          Menu Items
private static java.lang.String iconFile
          The little icon
private  javax.swing.JTextField iname
          input/browseable filename
private  javax.swing.JPanel indexFieldPanel
          Fields and Metadata items
private  javax.swing.ImageIcon indriIcon
          The Indri Icon.
private static java.lang.String[] lims
          Memory limit choices
private static java.lang.String logoFile
          The big logo
private  javax.swing.JComboBox memoryLim
          Multiple choices
private  javax.swing.JMenuBar menuBar
          MenuBar
private  javax.swing.JTextArea messages
          Messages pane for prog output
private  OffsetAnnotationTableModel offsetAnnotationFilesTableModel
           
private  javax.swing.JTable offsetAnnotationFileTable
           
private  javax.swing.JLabel status
          Status line messages visible for all tabs.
private  javax.swing.JComboBox stemmers
          Multiple choices
private  javax.swing.JButton stop
          Action Buttons
private  javax.swing.JButton stopBrowse
          Action Buttons
private  javax.swing.JTextField stopwordlist
          input/browseable filename
private  java.lang.String stopwords
          data directory paths
private static java.lang.String[] sTypes
          Stemmer types
private  javax.swing.JTabbedPane tabbedPane
          Top level container
private  javax.swing.JTextField txtPathToHarvestLinks
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
IndexUI()
          Get the ball rolling.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Omnibus for responding to user actions.
private  java.lang.Thread blinker(java.lang.String s1, java.lang.String s2)
          Make the status line blink while working.
private  void buildIndex()
          Ask the IndexEnvironment to add the files.
 void caretUpdate(javax.swing.event.CaretEvent event)
          Listens to the index name text field.
private static void createAndShowGUI()
          Create the GUI and show it.
protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
          Returns an ImageIcon, or null if the path was invalid.
private  void deleteDirectory(java.io.File dir)
          remove a directory and all of its files and subdirectories
private  long encodeMem()
           
private  java.lang.String encodeRegexp(java.lang.String regexp)
          Rewrite a shell filename pattern to a regular expression.
private  void ensureMessagesVisible()
          Keeps the message pane showing the last line appended.
private  java.lang.String[] formatDataFiles()
          Create the datafiles list of strings.
private  void formatDataFiles(java.io.File file, java.io.FileFilter f, java.util.Vector accum, java.lang.String offsetFile)
          Accumulate filenames for the input list.
private  void initGUI()
          Initialize the GUI elements, including preloading the help frame.
 void itemStateChanged(java.awt.event.ItemEvent e)
          Listens to the check boxes.
static void main(java.lang.String[] args)
          Fire it up.
private  void makeHelp()
          Create the frame that shows the help file and render the html.
private  javax.swing.JMenuBar makeMenuBar()
          Create the applications menu bar.
private  javax.swing.JMenuItem makeMenuItem(java.lang.String label)
          Creates a JMenuItem with this as its ActionListener.
private  javax.swing.JPanel makePanel()
          Create a JPanel with BorderLayout.
private  boolean safeToBuildIndex()
          Tests for likely failure scenarios.
private  void showException(java.lang.Exception e)
          Format an exception message in the messages text area.
 void tableChanged(javax.swing.event.TableModelEvent e)
          Listens for table model changes
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

status

private javax.swing.JLabel status
Status line messages visible for all tabs.


messages

private javax.swing.JTextArea messages
Messages pane for prog output


tabbedPane

private javax.swing.JTabbedPane tabbedPane
Top level container


doRecurse

private javax.swing.JCheckBox doRecurse
Single choice


doStem

private javax.swing.JCheckBox doStem
Single choice


stemmers

private javax.swing.JComboBox stemmers
Multiple choices


memoryLim

private javax.swing.JComboBox memoryLim
Multiple choices


docFormat

private javax.swing.JComboBox docFormat
Multiple choices


browse

private javax.swing.JButton browse
Action Buttons


cfbrowse

private javax.swing.JButton cfbrowse
Action Buttons


stopBrowse

private javax.swing.JButton stopBrowse
Action Buttons


cfRemove

private javax.swing.JButton cfRemove
Action Buttons


go

private javax.swing.JButton go
Action Buttons


stop

private javax.swing.JButton stop
Action Buttons


iname

private javax.swing.JTextField iname
input/browseable filename


stopwordlist

private javax.swing.JTextField stopwordlist
input/browseable filename


colFields

private javax.swing.JTextField colFields
field names


filterString

private javax.swing.JTextField filterString
filename filter


collectionFiles

private javax.swing.JList collectionFiles
browse multiple filenames


cfModel

private javax.swing.DefaultListModel cfModel
hold the file names


fc

private final javax.swing.JFileChooser fc
File chooser starting in current directory


stopwords

private java.lang.String stopwords
data directory paths


helpFile

private static final java.lang.String helpFile
Help file for the application

See Also:
Constant Field Values

iconFile

private static final java.lang.String iconFile
The little icon

See Also:
Constant Field Values

logoFile

private static final java.lang.String logoFile
The big logo


formats

private static final java.lang.String[] formats
Indri FileClassEnvironments


lims

private static final java.lang.String[] lims
Memory limit choices


sTypes

private static final java.lang.String[] sTypes
Stemmer types


appendIndex

boolean appendIndex
are we appending?


menuBar

private javax.swing.JMenuBar menuBar
MenuBar


fileMenu

private javax.swing.JMenu fileMenu
Menus


helpMenu

private javax.swing.JMenu helpMenu
Menus


fOpen

private javax.swing.JMenuItem fOpen
Menu Items


fSave

private javax.swing.JMenuItem fSave
Menu Items


fPrefs

private javax.swing.JMenuItem fPrefs
Menu Items


fQuit

private javax.swing.JMenuItem fQuit
Menu Items


hHelp

private javax.swing.JMenuItem hHelp
Menu Items


hAbout

private javax.swing.JMenuItem hAbout
Menu Items


indriIcon

private javax.swing.ImageIcon indriIcon
The Indri Icon.


aboutText

private static final java.lang.String aboutText
About the indexer.

See Also:
Constant Field Values

helpFrame

private javax.swing.JFrame helpFrame
Frame for help window


indexFieldPanel

private javax.swing.JPanel indexFieldPanel
Fields and Metadata items


fieldTable

private javax.swing.JTable fieldTable

fieldTableModel

private FieldTableModel fieldTableModel

btnAddField

private javax.swing.JButton btnAddField

btnRemoveField

private javax.swing.JButton btnRemoveField

offsetAnnotationFileTable

private javax.swing.JTable offsetAnnotationFileTable

offsetAnnotationFilesTableModel

private OffsetAnnotationTableModel offsetAnnotationFilesTableModel

txtPathToHarvestLinks

private javax.swing.JTextField txtPathToHarvestLinks

btnHarvestLinks

private javax.swing.JButton btnHarvestLinks

fieldColumnTooltips

private static java.lang.String[] fieldColumnTooltips

annotationsColumnTooltips

private static java.lang.String[] annotationsColumnTooltips

dataFilesOffsetFiles

private java.util.Vector dataFilesOffsetFiles

blinking

private volatile boolean blinking
Is the blinker running?

Constructor Detail

IndexUI

public IndexUI()
Get the ball rolling.

Method Detail

initGUI

private void initGUI()
Initialize the GUI elements, including preloading the help frame.


makeMenuBar

private javax.swing.JMenuBar makeMenuBar()
Create the applications menu bar.

Returns:
the JMenuBar.

makeMenuItem

private javax.swing.JMenuItem makeMenuItem(java.lang.String label)
Creates a JMenuItem with this as its ActionListener.

Parameters:
label - the label for the item.
Returns:
the created menu item.

makePanel

private javax.swing.JPanel makePanel()
Create a JPanel with BorderLayout.

Returns:
the Jpanel.

createImageIcon

protected static javax.swing.ImageIcon createImageIcon(java.lang.String path)
Returns an ImageIcon, or null if the path was invalid.

Parameters:
path - the image file to load.
Returns:
an ImageIcon, or null if the path was invalid.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Omnibus for responding to user actions.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
Listens for table model changes

Specified by:
tableChanged in interface javax.swing.event.TableModelListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Listens to the check boxes.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

caretUpdate

public void caretUpdate(javax.swing.event.CaretEvent event)
Listens to the index name text field. This enables updating the state of the BuildIndex button when the user types in the name of the index directly.

Specified by:
caretUpdate in interface javax.swing.event.CaretListener

makeHelp

private void makeHelp()
Create the frame that shows the help file and render the html.


createAndShowGUI

private static void createAndShowGUI()
Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread.


encodeRegexp

private java.lang.String encodeRegexp(java.lang.String regexp)
Rewrite a shell filename pattern to a regular expression.
* -> .*
? -> .?
Add ^ to beginning
Add $ to end
. -> \.

Parameters:
regexp - the filename pattern, eg "*.dat"
Returns:
a regular expression suitable for use with String.matches(), eg "^.*\.dat$"

safeToBuildIndex

private boolean safeToBuildIndex()
Tests for likely failure scenarios. If the path to the index doesn't exist, fail. If the named index already exists, offer a choice do either overwrite, append, or abandon. If overwrite is selected, removes all files in the target directory. This is potentially dangerous.

Returns:
true if it is safe to build the index otherwise false.

deleteDirectory

private void deleteDirectory(java.io.File dir)
remove a directory and all of its files and subdirectories


ensureMessagesVisible

private void ensureMessagesVisible()
Keeps the message pane showing the last line appended.


buildIndex

private void buildIndex()
Ask the IndexEnvironment to add the files.


formatDataFiles

private java.lang.String[] formatDataFiles()
Create the datafiles list of strings.

Returns:
The list of files

formatDataFiles

private void formatDataFiles(java.io.File file,
                             java.io.FileFilter f,
                             java.util.Vector accum,
                             java.lang.String offsetFile)
Accumulate filenames for the input list. If the File is a directory, iterate over all of the files in that directory that satisfy the filter. If recurse into subdirectories is selected and the File is a directory, invoke recursivly on on all directories within the directory.

Parameters:
accum - Vector to accumulate file names recusively.
file - a File (either a file or directory)
f - the filename filter to apply.

encodeMem

private long encodeMem()

showException

private void showException(java.lang.Exception e)
Format an exception message in the messages text area.

Parameters:
e - the exception

blinker

private java.lang.Thread blinker(java.lang.String s1,
                                 java.lang.String s2)
Make the status line blink while working.


main

public static void main(java.lang.String[] args)
Fire it up.