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 / SelectionButtonDialogFieldGroup.java
index e846b67..2655aa8 100644 (file)
@@ -26,95 +26,103 @@ import org.eclipse.swt.widgets.Label;
  * Dialog field describing a group with buttons (Checkboxes, radio buttons..)
  */
 public class SelectionButtonDialogFieldGroup extends DialogField {
-       
+
        private Composite fButtonComposite;
-       
+
        private Button[] fButtons;
+
        private String[] fButtonNames;
+
        private boolean[] fButtonsSelected;
+
        private boolean[] fButtonsEnabled;
-       
+
        private int fGroupBorderStyle;
+
        private int fGroupNumberOfColumns;
-       private int fButtonsStyle;      
-               
+
+       private int fButtonsStyle;
+
        /**
         * Creates a group without border.
         */
-       public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns) {
-               this(buttonsStyle, buttonNames, nColumns, SWT.NONE);            
-       }       
-       
-       
+       public SelectionButtonDialogFieldGroup(int buttonsStyle,
+                       String[] buttonNames, int nColumns) {
+               this(buttonsStyle, buttonNames, nColumns, SWT.NONE);
+       }
+
        /**
-        * Creates a group with border (label in border).
-        * Accepted button styles are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE
-        * For border styles see <code>Group</code>
-        */     
-       public SelectionButtonDialogFieldGroup(int buttonsStyle, String[] buttonNames, int nColumns, int borderStyle) {
+        * Creates a group with border (label in border). Accepted button styles
+        * are: SWT.RADIO, SWT.CHECK, SWT.TOGGLE For border styles see
+        * <code>Group</code>
+        */
+       public SelectionButtonDialogFieldGroup(int buttonsStyle,
+                       String[] buttonNames, int nColumns, int borderStyle) {
                super();
-               
-               Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK || buttonsStyle == SWT.TOGGLE);
-               fButtonNames= buttonNames;
-               
-               int nButtons= buttonNames.length;
-               fButtonsSelected= new boolean[nButtons];
-               fButtonsEnabled= new boolean[nButtons];
-               for (int i= 0; i < nButtons; i++) {
-                       fButtonsSelected[i]= false;
-                       fButtonsEnabled[i]= true;
+
+               Assert.isTrue(buttonsStyle == SWT.RADIO || buttonsStyle == SWT.CHECK
+                               || buttonsStyle == SWT.TOGGLE);
+               fButtonNames = buttonNames;
+
+               int nButtons = buttonNames.length;
+               fButtonsSelected = new boolean[nButtons];
+               fButtonsEnabled = new boolean[nButtons];
+               for (int i = 0; i < nButtons; i++) {
+                       fButtonsSelected[i] = false;
+                       fButtonsEnabled[i] = true;
                }
                if (fButtonsStyle == SWT.RADIO) {
-                       fButtonsSelected[0]= true;
+                       fButtonsSelected[0] = true;
                }
-               
-               fGroupBorderStyle= borderStyle;
-               fGroupNumberOfColumns= (nColumns <= 0) ? nButtons : nColumns;
-               
-               fButtonsStyle= buttonsStyle;
-               
+
+               fGroupBorderStyle = borderStyle;
+               fGroupNumberOfColumns = (nColumns <= 0) ? nButtons : nColumns;
+
+               fButtonsStyle = buttonsStyle;
+
        }
-       
+
        // ------- layout helpers
-               
+
        /*
         * @see DialogField#doFillIntoGrid
         */
        public Control[] doFillIntoGrid(Composite parent, int nColumns) {
                assertEnoughColumns(nColumns);
-                               
+
                if (fGroupBorderStyle == SWT.NONE) {
-                       Label label= getLabelControl(parent);
+                       Label label = getLabelControl(parent);
                        label.setLayoutData(gridDataForLabel(1));
-               
-                       Composite buttonsgroup= getSelectionButtonsGroup(parent);
-                       GridData gd= new GridData();
-                       gd.horizontalSpan= nColumns - 1;
+
+                       Composite buttonsgroup = getSelectionButtonsGroup(parent);
+                       GridData gd = new GridData();
+                       gd.horizontalSpan = nColumns - 1;
                        buttonsgroup.setLayoutData(gd);
-                       
+
                        return new Control[] { label, buttonsgroup };
                } else {
-                       Composite buttonsgroup= getSelectionButtonsGroup(parent);
-                       GridData gd= new GridData();
-                       gd.horizontalSpan= nColumns;
+                       Composite buttonsgroup = getSelectionButtonsGroup(parent);
+                       GridData gd = new GridData();
+                       gd.horizontalSpan = nColumns;
                        buttonsgroup.setLayoutData(gd);
-               
+
                        return new Control[] { buttonsgroup };
                }
-       }       
+       }
 
        /*
         * @see DialogField#doFillIntoGrid
-        */     
+        */
        public int getNumberOfControls() {
                return (fGroupBorderStyle == SWT.NONE) ? 2 : 1;
        }
