org.greenstone.gs3client
Class QueryFormControl

java.lang.Object
  extended by org.greenstone.gs3client.data.QueryFormData
      extended by org.greenstone.gs3client.data.QueryFormData.QueryFormParam
          extended by org.greenstone.gs3client.QueryFormControl

 class QueryFormControl
extends QueryFormData.QueryFormParam

Represents a control in a query form. This wrapper class is a subclass of QueryFormParam that presents its QueryFormParam details as an appropriate GUI item *with* label (based on the QueryFormParam's type) for display in its own JPanel. This wrapper class is a widget that knows to display this QueryFormParam -- and any child <param>s or <option>s -- in its own JPanel.

Author:
ak19

Nested Class Summary
 
Nested classes/interfaces inherited from class org.greenstone.gs3client.data.QueryFormData
QueryFormData.QueryFormParam
 
Field Summary
protected  javax.swing.JComponent ref
          the widget that's a visual representation of this QueryFormParam
(package private)  int width
           
 
Fields inherited from class org.greenstone.gs3client.data.QueryFormData.QueryFormParam
def, ignore, occurs, subElements, type
 
Fields inherited from class org.greenstone.gs3client.data.QueryFormData
displayItem, name, OCCURS_ATT
 
Constructor Summary
QueryFormControl(org.w3c.dom.Element param)
          Constructor that creates a QueryFormControl for a <param> element
QueryFormControl(org.w3c.dom.Element param, javax.swing.JPanel parentPanel)
          Constructor that creates a QueryFormControl for a <param> element inside a panel.
 
Method Summary
protected  void addGridBagComponent(javax.swing.JPanel panel, javax.swing.JComponent comp, java.awt.GridBagLayout gbLayout, java.awt.GridBagConstraints gbConstraints, int col, int row, int w, int h)
          The multi-panel is laid out with a GridBagLayout in order to make the layout more attractive (so that the form controls don't have as odd sizes as before when GraphPaperLayout was used).
 void createBooleanField()
          Creates check box controls for the <param> elements whose types are GSXML.PARAM_TYPE_BOOLEAN.
 void createEnumListing(org.w3c.dom.Element param)
          Creates combo boxes/drop-downs for the <param> elements whose types are GSXML.PARAM_TYPE_ENUM_SINGLE and listboxes for those whose types are GSXML.PARAM_TYPE_ENUM_MULTI.
 void createMultiPanel(org.w3c.dom.Element param, javax.swing.JPanel parentPanel)
          A multi-panel is created for a *set* of controls that occur more than once.
 void createTextField()
          Creates text fields for the <param> elements whose types are GSXML.PARAM_TYPE_STRING or GSXML.PARAM_TYPE_INTEGER).
 void createWidget(org.w3c.dom.Element param)
          Creates the appropriate form control for the <param> element, based on its type.
 void setSelectedValue(java.util.HashMap nameValsMap)
          If called after the form containing these param controls has been displayed and the user has entered/selected values (i.e.
 
Methods inherited from class org.greenstone.gs3client.data.QueryFormData.QueryFormParam
getSubElements, show
 
Methods inherited from class org.greenstone.gs3client.data.QueryFormData
extractDisplayItem, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ref

protected javax.swing.JComponent ref
the widget that's a visual representation of this QueryFormParam


width

int width
Constructor Detail

QueryFormControl

public QueryFormControl(org.w3c.dom.Element param)
Constructor that creates a QueryFormControl for a <param> element

Parameters:
param - - a <param> element in a Query Service's describe response XML message

QueryFormControl

public QueryFormControl(org.w3c.dom.Element param,
                        javax.swing.JPanel parentPanel)
Constructor that creates a QueryFormControl for a <param> element inside a panel.

Parameters:
param - - a <param> element in a Query Service's describe response XML message
parentPanel - - the panel inside which this QueryFormControl is to display itself.
Method Detail

createWidget

public void createWidget(org.w3c.dom.Element param)
Creates the appropriate form control for the <param> element, based on its type.

Parameters:
param - - a <param> element in a Query Service's describe response XML message

createBooleanField

public void createBooleanField()
Creates check box controls for the <param> elements whose types are GSXML.PARAM_TYPE_BOOLEAN.


createTextField

public void createTextField()
Creates text fields for the <param> elements whose types are GSXML.PARAM_TYPE_STRING or GSXML.PARAM_TYPE_INTEGER).


createEnumListing

public void createEnumListing(org.w3c.dom.Element param)
Creates combo boxes/drop-downs for the <param> elements whose types are GSXML.PARAM_TYPE_ENUM_SINGLE and listboxes for those whose types are GSXML.PARAM_TYPE_ENUM_MULTI.

Parameters:
param - - a <param> element in a Query Service's describe response XML message

createMultiPanel

public void createMultiPanel(org.w3c.dom.Element param,
                             javax.swing.JPanel parentPanel)
A multi-panel is created for a *set* of controls that occur more than once. Processes <param type="multi"> in a Query Service's describe response XML. (I.e. the type is GSXML.PARAM_TYPE_MULTI) Complicated case: can have 'occurs' field set. And this <param> element can have multiple <param>s itself, each with the 'ignore' possibly set and each with its own <option> elements.

Parameters:
param - - a <param> element in a Query Service's describe response XML message
parentPanel - - the panel inside which the multipanel is to display itself.

addGridBagComponent

protected void addGridBagComponent(javax.swing.JPanel panel,
                                   javax.swing.JComponent comp,
                                   java.awt.GridBagLayout gbLayout,
                                   java.awt.GridBagConstraints gbConstraints,
                                   int col,
                                   int row,
                                   int w,
                                   int h)
The multi-panel is laid out with a GridBagLayout in order to make the layout more attractive (so that the form controls don't have as odd sizes as before when GraphPaperLayout was used). This method sets the constraints for the given control and then adds it to the given JPanel. This method is called to add a control (or heading label) to the multi-panel using GridBagLayout.

Parameters:
panel - is the panel to add the control (or heading label) to.
comp - is the Query Form control or heading JLabel to be laid out.
gbLayout - is the GridBagLayout object used to lay out the panel.
gbConstraints - is the GridBagConstraints object for the panel's GridBagLayout.
col - is the column value of the top-left of the control (for setting the GridBagLayout's gridx value).
row - is the row value of the top-left of the control (for setting the GridBagLayout's gridy value).
w - is the number of columns spanned by the control (for setting the GridBagLayout's gridwidth value).
h - is the number of rows spanned by the control (for setting the GridBagLayout's gridheight value).

setSelectedValue

public void setSelectedValue(java.util.HashMap nameValsMap)
If called after the form containing these param controls has been displayed and the user has entered/selected values (i.e. after the search button to execute a query has been pressed), then this method puts the controls' associated QueryFormParam names and the user- entered/-selected values into the HashMap nameValsmap (= the argument). Note that for the GSXML.PARAM_TYPE_MULTI case - where each related set of controls may occur several times (depending on member variable 'occurs') - the value entered/selected for each control that has the same *name* (= key into the HashMap) is added into the HashMap as a comma-separated list associated with its name-key. This method requires that argument nameValsmap is a non-null HashMap.

Parameters:
nameValsMap - - a non-null HashMap. At the end of this method, the nameValsMap HashMap will contain mappings from query parameter field names to their user-entered values (for the field's associated form controls).