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
protected Button appendEnvironment;
protected Button replaceEnvironment;
protected Button envSelectButton;
-
+
/**
* Content provider for the environment table
*/
}
}
}
-
+
/**
* Label provider for the environment table
*/
// 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
appendReplaceComposite.setLayoutData(gridData);
appendReplaceComposite.setLayout(layout);
appendReplaceComposite.setFont(parent.getFont());
-
+
appendEnvironment= createRadioButton(appendReplaceComposite, LaunchConfigurationsMessages.EnvironmentTab_16); //$NON-NLS-1$
appendEnvironment.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
});
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.
appendEnvironment.setEnabled(enable);
replaceEnvironment.setEnabled(enable);
}
-
+
/**
* Creates and configures the table that displayed the key/value
* pairs that comprise the environment.
tc.setText(envTableColumnHeaders[i]);
}
}
-
+
/**
* Responds to a selection changed event in the environment table
* @param event the selection change event
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
handleEnvAddCGIButtonSelected();
}
});
-
+
envSelectButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.EnvironmentTab_18, null); //$NON-NLS-1$
envSelectButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
});
envRemoveButton.setEnabled(false);
}
-
+
/**
* Adds a new environment variable to the table.
*/
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
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() {
EnvironmentVariable var = (EnvironmentVariable) items[i].getData();
envVariables.remove(var.getName());
}
-
+
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", ""));
// 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.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();
}
return false;
}
public void removeListener(ILabelProviderListener listener) {
- }
+ }
};
}
String s2 = (String)o2;
return s1.compareTo(s2);
}
-
+
};
TreeMap envVars = new TreeMap(comparator);
envVars.putAll((Map)inputElement);
}
return elements;
}
- public void dispose() {
+ public void dispose() {
}
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
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;
}
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);
* 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();
{
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 {
public String getName() {
return LaunchConfigurationsMessages.EnvironmentTab_Environment_7; //$NON-NLS-1$
}
-
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage()
*/
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() {
}
return super.getInitialLocation(initialSize);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#getInitialSize()
*/
Point size = super.getInitialSize();
return DialogSettingsHelper.getInitialSize(getDialogSettingsSectionName(), size);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.window.Window#close()
*/