ucar.unidata.ui
Class HttpFormEntry

java.lang.Object
  extended by ucar.unidata.ui.HttpFormEntry

public class HttpFormEntry
extends Object

Class HttpFormEntry Represents a http form post input field.

Version:
$Revision: 1.18 $
Author:
IDV Development Team

Field Summary
static int TYPE_AREA
          Multi-line input field type
static int TYPE_FILE
          Just a label in the gui
static int TYPE_HIDDEN
          Hidden input field type
static int TYPE_INPUT
          Normal input field type
static int TYPE_LABEL
          Just a label in the gui
 
Constructor Summary
HttpFormEntry(int type, String name, String label)
          Create the entry
HttpFormEntry(int type, String name, String label, int rows, int cols)
          Create the entry
HttpFormEntry(int type, String name, String label, String value)
          Create the entry
HttpFormEntry(int type, String name, String label, String value, boolean required)
          Create the entry
HttpFormEntry(int type, String name, String label, String value, int rows, int cols)
          Create the entry
HttpFormEntry(int type, String name, String label, String value, int rows, int cols, boolean required)
          Create the entry
HttpFormEntry(String name, String label)
          Create the entry
HttpFormEntry(String name, String fileName, byte[] bytes)
          Create an entry that already holds the byte contents of a file.
 
Method Summary
 void addToGui(List guiComps)
          Add the label/gui component into the list of components
 void browse(JTextField fld)
          Open a file browser associated with the text field
static boolean checkEntries(List entries)
          Check the entries to make sure they have been filled in
static String[] doPost(List entries, String urlPath)
          Post the given entries tot he given url
 String getLabel()
          Get the label
 String getName()
          Get the name
 String getValue()
          Get the value the user entered.
static JComponent makeUI(List entries)
          Create the GUI from the list of entries
 boolean ok()
          Is this entry ok.
 boolean okToPost()
          Post the file
 void setValue(String newValue)
          Set the text value to the given newValue
static boolean showUI(List entries, JComponent extraTop, JComponent extraBottom, JDialog dialog, boolean shouldDoBusyWait)
          Show the UI in a modeful dialog.
static boolean showUI(List entries, String title, Window window, JComponent extraTop)
          Show the UI in a modeful dialog.
static boolean showUI(List entries, String title, Window parent, JComponent extraTop, JComponent extraBottom)
          Show the UI in a modeful dialog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_HIDDEN

public static final int TYPE_HIDDEN
Hidden input field type

See Also:
Constant Field Values

TYPE_INPUT

public static final int TYPE_INPUT
Normal input field type

See Also:
Constant Field Values

TYPE_AREA

public static final int TYPE_AREA
Multi-line input field type

See Also:
Constant Field Values

TYPE_LABEL

public static final int TYPE_LABEL
Just a label in the gui

See Also:
Constant Field Values

TYPE_FILE

public static final int TYPE_FILE
Just a label in the gui

See Also:
Constant Field Values
Constructor Detail

HttpFormEntry

public HttpFormEntry(String name,
                     String fileName,
                     byte[] bytes)
Create an entry that already holds the byte contents of a file. Having an entry like this will result in a multi-part post

Parameters:
name - The name of the file
fileName - filename - this is the name that is posted
bytes - the bytes

HttpFormEntry

public HttpFormEntry(String name,
                     String label)
Create the entry

Parameters:
name - The name
label - The label

HttpFormEntry

public HttpFormEntry(int type,
                     String name,
                     String label)
Create the entry

Parameters:
type - The type of this entry
name - The name
label - The label

HttpFormEntry

public HttpFormEntry(int type,
                     String name,
                     String label,
                     String value)
Create the entry

Parameters:
type - The type of this entry
name - The name
label - The label
value - Initial value

HttpFormEntry

public HttpFormEntry(int type,
                     String name,
                     String label,
                     String value,
                     boolean required)
Create the entry

