com.tensegrity.gui.swt.control.attributetree
Class SwtAttributeTree

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Control
          extended byorg.eclipse.swt.widgets.Scrollable
              extended byorg.eclipse.swt.widgets.Composite
                  extended bycom.tensegrity.gui.swt.control.attributetree.SwtAttributeTree
All Implemented Interfaces:
AttributeEditor, AttributeTree, BasicComponent, org.eclipse.swt.graphics.Drawable, Evaluable
Direct Known Subclasses:
SwtPreferenceTree

public class SwtAttributeTree
extends org.eclipse.swt.widgets.Composite
implements AttributeTree

SwtAttributeTree is the SWT counterpart to the SwingAttributeTree class. It is used to display and edit the attributes of one or more selected VisualGraphObject instances. The attributes themselves are organized in a treelike fashion while different editors are used to assist users in changing their values.

During a multiple selection, the tree tries to combine common attributes. If this is not possible, for example in the case of disparate values, each attribute is listed individually.

Please refer to SwingAttributeTree for a list of supported AttributeEditorProperties.

Similar to the Swing-based class, the SWT version is based on an implementation of the AttributeTreeModel. For more information please refer to class SwtAttributeTreeModel.

Version:
$Id: SwtAttributeTree.java,v 1.44 2005/11/03 16:20:44 ArndHouben Exp $
Author:
Arnd Houben

Field Summary
static java.lang.String COL_WIDTH_KEY
          Key for column width.
static boolean DEBUG
          Debug flag.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Fields inherited from interface com.tensegrity.gui.component.AttributeTree
PROPERTYNAME_ENABLE_WRITEPROTECTION, PROPERTYNAME_MERGEELEMENTTYPES, PROPERTYNAME_RENAMINGALLOWED, PROPERTYNAME_SHOWCATEGORIES
 
Fields inherited from interface com.tensegrity.gui.component.AttributeEditor
hiddenPrefix, SORT_ASCENDING, SORT_DESCENDING, SORT_NONE
 
Constructor Summary
SwtAttributeTree(org.eclipse.swt.widgets.Composite parent, UIManager uiManager)
          Constructs a new SwtAttributeTree instance
 
Method Summary
 void addMouseListener(org.eclipse.swt.events.MouseListener listener)
          This adds the specified listener to the internally used table, so that this listener gets notified whenever a mouse click occurs on the table.
 void applyEvList()
          Tells the component to apply its UIItemEvaluationList.
 void cancelEditing()
          Cancels editing and discards changes.
 void enableMergeElementTypes(boolean enabled)
          Enabled / Disables the merging of the element types.
 AttributableOnSet getAttributableOnSet()
          Returns the current AttributableOnSet.
 AttributeEditorStateManager getAttributeEditorStateManager()
          Returns the currently set state manager
 AttributeSet getCurrentAttributeSet()
          Returns the currently active AttributeSet.
 AttributeEditorProperties getEditorProperties()
          This method returns an instance of the currently used AttributeTableProperties instance.
 AttributeTableEditorSupplier getEditorSupplier()
          Returns the AttributeTableEditorSupplier which is used to provide an editor control for the currently selected tree item.
 int getHeight()
          Returns the height of the component in pixels.
 BasicComponent getParentComponent()
          Returns the parent Component of this instance.
 AttributeTableItem getSelectedItem()
          Returns the currently selected AttributeTableItem or null, if none is selected
 org.eclipse.swt.widgets.Table getTable()
          For backward compatibility only
 org.eclipse.jface.viewers.TableTreeViewer getTableTreeViewer()
          Returns the currently used table tree viewer
 int getWidth()
          Returns the width of the component in pixels.
 void hideAttribute(java.lang.String name)
          Hides the attribute identified by the given name.
 void installEvList()
          Tells the component to setup its internal state.
 boolean isMergingElementTypes()
          Returns whether element type merging is used or not
 boolean isTree()
          Returns true, if this editor is displaying an AttributeTree and will call get/setAttributesTree() instead of get/setAttributes().
 void propertiesChanged()
          Called from the AttributeEditorProperties when a setting changed.
 void refresh()
          Refreshes the attribute tree completely with information freshly obtained from the attribute tree's model
 void rehash()
          Reloads the AttributeSet from the AttributableOnSet and refreshes the view.
 void repaint()
          Triggers a repaint.
 void setAttributableOnSet(AttributableOnSet attributable)
          Sets the AttributableOnSet that should be shown in the editor.
 void setAttributeEditorStateManager(AttributeEditorStateManager manager)
          Sets the manager that is used to store and restore the state of the editor depending on the selected item.
 void setDefaultState()
          Sets the look of the AttributeTree to its default state, i.e. the default expanding level and the default column width.
 AttributeEditorProperties setEditorProperties(AttributeEditorProperties editorProperties)
          This method sets an instance of the AttributeTableProperties to be used.
 void setInput(AttributeTableItem rootItem)
          Sets the input of the AttributeTree, by specifing the root item.
 void showAttribute(java.lang.String name)
          Toggles the hidden flag for an attribute identified by the given name.
 boolean stopEditing()
          Stops the editing of an Attribute and saves the current value.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, computeSize, getChildren, getLayout, getTabList, layout, layout, setFocus, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBounds, setBounds, setCapture, setCursor, setEnabled, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COL_WIDTH_KEY

