de.mguennewig.pobjform.swing
Class SwingStringElement

java.lang.Object
  extended by de.mguennewig.pobjform.AbstractFormElement
      extended by de.mguennewig.pobjform.AbstractValueElement
          extended by de.mguennewig.pobjform.AbstractInputElement
              extended by de.mguennewig.pobjform.swing.SwingInputElement
                  extended by de.mguennewig.pobjform.swing.SwingStringElement
All Implemented Interfaces:
FormElement, InputElement, StringElement, SwingFormElement, ValueElement, java.awt.event.ActionListener, java.util.EventListener

public class SwingStringElement
extends SwingInputElement
implements StringElement, java.awt.event.ActionListener

Class description goes here.

Author:
Michael Günnewig

Field Summary
 
Fields inherited from interface de.mguennewig.pobjform.InputElement
MAX_INPUT_SIZE, RENDER_AS_DISABLED, RENDER_AS_HIDDEN, RENDER_AS_HIDDEN_WITH_LABEL, RENDER_AS_INPUT, RENDER_AS_TEXT
 
Constructor Summary
SwingStringElement(PObjSwingForm form, InputEntry entry)
          Creates a new SwingStringElement.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 javax.swing.JComponent getComponent()
          Returns the Swing component for the input element.
 java.lang.String getCurrentString()
          Returns the string representation of the current object.
 int getMaxLength()
           
 java.lang.Object getObject()
          Returns the current object.
 MapItem[] getRestrictTo()
          Returns the current allowed set of values.
 int getSize()
           
 java.lang.String getVisualString()
          Returns the human readable textual representation of the current value.
 boolean isEditable()
           
 boolean isStaticIfOneOption()
          Tests whether the input element will be rendered as static if the number of non-null options is exactly one.
 boolean removeOption(java.lang.Object value)
          Removes the given option from the current set of allowed values.
 void setEditable(boolean editable)
           
 void setMaxLength(int maxLength)
           
 void setObject(java.lang.Object obj)
          Sets the current object to the new value.
 void setProperty(java.lang.String property)
          Sets the property to a new value, and propagates the change to all child elements.
 void setRestrictTo(MapItem[] restrictTo)
          Sets the set of allowed values.
 void setRightAligned(boolean rightAligned)
          Sets whether the data should be right aligned.
 void setSize(int size)
           
 void setStaticIfOneOption(boolean staticIfOneOption)
          Sets whether the input element will be rendered as static if the number on non-null options is exactly one.
 void setVisualString(java.lang.String visual)
           
 
Methods inherited from class de.mguennewig.pobjform.swing.SwingInputElement
getErrorComponent, getInitialObject, getInitialString, getLabelComponent, hasChanged, setCurrentAsInitialState, setInitialString, setLabel, setRenderAs, updateErrorComponent
 
Methods inherited from class de.mguennewig.pobjform.AbstractInputElement
addChangeListener, getChangeListeners, getInputEntry, getRenderAs, getType, isHiddenInput, isMandatory, isRightAligned, isVisible, removeChangeListener, setMandatory, setVisible, validate
 
Methods inherited from class de.mguennewig.pobjform.AbstractFormElement
appendToList, getContainer, getEntry, getForm, getLabel, getProperty, getPullInPrefix, isPulledIn, omitRowHeader, setPullInPrefix, startsNewCell
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.mguennewig.pobjform.InputElement
addChangeListener, getInputEntry, getRenderAs, getType, isHiddenInput, isMandatory, isRightAligned, isVisible, removeChangeListener, setMandatory, setRenderAs
 
Methods inherited from interface de.mguennewig.pobjform.ValueElement
getInitialObject, getInitialString, setCurrentAsInitialState
 
Methods inherited from interface de.mguennewig.pobjform.FormElement
appendToList, getContainer, getEntry, getForm, getLabel, getProperty, getPullInPrefix, hasChanged, isPulledIn, omitRowHeader, setLabel, setPullInPrefix, setVisible, startsNewCell, validate
 

Constructor Detail

SwingStringElement

public SwingStringElement(PObjSwingForm form,
                          InputEntry entry)
Creates a new SwingStringElement.

Method Detail

setProperty

public void setProperty(java.lang.String property)
Sets the property to a new value, and propagates the change to all child elements.

Specified by:
setProperty in interface FormElement
Overrides:
setProperty in class AbstractFormElement

setRightAligned

public void setRightAligned(boolean rightAligned)
Sets whether the data should be right aligned.

Specified by:
setRightAligned in interface InputElement
Overrides:
setRightAligned in class AbstractInputElement

getObject

public java.lang.Object getObject()
Returns the current object.

Specified by:
getObject in interface ValueElement
Overrides:
getObject in class AbstractInputElement

setObject

public final void setObject(java.lang.Object obj)
Sets the current object to the new value.

Specified by:
setObject in interface ValueElement
Overrides:
setObject in class AbstractInputElement

getCurrentString

public final java.lang.String getCurrentString()
Description copied from interface: ValueElement
Returns the string representation of the current object.

Specified by:
getCurrentString in interface ValueElement

getVisualString

public java.lang.String getVisualString()
Returns the human readable textual representation of the current value.

This is the value used to write the current value into the UI element. It is never null.

Specified by:
getVisualString in interface InputElement
Overrides:
getVisualString in class AbstractInputElement

setVisualString

public void setVisualString(java.lang.String visual)

getSize

public final int getSize()
Specified by:
getSize in interface StringElement

setSize

public void setSize(int size)
Specified by:
setSize in interface StringElement

getMaxLength

public final int getMaxLength()
Specified by:
getMaxLength in interface StringElement

setMaxLength

public void setMaxLength(int maxLength)
Specified by:
setMaxLength in interface StringElement

getRestrictTo

public final MapItem[] getRestrictTo()
Description copied from interface: StringElement
Returns the current allowed set of values.

Specified by:
getRestrictTo in interface StringElement

setRestrictTo

public void setRestrictTo(MapItem[] restrictTo)
Description copied from interface: StringElement
Sets the set of allowed values.

This only restricts the visual options by using a selection box with these values.

Specified by:
setRestrictTo in interface StringElement

removeOption

public boolean removeOption(java.lang.Object value)
Removes the given option from the current set of allowed values.

Specified by:
removeOption in interface StringElement
Returns:
true if the value has been found in the current set of allowed values and removed, otherwise false.
See Also:
StringElement.getRestrictTo(), StringElement.setRestrictTo(MapItem[])

isEditable

public final boolean isEditable()

setEditable

public void setEditable(boolean editable)

getComponent

public javax.swing.JComponent getComponent()
Description copied from interface: SwingFormElement
Returns the Swing component for the input element.

Specified by:
getComponent in interface SwingFormElement

isStaticIfOneOption

public final boolean isStaticIfOneOption()
Tests whether the input element will be rendered as static if the number of non-null options is exactly one.

Specified by:
isStaticIfOneOption in interface StringElement
See Also:
StringElement.setStaticIfOneOption(boolean)

setStaticIfOneOption

public void setStaticIfOneOption(boolean staticIfOneOption)
Sets whether the input element will be rendered as static if the number on non-null options is exactly one.

Specified by:
setStaticIfOneOption in interface StringElement

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener