com.threerings.editor.swing.editors
Class TableArrayListEditor

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.samskivert.swing.CollapsiblePanel
                      extended by com.threerings.editor.swing.BasePropertyEditor
                          extended by com.threerings.editor.swing.PropertyEditor
                              extended by com.threerings.editor.swing.editors.ArrayListEditor
                                  extended by com.threerings.editor.swing.editors.TableArrayListEditor
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ChangeListener, ListSelectionListener, TableModel
Direct Known Subclasses:
PathTableArrayListEditor

public class TableArrayListEditor
extends ArrayListEditor
implements TableModel, ListSelectionListener, ChangeListener

An editor for objects or lists of objects or primitives. Uses a table.

See Also:
Serialized Form

Nested Class Summary
protected  class TableArrayListEditor.Column
          Represents a column in the table.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  JButton _addColumn
          The add column button.
protected  TableArrayListEditor.Column[] _columns
          The column info.
protected  JButton _copy
          The copy and delete buttons.
protected  JButton _delete
          The copy and delete buttons.
protected  ObjectPanel _opanel
          The object panel used to edit the non-inline properties.
protected  JTable _table
          The table containing the array data.
 
Fields inherited from class com.threerings.editor.swing.editors.ArrayListEditor
_add, _max, _min
 
Fields inherited from class com.threerings.editor.swing.PropertyEditor
_classesByName, _classesByType, _ctx, _lineage, _object, _property
 
Fields inherited from class com.threerings.editor.swing.BasePropertyEditor
_collapseIcon, _expandIcon, _highlight, _highlighted, _highlightIcon, _msgmgr, _msgs, BASE_BACKGROUND, DEFAULT_BACKGROUND, PANEL_BUTTON_SIZE, SHADE_DECREMENT
 
Fields inherited from class com.samskivert.swing.CollapsiblePanel
_content, _downIcon, _trigger, _upIcon
 
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
TableArrayListEditor()
           
 
Method Summary
 void actionPerformed(ActionEvent event)
           
protected  void addColumn()
          Adds a new column.
 void addTableModelListener(TableModelListener listener)
           
protected  void addValue(Object value)
          Adds an object to the end of the list.
protected  void copyColumn(int column)
          Copies the column at the specified index.
protected  void copyValue(int idx)
          Copies the element at the specified index.
protected  TableArrayListEditor.Column createArrayColumn(int column)
          Creates and returns an array column.
protected  void createArrayColumns()
          (Re)creates the columns for a 2D array property.
protected  void didInit()
          Override to perform custom initialization.
protected  void fireTableChanged(int firstRow, int lastRow, int column, int type)
          Fires a TableModelEvent.
 Class<?> getColumnClass(int column)
           
 int getColumnCount()
           
 String getColumnName(int column)
           
protected  String getMousePath(Point pt)
          Returns the path of the property under the mouse cursor relative to this property.
 int getRowCount()
           
protected  IntTuple getSelection()
          Returns the selection as a (row, column) pair.
 Object getValueAt(int row, int column)
           
protected  boolean is2DArray()
          Determines whether the property is a 2D array.
 boolean isCellEditable(int row, int column)
           
 void makeVisible(int idx)
          Ensures that the specified index is visible.
protected  void moveCell(int row, int col)
          Moves a single cell to the selected cell.
protected  void moveColumn(int column)
          Moves a column to the selected column.
protected  void moveValue(int row)
          Moves the specified row to the selected row.
protected  void moveWithinArray(Object array, int source, int dest)
          Moves the value at source to dest, shifting values left or right to make room.
protected  void removeColumn(int column)
          Deletes the column at the specified index.
 void removeTableModelListener(TableModelListener listener)
           
protected  void removeValue(int idx)
          Removes the element at the specified index.
protected  void setSelection(int row, int column)
          Sets the selection in using the convention of getSelection().
 void setValueAt(Object value, int row, int column)
           
 void stateChanged(ChangeEvent event)
           
 void update()
          Updates the state of the editor from the object.
protected  void updateColumnWidths()
          Updates the preferred widths of the columns.
protected  void updateSelected()
          Updates based on the selection state.
 void valueChanged(ListSelectionEvent event)
           
 
Methods inherited from class com.threerings.editor.swing.editors.ArrayListEditor
fireStateChanged, getActionLabel, getActionLabel, getLength, getValue, setValue
 
Methods inherited from class com.threerings.editor.swing.PropertyEditor
createEditor, getDefaultInstance, getMaximum, getMaxSize, getMinimum, getMinSize, getMode, getObject, getProperty, getPropertyColor, getPropertyLabel, getScale, getStep, getUnits, init, isTableCellType, registerEditorClass, registerEditorClass, setObject
 
