A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.externaltools / src / net / sourceforge / phpdt / externaltools / internal / ui / TreeAndListGroup.java
index 9da2dea..1255b2f 100644 (file)
@@ -1,11 +1,11 @@
 package net.sourceforge.phpdt.externaltools.internal.ui;
 
 /**********************************************************************
-Copyright (c) 2002 IBM Corp. and others. All rights reserved.
-This file is made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-**********************************************************************/
+ Copyright (c) 2002 IBM Corp. and others. All rights reserved.
+ This file is made available under the terms of the Common Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/cpl-v10.html
+ **********************************************************************/
 
 import java.util.Collection;
 import java.util.HashSet;
@@ -30,39 +30,59 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Tree;
 
 /**
- * This class was derived from org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup
- *
+ * This class was derived from
+ * org.eclipse.ui.internal.misc.CheckboxTreeAndListGroup
+ * 
  */
 public class TreeAndListGroup implements ISelectionChangedListener {
        private Object root;
+
        private Object currentTreeSelection;
+
        private Collection listeners = new HashSet();
 
        private ITreeContentProvider treeContentProvider;
+
        private IStructuredContentProvider listContentProvider;
+
        private ILabelProvider treeLabelProvider;
+
        private ILabelProvider listLabelProvider;
 
        // widgets
        private TreeViewer treeViewer;
+
        private TableViewer listViewer;
-       private boolean allowMultiselection= false;
+
+       private boolean allowMultiselection = false;
 
        /**
-        *      Create an instance of this class.  Use this constructor if you wish to specify
-        *      the width and/or height of the combined widget (to only hardcode one of the
-        *      sizing dimensions, specify the other dimension's value as -1)
-        *
-        *      @param parent org.eclipse.swt.widgets.Composite
-        *      @param style int
-        *  @param rootObject java.lang.Object
-        *      @param childPropertyName java.lang.String
-        *      @param parentPropertyName java.lang.String
-        *      @param listPropertyName java.lang.String
-        *      @param width int
-        *      @param height int
+        * Create an instance of this class. Use this constructor if you wish to
+        * specify the width and/or height of the combined widget (to only hardcode
+        * one of the sizing dimensions, specify the other dimension's value as -1)
+        * 
+        * @param parent
+        *            org.eclipse.swt.widgets.Composite
+        * @param style
+        *            int
+        * @param rootObject
+        *            java.lang.Object
+        * @param childPropertyName
+        *            java.lang.String
+        * @param parentPropertyName
+        *            java.lang.String
+        * @param listPropertyName
+        *            java.lang.String
+        * @param width
+        *            int
+        * @param height
+        *            int
         */
-       public TreeAndListGroup(Composite parent, Object rootObject, ITreeContentProvider treeContentProvider, ILabelProvider treeLabelProvider, IStructuredContentProvider listContentProvider, ILabelProvider listLabelProvider, int style, int width, int height) {
+       public TreeAndListGroup(Composite parent, Object rootObject,
+                       ITreeContentProvider treeContentProvider,
+                       ILabelProvider treeLabelProvider,
+                       IStructuredContentProvider listContentProvider,
+                       ILabelProvider listLabelProvider, int style, int width, int height) {
 
                root = rootObject;
                this.treeContentProvider = treeContentProvider;
@@ -71,13 +91,14 @@ public class TreeAndListGroup implements ISelectionChangedListener {
                this.listLabelProvider = listLabelProvider;
                createContents(parent, width, height, style);
        }
+
        /**
         * This method must be called just before this window becomes visible.
         */
        public void aboutToOpen() {
                currentTreeSelection = null;
 
-               //select the first element in the list
+               // select the first element in the list
                Object[] elements = treeContentProvider.getElements(root);
                Object primary = elements.length > 0 ? elements[0] : null;
                if (primary != null) {
@@ -85,35 +106,42 @@ public class TreeAndListGroup implements ISelectionChangedListener {
                }
                treeViewer.getControl().setFocus();
        }
+
        /**
-        *      Add the passed listener to collection of clients
-        *      that listen for changes to list viewer selection state
-        *
-        *      @param listener ISelectionChangedListener
+        * Add the passed listener to collection of clients that listen for changes
+        * to list viewer selection state
+        * 
+        * @param listener
+        *            ISelectionChangedListener
         */
        public void addSelectionChangedListener(ISelectionChangedListener listener) {
                listeners.add(listener);
        }
 
        /**
-        *      Notify                          all checked state listeners that the passed element
-        *has had its checked state changed to the passed state
-                */
+        * Notify all checked state listeners that the passed element has had its
+        * checked state changed to the passed state
+        */
        protected void notifySelectionListeners(SelectionChangedEvent event) {
                Iterator listenersEnum = listeners.iterator();
                while (listenersEnum.hasNext()) {
-                        ((ISelectionChangedListener) listenersEnum.next()).selectionChanged(event);
+                       ((ISelectionChangedListener) listenersEnum.next())
+                                       .selectionChanged(event);
                }
        }
 
        /**
-        *      Lay out and initialize self's visual components.
-        *
-        *      @param parent org.eclipse.swt.widgets.Composite
-        *      @param width int
-        *      @param height int
+        * Lay out and initialize self's visual components.
+        * 
+        * @param parent
+        *            org.eclipse.swt.widgets.Composite
+        * @param width
+        *            int
+        * @param height
+        *            int
         */
-       protected void createContents(Composite parent, int width, int height, int style) {
+       protected void createContents(Composite parent, int width, int height,
+                       int style) {
                // group pane
                Composite composite = new Composite(parent, style);
                composite.setFont(parent.getFont());
@@ -130,15 +158,16 @@ public class TreeAndListGroup implements ISelectionChangedListener {
 
                initialize();
        }
+
        /**
-        *      Create this group's list viewer.
+        * Create this group's list viewer.
         */
        protected void createListViewer(Composite parent, int width, int height) {
                int style;
                if (allowMultiselection) {
-                       style= SWT.MULTI;
+                       style = SWT.MULTI;
                } else {
-                       style= SWT.SINGLE;
+                       style = SWT.SINGLE;
                }
                listViewer = new TableViewer(parent, SWT.BORDER | style);
                GridData data = new GridData(GridData.FILL_BOTH);
@@ -154,8 +183,9 @@ public class TreeAndListGroup implements ISelectionChangedListener {
                        }
                });
        }
+
        /**
-        *      Create this group's tree viewer.
+        * Create this group's tree viewer.
         */
        protected void createTreeViewer(Composite parent, int width, int height) {
                Tree tree = new Tree(parent, SWT.BORDER);
@@ -170,31 +200,31 @@ public class TreeAndListGroup implements ISelectionChangedListener {
                treeViewer.setLabelProvider(treeLabelProvider);
                treeViewer.addSelectionChangedListener(this);
        }
-       
+
        public Table getListTable() {
                return listViewer.getTable();
        }
-       
+
        public IStructuredSelection getListTableSelection() {
-               ISelection selection=  this.listViewer.getSelection();
+               ISelection selection = this.listViewer.getSelection();
                if (selection instanceof IStructuredSelection) {
-                       return (IStructuredSelection)selection;
+                       return (IStructuredSelection) selection;
                } else {
                        return StructuredSelection.EMPTY;
                }
        }
-       
+
        protected void initialListItem(Object element) {
                Object parent = treeContentProvider.getParent(element);
                selectAndRevealFolder(parent);
        }
-       
+
        public void selectAndRevealFolder(Object treeElement) {
                treeViewer.reveal(treeElement);
                IStructuredSelection selection = new StructuredSelection(treeElement);
                treeViewer.setSelection(selection);
        }
-       
+
        public void selectAndRevealFile(Object treeElement) {
                listViewer.reveal(treeElement);
                IStructuredSelection selection = new StructuredSelection(treeElement);
@@ -202,19 +232,21 @@ public class TreeAndListGroup implements ISelectionChangedListener {
        }
 
        /**
-        *      Initialize this group's viewers after they have been laid out.
+        * Initialize this group's viewers after they have been laid out.
         */
        protected void initialize() {
                treeViewer.setInput(root);
        }
 
        /**
-        *      Handle the selection of an item in the tree viewer
-        *
-        *      @param selection ISelection
+        * Handle the selection of an item in the tree viewer
+        * 
+        * @param selection
+        *            ISelection
         */
        public void selectionChanged(SelectionChangedEvent event) {
-               IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+               IStructuredSelection selection = (IStructuredSelection) event
+                               .getSelection();
                Object selectedElement = selection.getFirstElement();
                if (selectedElement == null) {
                        currentTreeSelection = null;
@@ -229,25 +261,32 @@ public class TreeAndListGroup implements ISelectionChangedListener {
 
                currentTreeSelection = selectedElement;
        }
+
        /**
-        *      Set the list viewer's providers to those passed
-        *
-        *      @param contentProvider ITreeContentProvider
-        *      @param labelProvider ILabelProvider
+        * Set the list viewer's providers to those passed
+        * 
+        * @param contentProvider
+        *            ITreeContentProvider
+        * @param labelProvider
+        *            ILabelProvider
         */
-       public void setListProviders(IStructuredContentProvider contentProvider, ILabelProvider labelProvider) {
+       public void setListProviders(IStructuredContentProvider contentProvider,
+                       ILabelProvider labelProvider) {
                listViewer.setContentProvider(contentProvider);
                listViewer.setLabelProvider(labelProvider);
        }
+
        /**
-        *      Set the sorter that is to be applied to self's list viewer
+        * Set the sorter that is to be applied to self's list viewer
         */
        public void setListSorter(ViewerSorter sorter) {
                listViewer.setSorter(sorter);
        }
+
        /**
-        * Set the root of the widget to be new Root. Regenerate all of the tables and lists from this
-        * value.
+        * Set the root of the widget to be new Root. Regenerate all of the tables
+        * and lists from this value.
+        * 
         * @param newRoot
         */
        public void setRoot(Object newRoot) {
@@ -256,17 +295,21 @@ public class TreeAndListGroup implements ISelectionChangedListener {
        }
 
        /**
-        *      Set the tree viewer's providers to those passed
-        *
-        *      @param contentProvider ITreeContentProvider
-        *      @param labelProvider ILabelProvider
+        * Set the tree viewer's providers to those passed
+        * 
+        * @param contentProvider
+        *            ITreeContentProvider
+        * @param labelProvider
+        *            ILabelProvider
         */
-       public void setTreeProviders(ITreeContentProvider contentProvider, ILabelProvider labelProvider) {
+       public void setTreeProviders(ITreeContentProvider contentProvider,
+                       ILabelProvider labelProvider) {
                treeViewer.setContentProvider(contentProvider);
                treeViewer.setLabelProvider(labelProvider);
        }
+
        /**
-        *      Set the sorter that is to be applied to self's tree viewer
+        * Set the sorter that is to be applied to self's tree viewer
         */
        public void setTreeSorter(ViewerSorter sorter) {
                treeViewer.setSorter(sorter);
@@ -279,9 +322,9 @@ public class TreeAndListGroup implements ISelectionChangedListener {
 
                this.treeViewer.getTree().setFocus();
        }
-       
+
        public void setAllowMultiselection(boolean allowMultiselection) {
-               this.allowMultiselection= allowMultiselection;
-               
+               this.allowMultiselection = allowMultiselection;
+
        }
 }