org.eclipse.cdt.debug.mi.internal.ui.dialogfields
Class ListDialogField

java.lang.Object
  extended by org.eclipse.cdt.debug.mi.internal.ui.dialogfields.DialogField
      extended by org.eclipse.cdt.debug.mi.internal.ui.dialogfields.ListDialogField
Direct Known Subclasses:
CheckedListDialogField, SolibSearchPathBlock.SolibSearchPathListDialogField

public class ListDialogField
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
ListDialogField(IListAdapter adapter, java.lang.String[] buttonLabels, org.eclipse.jface.viewers.ILabelProvider lprovider)
          Creates the ListDialogField.
 
Method Summary
 void addElement(java.lang.Object element)
          Adds an element at the end of the list.
 void addElements(java.util.List elements)
          Adds elements at the end of the 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.
 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 elements shown at the given index.
 java.util.List getElements()
          Gets the elements shown in the list.
 org.eclipse.swt.widgets.Control getListControl(org.eclipse.swt.widgets.Composite parent)
          Returns the list control.
 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.jface.viewers.TableViewer getTableViewer()
          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 table.
 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 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.debug.mi.internal.ui.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

ListDialogField

public ListDialogField(IListAdapter adapter,
                       java.lang.String[] buttonLabels,
                       org.eclipse.jface.viewers.ILabelProvider lprovider)
Creates the ListDialogField.

Parameters:
adapter - A listener for button invocation, selection changes.
buttonLabels - The labels of all buttons: null is a valid array entry and marks a separator.
lprovider - The label provider to render the table entries
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 be handled 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 be handled 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

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.


getListControl

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

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

getTableViewer

public org.eclipse.jface.viewers.TableViewer getTableViewer()
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:
The - 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 elements shown at the given index.


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 list.


addElements

public void addElements(java.util.List elements)
Adds elements at the end of the 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 table.


getSelectedElements

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