org.eclipse.cdt.internal.ui.wizards.dialogfields
Class TreeListDialogField

java.lang.Object
  extended by org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField
      extended by org.eclipse.cdt.internal.ui.wizards.dialogfields.TreeListDialogField

public class TreeListDialogField
extends DialogField

A list with a button bar. Typical buttons are 'Add', 'Remove', 'Up' and 'Down'. List model is independend of widget creation. DialogFields controls are: Label, List and Composite containing buttons.


Constructor Summary
TreeListDialogField(ITreeListAdapter adapter, java.lang.String[] buttonLabels, org.eclipse.jface.viewers.ILabelProvider lprovider)
           
 
Method Summary
 void addElement(java.lang.Object element)
          Adds an element at the end of the tree list.
 void addElements(java.util.List elements)
          Adds elements at the end of the tree list.
 void dialogFieldChanged()
          Programatical invocation of a dialog field change.
 org.eclipse.swt.widgets.Control[] doFillIntoGrid(org.eclipse.swt.widgets.Composite parent, int nColumns)
          Creates all controls of the dialog field and fills it to a composite.
 void enableButton(int index, boolean enable)
          Sets a button enabled or disabled.
 void expandElement(java.lang.Object element, int level)
           
 org.eclipse.swt.widgets.Composite getButtonBox(org.eclipse.swt.widgets.Composite parent)
          Returns the composite containing the buttons.
 java.lang.Object getElement(int index)
          Gets the element shown at the given index.
 java.util.List getElements()
          Gets the elements shown in the list.
 int getIndexOfElement(java.lang.Object elem)
          Gets the index of an element in the list or -1 if element is not in list.
 int getNumberOfControls()
          Returns the number of columns of the dialog field.
 java.util.List getSelectedElements()
          Returns the selected elements.
 int getSize()
          Gets the number of elements
 org.eclipse.swt.widgets.Control getTreeControl(org.eclipse.swt.widgets.Composite parent)
          Returns the tree control.
 org.eclipse.jface.viewers.TreeViewer getTreeViewer()
          Returns the internally used table viewer.
 void insertElementAt(java.lang.Object element, int index)
          Adds an element at a position.
 void postSetSelection(org.eclipse.jface.viewers.ISelection selection)
           
 void refresh()
          Refreshes the tree.
 void refresh(java.lang.Object element)
          Refreshes the tree.
 void removeAllElements()
          Adds an element at a position.
 void removeElement(java.lang.Object element)
          Removes an element from the list.
 void removeElements(java.util.List elements)
          Removes elements from the list.
 void replaceElement(java.lang.Object oldElement, java.lang.Object newElement)
          Replace an element.
 void selectElements(org.eclipse.jface.viewers.ISelection selection)
           
 void selectFirstElement()
           
 void setButtonsMinWidth(int minWidth)
          Sets the minimal width of the buttons.
 void setDownButtonIndex(int downButtonIndex)
          Sets the index of the 'down' button in the button label array passed in the constructor.
 void setElements(java.util.List elements)
          Sets the elements shown in the list.
 void setRemoveButtonIndex(int removeButtonIndex)
          Sets the index of the 'remove' button in the button label array passed in the constructor.
 void setTreeExpansionLevel(int level)
           
 void setUpButtonIndex(int upButtonIndex)
          Sets the index of the 'up' button in the button label array passed in the constructor.
 void setViewerSorter(org.eclipse.jface.viewers.ViewerSorter viewerSorter)
          Sets the viewerSorter.
 
Methods inherited from class org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField
createEmptySpace, createEmptySpace, getLabelControl, isEnabled, postSetFocusOnDialogField, setDialogFieldListener, setEnabled, setFocus, setLabelText
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeListDialogField

public TreeListDialogField(ITreeListAdapter adapter,
                           java.lang.String[] buttonLabels,
                           org.eclipse.jface.viewers.ILabelProvider lprovider)
Parameters:
adapter - Can be null.
Method Detail

setRemoveButtonIndex

public void setRemoveButtonIndex(int removeButtonIndex)
Sets the index of the 'remove' button in the button label array passed in the constructor. The behaviour of the button marked as the 'remove' button will then behandled internally. (enable state, button invocation behaviour)


setUpButtonIndex

