replaced a lot of deprecated code; if someone runs into a commit conflict afterwards...
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / launcher / PHPEnvironmentTab2.java
index 9681d2c..418077a 100644 (file)
@@ -66,8 +66,8 @@ import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.TableColumn;
 import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.dialogs.ListSelectionDialog;
-import org.eclipse.ui.help.WorkbenchHelp;
 
 /**
  * @author Christian
@@ -81,16 +81,16 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
        protected TableViewer environmentTable;
        protected String[] envTableColumnHeaders =
        {
-               LaunchConfigurationsMessages.getString("EnvironmentTab.Variable_1"), //$NON-NLS-1$
-               LaunchConfigurationsMessages.getString("EnvironmentTab.Value_2"), //$NON-NLS-1$
+       LaunchConfigurationsMessages.EnvironmentTab_Variable_1, //$NON-NLS-1$
+       LaunchConfigurationsMessages.EnvironmentTab_Value_2 //$NON-NLS-1$
        };
        protected ColumnLayoutData[] envTableColumnLayouts =
        {
                new ColumnWeightData(50),
                new ColumnWeightData(50)
        };
-       private static final String NAME_LABEL= LaunchConfigurationsMessages.getString("EnvironmentTab.8"); //$NON-NLS-1$
-       private static final String VALUE_LABEL= LaunchConfigurationsMessages.getString("EnvironmentTab.9"); //$NON-NLS-1$
+   private static final String NAME_LABEL= LaunchConfigurationsMessages.EnvironmentTab_8; //$NON-NLS-1$
+   private static final String VALUE_LABEL= LaunchConfigurationsMessages.EnvironmentTab_9; //$NON-NLS-1$
        protected static final String P_VARIABLE = "variable"; //$NON-NLS-1$
        protected static final String P_VALUE = "value"; //$NON-NLS-1$
        protected static String[] envTableColumnProperties =
@@ -105,7 +105,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
        protected Button appendEnvironment;
        protected Button replaceEnvironment;
        protected Button envSelectButton;
-       
+
        /**
         * Content provider for the environment table
         */
@@ -155,7 +155,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                        }
                }
        }
-       
+
        /**
         * Label provider for the environment table
         */
@@ -187,21 +187,21 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                // Create main composite
                Composite mainComposite = new Composite(parent, SWT.NONE);
                setControl(mainComposite);
-               WorkbenchHelp.setHelp(getControl(), IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB);
+               PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_ENVIRONMENT_TAB);
                GridLayout layout = new GridLayout();
                layout.numColumns = 2;
                GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
                mainComposite.setLayout(layout);
                mainComposite.setLayoutData(gridData);
                mainComposite.setFont(parent.getFont());
-               
+
                createEnvironmentTable(mainComposite);
                createTableButtons(mainComposite);
                createAppendReplace(mainComposite);
-               
+
                Dialog.applyDialogFont(mainComposite);
        }
-       
+
        /**
         * Creates and configures the widgets which allow the user to
         * choose whether the specified environment should be appended
@@ -216,16 +216,16 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                appendReplaceComposite.setLayoutData(gridData);
                appendReplaceComposite.setLayout(layout);
                appendReplaceComposite.setFont(parent.getFont());
-               
-               appendEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.16")); //$NON-NLS-1$
+
+       appendEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.EnvironmentTab_16); //$NON-NLS-1$
                appendEnvironment.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                                updateLaunchConfigurationDialog();
                        }
                });
-               replaceEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.17")); //$NON-NLS-1$
+       replaceEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.EnvironmentTab_17); //$NON-NLS-1$
        }
-       
+
        /**
         * Updates the enablement of the append/replace widgets. The
         * widgets should disable when there are no environment variables specified.
@@ -235,7 +235,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                appendEnvironment.setEnabled(enable);
                replaceEnvironment.setEnabled(enable);
        }
-       
+
        /**
         * Creates and configures the table that displayed the key/value
         * pairs that comprise the environment.
@@ -257,7 +257,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                // Create label
                Label label = new Label(tableComposite, SWT.NONE);
                label.setFont(font);
-               label.setText(LaunchConfigurationsMessages.getString("EnvironmentTab.Environment_variables_to_set__3")); //$NON-NLS-1$
+       label.setText(LaunchConfigurationsMessages.EnvironmentTab_Environment_variables_to_set__3); //$NON-NLS-1$
                // Create table
                environmentTable = new TableViewer(tableComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
                Table table = environmentTable.getTable();
@@ -290,7 +290,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                        tc.setText(envTableColumnHeaders[i]);
                }
        }
-       
+
        /**
         * Responds to a selection changed event in the environment table
         * @param event the selection change event
@@ -300,7 +300,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                envEditButton.setEnabled(size == 1);
                envRemoveButton.setEnabled(size > 0);
        }
-       
+
        /**
         * Creates the add/edit/remove buttons for the environment table
         * @param parent the composite in which the buttons should be created
@@ -319,7 +319,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
 
                createVerticalSpacer(buttonComposite, 1);
                // Create buttons
-               envAddButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.New_4"), null); //$NON-NLS-1$
+       envAddButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_New_4, null); //$NON-NLS-1$
                envAddButton.addSelectionListener(new SelectionAdapter()
                {
                        public void widgetSelected(SelectionEvent event) {
@@ -332,14 +332,14 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                                handleEnvAddCGIButtonSelected();
                        }
                });
-               
-               envSelectButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.18"), null); //$NON-NLS-1$
+
+       envSelectButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_18, null); //$NON-NLS-1$
                envSelectButton.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent event) {
                                handleEnvSelectButtonSelected();
                        }
                });
-               envEditButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.Edit_5"), null); //$NON-NLS-1$
+       envEditButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_Edit_5, null); //$NON-NLS-1$
                envEditButton.addSelectionListener(new SelectionAdapter()
                {
                        public void widgetSelected(SelectionEvent event) {
@@ -347,7 +347,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                        }
                });
                envEditButton.setEnabled(false);
-               envRemoveButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.Remove_6"), null); //$NON-NLS-1$
+       envRemoveButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_Remove_6, null); //$NON-NLS-1$
                envRemoveButton.addSelectionListener(new SelectionAdapter()
                {
                        public void widgetSelected(SelectionEvent event) {
@@ -356,28 +356,28 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                });
                envRemoveButton.setEnabled(false);
        }
-       
+
        /**
         * Adds a new environment variable to the table.
         */
        protected void handleEnvAddButtonSelected() {
-               MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.getString("EnvironmentTab.22")); //$NON-NLS-1$
+       MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_22); //$NON-NLS-1$
                dialog.addTextField(NAME_LABEL, null, false);
                dialog.addVariablesField(VALUE_LABEL, null, true);
