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 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 =
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.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.
appendEnvironment.setEnabled(enable);
replaceEnvironment.setEnabled(enable);
}
-
+
/**
* Creates and configures the table that displayed the key/value
* pairs that comprise the environment.
// 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();
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
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) {
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) {
}
});
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) {
});
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
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;
}
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.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", ""));
// 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();
}
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) {
}
}
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;
}
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 {
* @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()
*/
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()
*/