Package ucar.unidata.ui
Class HttpFormEntry
java.lang.Object
ucar.unidata.ui.HttpFormEntry
Class HttpFormEntry Represents a http form post input field.
- Version:
- $Revision: 1.18 $
- Author:
- IDV Development Team
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Multi-line input field typestatic final int
Just a label in the guistatic final int
Hidden input field typestatic final int
Normal input field typestatic final int
Just a label in the gui -
Constructor Summary
ConstructorsConstructorDescriptionHttpFormEntry
(int type, String name, String label) Create the entryHttpFormEntry
(int type, String name, String label, int rows, int cols) Create the entryHttpFormEntry
(int type, String name, String label, String value) Create the entryHttpFormEntry
(int type, String name, String label, String value, boolean required) Create the entryHttpFormEntry
(int type, String name, String label, String value, int rows, int cols) Create the entryHttpFormEntry
(int type, String name, String label, String value, int rows, int cols, boolean required) Create the entryHttpFormEntry
(String name, String label) Create the entryHttpFormEntry
(String name, String fileName, byte[] bytes) Create an entry that already holds the byte contents of a file.HttpFormEntry
(String name, String label, String value) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the label/gui component into the list of componentsvoid
browse
(JTextField fld) Open a file browser associated with the text fieldstatic boolean
checkEntries
(List<HttpFormEntry> entries) Check the entries to make sure they have been filled instatic String[]
doPost
(List<HttpFormEntry> entries, String urlPath) Post the given entries tot he given urlbyte[]
getBytes()
Get the bytesgetLabel()
Get the labelgetName()
Get the namegetValue()
Get the value the user entered.static HttpFormEntry
static JComponent
makeUI
(List<HttpFormEntry> entries) Create the GUI from the list of entriesboolean
ok()
Is this entry ok.boolean
okToPost()
Post the filevoid
Set the text value to the given newValuestatic boolean
showUI
(List<HttpFormEntry> entries, String title, Window window, JComponent extraTop) Show the UI in a modeful dialog.static boolean
showUI
(List<HttpFormEntry> entries, String title, Window parent, JComponent extraTop, JComponent extraBottom) Show the UI in a modeful dialog.static boolean
showUI
(List<HttpFormEntry> entries, JComponent extraTop, JComponent extraBottom, JDialog dialog, boolean shouldDoBusyWait) Show the UI in a modeful dialog.
-
Field Details
-
TYPE_HIDDEN
public static final int TYPE_HIDDENHidden input field type- See Also:
-
TYPE_INPUT
public static final int TYPE_INPUTNormal input field type- See Also:
-
TYPE_AREA
public static final int TYPE_AREAMulti-line input field type- See Also:
-
TYPE_LABEL
public static final int TYPE_LABELJust a label in the gui- See Also:
-
TYPE_FILE
public static final int TYPE_FILEJust a label in the gui- See Also:
-
-
Constructor Details
-
HttpFormEntry
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 filefileName
- filename - this is the name that is postedbytes
- the bytes
-
HttpFormEntry
-
HttpFormEntry
Create the entry- Parameters:
name
- The namelabel
- The label
-
HttpFormEntry
Create the entry- Parameters:
type
- The type of this entryname
- The namelabel
- The label
-
HttpFormEntry
Create the entry- Parameters:
type
- The type of this entryname
- The namelabel
- The labelvalue
- Initial value
-
HttpFormEntry
Create the entry- Parameters:
type
- The type of this entryname
- The namelabel
- The labelvalue
- Initial valuerequired
- Is this entry required
-
HttpFormEntry
Create the entry- Parameters:
type
- The type of this entryname
- The namelabel
- The labelrows
- How may rows in the text areacols
- How many columns in the text area
-
HttpFormEntry
Create the entry- Parameters:
type
- The type of this entryname
- The namelabel
- The labelvalue
- Initial valuerows
- How many rowscols
- 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 entryname
- The namelabel
- The labelvalue
- Initial valuerows
- How many rowscols
- How many colsrequired
- Is this entry required
-
-
Method Details
-
ok
public boolean ok()Is this entry ok. That is, has their been input if it is required- Returns:
- Is ok
-
addToGui
Add the label/gui component into the list of components- Parameters:
guiComps
- A list.
-
browse
Open a file browser associated with the text field- Parameters:
fld
- the JTextField
-
getValue
Get the value the user entered.- Returns:
- The input value
-
setValue
Set the text value to the given newValue- Parameters:
newValue
- The new text
-
getName
Get the name- Returns:
- The name
-
getLabel
Get the label- Returns:
- The label
-
getBytes
public byte[] getBytes()Get the bytes- Returns:
- The bytes
-
makeUI
Create the GUI from the list of entries- Parameters:
entries
- List of entries- Returns:
- The gui
-
checkEntries
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<HttpFormEntry> 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 entriestitle
- The dialog titlewindow
- The parent windowextraTop
- 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<HttpFormEntry> 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 entriestitle
- The dialog titleparent
- The parent windowextraTop
- 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<HttpFormEntry> 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 entriesextraTop
- 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 windowdialog
- the dialogshouldDoBusyWait
- true to wait- Returns:
- Did user press ok
-
okToPost
public boolean okToPost()Post the file- Returns:
- true if posted
-
doPost
Post the given entries tot he given url- Parameters:
entries
- The entriesurlPath
- 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.