public class InputObject extends LiveObject implements HasProperties
Using the first method, constructing an InputObject with a field specification, the format for the "fields" variable is as follows:
"prompt$hotkey|fieldName$fieldType[$controlClass]|prompt$hotkey|fieldName$fieldType[$controlClass]|..."
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 Time object then you should have: "$Leve/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'.
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
InputObject() |
InputObject(String fields,
int inputLength)
Create an InputObject with the specified fields and with a particular input length.
|
Modifier and Type | Method and Description |
---|---|
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.
|
protected Editor |
makeNewEditor(int options)
This shoudl create the new Editor object but not add anything to it.
|
protected void |
setupInputStack(EditorStack 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.
|
action, action, addMeToPanel, addObjectToPanel, editorCanExit, enableEditorScrolling, fieldChanged, fieldChanged, fieldEvent, getEditor, getEditorScroller, getIcon, getName, input, isNamed, liveMain, main, menuItemSelected, prepareMainPanel, runAsApp, setToEditor, willBeSetToEditor
getParentObject, getParentObject, setParentObject
decode, decoded, decoded, decodeFields, decodeFields, encode, encoded, encoded, encodeFields, encodeFields, textDecode, textEncode
_getFieldType, _getSetField, cache, compareTo, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getMyFieldList, getNew
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareTo
textDecode, textEncode
public int inputLength
public String fields
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 or $P for a password string. Note also that for object values, you must use a '/' instead of a '.' to separate packages. e.g. Leve/sys/Time;
inputLength
- The length of the inputs.public PropertyList getProperties()
getProperties
in interface HasProperties
protected void setupInputStack(EditorStack 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.