1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / wizards / dialogfields / ListDialogField.java
index 867e0f2..3c85696 100644 (file)
@@ -10,7 +10,6 @@
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.ui.wizards.dialogfields;
 
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -19,7 +18,9 @@ import net.sourceforge.phpdt.internal.ui.util.PixelConverter;
 import net.sourceforge.phpdt.internal.ui.util.SWTUtil;
 import net.sourceforge.phpdt.internal.ui.util.TableLayoutComposite;
 
-import org.eclipse.jface.util.Assert;
+//incastrix
+//import org.eclipse.jface.text.Assert;
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.jface.viewers.ColumnLayoutData;
 import org.eclipse.jface.viewers.ColumnWeightData;
 import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -51,160 +52,178 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 
 /**
- * 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.
+ * 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.
  */
 public class ListDialogField extends DialogField {
-       
+
        public static class ColumnsDescription {
                private ColumnLayoutData[] columns;
+
                private String[] headers;
+
                private boolean drawLines;
-               
-               public ColumnsDescription(ColumnLayoutData[] columns, String[] headers, boolean drawLines) {
-                       this.columns= columns;
-                       this.headers= headers;
-                       this.drawLines= drawLines;
+
+               public ColumnsDescription(ColumnLayoutData[] columns, String[] headers,
+                               boolean drawLines) {
+                       this.columns = columns;
+                       this.headers = headers;
+                       this.drawLines = drawLines;
                }
-               
+
                public ColumnsDescription(String[] headers, boolean drawLines) {
                        this(createColumnWeightData(headers.length), headers, drawLines);
                }
-               
+
                public ColumnsDescription(int nColumns, boolean drawLines) {
                        this(createColumnWeightData(nColumns), null, drawLines);
                }
-               
+
                private static ColumnLayoutData[] createColumnWeightData(int nColumns) {
-                       ColumnLayoutData[] data= new ColumnLayoutData[nColumns];
-                       for (int i= 0; i < nColumns; i++) {
-                               data[i]= new ColumnWeightData(1);
-                       }                       
+                       ColumnLayoutData[] data = new ColumnLayoutData[nColumns];
+                       for (int i = 0; i < nColumns; i++) {
+                               data[i] = new ColumnWeightData(1);
+                       }
                        return data;
                }
        }
-       
+
        protected TableViewer fTable;
+
        protected ILabelProvider fLabelProvider;
+
        protected ListViewerAdapter fListViewerAdapter;
+
        protected List fElements;
+
        protected ViewerSorter fViewerSorter;
 
        protected String[] fButtonLabels;
+
        private Button[] fButtonControls;
-       
+
        private boolean[] fButtonsEnabled;
-       
+
        private int fRemoveButtonIndex;
+
        private int fUpButtonIndex;
+
        private int fDownButtonIndex;
-       
-       private Label fLastSeparator;
-       
+
+       //private Label fLastSeparator;
+
        private Control fTableControl;
+
        private Composite fButtonsControl;
+
        private ISelection fSelectionWhenEnabled;
-       
+
        private IListAdapter fListAdapter;
-       
+
        private Object fParentElement;
-       
+
        private ColumnsDescription fTableColumns;
-       
 
        /**
         * Creates the <code>ListDialogField</code>.
-        * @param adapter A listener for button invocation, selection changes. Can
-        * be <code>null</code>.
-        * @param buttonLabels The labels of all buttons: <code>null</code> is a valid array entry and
-        * marks a separator.
-        * @param lprovider The label provider to render the table entries
-        */     
-       public ListDialogField(IListAdapter adapter, String[] buttonLabels, ILabelProvider lprovider) {
+        * 
+        * @param adapter
+        *            A listener for button invocation, selection changes. Can be
+        *            <code>null</code>.
+        * @param buttonLabels
+        *            The labels of all buttons: <code>null</code> is a valid
+        *            array entry and marks a separator.
+        * @param lprovider
+        *            The label provider to render the table entries
+        */
+       public ListDialogField(IListAdapter adapter, String[] buttonLabels,
+                       ILabelProvider lprovider) {
                super();
-               fListAdapter= adapter;
+               fListAdapter = adapter;
+
+               fLabelProvider = lprovider;
+               fListViewerAdapter = new ListViewerAdapter();
+               fParentElement = this;
 
-               fLabelProvider= lprovider;
-               fListViewerAdapter= new ListViewerAdapter();
-               fParentElement= this;
+               fElements = new ArrayList(10);
 
-               fElements= new ArrayList(10);
-                                       
-               fButtonLabels= buttonLabels;
+               fButtonLabels = buttonLabels;
                if (fButtonLabels != null) {
-                       int nButtons= fButtonLabels.length;
-                       fButtonsEnabled= new boolean[nButtons];
-                       for (int i= 0; i < nButtons; i++) {
-                               fButtonsEnabled[i]= true;
+                       int nButtons = fButtonLabels.length;
+                       fButtonsEnabled = new boolean[nButtons];
+                       for (int i = 0; i < nButtons; i++) {
+                               fButtonsEnabled[i] = true;
                        }
-               }       
-                               
-               fTable= null;
-               fTableControl= null;
-               fButtonsControl= null;
-               fTableColumns= null;
-               
-               fRemoveButtonIndex= -1;
-               fUpButtonIndex= -1;
-               fDownButtonIndex= -1;
-       }
-               
+               }
+
+               fTable = null;
+               fTableControl = null;
+               fButtonsControl = null;
+               fTableColumns = null;
+
+               fRemoveButtonIndex = -1;
+               fUpButtonIndex = -1;
+               fDownButtonIndex = -1;
+       }
+
        /**
-        * 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)
-        */     
+        * 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)
+        */
        public void setRemoveButtonIndex(int removeButtonIndex) {
                Assert.isTrue(removeButtonIndex < fButtonLabels.length);
-               fRemoveButtonIndex= removeButtonIndex;
+               fRemoveButtonIndex = removeButtonIndex;
        }
 
        /**
-        * 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)
-        */     
+        * 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)
+        */
        public void setUpButtonIndex(int upButtonIndex) {
                Assert.isTrue(upButtonIndex < fButtonLabels.length);
-               fUpButtonIndex= upButtonIndex;
+               fUpButtonIndex = upButtonIndex;
        }
 
        /**
-        * 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)
-        */     
+        * 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)
+        */
        public void setDownButtonIndex(int downButtonIndex) {
                Assert.isTrue(downButtonIndex < fButtonLabels.length);
-               fDownButtonIndex= downButtonIndex;
+               fDownButtonIndex = downButtonIndex;
        }