-               
+
                if (dialog.open() != Window.OK) {
                        return;
                }
-               
+
                String name = dialog.getStringValue(NAME_LABEL);
                String value = dialog.getStringValue(VALUE_LABEL);
-               
+
                if (name != null && value != null && name.length() > 0 && value.length() >0) {
                        addVariable(new EnvironmentVariable(name.trim(), value.trim()));
                        updateAppendReplace();
                }
        }
-       
+
        /**
         * Attempts to add the given variable. Returns whether the variable
         * was added or not (as when the user answers not to overwrite an
@@ -391,7 +391,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                for (int i = 0; i < items.length; i++) {
                        EnvironmentVariable existingVariable = (EnvironmentVariable) items[i].getData();
                        if (existingVariable.getName().equals(name)) {
-                               boolean overWrite= MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.getString("EnvironmentTab.12"), MessageFormat.format(LaunchConfigurationsMessages.getString("EnvironmentTab.13"), new String[] {name})); //$NON-NLS-1$ //$NON-NLS-2$
+               boolean overWrite= MessageDialog.openQuestion(getShell(), LaunchConfigurationsMessages.EnvironmentTab_12, MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, new String[] {name})); //$NON-NLS-1$ //$NON-NLS-2$
                                if (!overWrite) {
                                        return false;
                                }
@@ -403,9 +403,9 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                updateLaunchConfigurationDialog();
                return true;
        }
-       
+
        /**
-        * Displays a dialog that allows user to select native environment variables 
+        * Displays a dialog that allows user to select native environment variables
         * to add to the table.
         */
        private void handleEnvSelectButtonSelected() {
@@ -418,30 +418,30 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                        EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
                        envVariables.remove(var.getName());
                }
-               
-               ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.getString("EnvironmentTab.19")); //$NON-NLS-1$
-               dialog.setTitle(LaunchConfigurationsMessages.getString("EnvironmentTab.20")); //$NON-NLS-1$
-               
+
+       ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.EnvironmentTab_19); //$NON-NLS-1$
+       dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); //$NON-NLS-1$
+
                int button = dialog.open();
                if (button == Window.OK) {
-                       Object[] selected = dialog.getResult();         
+                       Object[] selected = dialog.getResult();
                        for (int i = 0; i < selected.length; i++) {
-                               environmentTable.add(selected[i]);                              
+                               environmentTable.add(selected[i]);
                        }
                }
-               
+
                updateAppendReplace();
                updateLaunchConfigurationDialog();
        }