Parameters:
type - The type of this entry
name - The name
label - The label
value - Initial value
required - Is this entry required

HttpFormEntry

public HttpFormEntry(int type,
                     String name,
                     String label,
                     int rows,
                     int cols)
Create the entry

Parameters:
type - The type of this entry
name - The name
label - The label
rows - How may rows in the text area
cols - How many columns in the text area

HttpFormEntry

public HttpFormEntry(int type,
                     String name,
                     String label,
                     String value,
                     int rows,
                     int cols)
Create the entry

Parameters:
type - The type of this entry
name - The name
label - The label
value - Initial value
rows - How many rows
cols - How many cols

HttpFormEntry

public HttpFormEntry(int type,
                     String name,
                     String label,
                     String value,
                     int rows,
                     int cols,
                     boolean required)
Create the entry

Parameters:
type - The type of this entry
name - The name
label - The label
value - Initial value
rows - How many rows
cols - How many cols
required - Is this entry required
Method Detail

ok

public boolean ok()
Is this entry ok. That is, has their been input if it is required

Returns:
Is ok

addToGui

public void addToGui(List guiComps)
Add the label/gui component into the list of components

Parameters:
guiComps - A list.

browse

public void browse(JTextField fld)
Open a file browser associated with the text field

Parameters:
fld - the JTextField

getValue

public String getValue()
Get the value the user entered.

Returns:
The input value

setValue

public void setValue(String newValue)
Set the text value to the given newValue

Parameters:
newValue - The new text

getName

public String getName()
Get the name

Returns:
The name

getLabel

public String getLabel()
Get the label

Returns:
The label

makeUI

public static JComponent makeUI(List entries)
Create the GUI from the list of entries

Parameters:
entries - List of entries
Returns:
The gui

checkEntries

public static boolean checkEntries(List entries)
Check the entries to make sure they have been filled in

Parameters:
entries - list of entries
Returns:
false if some are not filled in.

showUI

public static boolean showUI(List entries,
                             String title,
                             Window window,
                             JComponent extraTop)
Show the UI in a modeful dialog. Note: this method should not be called from a swing process. It does a busy wait on the dialog and does not rely on the modality of the dialog to do its wait.

Parameters:
entries - List of entries
title - The dialog title
window - The parent window
extraTop - If non-null then this is added to the top of the gui. It allows you to provide a label, etc.
Returns:
Did user press ok

showUI

public static boolean showUI(List entries,
                             String title,
                             Window parent,
                             JComponent extraTop,
                             JComponent extraBottom)
Show the UI in a modeful dialog. Note: this method should not be called from a swing process. It does a busy wait on the dialog and does not rely on the modality of the dialog to do its wait.

Parameters:
entries - List of entries
title - The dialog title
parent - The parent window
extraTop - If non-null then this is added to the top of the gui. It allows you to provide a label, etc.
extraBottom - Like extraTop but on the bottom of the window
Returns:
Did user press ok

showUI

public static boolean showUI(List entries,
                             JComponent extraTop,
                             JComponent extraBottom,
                             JDialog dialog,
                             boolean shouldDoBusyWait)
Show the UI in a modeful dialog. Note: The calling method is responsible for disposing of the dialog. Also: This method should not be called from a swing process. It does a busy wait on the dialog and does not rely on the modality of the dialog to do its wait.

Parameters:
entries - List of entries
extraTop - If non-null then this is added to the top of the gui. It allows you to provide a label, etc.
extraBottom - Like extraTop but on the bottom of the window
dialog - the dialog
shouldDoBusyWait - true to wait
Returns:
Did user press ok

okToPost

public boolean okToPost()
Post the file

Returns:
true if posted

doPost

public static String[] doPost(List entries,
                              String urlPath)
Post the given entries tot he given url

Parameters:
entries - The entries
urlPath - The url to post to
Returns:
2 element array. First element is non-null if there was an error. Second element is non-null if no error. This is the returned html.