A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / wizards / dialogfields / TreeListDialogField.java
index 4cf3892..8bed2ad 100644 (file)
@@ -44,125 +44,138 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Tree;
 
-
 /**
- * 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 TreeListDialogField extends DialogField {
 
        protected TreeViewer fTree;
+
        protected ILabelProvider fLabelProvider;
+
        protected TreeViewerAdapter fTreeViewerAdapter;
+
        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 Tree fTreeControl;
+
        private Composite fButtonsControl;
+
        private ISelection fSelectionWhenEnabled;
 
        private ITreeListAdapter fTreeAdapter;
 
        private Object fParentElement;
+
        private int fTreeExpandLevel;
 
        /**
-        * @param adapter Can be <code>null</code>.
+        * @param adapter
+        *            Can be <code>null</code>.
         */
-       public TreeListDialogField(ITreeListAdapter adapter, String[] buttonLabels, ILabelProvider lprovider) {
+       public TreeListDialogField(ITreeListAdapter adapter, String[] buttonLabels,
+                       ILabelProvider lprovider) {
                super();
-               fTreeAdapter= adapter;
+               fTreeAdapter = adapter;
 
-               fLabelProvider= lprovider;
-               fTreeViewerAdapter= new TreeViewerAdapter();
-               fParentElement= this;
+               fLabelProvider = lprovider;
+               fTreeViewerAdapter = new TreeViewerAdapter();
+               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;
                        }
                }
 
-               fTree= null;
-               fTreeControl= null;
-               fButtonsControl= null;
+               fTree = null;
+               fTreeControl = null;
+               fButtonsControl = null;
+
+               fRemoveButtonIndex = -1;
+               fUpButtonIndex = -1;
+               fDownButtonIndex = -1;
 
-               fRemoveButtonIndex= -1;
-               fUpButtonIndex= -1;
-               fDownButtonIndex= -1;
-               
-               fTreeExpandLevel= 0;
+               fTreeExpandLevel = 0;
        }
 
        /**
-       * 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)
-       */
+        * 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)
+        */
        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 behandled 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 behandled 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
-       */
+        * Sets the viewerSorter.
+        * 
+        * @param viewerSorter
+        *            The viewerSorter to set
+        */
        public void setViewerSorter(ViewerSorter viewerSorter) {
-               fViewerSorter= viewerSorter;
+               fViewerSorter = viewerSorter;
        }
-       
+
        /**
-       * Sets the viewerSorter.
-       * @param viewerSorter The viewerSorter to set
-       */
+        * Sets the viewerSorter.
+        * 
+        * @param viewerSorter
+        *            The viewerSorter to set
+        */
        public void setTreeExpansionLevel(int level) {
-               fTreeExpandLevel= level;
+               fTreeExpandLevel = level;
                if (fTree != null) {
                        fTree.expandToLevel(level);
                }
-       }       
+       }
 
        // ------ adapter communication
 
