|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.izforge.izpack.panels.RuleInputField
This class assists the user in entering serial numbers.
Serial numbers, license number, CD keys and the like are often lenghty
alpha-numerical numbers. In many cases they are devided into multiple
parts by dash or point separators. Entering these in a single text field
can be a frustrating experience for the user. This class provides a way
of presenting the user with an assembly of input fields that are arranged
in the same way as the key, with the separators already in place.
Immideate testing for format compliance if performed ans soon as each
field is completed. In addition, the cursor is automatically advanced
to make entering numbers as painless as possible.
Formatting:
N:X:Y
- numeric field, accepts digits only
H:X:Y
- hex field, accepts only hexadecimal digits
A:X:Y
- alpha field, accepts only letters, no digits
AN:X:Y
- alpha-numeric field, accepts digits and letters
"N:4:4 - H:6:6 - AN:3:3 x A:5:5"
Nested Class Summary | |
(package private) class |
RuleInputField.FieldSpec
|
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
private RuleTextField |
activeField
|
private boolean |
backstep
|
private static int |
DEFAULT
Used internally to identify the default setting for the return format. |
static int |
DISPLAY_FORMAT
Used to specify the retsult format. |
static int |
ENCRYPTED
Used to specify the retsult format. |
private Processor |
encryptionService
Holds an instance of the Processor if one was specified
and available |
private java.util.Vector |
inputFields
This Vector holds a reference to each input field, in the
order in which they appear on the screen. |
private java.util.Vector |
items
|
static int |
PLAIN_STRING
Used to specify the retsult format. |
private int |
resultFormat
|
private java.lang.String |
separator
|
static int |
SPECIAL_SEPARATOR
Used to specify the retsult format. |
private java.awt.Toolkit |
toolkit
|
private Validator |
validationService
Holds an instance of the Validator if one was
specified and available |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Container |
|
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
RuleInputField(java.lang.String format,
java.lang.String preset,
java.lang.String separator,
java.lang.String validator,
java.lang.String processor,
int resultFormat,
java.awt.Toolkit toolkit)
Constructs a rule input field. |
Method Summary | |
void |
caretUpdate(javax.swing.event.CaretEvent event)
Called when the caret position is updated. |
private void |
createItems(java.lang.String format)
Creates the items that make up this field. |
void |
focusGained(java.awt.event.FocusEvent event)
Invoked when a component gains the keyboard focus. |
void |
focusLost(java.awt.event.FocusEvent event)
Invoked when a component loses the keyboard focus. |
java.lang.String |
getFieldContents(int index)
Returns the contents of the field indicated by index . |
int |
getNumFields()
Returns the number of sub-fields composing this RuleInputField . |
java.lang.String |
getText()
Returns the field contents, assembled acording to the encryption and separator rules. |
void |
keyPressed(java.awt.event.KeyEvent event)
This method is invoked when a key has been pressed. |
void |
keyReleased(java.awt.event.KeyEvent event)
This method is invoked when a key has been released. |
void |
keyTyped(java.awt.event.KeyEvent event)
This method is invoked when a key has been typed. |
private void |
setFields(java.lang.String data)
Sets each field to a pre-defined value. |
boolean |
validateContents()
This method validates the field content. |
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static int PLAIN_STRING
public static int DISPLAY_FORMAT
public static int SPECIAL_SEPARATOR
public static int ENCRYPTED
private static int DEFAULT
private java.util.Vector items
private java.util.Vector inputFields
Vector
holds a reference to each input field, in the
order in which they appear on the screen.
private RuleTextField activeField
private boolean backstep
private java.awt.Toolkit toolkit
private java.lang.String separator
private int resultFormat
private Validator validationService
Validator
if one was
specified and available
private Processor encryptionService
Processor
if one was specified
and available
Constructor Detail |
public RuleInputField(java.lang.String format, java.lang.String preset, java.lang.String separator, java.lang.String validator, java.lang.String processor, int resultFormat, java.awt.Toolkit toolkit)
format
- a string that specifies the formatting and to a
limited degree the behavior of this field.preset
- a string that specifies preset values for specific
sub-fields.separator
- a string to be used for separating the contents
of individual fields in the string returned by
getText()
validator
- A string that specifies a class to perform
validation services. The string must completely
identify the class, so that it can be instantiated.
The class must implement the RuleValidator
interface. If an attempt to instantiate this class
fails, no validation will be performed.processor
- A string that specifies a class to perform
processing services. The string must completely
identify the class, so that it can be instantiated.
The class must implement the Processor
interface. If an attempt to instantiate this class
fails, no processing will be performed. Instead,
the text is returned in the default formatting.resultFormat
- specifies in which format the resulting text
should be returned, wehn getText()
is called. The following values are legal:toolkit
- needed to gain access to beep()
Method Detail |
public int getNumFields()
RuleInputField
.
getNumFields
in interface ProcessingClient
public java.lang.String getFieldContents(int index) throws java.lang.IndexOutOfBoundsException
index
.
getFieldContents
in interface ProcessingClient
index
- the index of the sub-field from which the contents
is requested.
java.lang.IndexOutOfBoundsException
- if the index is out of bounds.public java.lang.String getText()
private void createItems(java.lang.String format)
items
. In addition, all fields are stored in
inputFields
.
format
- a string that specifies the layout of the input
fields and separators.private void setFields(java.lang.String data)
data
- a String
containing the preset values for
each field. The format of the string is as follows:
The content for the individuals fields must be separated
by whitespace. Each data block is preceeded by the index
of the field to set (counting starts at 0) followed by
a colon ':'and after that the actual data for the field.public boolean validateContents()
true
if the validation passes or no implementation
of a validation rule exists. Otherwise false
is
returned.public void keyTyped(java.awt.event.KeyEvent event)
keyTyped
in interface java.awt.event.KeyListener
event
- the key event forwarded by the system.public void keyPressed(java.awt.event.KeyEvent event)
keyPressed
in interface java.awt.event.KeyListener
event
- the key event forwarded by the system.public void keyReleased(java.awt.event.KeyEvent event)
keyReleased
in interface java.awt.event.KeyListener
event
- the key event forwarded by the system.public void focusGained(java.awt.event.FocusEvent event)
focusGained
in interface java.awt.event.FocusListener
event
- the focus event forwardes by the sytem.public void focusLost(java.awt.event.FocusEvent event)
focusLost
in interface java.awt.event.FocusListener
event
- the focus event forwardes by the sytem.public void caretUpdate(javax.swing.event.CaretEvent event)
caretUpdate
in interface javax.swing.event.CaretListener
event
- the caret event received from the text field
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |