com.threerings.admin.client
Class DSetEditor<E extends DSet.Entry>

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.threerings.admin.client.DSetEditor<E>
All Implemented Interfaces:
ActionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class DSetEditor<E extends DSet.Entry>
extends JPanel
implements ActionListener

Allows simple editing of DSets within a distributed object.

See Also:
Serialized Form

Nested Class Summary
static interface DSetEditor.Accessor<F extends DSet.Entry>
          An interface for a plugin defining how the editor interacts with its underlying data.
protected  class DSetEditor.DObjectAccessor<F extends E>
           
 
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  DSetEditor.Accessor<E> _accessor
          Provides access to our data we're editing.
protected  String[] _displayFields
           
protected  String[] _editableFields
           
protected  Class<?> _entryClass
           
protected  Predicate<E> _entryFilter
          An optional predicate to decide whether actually care about displaying a given entry.
protected  ObjectEditorTable.FieldInterpreter _interp
           
protected  ComparableArrayList<Comparable<Object>> _keys
          An array we use to track our entries' positions by key.
protected  String _setName
          The name of the set in that object.
protected  ObjectEditorTable _table
          The table used to edit.
protected static int MIN_HEIGHT
          The minimum height for our editor UI.
 
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
DSetEditor(DObject setter, String setName, Class<?> entryClass)
          Construct a DSet editor to merely display the specified set.
DSetEditor(DObject setter, String setName, Class<?> entryClass, String[] editableFields)
          Construct a DSetEditor, allowing the specified fields to be edited.
DSetEditor(DObject setter, String setName, Class<?> entryClass, String[] editableFields, ObjectEditorTable.FieldInterpreter interp)
          Construct a DSetEditor with a custom FieldInterpreter.
DSetEditor(DObject setter, String setName, Class<?> entryClass, String[] editableFields, ObjectEditorTable.FieldInterpreter interp, String[] displayFields, Predicate<E> entryFilter)
          Construct a DSetEditor that only displays entries that match the given Predicate.
 
Method Summary
 void actionPerformed(ActionEvent event)
           
protected  void addEntry(E entry)
          Handles the addition of an entry, assuming our filter allows it.
 void addNotify()
           
 Predicate<E> getFilter()
           
protected static Comparable<Object> getKey(DSet.Entry entry)
           
 Dimension getPreferredSize()
           
 DSet.Entry getSelectedEntry()
          Get the currently selected entry.
 String getSetName()
           
 JTable getTable()
          Get the table being used to display the set.
protected  void removeKey(Comparable<?> key)
          Takes care of removing a key from
 void removeNotify()
           
 void setAccessor(DSetEditor.Accessor<E> accessor)
          Sets the logic for how this editor interacts with its underlying data.
 void setData(ComparableArrayList<Comparable<Object>> keys, Collection<?> data)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, 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, 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

_setName

protected String _setName
The name of the set in that object.


_entryFilter

protected Predicate<E extends DSet.Entry> _entryFilter
An optional predicate to decide whether actually care about displaying a given entry.


_accessor

protected DSetEditor.Accessor<E extends DSet.Entry> _accessor
Provides access to our data we're editing.


_table

protected ObjectEditorTable _table
The table used to edit.


_keys

protected ComparableArrayList<Comparable<Object>> _keys
An array we use to track our entries' positions by key.


_entryClass

protected Class<?> _entryClass

_editableFields

protected String[] _editableFields

_interp

protected ObjectEditorTable.FieldInterpreter _interp

_displayFields

protected String[] _displayFields

MIN_HEIGHT

protected static final int MIN_HEIGHT
The minimum height for our editor UI.

See Also:
Constant Field Values
Constructor Detail

DSetEditor

public DSetEditor(DObject setter,
                  String setName,
                  Class<?> entryClass)
Construct a DSet editor to merely display the specified set.

Parameters:
setter - The object that contains the set.
setName - The name of the set in the object.
entryClass - The Class of the DSet.Entry elements contained in the set.

DSetEditor

public DSetEditor(DObject setter,
                  String setName,
                  Class<?> entryClass,
                  String[] editableFields)
Construct a DSetEditor, allowing the specified fields to be edited.

Parameters:
setter - The object that contains the set.
setName - The name of the set in the object.
entryClass - The Class of the DSet.Entry elements contained in the set.
editableFields - the names of the fields in the entryClass that should be editable.

DSetEditor

public DSetEditor(DObject setter,
                  String setName,
                  Class<?> entryClass,
                  String[] editableFields,
                  ObjectEditorTable.FieldInterpreter interp)
Construct a DSetEditor with a custom FieldInterpreter.

Parameters:
setter - The object that contains the set.
setName - The name of the set in the object.
entryClass - the Class of the DSet.Entry elements contained in the set.
editableFields - The names of the fields in the entryClass that should be editable.
interp - The FieldInterpreter to use.

DSetEditor

public DSetEditor(DObject setter,
                  String setName,
                  Class<?> entryClass,
                  String[] editableFields,
                  ObjectEditorTable.FieldInterpreter interp,
                  String[] displayFields,
                  Predicate<E> entryFilter)
Construct a DSetEditor that only displays entries that match the given Predicate.

Parameters:
setter - The object that contains the set.
setName - The name of the set in the object.
entryClass - The Class of the DSet.Entry elements contained in the set.
editableFields - The names of the fields in the entryClass that should be editable.
interp - The FieldInterpreter to use.
displayFields - The fields to display, or null for all.
entryFilter - The Predicate to use.
Method Detail

setAccessor

public void setAccessor(DSetEditor.Accessor<E> accessor)
Sets the logic for how this editor interacts with its underlying data.


getTable

public JTable getTable()
Get the table being used to display the set.


getSelectedEntry

public DSet.Entry getSelectedEntry()
Get the currently selected entry.


getPreferredSize

public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent

addNotify

public void addNotify()
Overrides:
addNotify in class JComponent

removeNotify

public void removeNotify()
Overrides:
removeNotify in class JComponent

addEntry

protected void addEntry(E entry)
Handles the addition of an entry, assuming our filter allows it.


removeKey

protected void removeKey(Comparable<?> key)
Takes care of removing a key from


actionPerformed

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

setData

public void setData(ComparableArrayList<Comparable<Object>> keys,
                    Collection<?> data)

getFilter

public Predicate<E> getFilter()

getSetName

public String getSetName()

getKey

protected static Comparable<Object> getKey(DSet.Entry entry)