-       
+
        /**
-        * Displays a dialog that allows user to select native environment variables 
+        * Displays a dialog that allows user to select native environment variables
         * to add to the table.
         */
        private void handleEnvAddCGIButtonSelected() {
 
                Map envVariables = new HashMap();
-               
+
 
                envVariables.put("HTTP_COOKIE",new EnvironmentVariable("HTTP_COOKIE", "TestCookie=1"));
                envVariables.put("REDIRECT_QUERY_STRING",new EnvironmentVariable("REDIRECT_QUERY_STRING", ""));
@@ -460,26 +460,26 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
 //             envVariables.put("REQUEST_URI" + OSFilePath;
 //             envVariables.put("PATH_INFO=" + OSFilePath;
 //             envVariables.put("PATH_TRANSLATED=" + OSFilePath;
-               
-               
+
+
                //get Environment Variables from the table
                TableItem[] items = environmentTable.getTable().getItems();
                for (int i = 0; i < items.length; i++) {
                        EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
                        envVariables.remove(var.getName());
                }
-               
-               ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.getString("EnvironmentTab.19")); //$NON-NLS-1$
-               dialog.setTitle(LaunchConfigurationsMessages.getString("EnvironmentTab.20")); //$NON-NLS-1$
-               
+
+       ListSelectionDialog dialog = new NativeEnvironmentDialog(getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.EnvironmentTab_19); //$NON-NLS-1$
+       dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); //$NON-NLS-1$
+
                int button = dialog.open();
                if (button == Window.OK) {
-                       Object[] selected = dialog.getResult();         
+                       Object[] selected = dialog.getResult();
                        for (int i = 0; i < selected.length; i++) {
-                               environmentTable.add(selected[i]);                              
+                               environmentTable.add(selected[i]);
                        }
                }
-               
+
                updateAppendReplace();
                updateLaunchConfigurationDialog();
        }
@@ -506,7 +506,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                                return false;
                        }
                        public void removeListener(ILabelProviderListener listener) {
-                       }                               
+                       }
                };
        }
 
@@ -525,7 +525,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                                                        String s2 = (String)o2;
                                                        return s1.compareTo(s2);
                                                }
-                                       
+
                                        };
                                        TreeMap envVars = new TreeMap(comparator);
                                        envVars.putAll((Map)inputElement);
@@ -538,7 +538,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                                }
                                return elements;
                        }
-                       public void dispose() { 
+                       public void dispose() {
                        }
                        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
                        }
@@ -571,10 +571,10 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                }
                String originalName= var.getName();
                String value= var.getValue();
-               MultipleInputDialog dialog= new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.getString("EnvironmentTab.11")); //$NON-NLS-1$
+       MultipleInputDialog dialog= new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_11); //$NON-NLS-1$
                dialog.addTextField(NAME_LABEL, originalName, false);
                dialog.addVariablesField(VALUE_LABEL, value, true);
-               
+
                if (dialog.open() != Window.OK) {
                        return;
                }
@@ -598,7 +598,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                IStructuredSelection sel = (IStructuredSelection) environmentTable.getSelection();
                environmentTable.getControl().setRedraw(false);
                for (Iterator i = sel.iterator(); i.hasNext(); ) {
-                       EnvironmentVariable var = (EnvironmentVariable) i.next();       
+                       EnvironmentVariable var = (EnvironmentVariable) i.next();
                environmentTable.remove(var);
                }
                environmentTable.getControl().setRedraw(true);
@@ -645,7 +645,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
         * Stores the environment in the given configuration
         * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
         */
-       public void performApply(ILaunchConfigurationWorkingCopy configuration) {       
+       public void performApply(ILaunchConfigurationWorkingCopy configuration) {
                // Convert the table's items into a Map so that this can be saved in the
                // configuration's attributes.
                TableItem[] items = environmentTable.getTable().getItems();
@@ -654,7 +654,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                {
                        EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
                        map.put(var.getName(), var.getValue());
-               } 
+               }
                if (map.size() == 0) {
                        configuration.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, (Map) null);
                } else {
@@ -667,9 +667,9 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
         * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
         */
        public String getName() {
-               return LaunchConfigurationsMessages.getString("EnvironmentTab.Environment_7"); //$NON-NLS-1$
+       return LaunchConfigurationsMessages.EnvironmentTab_Environment_7; //$NON-NLS-1$
        }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
         */
@@ -690,25 +690,25 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
        public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) {
                // do nothing when deactivated
        }
-       
+
        private class NativeEnvironmentDialog extends ListSelectionDialog {
                public NativeEnvironmentDialog(Shell parentShell, Object input, IStructuredContentProvider contentProvider, ILabelProvider labelProvider, String message) {
                        super(parentShell, input, contentProvider, labelProvider, message);
                        setShellStyle(getShellStyle() | SWT.RESIZE);
                }
-               
+
                protected IDialogSettings getDialogSettings() {
                        IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
                        IDialogSettings section = settings.getSection(getDialogSettingsSectionName());
                        if (section == null) {
                                section = settings.addNewSection(getDialogSettingsSectionName());
-                       } 
+                       }
                        return section;
                }
-               
+
                /**
                 * Returns the name of the section that this dialog stores its settings in
-                * 
+                *
                 * @return String
                 */
                protected String getDialogSettingsSectionName() {
@@ -726,7 +726,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                        }
                        return super.getInitialLocation(initialSize);
                }
-                       
+
                /* (non-Javadoc)
                 * @see org.eclipse.jface.window.Window#getInitialSize()
                 */
@@ -734,7 +734,7 @@ public class PHPEnvironmentTab2 extends AbstractLaunchConfigurationTab {
                        Point size = super.getInitialSize();
                        return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
                }
-               
+
                /* (non-Javadoc)
                 * @see org.eclipse.jface.window.Window#close()
                 */