A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / preferences / FoldingConfigurationBlock.java
index a1dfb5d..bafbeb7 100644 (file)
@@ -55,24 +55,25 @@ import org.eclipse.swt.widgets.Label;
  * @since 3.0
  */
 class FoldingConfigurationBlock {
-       
-       private static class ErrorPreferences implements IJavaFoldingPreferenceBlock {
+
+       private static class ErrorPreferences implements
+                       IJavaFoldingPreferenceBlock {
                private String fMessage;
-               
+
                protected ErrorPreferences(String message) {
-                       fMessage= message;
+                       fMessage = message;
                }
-               
+
                /*
                 * @see net.sourceforge.phpdt.internal.ui.text.folding.IJavaFoldingPreferences#createControl(org.eclipse.swt.widgets.Group)
                 */
                public Control createControl(Composite composite) {
-                       Composite inner= new Composite(composite, SWT.NONE);
+                       Composite inner = new Composite(composite, SWT.NONE);
                        inner.setLayout(new FillLayout(SWT.VERTICAL));
 
-                       Label label= new Label(inner, SWT.CENTER);
+                       Label label = new Label(inner, SWT.CENTER);
                        label.setText(fMessage);
-                       
+
                        return inner;
                }
 
@@ -87,51 +88,64 @@ class FoldingConfigurationBlock {
 
                public void dispose() {
                }
-               
+
        }
 
        /** The overlay preference store. */
        private final OverlayPreferenceStore fStore;
-       
+
        /* The controls */
        private Combo fProviderCombo;
+
        private Button fFoldingCheckbox;
+
        private ComboViewer fProviderViewer;
+
        private Map fProviderDescriptors;
+
        private Composite fGroup;
+
        private Map fProviderPreferences;
+
        private Map fProviderControls;
+
        private StackLayout fStackLayout;
-       
 
        public FoldingConfigurationBlock(OverlayPreferenceStore store) {
                Assert.isNotNull(store);
-               fStore= store;
+               fStore = store;
                fStore.addKeys(createOverlayStoreKeys());
-               fProviderDescriptors= createListModel();
-               fProviderPreferences= new HashMap();
-               fProviderControls= new HashMap();
+               fProviderDescriptors = createListModel();
+               fProviderPreferences = new HashMap();
+               fProviderControls = new HashMap();
        }
 
        private Map createListModel() {
-               JavaFoldingStructureProviderRegistry reg= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry();
+               JavaFoldingStructureProviderRegistry reg = PHPeclipsePlugin
+                               .getDefault().getFoldingStructureProviderRegistry();
                reg.reloadExtensions();
-               JavaFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors();
-               Map map= new HashMap();
-               for (int i= 0; i < descs.length; i++) {
+               JavaFoldingStructureProviderDescriptor[] descs = reg
+                               .getFoldingProviderDescriptors();
+               Map map = new HashMap();
+               for (int i = 0; i < descs.length; i++) {
                        map.put(descs[i].getId(), descs[i]);
                }
                return map;
        }
 
        private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
-               
-               ArrayList overlayKeys= new ArrayList();
 
-               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED));
-               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER));
-               
-               OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
+               ArrayList overlayKeys = new ArrayList();
+
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
+                               OverlayPreferenceStore.BOOLEAN,
+                               PreferenceConstants.EDITOR_FOLDING_ENABLED));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(
+                               OverlayPreferenceStore.STRING,
+                               PreferenceConstants.EDITOR_FOLDING_PROVIDER));
+
+               OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys
+                               .size()];
                overlayKeys.toArray(keys);
                return keys;
        }
@@ -139,64 +153,74 @@ class FoldingConfigurationBlock {
        /**
         * Creates page for folding preferences.
         * 
-        * @param parent the parent composite
+        * @param parent
+        *            the parent composite
         * @return the control for the preference page
         */
        Control createControl(Composite parent) {
 
-               Composite composite= new Composite(parent, SWT.NULL);
+               Composite composite = new Composite(parent, SWT.NULL);
                // assume parent page uses griddata
-               GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_CENTER | GridData.VERTICAL_ALIGN_FILL);
+               GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER
+                               | GridData.VERTICAL_ALIGN_FILL);
                composite.setLayoutData(gd);
