|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JPanel com.gridsystems.config.tools.swing.PopupTextField
public abstract class PopupTextField
Abstract class for fields that get its contents from a popup component.
Implementations of this class should define a graphic component that will
display in a popup windows. The openPopup() method must be able to launch
this popup window. If the popup is modalless, this method must also call
postCheckChange() once the data manipulation has finished.
The default implementation works if the value managed by the component is
the String shown at the text field. In any other case, the methods
setValue() and getValue() should be implemented to discern between the value
and its String representation. IMPORTANT: getValue() should return a copy of
the object if it can be modified from outside (the original implementation
returns String, that are inmutable).
Changes are detected at the method hasChanged() from comparing the values
stored before and after a possible modification (at the private fields
previousValue
and newValue
). These values are
set by the calls to preCheckChanges() and postCheckChanges().
postCheckChanges() also calls the hasChangedMethod() and, if it returns
true, launches a PropertyChanged event reporting the change.
Finally, the implementation of FocusListener only reacts to focus events
originated by the text field. Objects from this class and its
implementations should not be added as focus listeners of any component.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
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.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 | |
---|---|
PopupTextField()
Default constructor. |
Method Summary | |
---|---|
void |
discard()
Sets the previous value as the current one. |
void |
focusGained(java.awt.event.FocusEvent focusEvent)
Receives an event of focus gained. |
void |
focusLost(java.awt.event.FocusEvent focusEvent)
Receives an event of focus lost. |
java.lang.String |
getButtonText()
Gets the text to display at the button. |
java.lang.String |
getPropertyName()
Gets the property name of the component. |
java.lang.Object |
getValue()
Returns the value stored by the component. |
boolean |
hasChanged()
Tells if the value of the component has changed. |
boolean |
isFieldEditable()
Gets if the field can be modified by the user or not. |
protected abstract void |
openPopup()
Opens a popup to ask the user for data. |
void |
postCheckChanges()
Checks for changes in the value and, in that case, fires an event. |
void |
preCheckChanges()
Stores the value of the component value to check for future changes. |
void |
setButtonText(java.lang.String buttonText)
Sets the text to display at the button. |
void |
setEnabled(boolean enabled)
|
void |
setFieldEditable(boolean textEditable)
Sets if the field can be modified by the user or not. |
void |
setValue(java.lang.Object value)
Sets the value managed by the component. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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 |
Constructor Detail |
---|
public PopupTextField()
Method Detail |
---|
public void setEnabled(boolean enabled)
setEnabled
in class javax.swing.JComponent
public java.lang.Object getValue()
hasChanged()
public void setValue(java.lang.Object value)
The default implementation just sets the text of the text field to the result
of doing toString to value
(or the empty String if value
is null). Reimplement this method if the value shown is not the same than the actual
value. This is the value used to check for changes in hasChanged();
value
- The value to sethasChanged()
public final java.lang.String getPropertyName()
public final void setButtonText(java.lang.String buttonText)
buttonText
- a String with the new text to display at the button.public final java.lang.String getButtonText()
public final void setFieldEditable(boolean textEditable)
textEditable
- a boolean that is true if and only if the user should
be able to edit the text field.public final boolean isFieldEditable()
public final void preCheckChanges()
postCheckChanges()
public final void postCheckChanges()
public final void discard()
protected abstract void openPopup()
public boolean hasChanged()
previousValue
and newValue
set by
preCheckChanges()
and postCheckChanges()
.
The default implementation returns true if and only if both objects are
null or if the equals() method of them returns false.
preCheckChanges()
,
postCheckChanges()
public final void focusGained(java.awt.event.FocusEvent focusEvent)
focusGained
in interface java.awt.event.FocusListener
focusEvent
- the FocusEvent with the information of what has
happened.preCheckChanges()
public final void focusLost(java.awt.event.FocusEvent focusEvent)
focusLost
in interface java.awt.event.FocusListener
focusEvent
- the FocusEvent with the information of what has
happened.postCheckChanges()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |