|
QJCC homepage | |||||||||
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 biz.chitec.quarterback.swing.PropertiesEditorXML
An I18N-aware editor widget for Properties or similar stuff configured by an XML description. Useable for all kinds of configuration settings where the settings are stored in a Properties or a Map object. The editor is a "standard" JPanel from the outside. The properties are feeded in and read out using the setProperties() or getProperties() method or something similar. The editor shows the editing fields either flat on the panel or in several tabs in a tabbed pane.
The outfit of the editor is controlled by an XML description. That one is either given directly in the constructor or in the init() method. the XML file is only vaguely defined, there is currently no DTD or something like this. The following five tags are allowed:
The available locales are given in subsequent tags:
The evaluation of tag names and attribute names happens case-independant.
The editor gets all of its printable strings from a ResourceBundle. That one is given at construction time and evaluated using the RB class. If PropertiesEditorXML got a prefix during initialisation, every request to the ResourceBundle is prepended by that prefix, followed by a dot. The bundle should contain a ".label" entry for each name which is taken for the label left to the editing component. Additionally, a ".help" entry can be provided for showing some online help. All additional names, e.g. page tab titles or combo box entries, are taken without any further prefixes (apart from the global one described above).
PropertiesEditorXML uses the SAX framework for parsing the XML input. If you want to set the XML parser class explicitly, use the statix setXMLParserClass() method in advance to any instantiation. PropertiesEditorXML keeps only one XML parser instance for all editors, so all editors must be instantiated from the same thread (usually the AWT event dispatching thread).
For dynamic configurations, three item types exist: CUSTOMCOMBO, EXTERNALCOMBO, and EXTERNALDOUBLECOMBO. The "custom" type takes a list of Strings and shows them verbatim. It is feeded by directly by setCustomCombo(), which gets the key of the property as parameter. The data is taken only for this combo box.
The two "external" types are working differently. First, they work with Lists of NumberedStrings. So, only the numeric value is stored, but a String is presented. Then, these selection take their alternatives from a map of containers.
The class features a static method editProperties(), which renders a complete modal dialog allowing the editing of a given Properties bundle. It can be used as a convenience shortcut for many standard configuration scenarios.
PropertiesEditorXML is a very powerful and versatile class. It is the next step in a long list of such configuration editor classes in the QJCC and its predecessors. Its direct ancestor, PropertiesEditor, did almost the same things, but was completely ResourceBundle driven. After all, this lead to horrible and absolutely unmaintainable ResourceBundle files. Therefore, PropertiesEditorXML now tries to cleanup this situation.
Nested Class Summary | |
static class |
PropertiesEditorXML.DotLabelResourceBundle
Helper class which allows to use resource bundles where the resource names do not have the ".label" suffix in their key. |
private static interface |
PropertiesEditorXML.ExternalCombo
|
private class |
PropertiesEditorXML.ExternalComboBox
|
private class |
PropertiesEditorXML.ExternalDoubleComboBox
|
private class |
PropertiesEditorXML.FileNameChoice
Editor component to set up a font setting. |
private class |
PropertiesEditorXML.FontChoice
Editor component to set up a font setting. |
private class |
PropertiesEditorXML.HelpTextPresenter
Clever focus listener for elements to show appropriate help. |
private class |
PropertiesEditorXML.KeyStrokeEditor
|
private static class |
PropertiesEditorXML.LookAndFeelComboBox
Editor field for selecting a "Look'n'feel". |
private class |
PropertiesEditorXML.MultiLineEditor
|
private static class |
PropertiesEditorXML.MyFileFilter
File filter looking for file extensions or directories only. |
private class |
PropertiesEditorXML.PropertyControlBuilder
The XML parsing callback container. |
private class |
PropertiesEditorXML.PropertyControlElement
Holder of one widget to control a property. |
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 java.util.ResourceBundle |
baserb
|
private static int |
BOOL
|
private static int |
COMBO
|
private static int |
CUSTOMCOMBO
|
private java.util.Map |
customcombos
|
private static int |
EXTERNALCOMBO
|
private java.util.Set |
externalcombos
|
private java.util.Map |
externaldata
|
private static int |
EXTERNALDOUBLECOMBO
|
private static int |
FILENAME
|
private static int |
FLOAT
|
private static int |
FONT
|
private static java.lang.String[] |
fontnames
|
private JLabeller |
footer
|
private javax.swing.JComponent |
helppane
|
private javax.swing.JTextArea |
helptextarea
|
private PropertiesEditorXML.HelpTextPresenter |
helptextpresenter
|
private static int |
INT
|
private static javax.swing.ComboBoxModel |
interimcbm
|
private static int |
KEYSTROKE
|
private KeyStrokeReader |
keystrokereader
|
private static int |
LNF
|
private static int |
LOCALE
|
private static int |
MULTILINE
|
private java.lang.String |
prefix
|
private java.util.List |
propertycontrolers
|
private static java.util.List |
proptypelist
|
private java.util.ResourceBundle |
rb
|
private static boolean |
reloadxmlreader
|
private static int |
SLAFTHEME
|
private static java.lang.String[] |
slafthemes
|
private static int |
STRING
|
private static org.xml.sax.XMLReader |
xmlreader
|
private static java.lang.String |
xmlreaderclassname
|
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 | |
|
PropertiesEditorXML()
Initializes with own ResourceBundle only and empty prefix. |
|
PropertiesEditorXML(java.util.ResourceBundle rbx)
Constructor for the PropertiesEditor object. |
|
PropertiesEditorXML(java.util.ResourceBundle rbx,
org.xml.sax.InputSource isx)
Initializes with ResourceBundle, empty prefix and the XML source for the layout. |
|
PropertiesEditorXML(java.util.ResourceBundle rbx,
java.lang.String prefixx)
Constructor for the PropertiesEditor object |
|
PropertiesEditorXML(java.util.ResourceBundle rbx,
java.lang.String prefixx,
org.xml.sax.InputSource isx)
Initializes with ResourceBundle, prefix and the XML source for the layout. |
protected |
PropertiesEditorXML(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,
org.xml.sax.InputSource is,
java.lang.String prefix,
java.util.Map customs,
java.awt.event.ActionListener al)
Shows a complete modal dialog allowing to edit the given properties. |
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. |
private java.lang.String |
getRBStringWithPrefix(java.lang.String x)
|
protected java.util.Map |
getValues(java.util.Map props)
Get all the values internally. |
void |
init(org.xml.sax.InputSource is)
Initializes the visible layout using the given XML-driven InputSource. |
void |
setCustomCombo(java.lang.String prop,
java.util.List content)
Sets the selectable alternatives for a custom combo field. |
void |
setExternalData(java.util.Map edx)
Sets the selections for EXTERNALCOMBO and EXTERNALDOUBLECOMBO The given Map contains the keys for the respective selection elements of the properties dialog. |
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 |
setProperties(java.util.Map props,
boolean forceset)
Set data to show. |
void |
setResourceBundle(java.util.ResourceBundle rbx)
Sets the ResourceBundle with the Propertie's localized names explicitly. |
static void |
setXMLParserClass(java.lang.String parserclassname)
Sets the XML parser class explicitly and internally initializes the parser. |
static void |
setXMLReaderReload(boolean b)
If true, reloads the XML reader each time a Properties editor is opened. |
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 |
private static final javax.swing.ComboBoxModel interimcbm
private static final java.lang.String[] slafthemes
private static final int INT
private static final int STRING
private static final int BOOL
private static final int COMBO
private static final int FONT
private static final int LNF
private static final int SLAFTHEME
private static final int CUSTOMCOMBO
private static final int FILENAME
private static final int LOCALE
private static final int EXTERNALCOMBO
private static final int EXTERNALDOUBLECOMBO
private static final int MULTILINE
private static final int FLOAT
private static final int KEYSTROKE
private static final java.util.List proptypelist
private static java.lang.String[] fontnames
private static org.xml.sax.XMLReader xmlreader
private static java.lang.String xmlreaderclassname
private static boolean reloadxmlreader
private java.util.List propertycontrolers
private java.util.Map customcombos
private java.util.Set externalcombos
private java.util.Map externaldata
private java.util.ResourceBundle baserb
private java.util.ResourceBundle rb
private JLabeller footer
private javax.swing.JTextArea helptextarea
private javax.swing.JComponent helppane
private java.lang.String prefix
private PropertiesEditorXML.HelpTextPresenter helptextpresenter
private KeyStrokeReader keystrokereader
Constructor Detail |
public PropertiesEditorXML(java.util.ResourceBundle rbx, java.lang.String prefixx)
rbx
- The resource bundle with the properties configurationprefixx
- The ressources' names prefixpublic PropertiesEditorXML(java.util.ResourceBundle rbx)
rbx
- The resource bundle with the properties configurationprotected PropertiesEditorXML(java.lang.String prefix)
prefix
- prefix for all entries in the ResourceBundlepublic PropertiesEditorXML()
public PropertiesEditorXML(java.util.ResourceBundle rbx, java.lang.String prefixx, org.xml.sax.InputSource isx)
public PropertiesEditorXML(java.util.ResourceBundle rbx, org.xml.sax.InputSource isx)
Method Detail |
public static void setXMLParserClass(java.lang.String parserclassname) throws org.xml.sax.SAXException
parserclassname
- Name of the XML parser class
org.xml.sax.SAXException
- Thrown if the parser could not be initialized for any reasonpublic static void setXMLReaderReload(boolean b)
b
- public void setResourceBundle(java.util.ResourceBundle rbx)
rbx
- ResourceBundle with the localized names of the propertiespublic void init(org.xml.sax.InputSource is)
Note: PropertiesEditorXML does only use ONE XML parser for all parsing attempts done ever. Therefore, init() must never be called in parallel from different threads. As it will be called usually in the AWT event tread, this should not be that big problem anyway.
is
- The input source with the XML data describing the properties editor.public void setFooter(JLabeller f)
f
- The new footer valuepublic void showHelp(boolean doshow)
doshow
- true to show, false to hidepublic void setCustomCombo(java.lang.String prop, java.util.List content)
prop
- The property name for which the alternatives are given.content
- The selectable alternatives. Will be shown in given order.public void setExternalData(java.util.Map edx)
edx
- Map of settings for selectionspublic void setMap(java.util.Map props)
props
- The new hashtable valuepublic void setProperties(java.util.Map props, boolean forceset)
props
- The new properties valueforceset
- Flag whether all fields should be set or only the ones which have values in the given map.public void setProperties(java.util.Map props)
props
- The new properties valuepublic java.util.Properties getProperties()
public java.util.Map getMap()
public java.util.Properties fillProperties(java.util.Properties props)
props
- The Properties table to write in
protected java.util.Map getValues(java.util.Map props)
props
- Description of the Parameter
private java.lang.String getRBStringWithPrefix(java.lang.String x)
private static java.awt.Component getFocusComponentForJComboBox(javax.swing.JComboBox box)
box
- Description of the Parameter
public static final void editProperties(java.util.Properties inputprops, java.awt.Frame parent, java.util.ResourceBundle rb, org.xml.sax.InputSource is, java.lang.String prefix, java.util.Map customs, java.awt.event.ActionListener al)
inputprops
- Properties to load into the dialog.parent
- Parent frame for the dialog.rb
- ResourceBundle with all i18n'd Strings to show.is
- InputSource with the XML-based layout descriptions.prefix
- Prefix for the ResourceBundle strings. May be empty or null.customs
- Content for the CUSTOMCOMBO-controls. May be null.al
- ActionListener called when OK is pressed. EventSource is the PropertiesEditor,
the ActionListener has store the data from the dialog somehow. May be null,
but that does not make that much sense...
|
QJCC homepage | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |