qflib 0.99

de.qfs.lib.option
Class TableOptionEdit

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byde.qfs.lib.option.OptionEdit
                      extended byde.qfs.lib.option.TableOptionEdit
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TableOptionEdit
extends OptionEdit

JTable based Edit for a TableOption. It uses the following resources:

Resource name Usage
option.name.label The label for the Option (optional, default empty).
option.name.mnemonic Keyboard accelerator (optional, default none).
option.name.disabled If true, the edit will be disabled and remain so even if setEnabled(true) is called (optional, default false).
option.name.width Preferred width of the edit (optional, no default).
option.name.height Preferred height of the edit (optional, no default).
option.name.weight The weight (a double) to use for the edit when placed in the Grid of an OptionGroup (optional, default 1.0).
option.name.configure Whether a ConfigWrapper should be created for the table and registered with the Configuration under the name name.table (optional, default false).
option.name.canedit Whether the cell values can be edited (optional, default true).
option.name.caninsert Whether new rows can be added (optional, default true).
option.name.canremove Whether rows can be deleted (optional, default true).
option.name.canmove Whether rows can be moved up or down (optional, default true).
option.name.directinsert Whether new rows are inserted directly (true) or created via an OptionDialog (false) (optional, default (!canedit)).
option.name.directedit Whether typing a key starts editing the focused cell. This is the default value for the whole table and can be overridden for each column separately (optional, default true).
option.name.autosize Whether a double-click on the table header will resize the column to fit its values (optional, default true).
option.name.selectrow Whether to select the whole row (optional, default false).
option.name.multirow Whether to support multiple row selection (optional, default false).
option.name.cutpaste Whether to support cut/copy/paste (optional, default false).
option.name.columns Whitespace separated list of column identifiers (required).
option.name.column.id.name The name of the column to display in the table's header (optional, default id).
option.name.column.id.type The type of the column. Currently supported are string, taxt, booleanand int (optional, default string).
option.name.column.id.cwidth The initial width of the column (optional, no default).
option.name.column.id.nullok Whether empty values are legal in this column (optional, default false).
option.name.column.id.negativeok Whether negative values are legal in this column (optional, default false, only for columns of type int).
option.name.column.id.default Default value for new rows (optional, default null).
option.name.column.id.disabled If true, values in this column cannot be edited (optional, default false).
option.name.column.id.directedit Whether typing a key starts editing the focused cell (optional, default taken from the value for the whole table).

To edit a row's values in a dialog, an OptionDialog with the same name as the edit's option is used. You can customize this dialog in the usual way. The OptionGroup for this dialog also has the same name. If the resource option.group.name.type is not defined, default values are set to create a plain group with an edit for each column. The labels of these edits are copied from the table hader. If you define the resource option.group.name.type you take full responsibility for all of the groups resources.

Since:
0.98.1
Author:
Gregor Schmid
See Also:
Serialized Form

Nested Class Summary
protected  class TableOptionEdit.BooleanEditor
          Editor for Boolean table cell.
protected  class TableOptionEdit.Column
          Structure that holds column data.
protected  class TableOptionEdit.Editor
          Baseclass for the cell editors.
protected  class TableOptionEdit.Model
          The table model used by the edit.
 class TableOptionEdit.NumberEditor
          Editor for Number table cell.
static class TableOptionEdit.RowSelection
           
 class TableOptionEdit.StringEditor
          Editor for String table cell.
protected  class TableOptionEdit.Table
           
 
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
protected  boolean canedit
          Whether editing via dialog is allowed.
protected  boolean caninsert
          Whether adding rows is allowed.
protected  boolean canmove
          Whether moving rows is allowed.
protected  boolean canremove
          Whether removing rows is allowed.
protected  TableOptionEdit.Column[] columns
          The columns of the table.
protected  boolean cutpaste
          Whether to support cut/copy/paste
protected  boolean directedit
          Whether to start editing immediately on a keypress.
protected  boolean directinsert
          Whether to insert new rows directly.
protected  boolean enabled
          Whether the edit is currently enabled.
protected  javax.swing.JLabel label
          The label of the edit.
protected  boolean multirow
          Whether to allow multiple row selection.
protected  boolean selectrow
          Whether to select the whole row.
protected  TableOptionEdit.Table table
          The table of the edit.
protected  double weight
          The y-weight of the table.
protected  ConfigWrapper wrapper
          The config wrapper for the table.
 
Fields inherited from class de.qfs.lib.option.OptionEdit
disabled, group, option
 
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
TableOptionEdit()
          Create a new TableOptionEdit.
 
Method Summary
 boolean checkValue()
          Check the currently entered value of the ValueEdit.
protected  TableOptionEdit.Table createTable()
          Create the table for the option edit.
 double getWeight()
          Get the y-weight for the TableOptionEdit.
protected  void init()
          Initialize the Edit.
 boolean isEnabled()
          See if the ValueEdit is enabled.
 boolean isModified()
          Query whether the edit has been modified, i.e. the current value of the edit differs from the option's value.
 void readValue()
          Read the current value of the table.
 void requestFocus()
          Request the focus for the ValueEdit.
 void setEnabled(boolean enabled)
          Set the enabled flag.
 void setValue(java.lang.Object value)
          Set the Edit's value.
 void update(Option option)
          Update the display for a possibly new Option.
 
Methods inherited from class de.qfs.lib.option.OptionEdit
addPackage, getBoolean, getInt, getOption, getOptionGroup, getString, isDisabled, makeEdit, setDisabled, setOptionGroup, update
 
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, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, 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, 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

label

protected javax.swing.JLabel label
The label of the edit.


table

protected TableOptionEdit.Table table
The table of the edit.


wrapper

protected ConfigWrapper wrapper
The config wrapper for the table.


columns

protected TableOptionEdit.Column[] columns
The columns of the table.


enabled

protected boolean enabled
Whether the edit is currently enabled.


canedit

protected boolean canedit
Whether editing via dialog is allowed.


caninsert

protected boolean caninsert
Whether adding rows is allowed.


canremove

protected boolean canremove
Whether removing rows is allowed.


canmove

protected boolean canmove
Whether moving rows is allowed.


directinsert

protected boolean directinsert
Whether to insert new rows directly.


directedit

protected boolean directedit
Whether to start editing immediately on a keypress.


selectrow

protected boolean selectrow
Whether to select the whole row.


multirow

protected boolean multirow
Whether to allow multiple row selection.


cutpaste

protected boolean cutpaste
Whether to support cut/copy/paste


weight

protected double weight
The y-weight of the table.

Constructor Detail

TableOptionEdit

public TableOptionEdit()
Create a new TableOptionEdit.

Method Detail

init

protected void init()
Initialize the Edit.

Specified by:
init in class OptionEdit

update

public void update(Option option)
Update the display for a possibly new Option.

Specified by:
update in class OptionEdit
Parameters:
option - The new option.

isModified

public boolean isModified()
Query whether the edit has been modified, i.e. the current value of the edit differs from the option's value.

Specified by:
isModified in class OptionEdit
Returns:
True if the values in the edit and option differ.
Since:
0.99.0

checkValue

public boolean checkValue()
Check the currently entered value of the ValueEdit. If the value is not valid, request the focus and bring up a dialog box explaining why.

Specified by:
checkValue in class OptionEdit
Returns:
True if the value is valid, false otherwise.

readValue

public void readValue()
Read the current value of the table.

Specified by:
readValue in class OptionEdit

getWeight

public double getWeight()
Get the y-weight for the TableOptionEdit.

Overrides:
getWeight in class OptionEdit
Returns:
1.0

setEnabled

public void setEnabled(boolean enabled)
Set the enabled flag.

Parameters:
enabled - The flag to set.

isEnabled

public boolean isEnabled()
See if the ValueEdit is enabled.

Returns:
True if it is enabled.

requestFocus

public void requestFocus()
Request the focus for the ValueEdit.


setValue

public void setValue(java.lang.Object value)
Set the Edit's value. Same format as the data parameter in the constructor.

Parameters:
value - The value of the Edit.

createTable

protected TableOptionEdit.Table createTable()
Create the table for the option edit. Factory method for derived classes.

Returns:
The table for the TableOptionEdit.
Since:
0.99.0

qflib 0.99