public void setUpButtonIndex(int upButtonIndex)
Sets the index of the 'up' button in the button label array passed in the constructor. The behaviour of the button marked as the 'up' button will then behandled internally. (enable state, button invocation behaviour)


setDownButtonIndex

public void setDownButtonIndex(int downButtonIndex)
Sets the index of the 'down' button in the button label array passed in the constructor. The behaviour of the button marked as the 'down' button will then be handled internally. (enable state, button invocation behaviour)


setViewerSorter

public void setViewerSorter(org.eclipse.jface.viewers.ViewerSorter viewerSorter)
Sets the viewerSorter.

Parameters:
viewerSorter - The viewerSorter to set

setTreeExpansionLevel

public void setTreeExpansionLevel(int level)

doFillIntoGrid

public org.eclipse.swt.widgets.Control[] doFillIntoGrid(org.eclipse.swt.widgets.Composite parent,
                                                        int nColumns)
Description copied from class: DialogField
Creates all controls of the dialog field and fills it to a composite. The composite is assumed to have MGridLayout as layout. The dialog field will adjust its controls' spans to the number of columns given. To be reimplemented by dialog field implementors.

Overrides:
doFillIntoGrid in class DialogField

getNumberOfControls

public int getNumberOfControls()
Description copied from class: DialogField
Returns the number of columns of the dialog field. To be reimplemented by dialog field implementors.

Overrides:
getNumberOfControls in class DialogField

setButtonsMinWidth

public void setButtonsMinWidth(int minWidth)
Sets the minimal width of the buttons. Must be called after widget creation.


getTreeControl

public org.eclipse.swt.widgets.Control getTreeControl(org.eclipse.swt.widgets.Composite parent)
Returns the tree control. When called the first time, the control will be created.

Parameters:
parent - parent composite when called the first time, or null after.

getTreeViewer

public org.eclipse.jface.viewers.TreeViewer getTreeViewer()
Returns the internally used table viewer.


getButtonBox

public org.eclipse.swt.widgets.Composite getButtonBox(org.eclipse.swt.widgets.Composite parent)
Returns the composite containing the buttons. When called the first time, the control will be created.

Parameters:
parent - parent composite when called the first time, or null after.

dialogFieldChanged

public void dialogFieldChanged()
Description copied from class: DialogField
Programatical invocation of a dialog field change.

Overrides:
dialogFieldChanged in class DialogField

enableButton

public void enableButton(int index,
                         boolean enable)
Sets a button enabled or disabled.


setElements

public void setElements(java.util.List elements)
Sets the elements shown in the list.


getElements

public java.util.List getElements()
Gets the elements shown in the list. The list returned is a copy, so it can be modified by the user.


getElement

public java.lang.Object getElement(int index)
Gets the element shown at the given index.


getIndexOfElement

public int getIndexOfElement(java.lang.Object elem)
Gets the index of an element in the list or -1 if element is not in list.


replaceElement

public void replaceElement(java.lang.Object oldElement,
                           java.lang.Object newElement)
                    throws java.lang.IllegalArgumentException
Replace an element.

Throws:
java.lang.IllegalArgumentException

addElement

public void addElement(java.lang.Object element)
Adds an element at the end of the tree list.


addElements

public void addElements(java.util.List elements)
Adds elements at the end of the tree list.


insertElementAt

public void insertElementAt(java.lang.Object element,
                            int index)
Adds an element at a position.


removeAllElements

public void removeAllElements()
Adds an element at a position.


removeElement

public void removeElement(java.lang.Object element)
                   throws java.lang.IllegalArgumentException
Removes an element from the list.

Throws:
java.lang.IllegalArgumentException

removeElements

public void removeElements(java.util.List elements)
Removes elements from the list.


getSize

public int getSize()
Gets the number of elements


selectElements

public void selectElements(org.eclipse.jface.viewers.ISelection selection)

selectFirstElement

public void selectFirstElement()

postSetSelection

public void postSetSelection(org.eclipse.jface.viewers.ISelection selection)

refresh

public void refresh()
Refreshes the tree.


refresh

public void refresh(java.lang.Object element)
Refreshes the tree.


getSelectedElements

public java.util.List getSelectedElements()
Returns the selected elements.


expandElement

public void expandElement(java.lang.Object element,
                          int level)