public static final java.lang.String COL_WIDTH_KEY
Key for column width. Used with TableColumn#getData()

See Also:
Constant Field Values

DEBUG

public static final boolean DEBUG
Debug flag. Set to true to enable debug print outs

See Also:
Constant Field Values
Constructor Detail

SwtAttributeTree

public SwtAttributeTree(org.eclipse.swt.widgets.Composite parent,
                        UIManager uiManager)
Constructs a new SwtAttributeTree instance

Parameters:
parent - the Composite to add this SwtAttributeTree to
uiManager - the UIManager to use for internationalization
Method Detail

setAttributableOnSet

public void setAttributableOnSet(AttributableOnSet attributable)
Description copied from interface: AttributeEditor
Sets the AttributableOnSet that should be shown in the editor. The parameter may be null in which case the editor will be empty.

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

setDefaultState

public final void setDefaultState()
Sets the look of the AttributeTree to its default state, i.e. the default expanding level and the default column width.


getEditorSupplier

public final AttributeTableEditorSupplier getEditorSupplier()
Returns the AttributeTableEditorSupplier which is used to provide an editor control for the currently selected tree item.

Returns:
the internally used AttributeTableEditorSupplier

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.

getCurrentAttributeSet

public AttributeSet getCurrentAttributeSet()
Description copied from interface: AttributeEditor
Returns the currently active AttributeSet. This set is the instance that is currently shown in the editor, while retrieving the AttributableOnSet and calling AttributableOnSet.getAttributes() or AttributableOnSet.getAttributesTree() might return a clone of the AttributeSet. Note: Changes to the AttributeSet will not have an effect on the AttributableOnSet and changes in the structure will not be visible in the editor. Changes will be discarded when an event occurrs that requires reloading the AttributeSet from the AttributableOnSet.

Specified by:
getCurrentAttributeSet in interface AttributeEditor
Returns:
AttributeSet The AttributeSet that is currently shown in the editor.

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

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.

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.

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

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

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

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

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

getWidth

public int getWidth()
Description copied from interface: BasicComponent
Returns the width of the component in pixels.

Specified by:
getWidth in interface BasicComponent
Returns:
the width of the component in pixels.

getHeight

public int getHeight()
Description copied from interface: BasicComponent
Returns the height of the component in pixels.

Specified by:
getHeight in interface BasicComponent
Returns:
the height of the component in pixels.

repaint

public void repaint()
Description copied from interface: BasicComponent
Triggers a repaint.

Specified by:
repaint in interface BasicComponent

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.

installEvList

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

Specified by:
installEvList in interface Evaluable

applyEvList

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

Specified by:
applyEvList in interface Evaluable

getTable

public org.eclipse.swt.widgets.Table getTable()
For backward compatibility only

Returns:
the internally used table

getTableTreeViewer

public final org.eclipse.jface.viewers.TableTreeViewer getTableTreeViewer()
Returns the currently used table tree viewer

Returns:
the currently used TableTreeViewer instance

enableMergeElementTypes

public void enableMergeElementTypes(boolean enabled)
Enabled / Disables the merging of the element types.

Parameters:
enabled - True, to enable merging

isMergingElementTypes

public boolean isMergingElementTypes()
Returns whether element type merging is used or not

Returns:
True, if element types are merged

addMouseListener

public void addMouseListener(org.eclipse.swt.events.MouseListener listener)
This adds the specified listener to the internally used table, so that this listener gets notified whenever a mouse click occurs on the table.


getSelectedItem

public final AttributeTableItem getSelectedItem()
Returns the currently selected AttributeTableItem or null, if none is selected

Returns:
selected AttributeTableItem or null;

setAttributeEditorStateManager

public void setAttributeEditorStateManager(AttributeEditorStateManager manager)
Description copied from interface: AttributeTree
Sets the manager that is used to store and restore the state of the editor depending on the selected item.

Specified by:
setAttributeEditorStateManager in interface AttributeTree
Parameters:
manager - The manager to set

getAttributeEditorStateManager

public AttributeEditorStateManager getAttributeEditorStateManager()
Description copied from interface: AttributeTree
Returns the currently set state manager

Specified by:
getAttributeEditorStateManager in interface AttributeTree
Returns:
the currently set state manager

refresh

public final void refresh()
Refreshes the attribute tree completely with information freshly obtained from the attribute tree's model


setInput

public final void setInput(AttributeTableItem rootItem)
Sets the input of the AttributeTree, by specifing the root item.

Parameters:
rootItem - the AttributeTableItem to which all other items are directly or indirectly connected.


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