com.tensegrity.gui.swing.control.attributetable
Class SwingAttributeTable

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JTable
                  extended bycom.tensegrity.gui.swing.control.attributetable.SwingAttributeTable
All Implemented Interfaces:
javax.accessibility.Accessible, AttributableOnSetListener, AttributeEditor, AttributeTable, BasicComponent, javax.swing.event.CellEditorListener, Evaluable, java.util.EventListener, EventListenerTag, java.awt.image.ImageObserver, JPopupMenuSource, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener
Direct Known Subclasses:
PreferenceTable

public class SwingAttributeTable
extends javax.swing.JTable
implements Evaluable, AttributeTable, AttributableOnSetListener, JPopupMenuSource

Class SwingAttributeTable is a Swing-based implementation of the AttributeTable interface. This has been realized by extending the JTable class.

A typical SwingAttributeTable showing the attributes of a VisualNode object might look like this:

Screenshot SwingAttributeTable

To create an instance of this class you have to pass a reference to an initialized UIManager.

To embed the table in a Swing-based application you can benefit by using the AttributeTablePanel class, which wraps this table in a JPanel instance.

This implementation supports the following settings, which can be changed using an AttributeEditorProperties object:

Version:
$Id: SwingAttributeTable.java,v 1.93 2005/12/14 14:08:27 BurkhardWick Exp $
Author:
StepanRutz, MichaelKegel
See Also:
Serialized Form

Nested Class Summary
static class SwingAttributeTable.CustomMappedComparator
          Custom attribute comparator.
 
Nested classes inherited from class javax.swing.JTable
javax.swing.JTable.AccessibleJTable
 
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
 
Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
 
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 com.tensegrity.gui.component.AttributeEditor
hiddenPrefix, SORT_ASCENDING, SORT_DESCENDING, SORT_NONE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SwingAttributeTable(UIManager uiManager)
          Constructs an attribute table that is editable.
SwingAttributeTable(UIManager uiManager, boolean editable)
          Constructs an attribute table.
SwingAttributeTable(UIManager uiManager, boolean editable, java.lang.String attributeEditorPropertiesFilename)
          Constructs an attribute table.
 
Method Summary
 void applyEvList()
          Tells the component to apply its UIItemEvaluationList.
 void attributesChanged(AttributableOnSetEvent attributableonsetevent)
          Invoked when an attribute in an AttributableOnSet object has changed.
 void cancelEditing()
          Cancels editing and discards changes.
 void destroyPopupMenu()
           
 void editingStopped(javax.swing.event.ChangeEvent e)
           
 void foldCategories()
          Folds the categories
 AttributableOnSet getAttributableOnSet()
          Returns the current AttributableOnSet.
 com.tensegrity.gui.swing.control.attributetable.AttributeTableCellEditor getAttributeTableCellEditor()
          Returns the active cell editor.
 AttributeTableCellRenderer getAttributeTableCellRenderer()
          Returns the active renderer.
 com.tensegrity.gui.swing.control.attributetable.AttributeTableModel getAttributeTableModel()
          Returns the data-model.
 AttributeSet getCurrentAttributeSet()
          Returns the AttributeSet currently displayed in the table.
 AttributeEditorProperties getEditorProperties()
          This method returns an instance of the currently used AttributeTableProperties instance.
 BasicComponent getParentComponent()
          Returns the parent Component of this instance.
 javax.swing.JPopupMenu getPopupMenu()
           
 PopupMenuMarkup getPopupMenu(java.lang.Object eventObject)
          Returns the current popup menu of the popup source.
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
           
 UIManager getUIManager()
          Returns the uiManager of this instance
 void hideAttribute(java.lang.String name)
          Hides the attribute identified by the given name.
 void initPopupMenu()
          Creates the menuitems and adds them to the given menu.
 void installEvList()
          Tells the component to setup its internal state.
 boolean isEditable()
          Returns the editable flag
 boolean isTree()
          Returns true, if this editor is displaying an AttributeTree and will call get/setAttributesTree() instead of get/setAttributes().
protected  boolean processKeyBinding(javax.swing.KeyStroke ks, java.awt.event.KeyEvent e, int condition, boolean pressed)
           
protected  void processMouseEvent(java.awt.event.MouseEvent e)
           
protected  void processMouseMotionEvent(java.awt.event.MouseEvent e)
           
 void propertiesChanged()
          Called from the AttributeEditorProperties when a setting changed.
 void rehash()
          Reloads the AttributeSet from the AttributableOnSet and refreshes the view.
