jsky.catalog.gui
Class CatalogQueryPanel

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 jsky.catalog.gui.CatalogQueryPanel
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, Storeable

public class CatalogQueryPanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener, Storeable

Displays a panel containing widgets to use for searching a given catalog. Based on the catalog configuration information, different search fields are presented.

See Also:
Serialized Form

Nested Class Summary
 
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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static java.awt.Insets LABEL_INSETS
          Isets used for labels in the GridBagLayout
protected static java.awt.Dimension MIN_COMPONENT_SIZE
          Used to keep the combo boxes from getting too wide
protected  java.text.NumberFormat nf
          Used to format floating point values
protected static java.awt.Insets VALUE_INSETS
          Isets used for values in the GridBagLayout
 
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
  CatalogQueryPanel(Catalog catalog)
          Create a CatalogQueryPanel containing catalog specific labels and components for the search parameters specified in the catalog configuration file.
  CatalogQueryPanel(Catalog catalog, int numCols)
          Create a CatalogQueryPanel containing catalog specific labels and components for the search parameters specified in the catalog configuration file.
protected CatalogQueryPanel(Catalog catalog, int numCols, boolean doLayout)
          This constructor is for use by derived classes.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Called when a query parameter is changed to start the search.
 void addActionListener(java.awt.event.ActionListener l)
          Register to receive action events from this object whenever a query parameter is changed.
 void addChangeListener(javax.swing.event.ChangeListener l)
          Register to receive change events from this object whenever an item is selected from a JComboBox.
protected  int doGridBagLayout(GridBagUtil layout)
          Combine the panel items in the correct layout.
protected  void fireActionEvent()
          Notify any action listeners.
protected  void fireChange(javax.swing.JComponent c)
          Notify any listeners that a query parameter (from a JComboBox) has changed.
 Catalog getCatalog()
          Return the catalog for this object
 javax.swing.JComponent getComponentForLabel(java.lang.String s)
          Return the display component corresponding to the given label text, or null if not found.
 java.lang.String getLabelForComponent(javax.swing.JComponent c)
          Return the text of the label corresponding to the given display component, or null if not found.
protected  int getNumCols()
          Return the number of columns to use for the display (should be an even number)
 QueryArgs getQueryArgs()
          Return a QueryArgs object based on the current panel settings that can be passed to the Catalog.query() method.
protected  java.lang.Object getValue(FieldDesc p, javax.swing.JComponent c)
          Return the value in the given component, or null if there is no value there.
protected  java.lang.Object getValue(int i)
          Return the value in the ith component, or null if there is no value there.
 void initQueryArgs(QueryArgs queryArgs)
          Initialize a QueryArgs object based on the current panel settings that can be passed to the Catalog.query() method.
protected  javax.swing.JCheckBox makeCheckBox()
          Make and return a checkbutton
protected  javax.swing.JComponent makeComboBox(FieldDesc p)
          Make and return a combo box with the values that the given field may have.
protected  javax.swing.JComponent makeComponent(FieldDesc p)
          Make and return the component for entering the value of the given query parameter.
protected  javax.swing.JLabel makeLabel(java.lang.String s)
          Make panel label with the given text
protected  void makePanelItems()
          Make the display panel items
protected  javax.swing.JTextField makeTextField(int width)
          Make and return a text field with the given width.
 void removeActionListener(java.awt.event.ActionListener l)
          Stop receiving action events from this object.
 void removeChangeListener(javax.swing.event.ChangeListener l)
          Stop receiving change events from this object.
protected  void removePanelItems()
          Remove the panel items.
 boolean restoreSettings(java.lang.Object obj)
          Restore the settings previously stored.
 void setQueryArgs(QueryArgs queryArgs)
          Set the values displayed in the query panel from the given object.
protected  void setValue(int i, java.lang.Object value)
          Set the value in the ith component.
protected  void setValue(javax.swing.JComponent c, java.lang.Object value)
          Set the value in the given component.
protected  void setValue(java.lang.String label, java.lang.Object value)
          Set the value in the named component.
 java.lang.Object storeSettings()
          Store the current settings in a serializable object and return the object.
 void update()
          Update the display to reflect any changes in the catalog's query parameters
 
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, 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, 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

LABEL_INSETS

protected static final java.awt.Insets LABEL_INSETS
Isets used for labels in the GridBagLayout


VALUE_INSETS

protected static final java.awt.Insets VALUE_INSETS
Isets used for values in the GridBagLayout


nf

protected java.text.NumberFormat nf
Used to format floating point values


MIN_COMPONENT_SIZE

protected static final java.awt.Dimension MIN_COMPONENT_SIZE
Used to keep the combo boxes from getting too wide