@@ -173,9 +186,10 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Checks if the button pressed is handled internally
-       * @return Returns true if button has been handled.
-       */
+        * Checks if the button pressed is handled internally
+        * 
+        * @return Returns true if button has been handled.
+        */
        protected boolean managedButtonPressed(int index) {
                if (index == fRemoveButtonIndex) {
                        remove();
@@ -192,73 +206,76 @@ public class TreeListDialogField extends DialogField {
        // ------ layout helpers
 
        /*
-       * @see DialogField#doFillIntoGrid
-       */
+        * @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= getTreeControl(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 = getTreeControl(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
-       */
+        * @see DialogField#getNumberOfControls
+        */
        public int getNumberOfControls() {
                return 3;
        }
 
        /**
-       * Sets the minimal width of the buttons. Must be called after widget creation.
-       */
+        * 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;
+                       ((GridData) fLastSeparator.getLayoutData()).widthHint = minWidth;
                }
        }
 
        // ------ ui creation
 
        /**
-       * Returns the tree 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 tree 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 getTreeControl(Composite parent) {
                if (fTreeControl == null) {
                        assertCompositeNotNull(parent);
 
-                       fTree= createTreeViewer(parent);
+                       fTree = createTreeViewer(parent);
 
-                       fTreeControl= (Tree) fTree.getControl();
+                       fTreeControl = (Tree) fTree.getControl();
                        fTreeControl.addKeyListener(new KeyAdapter() {
                                public void keyPressed(KeyEvent e) {
                                        handleKeyPressed(e);
@@ -286,94 +303,100 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Returns the internally used table viewer.
-       */
+        * Returns the internally used table viewer.
+        */
        public TreeViewer getTreeViewer() {
                return fTree;
        }
 
        /*
-       * Subclasses may override to specify a different style.
-       */
+        * Subclasses may override to specify a different style.
+        */
        protected int getTreeStyle() {
-               int style= SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
+               int style = SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL;
                return style;
        }
 
        protected TreeViewer createTreeViewer(Composite parent) {
-               Tree tree= new Tree(parent, getTreeStyle());
+               Tree tree = new Tree(parent, getTreeStyle());
                return new TreeViewer(tree);
        }
 
-       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;
-               gd.heightHint= SWTUtil.getButtonHeightHint(button);
-               gd.widthHint= SWTUtil.getButtonWidthHint(button);
+               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;
@@ -381,7 +404,7 @@ public class TreeListDialogField extends DialogField {
 
        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;
@@ -391,12 +414,13 @@ public class TreeListDialogField 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(fTree.getSelection(), fRemoveButtonIndex)) {
+                       if (fRemoveButtonIndex != -1
+                                       && isButtonEnabled(fTree.getSelection(), fRemoveButtonIndex)) {
                                managedButtonPressed(fRemoveButtonIndex);
                                return;
                        }
@@ -407,42 +431,40 @@ public class TreeListDialogField extends DialogField {
        // ------ enable / disable management
 
        /*
-       * @see DialogField#dialogFieldChanged
-       */
+        * @see DialogField#dialogFieldChanged
+        */
        public void dialogFieldChanged() {
                super.dialogFieldChanged();
                updateButtonState();
        }
 
        /*
-       * Updates the enable state of the all buttons
-       */
+        * Updates the enable state of the all buttons
+        */
        protected void updateButtonState() {
                if (fButtonControls != null) {
-                       ISelection sel= fTree.getSelection();
-                       for (int i= 0; i < fButtonControls.length; i++) {
-                               Button button= fButtonControls[i];
+                       ISelection sel = fTree.getSelection();
+                       for (int i = 0; i < fButtonControls.length; i++) {
+                               Button button = fButtonControls[i];
                                if (isOkToUse(button)) {
                                        button.setEnabled(isButtonEnabled(sel, i));
                                }
                        }
                }
        }
-       
-       
+
        protected boolean containsAttributes(List selected) {
-               for (int i= 0; i < selected.size(); i++) {
+               for (int i = 0; i < selected.size(); i++) {
                        if (!fElements.contains(selected.get(i))) {
                                return true;
                        }
                }
                return false;
        }
-       
 
        protected boolean getManagedButtonState(ISelection sel, int index) {
-               List selected= getSelectedElements();
-               boolean hasAttributes= containsAttributes(selected);
+               List selected = getSelectedElements();
+               boolean hasAttributes = containsAttributes(selected);
                if (index == fRemoveButtonIndex) {
                        return !selected.isEmpty() && !hasAttributes;
                } else if (index == fUpButtonIndex) {
@@ -454,19 +476,19 @@ public class TreeListDialogField extends DialogField {
        }
 
        /*
-       * @see DialogField#updateEnableState
-       */
+        * @see DialogField#updateEnableState
+        */
        protected void updateEnableState() {
                super.updateEnableState();
 
-               boolean enabled= isEnabled();
+               boolean enabled = isEnabled();
                if (isOkToUse(fTreeControl)) {
                        if (!enabled) {
-                               fSelectionWhenEnabled= fTree.getSelection();
+                               fSelectionWhenEnabled = fTree.getSelection();
                                selectElements(null);
                        } else {
                                selectElements(fSelectionWhenEnabled);
-                               fSelectionWhenEnabled= null;
+                               fSelectionWhenEnabled = null;
                        }
                        fTreeControl.setEnabled(enabled);
                }
@@ -474,27 +496,27 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Sets a button enabled or disabled.
-       */
+        * 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.
-       */
+        * Sets the elements shown in the list.
+        */
        public void setElements(List elements) {
-               fElements= new ArrayList(elements);
+               fElements = new ArrayList(elements);
                refresh();
                if (fTree != null) {
                        fTree.expandToLevel(fTreeExpandLevel);
@@ -503,40 +525,41 @@ public class TreeListDialogField 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 element shown at the given index.
-       */
+        * Gets the element 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.
-    */
+        * 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);
+        * Replace an element.
+        */
+       public void replaceElement(Object oldElement, Object newElement)
+                       throws IllegalArgumentException {
+               int idx = fElements.indexOf(oldElement);
                if (idx != -1) {
                        fElements.set(idx, newElement);
                        if (fTree != null) {
-                               List selected= getSelectedElements();
+                               List selected = getSelectedElements();
                                if (selected.remove(oldElement)) {
                                        selected.add(newElement);
                                }
-                               boolean isExpanded= fTree.getExpandedState(oldElement);
+                               boolean isExpanded = fTree.getExpandedState(oldElement);
                                fTree.remove(oldElement);
                                fTree.add(fParentElement, newElement);
                                if (isExpanded) {
@@ -551,8 +574,8 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Adds an element at the end of the tree list.
-       */
+        * Adds an element at the end of the tree list.
+        */
        public void addElement(Object element) {
                if (fElements.contains(element)) {
                        return;
@@ -566,17 +589,17 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Adds elements at the end of the tree list.
-       */
+        * Adds elements at the end of the tree list.
+        */
        public void addElements(List elements) {
-               int nElements= elements.size();
+               int nElements = elements.size();
 
                if (nElements > 0) {
                        // filter duplicated
-                       ArrayList elementsToAdd= new ArrayList(nElements);
+                       ArrayList elementsToAdd = new ArrayList(nElements);
 
-                       for (int i= 0; i < nElements; i++) {
-                               Object elem= elements.get(i);
+                       for (int i = 0; i < nElements; i++) {
+                               Object elem = elements.get(i);
                                if (!fElements.contains(elem)) {
                                        elementsToAdd.add(elem);
                                }
@@ -584,7 +607,7 @@ public class TreeListDialogField extends DialogField {
                        fElements.addAll(elementsToAdd);
                        if (fTree != null) {
                                fTree.add(fParentElement, elementsToAdd.toArray());
-                               for (int i= 0; i < elementsToAdd.size(); i++) {
+                               for (int i = 0; i < elementsToAdd.size(); i++) {
                                        fTree.expandToLevel(elementsToAdd.get(i), fTreeExpandLevel);
                                }
                        }
@@ -593,8 +616,8 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Adds an element at a position.
-       */
+        * Adds an element at a position.
+        */
        public void insertElementAt(Object element, int index) {
                if (fElements.contains(element)) {
                        return;
@@ -611,8 +634,8 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Adds an element at a position.
-       */
+        * Adds an element at a position.
+        */
        public void removeAllElements() {
                if (fElements.size() > 0) {
                        fElements.clear();
@@ -622,8 +645,8 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Removes an element from the list.
-       */
+        * Removes an element from the list.
+        */
        public void removeElement(Object element) throws IllegalArgumentException {
                if (fElements.remove(element)) {
                        if (fTree != null) {
@@ -636,8 +659,8 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Removes elements from the list.
-       */
+        * Removes elements from the list.
+        */
        public void removeElements(List elements) {
                if (elements.size() > 0) {
                        fElements.removeAll(elements);
@@ -649,30 +672,30 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Gets the number of elements
-       */
+        * Gets the number of elements
+        */
        public int getSize() {
                return fElements.size();
        }
 
        public void selectElements(ISelection selection) {
-               fSelectionWhenEnabled= selection;
+               fSelectionWhenEnabled = selection;
                if (fTree != null) {
                        fTree.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(fTree, 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) {
@@ -682,7 +705,7 @@ public class TreeListDialogField extends DialogField {
 
        public void postSetSelection(final ISelection selection) {
                if (isOkToUse(fTreeControl)) {
-                       Display d= fTreeControl.getDisplay();
+                       Display d = fTreeControl.getDisplay();
                        d.asyncExec(new Runnable() {
                                public void run() {
                                        if (isOkToUse(fTreeControl)) {
@@ -694,38 +717,38 @@ public class TreeListDialogField extends DialogField {
        }
 
        /**
-       * Refreshes the tree.
-       */
+        * Refreshes the tree.
+        */
        public void refresh() {
                if (fTree != null) {
                        fTree.refresh();
                }
        }
-       
+
        /**
-       * Refreshes the tree.
-       */
+        * Refreshes the tree.
+        */
        public void refresh(Object element) {
                if (fTree != null) {
                        fTree.refresh(element);
                }
-       }       
+       }
 
        // ------- 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) {
@@ -749,8 +772,8 @@ public class TreeListDialogField extends DialogField {
        }
 
        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;
@@ -770,9 +793,9 @@ public class TreeListDialogField extends DialogField {
 
        private boolean canMoveUp(List selectedElements) {
                if (isOkToUse(fTreeControl)) {
-                       int nSelected= selectedElements.size();
-                       int nElements= fElements.size();
-                       for (int i= 0; i < nElements && nSelected > 0; i++) {
+                       int nSelected = selectedElements.size();
+                       int nElements = fElements.size();
+                       for (int i = 0; i < nElements && nSelected > 0; i++) {
                                if (!selectedElements.contains(fElements.get(i))) {
                                        return true;
                                }
@@ -784,26 +807,26 @@ public class TreeListDialogField extends DialogField {
 
        private boolean canMoveDown(List selectedElements) {
                if (isOkToUse(fTreeControl)) {
-                       int nSelected= selectedElements.size();                 
-                       for (int i= fElements.size() - 1; i >= 0 && nSelected > 0; i--) {
+                       int nSelected = selectedElements.size();
+                       for (int i = fElements.size() - 1; i >= 0 && nSelected > 0; i--) {
                                if (!selectedElements.contains(fElements.get(i))) {
                                        return true;
                                }
-                               nSelected--;                            
+                               nSelected--;
                        }
                }
                return false;
        }
 
        /**
-       * Returns the selected elements.
-       */
+        * Returns the selected elements.
+        */
        public List getSelectedElements() {
-               ArrayList result= new ArrayList();
+               ArrayList result = new ArrayList();
                if (fTree != null) {
-                       ISelection selection= fTree.getSelection();
+                       ISelection selection = fTree.getSelection();
                        if (selection instanceof IStructuredSelection) {
-                               Iterator iter= ((IStructuredSelection)selection).iterator();
+                               Iterator iter = ((IStructuredSelection) selection).iterator();
                                while (iter.hasNext()) {
                                        result.add(iter.next());
                                }
@@ -811,19 +834,19 @@ public class TreeListDialogField extends DialogField {
                }
                return result;
        }
-       
+
        public void expandElement(Object element, int level) {
                if (fTree != null) {
                        fTree.expandToLevel(element, level);
                }
        }
-       
 
        // ------- TreeViewerAdapter
 
-       private class TreeViewerAdapter implements ITreeContentProvider, ISelectionChangedListener, IDoubleClickListener {
+       private class TreeViewerAdapter implements ITreeContentProvider,
+                       ISelectionChangedListener, IDoubleClickListener {
 
-               private final Object[] NO_ELEMENTS= new Object[0];
+               private final Object[] NO_ELEMENTS = new Object[0];
 
                // ------- ITreeContentProvider Interface ------------
 
@@ -841,40 +864,45 @@ public class TreeListDialogField extends DialogField {
                public Object[] getElements(Object obj) {
                        return fElements.toArray();
                }
-               
+
                public Object[] getChildren(Object element) {
                        if (fTreeAdapter != null) {
-                               return fTreeAdapter.getChildren(TreeListDialogField.this, element);
+                               return fTreeAdapter.getChildren(TreeListDialogField.this,
+                                               element);
                        }
                        return NO_ELEMENTS;
                }
 
                public Object getParent(Object element) {
                        if (!fElements.contains(element) && fTreeAdapter != null) {
-                               return fTreeAdapter.getParent(TreeListDialogField.this, element);
+                               return fTreeAdapter
+                                               .getParent(TreeListDialogField.this, element);
                        }
                        return fParentElement;
                }
 
                public boolean hasChildren(Object element) {
                        if (fTreeAdapter != null) {
-                               return fTreeAdapter.hasChildren(TreeListDialogField.this, element);
+                               return fTreeAdapter.hasChildren(TreeListDialogField.this,
+                                               element);
                        }
                        return false;
-               }               
+               }
 
                // ------- 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) {
                        doDoubleClick(event);
-               }               
+               }
 
        }
 
@@ -884,13 +912,11 @@ public class TreeListDialogField extends DialogField {
                        fTreeAdapter.selectionChanged(this);
                }
        }
-       
+
        protected void doDoubleClick(DoubleClickEvent event) {
                if (fTreeAdapter != null) {
                        fTreeAdapter.doubleClicked(this);
                }
        }
 
-       
-
 }