verinec.gui.configurator.nodeeditor
Class EditorComboBox

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JComboBox
                  extended by verinec.gui.configurator.nodeeditor.EditorComboBox
All Implemented Interfaces:
ActionListener, FocusListener, ImageObserver, ItemSelectable, MenuContainer, Serializable, EventListener, Accessible, ListDataListener, IEditorComponent
Direct Known Subclasses:
OptionalElementComboBox

public class EditorComboBox
extends JComboBox
implements FocusListener, ActionListener, IEditorComponent

The EditorComboBox works very similar to the EditorTextField, except that there is no need for validation of the input data. It also changes color upon modification and creates or removes XML attributes if necessary.

The array holding the strings to choose from is a constant in the InputValidator class and is passed as an argument on creation.

Author:
Damian Vogel
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComboBox
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  String attributeName
          The Name of the XML attribute in which the value is stored.
protected  Element elem
          A link to the XML Element which contains the XML attribute.
private  JLabel label
          The label; is stored as an instance field and will be displayed next to the field.
private  Logger logger
           
private  String previousInputValue
          If the value of a field is changed, its original value is stored in this variable.
 
Fields inherited from class javax.swing.JComboBox
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
 
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
EditorComboBox(String attributeName, Element elem, String[] inputValidatorMessage, String labelString)
          See the Field summary for detailed information about the different parameters.
 
Method Summary
 void actionPerformed(ActionEvent e)
          React on an action: call transferFocus.
 void checkInput()
          If the value is empty, the Attribute is removed - unless the Attribute is necessary, in which case it is reset to its previous value (which obviously was correct).
 void discard()
          Resets all the changed (i.e. green) values.
 void discardRed()
          Should never happen and does nothing, a combobox value cannot be invalid.
 void focusGained(FocusEvent e)
          Necessary for a class implementing FocusListener.
 void focusLost(FocusEvent e)
          After the focus is lost, check the field input.
 JLabel getJLabel()
          Get the label.
 void save()
          Saves the current value of the field.
 boolean update()
          Checks if there have been changes in the fields.
 
Methods inherited from class javax.swing.JComboBox
addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setSelectedItem, setUI, showPopup, 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, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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
 

Field Detail

attributeName

protected final String attributeName
The Name of the XML attribute in which the value is stored.


previousInputValue

private String previousInputValue
If the value of a field is changed, its original value is stored in this variable.


elem

protected Element elem
A link to the XML Element which contains the XML attribute.


label

private JLabel label
The label; is stored as an instance field and will be displayed next to the field.


logger

private Logger logger
Constructor Detail

EditorComboBox

public EditorComboBox(String attributeName,
                      Element elem,
                      String[] inputValidatorMessage,
                      String labelString)
See the Field summary for detailed information about the different parameters.

Parameters:
attributeName - The Name of the XML attribute in which the value is stored.
elem - The XML Element which contains the attribute controlled by this combo box.
inputValidatorMessage - An array of strings which is passed on to the super constructor.
labelString - Text to display for the value.
Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
React on an action: call transferFocus.

Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class JComboBox
Parameters:
e - The action.

focusGained

public void focusGained(FocusEvent e)
Necessary for a class implementing FocusListener. At the moment, we don't care about a field gaining focus.

Specified by:
focusGained in interface FocusListener
Parameters:
e - The event.

focusLost

public void focusLost(FocusEvent e)
After the focus is lost, check the field input.

Specified by:
focusLost in interface FocusListener
Parameters:
e - The event.

checkInput

public void checkInput()
If the value is empty, the Attribute is removed - unless the Attribute is necessary, in which case it is reset to its previous value (which obviously was correct). If it is changed successfully, the color of the field changes to green.


update

public boolean update()
Checks if there have been changes in the fields.

Specified by:
update in interface IEditorComponent
Returns:
If there is nothing changed, false is returned. If there are changed values, (i.e. green or red fields) true is returned.

save

public void save()
Saves the current value of the field.

Specified by:
save in interface IEditorComponent

discard

public void discard()
Resets all the changed (i.e. green) values. The target value (the value which will be in the field after this function executed) is stored in the variable previousInputValue.

Specified by:
discard in interface IEditorComponent

discardRed

public void discardRed()
Should never happen and does nothing, a combobox value cannot be invalid.

Specified by:
discardRed in interface IEditorComponent

getJLabel

public JLabel getJLabel()
Get the label.

Returns:
The description for the field.

Copyright © 2005 Verinec, DIUF