-       
+
        // ------- ui creation
-       
-       private Button createSelectionButton(int index, Composite group, SelectionListener listener) {
-               Button button= new Button(group, fButtonsStyle | SWT.LEFT);
-               button.setFont(group.getFont());                        
+
+       private Button createSelectionButton(int index, Composite group,
+                       SelectionListener listener) {
+               Button button = new Button(group, fButtonsStyle | SWT.LEFT);
+               button.setFont(group.getFont());
                button.setText(fButtonNames[index]);
                button.setEnabled(isEnabled() && fButtonsEnabled[index]);
                button.setSelection(fButtonsSelected[index]);
@@ -124,48 +132,53 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
        }
 
        /**
-        * Returns the group widget. When called the first time, the widget will be created.
-        * @param The parent composite when called the first time, or <code>null</code>
-        * after.
+        * Returns the group widget. When called the first time, the widget will be
+        * created.
+        * 
+        * @param The
+        *            parent composite when called the first time, or
+        *            <code>null</code> after.
         */
        public Composite getSelectionButtonsGroup(Composite parent) {
                if (fButtonComposite == null) {
                        assertCompositeNotNull(parent);
-                       
-                       GridLayout layout= new GridLayout();
-                       layout.makeColumnsEqualWidth= true;
-                       layout.numColumns= fGroupNumberOfColumns;                       
-                       
+
+                       GridLayout layout = new GridLayout();
+                       layout.makeColumnsEqualWidth = true;
+                       layout.numColumns = fGroupNumberOfColumns;
+
                        if (fGroupBorderStyle != SWT.NONE) {
-                               Group group= new Group(parent, fGroupBorderStyle);
+                               Group group = new Group(parent, fGroupBorderStyle);
                                if (fLabelText != null && fLabelText.length() > 0) {
                                        group.setText(fLabelText);
                                }
-                               fButtonComposite= group;
+                               fButtonComposite = group;
                        } else {
-                               fButtonComposite= new Composite(parent, SWT.NULL);
-                               layout.marginHeight= 0;
-                               layout.marginWidth= 0;
+                               fButtonComposite = new Composite(parent, SWT.NULL);
+                               layout.marginHeight = 0;
+                               layout.marginWidth = 0;
                        }
 
                        fButtonComposite.setLayout(layout);
-                       
-                       SelectionListener listener= new SelectionListener() {
+
+                       SelectionListener listener = new SelectionListener() {
                                public void widgetDefaultSelected(SelectionEvent e) {
                                        doWidgetSelected(e);
                                }
+
                                public void widgetSelected(SelectionEvent e) {
                                        doWidgetSelected(e);
                                }
-                       };      
-                       int nButtons= fButtonNames.length;
-                       fButtons= new Button[nButtons]; 
-                       for (int i= 0; i < nButtons; i++) {
-                               fButtons[i]= createSelectionButton(i, fButtonComposite, listener);
+                       };
+                       int nButtons = fButtonNames.length;
+                       fButtons = new Button[nButtons];
+                       for (int i = 0; i < nButtons; i++) {
+                               fButtons[i] = createSelectionButton(i, fButtonComposite,
+                                               listener);
                        }
-                       int nRows= nButtons / fGroupNumberOfColumns;
-                       int nFillElements= nRows * fGroupNumberOfColumns - nButtons;
-                       for (int i= 0; i < nFillElements; i++) {
+                       int nRows = nButtons / fGroupNumberOfColumns;
+                       int nFillElements = nRows * fGroupNumberOfColumns - nButtons;
+                       for (int i = 0; i < nFillElements; i++) {
                                createEmptySpace(fButtonComposite);
                        }
                }
@@ -173,31 +186,34 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
        }
 
        /**
-        * Returns a button from the group or <code>null</code> if not yet created.
-        */     
+        * Returns a button from the group or <code>null</code> if not yet
+        * created.
+        */
        public Button getSelectionButton(int index) {
                if (index >= 0 && index < fButtons.length) {
                        return fButtons[index];
                }
                return null;
        }
-       
+
        private void doWidgetSelected(SelectionEvent e) {
-               Button button= (Button)e.widget;
-               for (int i= 0; i < fButtons.length; i++) {
+               Button button = (Button) e.widget;
+               for (int i = 0; i < fButtons.length; i++) {
                        if (fButtons[i] == button) {
-                               fButtonsSelected[i]= button.getSelection();
+                               fButtonsSelected[i] = button.getSelection();
                                dialogFieldChanged();
                                return;
                        }
                }
-       }       
-       
-       // ------ model access  
+       }
+
+       // ------ model access
 
        /**
         * Returns the selection state of a button contained in the group.
-        * @param The index of the button
+        * 
+        * @param The
+        *            index of the button
         */
        public boolean isSelected(int index) {
                if (index >= 0 && index < fButtonsSelected.length) {
@@ -205,16 +221,16 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
                }
                return false;
        }
-       
+
        /**
         * Sets the selection state of a button contained in the group.
         */
        public void setSelection(int index, boolean selected) {
                if (index >= 0 && index < fButtonsSelected.length) {
                        if (fButtonsSelected[index] != selected) {
-                               fButtonsSelected[index]= selected;
+                               fButtonsSelected[index] = selected;
                                if (fButtons != null) {
-                                       Button button= fButtons[index];
+                                       Button button = fButtons[index];
                                        if (isOkToUse(button)) {
                                                button.setSelection(selected);
                                        }
@@ -224,32 +240,32 @@ public class SelectionButtonDialogFieldGroup extends DialogField {
        }
 
        // ------ enable / disable management
-       
+
        protected void updateEnableState() {
                super.updateEnableState();
                if (fButtons != null) {
-                       boolean enabled= isEnabled();
-                       for (int i= 0; i < fButtons.length; i++) {
-                               Button button= fButtons[i];
+                       boolean enabled = isEnabled();
+                       for (int i = 0; i < fButtons.length; i++) {
+                               Button button = fButtons[i];
                                if (isOkToUse(button)) {
                                        button.setEnabled(enabled && fButtonsEnabled[i]);
                                }
                        }
                }
        }
-       
+
        /**
         * Sets the enable state of a button contained in the group.
-        */     
+        */
        public void enableSelectionButton(int index, boolean enable) {
                if (index >= 0 && index < fButtonsEnabled.length) {
-                       fButtonsEnabled[index]= enable;
+                       fButtonsEnabled[index] = enable;
                        if (fButtons != null) {
-                               Button button= fButtons[index];
+                               Button button = fButtons[index];
                                if (isOkToUse(button)) {
                                        button.setEnabled(isEnabled() && enable);
                                }
                        }
                }
-       }       
+       }
 }