-               GridLayout layout= new GridLayout();
-               layout.numColumns= 2;
-               PixelConverter pc= new PixelConverter(composite);
-               layout.verticalSpacing= pc.convertHeightInCharsToPixels(1) / 2;
+               GridLayout layout = new GridLayout();
+               layout.numColumns = 2;
+               PixelConverter pc = new PixelConverter(composite);
+               layout.verticalSpacing = pc.convertHeightInCharsToPixels(1) / 2;
                composite.setLayout(layout);
-               
-               
+
                /* check box for new editors */
-               fFoldingCheckbox= new Button(composite, SWT.CHECK);
-               fFoldingCheckbox.setText(PreferencesMessages.getString("FoldingConfigurationBlock.enable")); //$NON-NLS-1$
-               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+               fFoldingCheckbox = new Button(composite, SWT.CHECK);
+               fFoldingCheckbox.setText(PreferencesMessages
+                               .getString("FoldingConfigurationBlock.enable")); //$NON-NLS-1$
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
+                               | GridData.VERTICAL_ALIGN_BEGINNING);
                fFoldingCheckbox.setLayoutData(gd);
                fFoldingCheckbox.addSelectionListener(new SelectionListener() {
                        public void widgetSelected(SelectionEvent e) {
-                               boolean enabled= fFoldingCheckbox.getSelection(); 
-                               fStore.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED, enabled);
+                               boolean enabled = fFoldingCheckbox.getSelection();
+                               fStore.setValue(PreferenceConstants.EDITOR_FOLDING_ENABLED,
+                                               enabled);
                                updateCheckboxDependencies();
                        }
 
                        public void widgetDefaultSelected(SelectionEvent e) {
                        }
                });
-               
-               Label label= new Label(composite, SWT.CENTER);
-               gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+
+               Label label = new Label(composite, SWT.CENTER);
+               gd = new GridData(GridData.FILL_HORIZONTAL
+                               | GridData.VERTICAL_ALIGN_BEGINNING);
                label.setLayoutData(gd);
 
                /* list */
-               Composite comboComp= new Composite(composite, SWT.NONE);
-               gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
-               GridLayout gridLayout= new GridLayout(2, false);
-               gridLayout.marginWidth= 0;
+               Composite comboComp = new Composite(composite, SWT.NONE);
+               gd = new GridData(GridData.FILL_HORIZONTAL
+                               | GridData.VERTICAL_ALIGN_BEGINNING);
+               GridLayout gridLayout = new GridLayout(2, false);
+               gridLayout.marginWidth = 0;
                comboComp.setLayout(gridLayout);
-               
-               Label comboLabel= new Label(comboComp, SWT.CENTER);
-               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
+
+               Label comboLabel = new Label(comboComp, SWT.CENTER);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
+                               | GridData.VERTICAL_ALIGN_CENTER);
                comboLabel.setLayoutData(gd);
-               comboLabel.setText(PreferencesMessages.getString("FoldingConfigurationBlock.combo_caption")); //$NON-NLS-1$
-               
-               label= new Label(composite, SWT.CENTER);
-               gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
+               comboLabel.setText(PreferencesMessages
+                               .getString("FoldingConfigurationBlock.combo_caption")); //$NON-NLS-1$
+
+               label = new Label(composite, SWT.CENTER);
+               gd = new GridData(GridData.FILL_HORIZONTAL
+                               | GridData.VERTICAL_ALIGN_BEGINNING);
                label.setLayoutData(gd);
 
-               fProviderCombo= new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
-               gd= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER);
+               fProviderCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_END
+                               | GridData.VERTICAL_ALIGN_CENTER);
                fProviderCombo.setLayoutData(gd);
 
                /* list viewer */