Constructor Detail

CatalogQueryPanel

public CatalogQueryPanel(Catalog catalog,
                         int numCols)
Create a CatalogQueryPanel containing catalog specific labels and components for the search parameters specified in the catalog configuration file.

Parameters:
catalog - the catalog to use
numCols - the number of columns to use for the display (should be an even number)

CatalogQueryPanel

public CatalogQueryPanel(Catalog catalog)
Create a CatalogQueryPanel containing catalog specific labels and components for the search parameters specified in the catalog configuration file.

Parameters:
catalog - the catalog to use

CatalogQueryPanel

protected CatalogQueryPanel(Catalog catalog,
                            int numCols,
                            boolean doLayout)
This constructor is for use by derived classes. The doLayout flag can be set to false to delay the calling of the GUI creation methods makePanelItems() and doGridBagLayout() until the derived class has had a chance to do something.

Parameters:
catalog - the catalog to use
numCols - the number of columns to use for the display (should be an even number)
doLayout - if true, layout the GUI layout, otherwise the derived class must do it
Method Detail

getNumCols

protected int getNumCols()
Return the number of columns to use for the display (should be an even number)


update

public void update()
Update the display to reflect any changes in the catalog's query parameters


addActionListener

public void addActionListener(java.awt.event.ActionListener l)
Register to receive action events from this object whenever a query parameter is changed.


removeActionListener

public void removeActionListener(java.awt.event.ActionListener l)
Stop receiving action events from this object.


fireActionEvent

protected void fireActionEvent()
Notify any action listeners.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Called when a query parameter is changed to start the search.

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

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener l)
Register to receive change events from this object whenever an item is selected from a JComboBox.


removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener l)
Stop receiving change events from this object.


fireChange

protected void fireChange(javax.swing.JComponent c)
Notify any listeners that a query parameter (from a JComboBox) has changed.


makeLabel

protected javax.swing.JLabel makeLabel(java.lang.String s)
Make panel label with the given text


getCatalog

public Catalog getCatalog()
Return the catalog for this object


makeComponent

protected javax.swing.JComponent makeComponent(FieldDesc p)
Make and return the component for entering the value of the given query parameter.


makeTextField

protected javax.swing.JTextField makeTextField(int width)
Make and return a text field with the given width.


makeCheckBox

protected javax.swing.JCheckBox makeCheckBox()
Make and return a checkbutton


makeComboBox

protected javax.swing.JComponent makeComboBox(FieldDesc p)
Make and return a combo box with the values that the given field may have.


makePanelItems

protected void makePanelItems()
Make the display panel items


removePanelItems

protected void removePanelItems()
Remove the panel items.


getLabelForComponent

public java.lang.String getLabelForComponent(javax.swing.JComponent c)
Return the text of the label corresponding to the given display component, or null if not found.


getComponentForLabel

public javax.swing.JComponent getComponentForLabel(java.lang.String s)
Return the display component corresponding to the given label text, or null if not found.


doGridBagLayout

protected int doGridBagLayout(GridBagUtil layout)
Combine the panel items in the correct layout.

Parameters:
layout - utility object used for the layout
Returns:
the number of rows in the layout

initQueryArgs

public void initQueryArgs(QueryArgs queryArgs)
Initialize a QueryArgs object based on the current panel settings that can be passed to the Catalog.query() method.


getQueryArgs

public QueryArgs getQueryArgs()
Return a QueryArgs object based on the current panel settings that can be passed to the Catalog.query() method.

Returns:
the QueryArgs object to use for a catalog query.

setQueryArgs

public void setQueryArgs(QueryArgs queryArgs)
Set the values displayed in the query panel from the given object.

Parameters:
queryArgs - QueryArgs object describing the values (null values are ignored)

getValue

protected java.lang.Object getValue(FieldDesc p,
                                    javax.swing.JComponent c)
Return the value in the given component, or null if there is no value there.


getValue

protected java.lang.Object getValue(int i)
Return the value in the ith component, or null if there is no value there.


setValue

protected void setValue(int i,
                        java.lang.Object value)
Set the value in the ith component.


setValue

protected void setValue(java.lang.String label,
                        java.lang.Object value)
Set the value in the named component.


setValue

protected void setValue(javax.swing.JComponent c,
                        java.lang.Object value)
Set the value in the given component.


storeSettings

public java.lang.Object storeSettings()
Store the current settings in a serializable object and return the object.

Specified by:
storeSettings in interface Storeable

restoreSettings

public boolean restoreSettings(java.lang.Object obj)
Restore the settings previously stored.

Specified by:
restoreSettings in interface Storeable