protected  void rehashCategories(AttributeSet attributes)
           
 void scrollToAttribute(java.lang.String path)
          Makes an attribute visible by scrolling to it.
 void setAttributableOnSet(AttributableOnSet attributable)
          Associates a new attributeset with the attributetable's model.
 void setAttributeCellRenderer(AttributeTableCellRenderer renderer)
          TODO: comment.
 void setEditable(boolean editable)
          Sets the editable flag. if false, then table is read-only.
 AttributeEditorProperties setEditorProperties(AttributeEditorProperties editorProperties)
          This method sets an instance of the AttributeTableProperties to be used.
 void showAttribute(java.lang.String name)
          Toggles the hidden flag for an attribute identified by the given name.
 void showCategories(boolean show)
           
 void sort(int mode)
          Sorts the table.
 boolean stopEditing()
          Stops the editing of an Attribute and saves the current value.
 void unfoldCategories()
          Unfolds the categories
 void updateUI()
          Custom ui update.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, 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, processKeyEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, 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, 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, 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
 
Methods inherited from interface com.tensegrity.gui.component.BasicComponent
getHeight, getWidth, repaint
 

Constructor Detail

SwingAttributeTable

public SwingAttributeTable(UIManager uiManager)
Constructs an attribute table that is editable.


SwingAttributeTable

public SwingAttributeTable(UIManager uiManager,
                           boolean editable)
Constructs an attribute table.

Parameters:
editable - flag for editing, if set to true, then the table is editable, otherwise it is not.

SwingAttributeTable

public SwingAttributeTable(UIManager uiManager,
                           boolean editable,
                           java.lang.String attributeEditorPropertiesFilename)
Constructs an attribute table.

Parameters:
editable - flag for editing, if set to true, then the table is editable, otherwise it is not.
attributeEditorPropertiesFilename - the file name for the properties file holding the attribute editor settings This parameter can be null to disable persistence or can be AttributeEditorProperties.DEFAULT_FILENAME to use the default for the main attribute editor.
Method Detail

setAttributableOnSet

public void setAttributableOnSet(AttributableOnSet attributable)
Associates a new attributeset with the attributetable's model.

Specified by:
setAttributableOnSet in interface AttributeEditor
Parameters:
attributable - the AttributableOnSet to set.

getCurrentAttributeSet

public AttributeSet getCurrentAttributeSet()
Returns the AttributeSet currently displayed in the table.

Specified by:
getCurrentAttributeSet in interface AttributeEditor
Returns:
AttributeSet the current AttributeSet of the table

stopEditing

public boolean stopEditing()
Description copied from interface: AttributeEditor
Stops the editing of an Attribute and saves the current value.

Specified by:
stopEditing in interface AttributeEditor
Returns:
true, if editing was active

cancelEditing

public void cancelEditing()
Description copied from interface: AttributeEditor
Cancels editing and discards changes.

Specified by:
cancelEditing in interface AttributeEditor

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()

rehashCategories

protected void rehashCategories(AttributeSet attributes)

sort

public void sort(int mode)
Sorts the table.

Parameters:
mode - one the constants defined in this class.

unfoldCategories

public void unfoldCategories()
Unfolds the categories


foldCategories

public void foldCategories()
Folds the categories


initPopupMenu

public void initPopupMenu()
Creates the menuitems and adds them to the given menu.


destroyPopupMenu

public void destroyPopupMenu()

applyEvList

public void applyEvList()
Description copied from interface: Evaluable
Tells the component to apply its UIItemEvaluationList.

Specified by:
applyEvList in interface Evaluable

installEvList

public void installEvList()
Description copied from interface: Evaluable
Tells the component to setup its internal state.

Specified by:
installEvList in interface Evaluable

getAttributeTableModel

public final com.tensegrity.gui.swing.control.attributetable.AttributeTableModel getAttributeTableModel()
Returns the data-model.

Returns:
the table data-model of this attributetable.

getAttributeTableCellRenderer

public final AttributeTableCellRenderer getAttributeTableCellRenderer()
Returns the active renderer.

Returns:
the table cell renderer of this attributetable.

getAttributeTableCellEditor

public final com.tensegrity.gui.swing.control.attributetable.AttributeTableCellEditor getAttributeTableCellEditor()
Returns the active cell editor.

Returns:
the table cell-editor of this attributetable.

isEditable

public boolean isEditable()
Returns the editable flag

Returns:
boolean true if the table is editable.

setEditable

public void setEditable(boolean editable)
Sets the editable flag. if false, then table is read-only.

Parameters:
editable - The editable to set

editingStopped

public void editingStopped(javax.swing.event.ChangeEvent e)
Specified by:
editingStopped in interface javax.swing.event.CellEditorListener