-               fProviderViewer= new ComboViewer(fProviderCombo);
+               fProviderViewer = new ComboViewer(fProviderCombo);
                fProviderViewer.setContentProvider(new IStructuredContentProvider() {
 
                        /*
@@ -206,9 +230,11 @@ class FoldingConfigurationBlock {
                        }
 
                        /*
-                        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+                        * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
+                        *      java.lang.Object, java.lang.Object)
                         */
-                       public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+                       public void inputChanged(Viewer viewer, Object oldInput,
+                                       Object newInput) {
                        }
 
                        /*
@@ -225,42 +251,50 @@ class FoldingConfigurationBlock {
                        public Image getImage(Object element) {
                                return null;
                        }
-                       
+
                        /*
                         * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
                         */
                        public String getText(Object element) {
-                               return ((JavaFoldingStructureProviderDescriptor) element).getName();
+                               return ((JavaFoldingStructureProviderDescriptor) element)
+                                               .getName();
                        }
                });
-               fProviderViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+               fProviderViewer
+                               .addSelectionChangedListener(new ISelectionChangedListener() {
 
-                       public void selectionChanged(SelectionChangedEvent event) {
-                               IStructuredSelection sel= (IStructuredSelection) event.getSelection();
-                               if (!sel.isEmpty()) {
-                                       fStore.setValue(PreferenceConstants.EDITOR_FOLDING_PROVIDER, ((JavaFoldingStructureProviderDescriptor) sel.getFirstElement()).getId());
-                                       updateListDependencies();
-                               }
-                       }
-               });
+                                       public void selectionChanged(SelectionChangedEvent event) {
+                                               IStructuredSelection sel = (IStructuredSelection) event
+                                                               .getSelection();
+                                               if (!sel.isEmpty()) {
+                                                       fStore
+                                                                       .setValue(
+                                                                                       PreferenceConstants.EDITOR_FOLDING_PROVIDER,
+                                                                                       ((JavaFoldingStructureProviderDescriptor) sel
+                                                                                                       .getFirstElement()).getId());
+                                                       updateListDependencies();
+                                               }
+                                       }
+                               });
                fProviderViewer.setInput(fProviderDescriptors);
                fProviderViewer.refresh();
-               
-               Composite groupComp= new Composite(composite, SWT.NONE);
-               gd= new GridData(GridData.FILL_BOTH);
-               gd.horizontalSpan= 2;
+
+               Composite groupComp = new Composite(composite, SWT.NONE);
+               gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 2;
                groupComp.setLayoutData(gd);
-               gridLayout= new GridLayout(1, false);
-               gridLayout.marginWidth= 0;
+               gridLayout = new GridLayout(1, false);
+               gridLayout.marginWidth = 0;
                groupComp.setLayout(gridLayout);
-               
+
                /* contributed provider preferences. */
-               fGroup= new Composite(groupComp, SWT.NONE);
-               gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
+               fGroup = new Composite(groupComp, SWT.NONE);
+               gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING
+                               | GridData.VERTICAL_ALIGN_BEGINNING);
                fGroup.setLayoutData(gd);
-               fStackLayout= new StackLayout();
+               fStackLayout = new StackLayout();
                fGroup.setLayout(fStackLayout);
-               
+
                return composite;
        }
 
