QJCC homepage

biz.chitec.quarterback.swing
Class PropertiesEditor

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bybiz.chitec.quarterback.swing.PropertiesEditor
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PropertiesEditor
extends javax.swing.JPanel

Don't use this for new projects any more, use PropertiesEditorXML instead. A complete and quite complex widget to edit the contents of a Map or a Properties object. PropertiesEditor is completely Resource-driven: It gets the object names and descriptions out of a ResourceBundle and presents them either on a single Pane or on multiple tabs of a tabbed pane.

The object knows about integer numbers, strings, boolean values or combo box choices, for which it presents the appropriate data editing widget. A specialized combo box knows about the available fonts of the system.

Version:
$Id: e3e2dc10c2e47665521d0b41e21e783882dd9401 $
Author:
Dirk Hillbrecht 1999-2000, chitec/Dirk Hillbrecht 2000-2003, cantamen/Dirk Hillbrecht 2003. Distributed under the terms of the GNU LGPL.
See Also:
Serialized Form

Nested Class Summary
private  class PropertiesEditor.FileNameChoice
          Editor component to set up a font setting.
private  class PropertiesEditor.FontChoice
          Editor component to set up a font setting.
private static class PropertiesEditor.LookAndFeelComboBox
          Editor field for selecting a "Look'n'feel".
private static class PropertiesEditor.MyFileFilter
          File filter looking for file extensions or directories only.
private  class PropertiesEditor.PropBaseNameIterator
          Iterator over the property names in the editor's properties themselves.
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
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 static int BOOL
           
private  boolean cardexists
           
private  java.lang.String[] cardtitle
           
private  java.lang.String[] cardtitletip
           
private  java.util.List[] choicekatvalues
           
private static int COMBO
           
private static int CUSTOMCOMBO
           
private  java.util.Map customcombos
           
private static int FILENAME
           
private static int FONT
           
private  java.lang.String[] fontnames
           
private  JLabeller footer
           
private  javax.swing.JComponent helppane
           
private  java.lang.String[] helptext
           
private  javax.swing.JTextArea helptextarea
           
private static int INT
           
private  javax.swing.JLabel[] jlabel
           
private  java.util.Map katelemmap
           
private  javax.swing.JComponent[] katentryelem
           
private  int katnum
           
private  int[] kattype
           
private  java.lang.String[] labelname
           
private static int LINE
           
private static int LNF
           
private static int LOCALE
           
private  javax.swing.JComponent mainpanel
           
private  java.lang.String prefix
           
private  java.lang.String[] propname
           
private static java.util.List proptypelist
           
private  java.util.ResourceBundle rb
           
private static int SLAFTHEME
           
private static java.lang.String[] slafthemes
           
private static int STRING
           
 
Fields inherited from class javax.swing.JPanel
 
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
protected PropertiesEditor()
          Initializes with own ResourceBundle only and prefix "entry"
  PropertiesEditor(java.util.ResourceBundle rbx)
          Constructor for the PropertiesEditor object.
  PropertiesEditor(java.util.ResourceBundle rbx, java.lang.String prefixx)
          Constructor for the PropertiesEditor object
protected PropertiesEditor(java.lang.String prefix)
          Initializes with own ResourceBundle only and a custom prefix.
 
Method Summary
static void editProperties(java.util.Properties inputprops, java.awt.Frame parent, java.util.ResourceBundle rb, java.lang.String prefix, java.util.Map customs, java.awt.event.ActionListener al)
           
 java.util.Properties fillProperties(java.util.Properties props)
          Fill properties of editor into existing Properties.
private static java.awt.Component getFocusComponentForJComboBox(javax.swing.JComboBox box)
          Helper method to work around a problem with Metal-JCombo-boxes and focus handling.
 java.util.Map getMap()
          Deprecated. Use getProperties() instead
 java.util.Properties getProperties()
          Get all properties back from the editor.
protected  java.util.Map getValues(java.util.Map props)
          Get all the values internally.
private  int mkprop(java.lang.String x)
          Converts between string and integer representation of property types.
 void setCustomCombo(java.lang.String prop, java.util.List content)
          Sets the selectable alternatives for a custom combo field.
 void setFooter(JLabeller f)
          Set a footer to print error messages to.
 void setMap(java.util.Map props)
          Deprecated. Use setProperties instead.
 void setProperties(java.util.Map props)
          Set data to show.
 void showHelp(boolean doshow)
          Should help window been shown?
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
 
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

slafthemes

private static final java.lang.String[] slafthemes

INT

private static final int INT
See Also:
Constant Field Values

STRING

private static final int STRING
See Also:
Constant Field Values

BOOL

private static final int BOOL
See Also:
Constant Field Values

COMBO

private static final int COMBO
See Also:
Constant Field Values

FONT

