|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.data.DataObject
ewe.data.LiveObject
ewe.data.InputObject
This is a utility object which can be used to input data from a user. There are two
basic ways of doing this:
Using the first method, constructing an InputObject with a field specification, the format for the "fields" variable is as follows:
"prompt$hotkey|fieldName$fieldType|prompt$hotkey|fieldName$fieldType|..."
prompt can be any string which will be displayed as a prompt for an input field. If you end the prompt with
the sequence "$x", where 'x' can be any character, then 'x' will be considered the hot key for that field.
fieldName must be a field name for the previous prompt. This must be followed by a '$' and then an optional
java type in 'L' format. For example if you want to input a ewe.sys.Time object then you should have: "$Lewe/sys/Time;"
immediately following the field name. If you want to enter an integer then you should have: "$I" immediately following the
field name. A '$' with nothing after it denotes a String.
For example:
public static void main(String args[])
{
ewe.sys.Vm.startEwe(args);
PropertyList defaultValues = PropertyList.fromStrings("name|Homer Simpson|age|42");
PropertyList entered = new InputObject("Name:$n|name$|Age:$a|age$I",30).input(null,"Please enter data!",defaultValues);
if (entered != null) ewe.sys.Vm.debug(entered.toString());
ewe.sys.Vm.exit(0);
}
With the second method, in the overriden setupInputStack(InputStack is,Editor ed) you should add the appropiate input controls and fields to the InputStack 'is' and editor 'ed'.
| Field Summary | |
String |
fields
This is the specification of the fields to be input. |
int |
inputLength
This is the default input length, currently set to 30 characters. |
| Constructor Summary | |
InputObject()
|
|
InputObject(String fields,
int inputLength)
Create an InputObject with the specified fields and with a particular input length. |
|
| Method Summary | |
void |
addToPanel(CellPanel cp,
Editor ed,
int which)
You should not need to override this, but you can if you want to completely change the way the input form will look. |
PropertyList |
getProperties()
Get the property list which holds the values for the entered fields. |
PropertyList |
input(Frame parent,
String title,
PropertyList values)
This does the following: Sets the values of the fields to be as specified in the "values" PropertyList parameter. |
protected boolean |
isValid(PropertyList pl,
Editor ed)
This is called before the InputObject form exits with an exit code of IDOK. |
static void |
main(String[] args)
This allows you to test the InputObject with specified data. |
protected Editor |
makeNewEditor(int options)
This shoudl create the new Editor object but not add anything to it. |
protected void |
setupInputStack(InputStack is,
Editor ed)
You can override this to add your own custom fields and controls. |
protected void |
showErrorMessage(String title,
String message)
Use this if you wish from the isValid() method to display a message if the input is invalid. |
| Methods inherited from class ewe.data.LiveObject |
action, action, addMeToPanel, addObjectToPanel, decode, decoded, decodeFields, enableEditorScrolling, encode, encoded, encodeFields, fieldChanged, fieldChanged, fieldEvent, getEditor, getEditorScroller, getIcon, getName, input, runAsApp, textDecode, textEncode |
| Methods inherited from class ewe.data.DataObject |
_getSetField, appendAllFields, compareTo, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, toString |
| Methods inherited from interface ewe.data.DataUnit |
copyFrom, getNew |
| Methods inherited from interface ewe.util.Copyable |
getCopy |
| Methods inherited from interface ewe.util.Comparable |
compareTo |
| Field Detail |
public int inputLength
public String fields
| Constructor Detail |
public InputObject()
public InputObject(String fields,
int inputLength)
fields - This can be in two formats:The type of the field must be specified and should be for primitive (non-object values): I (integer), D (double), Z (boolean) or, to specify an object type: Lfull_class_name;. Note that can just have a '$' with nothing following to specify a String. Note also that for object values, you must use a '/' instead of a '.' to separate packages. e.g. Lewe/sys/Time;
inputLength - The length of the inputs.| Method Detail |
public PropertyList getProperties()
getProperties in interface HasProperties
protected void setupInputStack(InputStack is,
Editor ed)
public void addToPanel(CellPanel cp,
Editor ed,
int which)
addToPanel in class LiveObject
public PropertyList input(Frame parent,
String title,
PropertyList values)
protected Editor makeNewEditor(int options)
makeNewEditor in class LiveObject
protected void showErrorMessage(String title,
String message)
title - the title of the message box.message - the text of the message.
protected boolean isValid(PropertyList pl,
Editor ed)
pl - the PropertyList holding the input data.ed - the Editor form used for input.
public static void main(String[] args)
Try it out with the following field lists:
"lastName$,firstNames$,smoker$Z,salary$D,dob$Lewe/sys/Time;
and
"Contact Name$n|name$|Company$c|company$|Age$a|age$I"
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||