@@ -268,43 +302,48 @@ class FoldingConfigurationBlock {
        }
 
        void updateListDependencies() {
-               String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
-               JavaFoldingStructureProviderDescriptor desc= (JavaFoldingStructureProviderDescriptor) fProviderDescriptors.get(id);
+               String id = fStore
+                               .getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+               JavaFoldingStructureProviderDescriptor desc = (JavaFoldingStructureProviderDescriptor) fProviderDescriptors
+                               .get(id);
                IJavaFoldingPreferenceBlock prefs;
-               
+
                if (desc == null) {
                        // safety in case there is no such descriptor
-                       String message= PreferencesMessages.getString("FoldingConfigurationBlock.error.not_exist"); //$NON-NLS-1$
-                       PHPeclipsePlugin.log(new Status(IStatus.WARNING, PHPeclipsePlugin.getPluginId(), IStatus.OK, message, null));
-                       prefs= new ErrorPreferences(message);
+                       String message = PreferencesMessages
+                                       .getString("FoldingConfigurationBlock.error.not_exist"); //$NON-NLS-1$
+                       PHPeclipsePlugin.log(new Status(IStatus.WARNING, PHPeclipsePlugin
+                                       .getPluginId(), IStatus.OK, message, null));
+                       prefs = new ErrorPreferences(message);
                } else {
-                       prefs= (IJavaFoldingPreferenceBlock) fProviderPreferences.get(id);
+                       prefs = (IJavaFoldingPreferenceBlock) fProviderPreferences.get(id);
                        if (prefs == null) {
                                try {
-                                       prefs= desc.createPreferences();
+                                       prefs = desc.createPreferences();
                                        fProviderPreferences.put(id, prefs);
                                } catch (CoreException e) {
                                        PHPeclipsePlugin.log(e);
-                                       prefs= new ErrorPreferences(e.getLocalizedMessage());
+                                       prefs = new ErrorPreferences(e.getLocalizedMessage());
                                }
                        }
                }
-               
-               Control control= (Control) fProviderControls.get(id);
+
+               Control control = (Control) fProviderControls.get(id);
                if (control == null) {
-                       control= prefs.createControl(fGroup);
+                       control = prefs.createControl(fGroup);
                        if (control == null) {
-                               String message= PreferencesMessages.getString("FoldingConfigurationBlock.info.no_preferences"); //$NON-NLS-1$
-                               control= new ErrorPreferences(message).createControl(fGroup);
+                               String message = PreferencesMessages
+                                               .getString("FoldingConfigurationBlock.info.no_preferences"); //$NON-NLS-1$
+                               control = new ErrorPreferences(message).createControl(fGroup);
                        } else {
                                fProviderControls.put(id, control);
                        }
                }
-               fStackLayout.topControl= control;
+               fStackLayout.topControl = control;
                control.pack();
                fGroup.layout();
                fGroup.getParent().layout();
-               
+
                prefs.initialize();
        }
 
@@ -313,36 +352,45 @@ class FoldingConfigurationBlock {
        }
 
        void performOk() {
-               for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
-                       IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) it.next();
+               for (Iterator it = fProviderPreferences.values().iterator(); it
+                               .hasNext();) {
+                       IJavaFoldingPreferenceBlock prefs = (IJavaFoldingPreferenceBlock) it
+                                       .next();
                        prefs.performOk();
                }
        }
-       
+
        void performDefaults() {
                restoreFromPreferences();
-               for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
-                       IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) it.next();
+               for (Iterator it = fProviderPreferences.values().iterator(); it
+                               .hasNext();) {
+                       IJavaFoldingPreferenceBlock prefs = (IJavaFoldingPreferenceBlock) it
+                                       .next();
                        prefs.performDefaults();
                }
        }
-       
+
        void dispose() {
-               for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) {
-                       IJavaFoldingPreferenceBlock prefs= (IJavaFoldingPreferenceBlock) it.next();
+               for (Iterator it = fProviderPreferences.values().iterator(); it
+                               .hasNext();) {
+                       IJavaFoldingPreferenceBlock prefs = (IJavaFoldingPreferenceBlock) it
+                                       .next();
                        prefs.dispose();
                }
        }
 
        private void restoreFromPreferences() {
-               boolean enabled= fStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+               boolean enabled = fStore
+                               .getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
                fFoldingCheckbox.setSelection(enabled);
                updateCheckboxDependencies();
-               
-               String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
-               Object provider= fProviderDescriptors.get(id);
+
+               String id = fStore
+                               .getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER);
+               Object provider = fProviderDescriptors.get(id);
                if (provider != null) {
-                       fProviderViewer.setSelection(new StructuredSelection(provider), true);
+                       fProviderViewer.setSelection(new StructuredSelection(provider),
+                                       true);
                        updateListDependencies();
                }
        }