private static final int FONT
See Also:
Constant Field Values

LNF

private static final int LNF
See Also:
Constant Field Values

SLAFTHEME

private static final int SLAFTHEME
See Also:
Constant Field Values

LINE

private static final int LINE
See Also:
Constant Field Values

CUSTOMCOMBO

private static final int CUSTOMCOMBO
See Also:
Constant Field Values

FILENAME

private static final int FILENAME
See Also:
Constant Field Values

LOCALE

private static final int LOCALE
See Also:
Constant Field Values

proptypelist

private static final java.util.List proptypelist

cardexists

private boolean cardexists

katnum

private int katnum

kattype

private int[] kattype

propname

private java.lang.String[] propname

labelname

private java.lang.String[] labelname

cardtitle

private java.lang.String[] cardtitle

cardtitletip

private java.lang.String[] cardtitletip

jlabel

private javax.swing.JLabel[] jlabel

katentryelem

private javax.swing.JComponent[] katentryelem

choicekatvalues

private java.util.List[] choicekatvalues

mainpanel

private javax.swing.JComponent mainpanel

rb

private java.util.ResourceBundle rb

footer

private JLabeller footer

fontnames

private java.lang.String[] fontnames

helptext

private java.lang.String[] helptext

helptextarea

private javax.swing.JTextArea helptextarea

helppane

private javax.swing.JComponent helppane

katelemmap

private java.util.Map katelemmap

prefix

private java.lang.String prefix

customcombos

private java.util.Map customcombos
Constructor Detail

PropertiesEditor

public PropertiesEditor(java.util.ResourceBundle rbx,
                        java.lang.String prefixx)
Constructor for the PropertiesEditor object

Parameters:
rbx - The resource bundle with the properties configuration
prefixx - The ressources' names prefix

PropertiesEditor

public PropertiesEditor(java.util.ResourceBundle rbx)
Constructor for the PropertiesEditor object. Initializes the prefix with "entry"

Parameters:
rbx - The resource bundle with the properties configuration

PropertiesEditor

protected PropertiesEditor(java.lang.String prefix)
Initializes with own ResourceBundle only and a custom prefix. This is only sensible for derived classes which bring their own ResourceBundle with them.

Parameters:
prefix - prefix for all entries in the ResourceBundle

PropertiesEditor

protected PropertiesEditor()
Initializes with own ResourceBundle only and prefix "entry"

Method Detail

setFooter

public void setFooter(JLabeller f)
Set a footer to print error messages to.

Parameters:
f - The new footer value

showHelp

public void showHelp(boolean doshow)
Should help window been shown?

Parameters:
doshow - true to show, false to hide

setCustomCombo

public void setCustomCombo(java.lang.String prop,
                           java.util.List content)
Sets the selectable alternatives for a custom combo field. Should be called before the data to show is loaded. If called afterwards, tries to preserve selection.

Parameters:
prop - The property name for which the alternatives are given.
content - The selectable alternatives. Will be shown in given order.

setMap

public void setMap(java.util.Map props)
Deprecated. Use setProperties instead.

Set data to show.

Parameters:
props - The new hashtable value

setProperties

public void setProperties(java.util.Map props)
Set data to show. All fields on the Editor are filled with the data in the Properties object. If no data exist for a certain setting, the control is set to blank, false or the first available choice.

Parameters:
props - The new properties value

getProperties

public java.util.Properties getProperties()
Get all properties back from the editor.

Returns:
The properties value

getMap

public java.util.Map getMap()
Deprecated. Use getProperties() instead

Get all properties back from the editor.

Returns:
The hashtable value

fillProperties

public java.util.Properties fillProperties(java.util.Properties props)
Fill properties of editor into existing Properties. Note that this will overwrite all selectable parameters with the values inserted here.

Parameters:
props - The Properties table to write in
Returns:
The changed Properties class

getValues

protected java.util.Map getValues(java.util.Map props)
Get all the values internally. Does the work for getProperties() and getMap().

Parameters:
props - Description of the Parameter
Returns:
The values value

mkprop

private int mkprop(java.lang.String x)
Converts between string and integer representation of property types.

Parameters:
x - Description of the Parameter
Returns:
Description of the Return Value

getFocusComponentForJComboBox

private static java.awt.Component getFocusComponentForJComboBox(javax.swing.JComboBox box)
Helper method to work around a problem with Metal-JCombo-boxes and focus handling. See Java bug parade #4243641.

Parameters:
box - Description of the Parameter
Returns:
The focusComponentForJComboBox value

editProperties

public static final void editProperties(java.util.Properties inputprops,
                                        java.awt.Frame parent,
                                        java.util.ResourceBundle rb,
                                        java.lang.String prefix,
                                        java.util.Map customs,
                                        java.awt.event.ActionListener al)

QJCC homepage