-       
+
        /**
         * Sets the viewerSorter.
-        * @param viewerSorter The viewerSorter to set
+        * 
+        * @param viewerSorter
+        *            The viewerSorter to set
         */
-       public void setViewerSorter(ViewerSorter viewerSorter) {
-               fViewerSorter= viewerSorter;
-       }
-       
+//     public void setViewerSorter(ViewerSorter viewerSorter) {
+//             fViewerSorter = viewerSorter;
+//     }
+
        public void setTableColumns(ColumnsDescription column) {
-               fTableColumns= column;
+               fTableColumns = column;
        }
-       
-       
-       
+
        // ------ adapter communication
-       
+
        private void buttonPressed(int index) {
                if (!managedButtonPressed(index) && fListAdapter != null) {
                        fListAdapter.customButtonPressed(this, index);
                }
        }
-       
+
        /**
         * Checks if the button pressed is handled internally
+        * 
         * @return Returns true if button has been handled.
         */
        protected boolean managedButtonPressed(int index) {
@@ -219,95 +238,98 @@ public class ListDialogField extends DialogField {
                }
                return true;
        }
-       
 
        // ------ layout helpers
-       
+
        /*
         * @see DialogField#doFillIntoGrid
         */
        public Control[] doFillIntoGrid(Composite parent, int nColumns) {
-               PixelConverter converter= new PixelConverter(parent);
-               
+               PixelConverter converter = new PixelConverter(parent);
+
                assertEnoughColumns(nColumns);
-               
-               Label label= getLabelControl(parent);
-               GridData gd= gridDataForLabel(1);
-               gd.verticalAlignment= GridData.BEGINNING;
+
+               Label label = getLabelControl(parent);
+               GridData gd = gridDataForLabel(1);
+               gd.verticalAlignment = GridData.BEGINNING;
                label.setLayoutData(gd);
-               
-               Control list= getListControl(parent);
-               gd= new GridData();
-               gd.horizontalAlignment= GridData.FILL;
-               gd.grabExcessHorizontalSpace= false;
-               gd.verticalAlignment= GridData.FILL;
-               gd.grabExcessVerticalSpace= true;
-               gd.horizontalSpan= nColumns - 2;
-               gd.widthHint= converter.convertWidthInCharsToPixels(50);
-               gd.heightHint= converter.convertHeightInCharsToPixels(6);
+
+               Control list = getListControl(parent);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = false;
+               gd.verticalAlignment = GridData.FILL;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalSpan = nColumns - 2;
+               gd.widthHint = converter.convertWidthInCharsToPixels(50);
+               gd.heightHint = converter.convertHeightInCharsToPixels(6);
 
                list.setLayoutData(gd);
-               
-               Composite buttons= getButtonBox(parent);
-               gd= new GridData();
-               gd.horizontalAlignment= GridData.FILL;
-               gd.grabExcessHorizontalSpace= false;
-               gd.verticalAlignment= GridData.FILL;
-               gd.grabExcessVerticalSpace= true;
-               gd.horizontalSpan= 1;
+
+               Composite buttons = getButtonBox(parent);
+               gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = false;
+               gd.verticalAlignment = GridData.FILL;
+               gd.grabExcessVerticalSpace = true;
+               gd.horizontalSpan = 1;
                buttons.setLayoutData(gd);
-               
+
                return new Control[] { label, list, buttons };
        }
 
        /*
         * @see DialogField#getNumberOfControls
-        */     
+        */
        public int getNumberOfControls() {
-               return 3;       
+               return 3;
        }
 
        /**
-        * Sets the minimal width of the buttons. Must be called after widget creation.
-        */             
-       public void setButtonsMinWidth(int minWidth) {
-               if (fLastSeparator != null) {
-                       ((GridData)fLastSeparator.getLayoutData()).widthHint= minWidth;
-               }
-       }
-       
-       
+        * Sets the minimal width of the buttons. Must be called after widget
+        * creation.
+        */
+//     public void setButtonsMinWidth(int minWidth) {
+//             if (fLastSeparator != null) {
+//                     ((GridData) fLastSeparator.getLayoutData()).widthHint = minWidth;
+//             }
+//     }
+
        // ------ ui creation