attributesChanged

public void attributesChanged(AttributableOnSetEvent attributableonsetevent)
Description copied from interface: AttributableOnSetListener
Invoked when an attribute in an AttributableOnSet object has changed.

Specified by:
attributesChanged in interface AttributableOnSetListener
Parameters:
attributableonsetevent - the event carrying information.

getPopupMenu

public PopupMenuMarkup getPopupMenu(java.lang.Object eventObject)
Description copied from interface: JPopupMenuSource
Returns the current popup menu of the popup source.

Specified by:
getPopupMenu in interface JPopupMenuSource
Parameters:
eventObject - the mouse-event that triggered the request.
Returns:
the current popup menu of the popup source.

rehash

public void rehash()
Description copied from interface: AttributeEditor
Reloads the AttributeSet from the AttributableOnSet and refreshes the view.

Specified by:
rehash in interface AttributeEditor

scrollToAttribute

public void scrollToAttribute(java.lang.String path)
Makes an attribute visible by scrolling to it.


updateUI

public void updateUI()
Custom ui update. Recreates the popup menu as well.


hideAttribute

public void hideAttribute(java.lang.String name)
Description copied from interface: AttributeEditor
Hides the attribute identified by the given name. Such a name usually describes the full path to that attribute, like: GEOMETRY.X or COMPOSITE.name. This method will just forward the call to AttributeEditorProperties.setVisible(String, boolean)

Specified by:
hideAttribute in interface AttributeEditor
Parameters:
name - the full name of the attribute.
See Also:
AttributeEditor.hideAttribute(String)

showAttribute

public void showAttribute(java.lang.String name)
Description copied from interface: AttributeEditor
Toggles the hidden flag for an attribute identified by the given name. Similar to hideAttribute(String), this name describes the full path to the attribute. This method will just forward the call to AttributeEditorProperties.setVisible(String, boolean)

Specified by:
showAttribute in interface AttributeEditor
Parameters:
name - the full name of the attribute.
See Also:
AttributeEditor.showAttribute(String)

getEditorProperties

public AttributeEditorProperties getEditorProperties()
Description copied from interface: AttributeEditor
This method returns an instance of the currently used AttributeTableProperties instance.

Specified by:
getEditorProperties in interface AttributeEditor
Returns:
The properties instance used by this editor
See Also:
AttributeEditor.getEditorProperties()

setEditorProperties

public AttributeEditorProperties setEditorProperties(AttributeEditorProperties editorProperties)
Description copied from interface: AttributeEditor
This method sets an instance of the AttributeTableProperties to be used.

Specified by:
setEditorProperties in interface AttributeEditor
Parameters:
editorProperties - The properties instance that should be used by this editor
Returns:
The properties instance that has been used before

getAttributableOnSet

public AttributableOnSet getAttributableOnSet()
Description copied from interface: AttributeEditor
Returns the current AttributableOnSet. This might be null.

Specified by:
getAttributableOnSet in interface AttributeEditor
Returns:
The AttributableOnSet or null, if the editor is empty.

showCategories

public void showCategories(boolean show)
See Also:
#showCategories()

getParentComponent

public BasicComponent getParentComponent()
Description copied from interface: BasicComponent
Returns the parent Component of this instance.

Specified by:
getParentComponent in interface BasicComponent
Returns:
the parent component or null if no parent exists.

propertiesChanged

public void propertiesChanged()
Description copied from interface: AttributeEditor
Called from the AttributeEditorProperties when a setting changed. The editor implementation should rehash the attributes whenever this method is called.

Specified by:
propertiesChanged in interface AttributeEditor

getUIManager

public UIManager getUIManager()
Returns the uiManager of this instance

Returns:
The uiManager of this instance

setAttributeCellRenderer

public void setAttributeCellRenderer(AttributeTableCellRenderer renderer)
TODO: comment.

Parameters:
renderer -

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)

isTree

public boolean isTree()
Description copied from interface: AttributeEditor
Returns true, if this editor is displaying an AttributeTree and will call get/setAttributesTree() instead of get/setAttributes().

Specified by:
isTree in interface AttributeEditor
Returns:
true, if this editor is displaying an AttributeTree

processKeyBinding

protected boolean processKeyBinding(javax.swing.KeyStroke ks,
                                    java.awt.event.KeyEvent e,
                                    int condition,
                                    boolean pressed)

processMouseEvent

protected void processMouseEvent(java.awt.event.MouseEvent e)

processMouseMotionEvent

protected void processMouseMotionEvent(java.awt.event.MouseEvent e)


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.