Methods inherited from class com.threerings.editor.swing.BasePropertyEditor
addChangeListener, copyPropertyPath, createButton, darkenColor, fireStateChanged, getBackgroundColor, getColor, getColor, getColor, getDarkerBackground, getLabel, getLabel, getLabel, getLabel, getLabels, getLabels, getLabels, getMousePath, getPropertyColor, loadIcon, makeCollapsible, removeChangeListener, updateBorder
 
Methods inherited from class com.samskivert.swing.CollapsiblePanel
getContent, isCollapsed, setCollapsed, setGap, setTrigger, setTriggerContainer, setTriggerContainer, setTriggerContainer
 
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, setEnabled, 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

_columns

protected TableArrayListEditor.Column[] _columns
The column info.


_table

protected JTable _table
The table containing the array data.


_addColumn

protected JButton _addColumn
The add column button.


_copy

protected JButton _copy
The copy and delete buttons.


_delete

protected JButton _delete
The copy and delete buttons.


_opanel

protected ObjectPanel _opanel
The object panel used to edit the non-inline properties.

Constructor Detail

TableArrayListEditor

public TableArrayListEditor()
Method Detail

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int column)
Specified by:
getColumnName in interface TableModel

getColumnClass

public Class<?> getColumnClass(int column)
Specified by:
getColumnClass in interface TableModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Specified by:
isCellEditable in interface TableModel

getValueAt

public Object getValueAt(int row,
                         int column)
Specified by:
getValueAt in interface TableModel

setValueAt

public void setValueAt(Object value,
                       int row,
                       int column)
Specified by:
setValueAt in interface TableModel

addTableModelListener

public void addTableModelListener(TableModelListener listener)
Specified by:
addTableModelListener in interface TableModel

removeTableModelListener

public void removeTableModelListener(TableModelListener listener)
Specified by:
removeTableModelListener in interface TableModel

valueChanged

public void valueChanged(ListSelectionEvent event)
Specified by:
valueChanged in interface ListSelectionListener

stateChanged

public void stateChanged(ChangeEvent event)
Specified by:
stateChanged in interface ChangeListener

actionPerformed

public void actionPerformed(ActionEvent event)
Specified by:
actionPerformed in interface ActionListener
Overrides:
actionPerformed in class ArrayListEditor

update

public void update()
Description copied from class: PropertyEditor
Updates the state of the editor from the object.

Specified by:
update in class PropertyEditor

makeVisible

public void makeVisible(int idx)
Description copied from class: ArrayListEditor
Ensures that the specified index is visible.

Specified by:
makeVisible in class ArrayListEditor

didInit

protected void didInit()
Description copied from class: PropertyEditor
Override to perform custom initialization.

Overrides:
didInit in class ArrayListEditor

getMousePath

protected String getMousePath(Point pt)
Description copied from class: BasePropertyEditor
Returns the path of the property under the mouse cursor relative to this property.

Overrides:
getMousePath in class BasePropertyEditor
Parameters:
pt - the location of the mouse cursor.

addValue

protected void addValue(Object value)
Description copied from class: ArrayListEditor
Adds an object to the end of the list.

Overrides:
addValue in class ArrayListEditor

copyValue

protected void copyValue(int idx)
Description copied from class: ArrayListEditor
Copies the element at the specified index.

Overrides:
copyValue in class ArrayListEditor

removeValue

protected void removeValue(int idx)
Description copied from class: ArrayListEditor
Removes the element at the specified index.

Overrides:
removeValue in class ArrayListEditor

addColumn

protected void addColumn()
Adds a new column.


copyColumn

protected void copyColumn(int column)
Copies the column at the specified index.


removeColumn

protected void removeColumn(int column)
Deletes the column at the specified index.


updateColumnWidths

protected void updateColumnWidths()
Updates the preferred widths of the columns.


is2DArray

protected boolean is2DArray()
Determines whether the property is a 2D array.


createArrayColumns

protected void createArrayColumns()
(Re)creates the columns for a 2D array property.


createArrayColumn

protected TableArrayListEditor.Column createArrayColumn(int column)
Creates and returns an array column.


moveValue

protected void moveValue(int row)
Moves the specified row to the selected row.


moveColumn

protected void moveColumn(int column)
Moves a column to the selected column.


moveCell

protected void moveCell(int row,
                        int col)
Moves a single cell to the selected cell.


moveWithinArray

protected void moveWithinArray(Object array,
                               int source,
                               int dest)
Moves the value at source to dest, shifting values left or right to make room.


updateSelected

protected void updateSelected()
Updates based on the selection state.


getSelection

protected IntTuple getSelection()
Returns the selection as a (row, column) pair. If an entire row is selected, column will be -1. If an entire column is selected, row will be -1. If both numbers are valid, a single cell at that location is selected. Otherwise, the method returns null to indicate that there is no usable selection.


setSelection

protected void setSelection(int row,
                            int column)
Sets the selection in using the convention of getSelection().


fireTableChanged

protected void fireTableChanged(int firstRow,
                                int lastRow,
                                int column,
                                int type)
Fires a TableModelEvent.