-       
+
        /**
-        * Returns the list control. When called the first time, the control will be created.
-        * @param The parent composite when called the first time, or <code>null</code>
-        * after.
+        * Returns the list control. When called the first time, the control will be
+        * created.
+        * 
+        * @param The
+        *            parent composite when called the first time, or
+        *            <code>null</code> after.
         */
        public Control getListControl(Composite parent) {
                if (fTableControl == null) {
                        assertCompositeNotNull(parent);
-                       
+
                        if (fTableColumns == null) {
-                               fTable= createTableViewer(parent);
-                               Table tableControl= fTable.getTable();
-                               
-                               fTableControl= tableControl;
+                               fTable = createTableViewer(parent);
+                               Table tableControl = fTable.getTable();
+
+                               fTableControl = tableControl;
                                tableControl.setLayout(new TableLayout());
                        } else {
-                               TableLayoutComposite composite= new TableLayoutComposite(parent, SWT.NONE);
-                               fTableControl= composite;
-                               
-                               fTable= createTableViewer(composite);
-                               Table tableControl= fTable.getTable();
-                                                               
+                               TableLayoutComposite composite = new TableLayoutComposite(
+                                               parent, SWT.NONE);
+                               fTableControl = composite;
+
+                               fTable = createTableViewer(composite);
+                               Table tableControl = fTable.getTable();
+
                                tableControl.setHeaderVisible(fTableColumns.headers != null);
                                tableControl.setLinesVisible(fTableColumns.drawLines);
-                               ColumnLayoutData[] columns= fTableColumns.columns;
-                               for (int i= 0; i < columns.length; i++) {
+                               ColumnLayoutData[] columns = fTableColumns.columns;
+                               for (int i = 0; i < columns.length; i++) {
                                        composite.addColumnData(columns[i]);
-                                       TableColumn column= new TableColumn(tableControl, SWT.NONE);
-                                       //tableLayout.addColumnData(columns[i]);
+                                       TableColumn column = new TableColumn(tableControl, SWT.NONE);
+                                       // tableLayout.addColumnData(columns[i]);
                                        if (fTableColumns.headers != null) {
                                                column.setText(fTableColumns.headers[i]);
                                        }
@@ -319,20 +341,20 @@ public class ListDialogField extends DialogField {
                                        handleKeyPressed(e);
                                }
                        });
-                       
-                       //fTableControl.setLayout(tableLayout);                                         
-                       
+
+                       // fTableControl.setLayout(tableLayout);
+
                        fTable.setContentProvider(fListViewerAdapter);
                        fTable.setLabelProvider(fLabelProvider);
                        fTable.addSelectionChangedListener(fListViewerAdapter);
                        fTable.addDoubleClickListener(fListViewerAdapter);
-                       
+
                        fTable.setInput(fParentElement);
-                       
+
                        if (fViewerSorter != null) {
                                fTable.setSorter(fViewerSorter);
                        }
-                       
+
                        fTableControl.setEnabled(isEnabled());
                        if (fSelectionWhenEnabled != null) {
                                postSetSelection(fSelectionWhenEnabled);
@@ -343,104 +365,110 @@ public class ListDialogField extends DialogField {
 
        /**
         * Returns the internally used table viewer.
-        */             
+        */
        public TableViewer getTableViewer() {
                return fTable;
        }
-       
-       /* 
+
+       /*
         * Subclasses may override to specify a different style.
         */
-       protected int getListStyle(){
-               int style=  SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL ;
+       protected int getListStyle() {
+               int style = SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
                if (fTableColumns != null) {
                        style |= SWT.FULL_SELECTION;
                }
-               return style;           
+               return style;
        }
-       
+
        protected TableViewer createTableViewer(Composite parent) {
-               Table table= new Table(parent, getListStyle());
+               Table table = new Table(parent, getListStyle());
                return new TableViewer(table);
-       }       
-       
-       protected Button createButton(Composite parent, String label, SelectionListener listener) {
-               Button button= new Button(parent, SWT.PUSH);
+       }
+
+       protected Button createButton(Composite parent, String label,
+                       SelectionListener listener) {
+               Button button = new Button(parent, SWT.PUSH);
                button.setText(label);
                button.addSelectionListener(listener);
-               GridData gd= new GridData();
-               gd.horizontalAlignment= GridData.FILL;
-               gd.grabExcessHorizontalSpace= true;
-               gd.verticalAlignment= GridData.BEGINNING;
+               GridData gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.grabExcessHorizontalSpace = true;
+               gd.verticalAlignment = GridData.BEGINNING;
                gd.heightHint = SWTUtil.getButtonHeightHint(button);
                gd.widthHint = SWTUtil.getButtonWidthHint(button);
-       
+
                button.setLayoutData(gd);
                return button;
        }
-       
+
        private Label createSeparator(Composite parent) {
-               Label separator= new Label(parent, SWT.NONE);
+               Label separator = new Label(parent, SWT.NONE);
                separator.setVisible(false);
-               GridData gd= new GridData();
-               gd.horizontalAlignment= GridData.FILL;
-               gd.verticalAlignment= GridData.BEGINNING;
-               gd.heightHint= 4;
+               GridData gd = new GridData();
+               gd.horizontalAlignment = GridData.FILL;
+               gd.verticalAlignment = GridData.BEGINNING;
+               gd.heightHint = 4;
                separator.setLayoutData(gd);
                return separator;
-       }                       
+       }
 
        /**
-        * Returns the composite containing the buttons. When called the first time, the control
-        * will be created.
-        * @param The parent composite when called the first time, or <code>null</code>
-        * after.
-        */     
+        * Returns the composite containing the buttons. When called the first time,
+        * the control will be created.
+        * 
+        * @param The
+        *            parent composite when called the first time, or
+        *            <code>null</code> after.
+        */
        public Composite getButtonBox(Composite parent) {
                if (fButtonsControl == null) {
                        assertCompositeNotNull(parent);
-                       
-                       SelectionListener listener= new SelectionListener() {
+
+                       SelectionListener listener = new SelectionListener() {
                                public void widgetDefaultSelected(SelectionEvent e) {
                                        doButtonSelected(e);
                                }
+
                                public void widgetSelected(SelectionEvent e) {
                                        doButtonSelected(e);
                                }
                        };
-                       
-                       Composite contents= new Composite(parent, SWT.NULL);
-                       GridLayout layout= new GridLayout();
-                       layout.marginWidth= 0;
-                       layout.marginHeight= 0;
+
+                       Composite contents = new Composite(parent, SWT.NULL);
+                       GridLayout layout = new GridLayout();
+                       layout.marginWidth = 0;
+                       layout.marginHeight = 0;
                        contents.setLayout(layout);
-                       
+
                        if (fButtonLabels != null) {
-                               fButtonControls= new Button[fButtonLabels.length];
-                               for (int i= 0; i < fButtonLabels.length; i++) {
-                                       String currLabel= fButtonLabels[i];
+                               fButtonControls = new Button[fButtonLabels.length];
+                               for (int i = 0; i < fButtonLabels.length; i++) {
+                                       String currLabel = fButtonLabels[i];
                                        if (currLabel != null) {
-                                               fButtonControls[i]= createButton(contents, currLabel, listener);
-                                               fButtonControls[i].setEnabled(isEnabled() && fButtonsEnabled[i]);
+                                               fButtonControls[i] = createButton(contents, currLabel,
+                                                               listener);
+                                               fButtonControls[i].setEnabled(isEnabled()
+                                                               && fButtonsEnabled[i]);
                                        } else {
-                                               fButtonControls[i]= null;
+                                               fButtonControls[i] = null;
                                                createSeparator(contents);
                                        }
                                }
                        }
-                                               
-                       fLastSeparator= createSeparator(contents);      
-       
+
+                       //fLastSeparator = createSeparator(contents);
+
                        updateButtonState();
-                       fButtonsControl= contents;
+                       fButtonsControl = contents;
                }
-               
+
                return fButtonsControl;
        }
-       
+
        private void doButtonSelected(SelectionEvent e) {
                if (fButtonControls != null) {
-                       for (int i= 0; i < fButtonControls.length; i++) {
+                       for (int i = 0; i < fButtonControls.length; i++) {
                                if (e.widget == fButtonControls[i]) {
                                        buttonPressed(i);
                                        return;
@@ -448,44 +476,46 @@ public class ListDialogField extends DialogField {
                        }
                }
        }
-       
+
        /**
-        * Handles key events in the table viewer. Specifically
-        * when the delete key is pressed.
+        * Handles key events in the table viewer. Specifically when the delete key
+        * is pressed.
         */
        protected void handleKeyPressed(KeyEvent event) {
                if (event.character == SWT.DEL && event.stateMask == 0) {
-                       if (fRemoveButtonIndex != -1 && isButtonEnabled(fTable.getSelection(), fRemoveButtonIndex)) {
+                       if (fRemoveButtonIndex != -1
+                                       && isButtonEnabled(fTable.getSelection(),
+                                                       fRemoveButtonIndex)) {
                                managedButtonPressed(fRemoveButtonIndex);
                        }
-               } 
-       }       
-       
+               }
+       }
+
        // ------ enable / disable management
 
        /*
         * @see DialogField#dialogFieldChanged
-        */     
+        */
        public void dialogFieldChanged() {
                super.dialogFieldChanged();
                updateButtonState();
        }
-       
+
        /*
         * Updates the enable state of the all buttons
-        */ 
+        */
        protected void updateButtonState() {
                if (fButtonControls != null) {
-                       ISelection sel= fTable.getSelection();
-                       for (int i= 0; i < fButtonControls.length; i++) {
-                               Button button= fButtonControls[i];
+                       ISelection sel = fTable.getSelection();
+                       for (int i = 0; i < fButtonControls.length; i++) {
+                               Button button = fButtonControls[i];
                                if (isOkToUse(button)) {
                                        button.setEnabled(isButtonEnabled(sel, i));
-                               }                               
+                               }
                        }
                }
        }
-       
+
        protected boolean getManagedButtonState(ISelection sel, int index) {
                if (index == fRemoveButtonIndex) {
                        return !sel.isEmpty();
@@ -495,22 +525,22 @@ public class ListDialogField extends DialogField {
                        return !sel.isEmpty() && canMoveDown();
                }
                return true;
-       }               
+       }
 
        /*
         * @see DialogField#updateEnableState
-        */     
+        */
        protected void updateEnableState() {
                super.updateEnableState();
-               
-               boolean enabled= isEnabled();
+
+               boolean enabled = isEnabled();
                if (isOkToUse(fTableControl)) {
                        if (!enabled) {
-                               fSelectionWhenEnabled= fTable.getSelection();
+                               fSelectionWhenEnabled = fTable.getSelection();
                                selectElements(null);
                        } else {
                                selectElements(fSelectionWhenEnabled);
-                               fSelectionWhenEnabled= null;
+                               fSelectionWhenEnabled = null;
                        }
                        fTableControl.setEnabled(enabled);
                }
@@ -519,27 +549,26 @@ public class ListDialogField extends DialogField {
 
        /**
         * Sets a button enabled or disabled.
-        */     
+        */
        public void enableButton(int index, boolean enable) {
                if (fButtonsEnabled != null && index < fButtonsEnabled.length) {
-                       fButtonsEnabled[index]= enable;
+                       fButtonsEnabled[index] = enable;
                        updateButtonState();
                }
        }
-       
+
        private boolean isButtonEnabled(ISelection sel, int index) {
-               boolean extraState= getManagedButtonState(sel, index);
+               boolean extraState = getManagedButtonState(sel, index);
                return isEnabled() && extraState && fButtonsEnabled[index];
-       }               
-       
+       }
 
        // ------ model access
-       
+
        /**
         * Sets the elements shown in the list.
         */
        public void setElements(List elements) {
-               fElements= new ArrayList(elements);
+               fElements = new ArrayList(elements);
                if (fTable != null) {
                        fTable.refresh();
                }
@@ -547,36 +576,37 @@ public class ListDialogField extends DialogField {
        }
 
        /**
-        * Gets the elements shown in the list.
-        * The list returned is a copy, so it can be modified by the user.
-        */     
+        * Gets the elements shown in the list. The list returned is a copy, so it
+        * can be modified by the user.
+        */
        public List getElements() {
                return new ArrayList(fElements);
        }
 
        /**
         * Gets the elements shown at the given index.
-        */             
+        */
        public Object getElement(int index) {
                return fElements.get(index);
        }
-       
+
        /**
-       * Gets the index of an element in the list or -1 if element is not in list.
-       */
-       public int getIndexOfElement(Object elem) {
-               return fElements.indexOf(elem);
-       }       
+        * Gets the index of an element in the list or -1 if element is not in list.
+        */
+//     public int getIndexOfElement(Object elem) {
+//             return fElements.indexOf(elem);
+//     }
 
        /**
         * Replace an element.
-        */             
-       public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException { 
-               int idx= fElements.indexOf(oldElement);
+        */
+       public void replaceElement(Object oldElement, Object newElement)
+                       throws IllegalArgumentException {
+               int idx = fElements.indexOf(oldElement);
                if (idx != -1) {
                        fElements.set(idx, newElement);
                        if (fTable != null) {
-                               List selected= getSelectedElements();
+                               List selected = getSelectedElements();
                                if (selected.remove(oldElement)) {
                                        selected.add(newElement);
                                }
@@ -587,12 +617,12 @@ public class ListDialogField extends DialogField {
                } else {
                        throw new IllegalArgumentException();
                }
-       }       
+       }
 
        /**
         * Adds an element at the end of the list.
-        */             
-       public void addElement(Object element) {                
+        */
+       public void addElement(Object element) {
                if (fElements.contains(element)) {
                        return;
                }
@@ -605,31 +635,31 @@ public class ListDialogField extends DialogField {
 
        /**
         * Adds elements at the end of the list.
-        */     
-       public void addElements(List elements) {
-               int nElements= elements.size();
-               
-               if (nElements > 0) {
-                       // filter duplicated
-                       ArrayList elementsToAdd= new ArrayList(nElements);
-                       
-                       for (int i= 0; i < nElements; i++) {
-                               Object elem= elements.get(i);
-                               if (!fElements.contains(elem)) {
-                                       elementsToAdd.add(elem);
-                               }       
-                       }
-                       fElements.addAll(elementsToAdd);
-                       if (fTable != null) {
-                               fTable.add(elementsToAdd.toArray());
-                       }
-                       dialogFieldChanged();
-               }
-       }       
+        */
+//     public void addElements(List elements) {
+//             int nElements = elements.size();
+//
+//             if (nElements > 0) {
+//                     // filter duplicated
+//                     ArrayList elementsToAdd = new ArrayList(nElements);
+//
+//                     for (int i = 0; i < nElements; i++) {
+//                             Object elem = elements.get(i);
+//                             if (!fElements.contains(elem)) {
+//                                     elementsToAdd.add(elem);
+//                             }
+//                     }
+//                     fElements.addAll(elementsToAdd);
+//                     if (fTable != null) {
+//                             fTable.add(elementsToAdd.toArray());
+//                     }
+//                     dialogFieldChanged();
+//             }
+//     }
 
        /**
         * Adds an element at a position.
-        */             
+        */
        public void insertElementAt(Object element, int index) {
                if (fElements.contains(element)) {
                        return;
@@ -638,41 +668,40 @@ public class ListDialogField extends DialogField {
                if (fTable != null) {
                        fTable.add(element);
                }
-               
-               dialogFieldChanged();
-       }       
 
+               dialogFieldChanged();
+       }
 
        /**
         * Adds an element at a position.
-        */     
-       public void removeAllElements() {
-               if (fElements.size() > 0) {
-                       fElements.clear();
-                       if (fTable != null) {
-                               fTable.refresh();
-                       }
-                       dialogFieldChanged();
-               }
-       }
-               
+        */
+//     public void removeAllElements() {
+//             if (fElements.size() > 0) {
+//                     fElements.clear();
+//                     if (fTable != null) {
+//                             fTable.refresh();
+//                     }
+//                     dialogFieldChanged();
+//             }
+//     }
+
        /**
         * Removes an element from the list.
-        */             
-       public void removeElement(Object element) throws IllegalArgumentException {
-               if (fElements.remove(element)) {
-                       if (fTable != null) {
-                               fTable.remove(element);
-                       }
-                       dialogFieldChanged();
-               } else {
-                       throw new IllegalArgumentException();
-               }
-       }
+        */
+//     public void removeElement(Object element) throws IllegalArgumentException {
+//             if (fElements.remove(element)) {
+//                     if (fTable != null) {
+//                             fTable.remove(element);
+//                     }
+//                     dialogFieldChanged();
+//             } else {
+//                     throw new IllegalArgumentException();
+//             }
+//     }
 
        /**
         * Removes elements from the list.
-        */             
+        */
        public void removeElements(List elements) {
                if (elements.size() > 0) {
                        fElements.removeAll(elements);
@@ -685,41 +714,39 @@ public class ListDialogField extends DialogField {
 
        /**
         * Gets the number of elements
-        */             
+        */
        public int getSize() {
                return fElements.size();
        }
-       
 
        public void selectElements(ISelection selection) {
-               fSelectionWhenEnabled= selection;
+               fSelectionWhenEnabled = selection;
                if (fTable != null) {
                        fTable.setSelection(selection, true);
                }
        }
-       
+
        public void selectFirstElement() {
-               Object element= null;
+               Object element = null;
                if (fViewerSorter != null) {
-                       Object[] arr= fElements.toArray(); 
+                       Object[] arr = fElements.toArray();
                        fViewerSorter.sort(fTable, arr);
                        if (arr.length > 0) {
-                               element= arr[0];
+                               element = arr[0];
                        }
                } else {
                        if (fElements.size() > 0) {
-                               element= fElements.get(0);
+                               element = fElements.get(0);
                        }
                }
                if (element != null) {
                        selectElements(new StructuredSelection(element));
                }
        }
-       
-               
+
        public void postSetSelection(final ISelection selection) {
                if (isOkToUse(fTableControl)) {
-                       Display d= fTableControl.getDisplay();
+                       Display d = fTableControl.getDisplay();
                        d.asyncExec(new Runnable() {
                                public void run() {
                                        if (isOkToUse(fTableControl)) {
@@ -729,7 +756,7 @@ public class ListDialogField extends DialogField {
                        });
                }
        }
-       
+
        /**
         * Refreshes the table.
         */
@@ -738,69 +765,68 @@ public class ListDialogField extends DialogField {
                        fTable.refresh();
                }
        }
-       
+
        // ------- list maintenance
-       
+
        private List moveUp(List elements, List move) {
-               int nElements= elements.size();
-               List res= new ArrayList(nElements);
-               Object floating= null;
-               for (int i= 0; i < nElements; i++) {
-                       Object curr= elements.get(i);
+               int nElements = elements.size();
+               List res = new ArrayList(nElements);
+               Object floating = null;
+               for (int i = 0; i < nElements; i++) {
+                       Object curr = elements.get(i);
                        if (move.contains(curr)) {
                                res.add(curr);
                        } else {
                                if (floating != null) {
                                        res.add(floating);
                                }
-                               floating= curr;
+                               floating = curr;
                        }
                }
                if (floating != null) {
                        res.add(floating);
                }
                return res;
-       }       
-       
+       }
+
        private void moveUp(List toMoveUp) {
                if (toMoveUp.size() > 0) {
                        setElements(moveUp(fElements, toMoveUp));
                        fTable.reveal(toMoveUp.get(0));
                }
        }
-       
+
        private void moveDown(List toMoveDown) {
                if (toMoveDown.size() > 0) {
                        setElements(reverse(moveUp(reverse(fElements), toMoveDown)));
                        fTable.reveal(toMoveDown.get(toMoveDown.size() - 1));
                }
        }
-       
+
        private List reverse(List p) {
-               List reverse= new ArrayList(p.size());
-               for (int i= p.size()-1; i >= 0; i--) {
+               List reverse = new ArrayList(p.size());
+               for (int i = p.size() - 1; i >= 0; i--) {
                        reverse.add(p.get(i));
                }
                return reverse;
        }
-       
-       
+
        private void remove() {
                removeElements(getSelectedElements());
        }
-       
+
        private void up() {
                moveUp(getSelectedElements());
        }
-       
+
        private void down() {
                moveDown(getSelectedElements());
        }
-       
+
        private boolean canMoveUp() {
                if (isOkToUse(fTableControl)) {
-                       int[] indc= fTable.getTable().getSelectionIndices();
-                       for (int i= 0; i < indc.length; i++) {
+                       int[] indc = fTable.getTable().getSelectionIndices();
+                       for (int i = 0; i < indc.length; i++) {
                                if (indc[i] != i) {
                                        return true;
                                }
@@ -808,29 +834,29 @@ public class ListDialogField extends DialogField {
                }
                return false;
        }
-       
+
        private boolean canMoveDown() {
                if (isOkToUse(fTableControl)) {
-                       int[] indc= fTable.getTable().getSelectionIndices();
-                       int k= fElements.size() - 1;
-                       for (int i= indc.length - 1; i >= 0 ; i--, k--) {
+                       int[] indc = fTable.getTable().getSelectionIndices();
+                       int k = fElements.size() - 1;
+                       for (int i = indc.length - 1; i >= 0; i--, k--) {
                                if (indc[i] != k) {
                                        return true;
                                }
                        }
                }
                return false;
-       }       
+       }
 
        /**
         * Returns the selected elements.
         */
        public List getSelectedElements() {
-               List result= new ArrayList();
+               List result = new ArrayList();
                if (fTable != null) {
-                       ISelection selection= fTable.getSelection();
+                       ISelection selection = fTable.getSelection();
                        if (selection instanceof IStructuredSelection) {
-                               Iterator iter= ((IStructuredSelection)selection).iterator();
+                               Iterator iter = ((IStructuredSelection) selection).iterator();
                                while (iter.hasNext()) {
                                        result.add(iter.next());
                                }
@@ -838,35 +864,38 @@ public class ListDialogField extends DialogField {
                }
                return result;
        }
-       
+
        // ------- ListViewerAdapter
-       
-       private class ListViewerAdapter implements IStructuredContentProvider, ISelectionChangedListener, IDoubleClickListener {
+
+       private class ListViewerAdapter implements IStructuredContentProvider,
+                       ISelectionChangedListener, IDoubleClickListener {
 
                // ------- ITableContentProvider Interface ------------
-       
+
                public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                        // will never happen
                }
-               
+
                public boolean isDeleted(Object element) {
                        return false;
                }
-       
+
                public void dispose() {
                }
-               
+
                public Object[] getElements(Object obj) {
                        return fElements.toArray();
                }
-       
+
                // ------- ISelectionChangedListener Interface ------------
-               
+
                public void selectionChanged(SelectionChangedEvent event) {
                        doListSelected(event);
                }
-               
-               /* (non-Javadoc)
+
+               /*
+                * (non-Javadoc)
+                * 
                 * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
                 */
                public void doubleClick(DoubleClickEvent event) {
@@ -874,21 +903,18 @@ public class ListDialogField extends DialogField {
                }
 
        }
-       
-       
+
        protected void doListSelected(SelectionChangedEvent event) {
                updateButtonState();
                if (fListAdapter != null) {
                        fListAdapter.selectionChanged(this);
                }
        }
-       
+
        protected void doDoubleClick(DoubleClickEvent event) {
                if (fListAdapter != null) {
                        fListAdapter.doubleClicked(this);
                }
-       }       
-
-
+       }
 
 }