Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties9
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java259
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableContentProvider.java74
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableLabelProvider.java50
4 files changed, 185 insertions, 207 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
index f1e80141e..17ce9ed37 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties
@@ -93,3 +93,12 @@ DeleteLaunchConfigurationAction.Dele&te_1=Dele&te
CreateLaunchConfigurationAction.Ne&w_1=Ne&w
CreateLaunchConfigurationAction.New_configuration_2=New_configuration
+EnvironmentTab.Variable_1=Variable
+EnvironmentTab.Value_2=Value
+EnvironmentTab.Environment_variables_to_set__3=Environment variables to set:
+EnvironmentTab.New_4=New
+EnvironmentTab.Edit_5=Edit
+EnvironmentTab.Remove_6=Remove
+EnvironmentTab.variable_7=variable
+EnvironmentTab.value_8=value
+EnvironmentTab.Environment_9=Environment
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java
index d1139800d..028700947 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java
@@ -14,20 +14,31 @@ package org.eclipse.debug.ui;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsMessages;
import org.eclipse.jface.viewers.ColumnLayoutData;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -43,27 +54,113 @@ import org.eclipse.swt.widgets.TableItem;
*/
public class EnvironmentTab extends AbstractLaunchConfigurationTab {
- private TableViewer environmentTable;
- private String[] envTableColumnHeaders =
+ protected TableViewer environmentTable;
+ protected String[] envTableColumnHeaders =
{
- "Variable",
- "Value",
+ LaunchConfigurationsMessages.getString("EnvironmentTab.Variable_1"), //$NON-NLS-1$
+ LaunchConfigurationsMessages.getString("EnvironmentTab.Value_2"), //$NON-NLS-1$
};
- private ColumnLayoutData[] envTableColumnLayouts =
+ protected ColumnLayoutData[] envTableColumnLayouts =
{
new ColumnWeightData(50),
new ColumnWeightData(50)
};
- private static final String P_VARIABLE = "variable"; //$NON-NLS-1$
- private static final String P_VALUE = "value"; //$NON-NLS-1$
- private static String[] envTableColumnProperties =
+ protected static final String P_VARIABLE = "variable"; //$NON-NLS-1$
+ protected static final String P_VALUE = "value"; //$NON-NLS-1$
+ protected static String[] envTableColumnProperties =
{
P_VARIABLE,
P_VALUE
};
- private Button envAddButton;
- private Button envEditButton;
- private Button envRemoveButton;
+ protected Button envAddButton;
+ protected Button envEditButton;
+ protected Button envRemoveButton;
+
+ /**
+ * Cell modifier for the environment table
+ */
+ protected class EnvironmentCellModifier implements ICellModifier {
+ public boolean canModify(Object element, String property) {
+ return true;
+ }
+ public Object getValue(Object element, String property) {
+ String result = null;
+ EnvironmentVariable var = (EnvironmentVariable) element;
+ if (property.equals(P_VARIABLE))
+ result = var.getName();
+ else if (property.equals(P_VALUE))
+ result = var.getValue();
+ return result;
+ }
+ public void modify(Object element, String property, Object value) {
+ TableItem ti = (TableItem) element;
+ EnvironmentVariable var = (EnvironmentVariable) ti.getData();
+ if (property.equals(P_VARIABLE))
+ var.setName((String) value);
+ else if (property.equals(P_VALUE))
+ var.setValue((String) value);
+ else return;
+ // update viewer's display and update the dialog
+ String properties[] = new String[1];
+ properties[0] = property;
+ environmentTable.update(var, properties);
+ updateLaunchConfigurationDialog();
+ }
+ }
+
+ /**
+ * Content provider for the environment table
+ */
+ protected class EnvironmentVariableContentProvider implements IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ EnvironmentVariable[] elements = new EnvironmentVariable[0];
+ ILaunchConfiguration config = (ILaunchConfiguration) inputElement;
+ Map m;
+ try {
+ m = config.getAttribute(IDebugUIConstants.ATTR_ENVIRONMENT_VARIABLES, (Map) null);
+ } catch (CoreException e) {
+ DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Error reading configuration", e)); //$NON-NLS-1$
+ return elements;
+ }
+ if (m != null && !m.isEmpty()) {
+ elements = new EnvironmentVariable[m.size()];
+ String[] varNames = new String[m.size()];
+ m.keySet().toArray(varNames);
+ for (int i = 0; i < m.size(); i++) {
+ elements[i] = new EnvironmentVariable((String) varNames[i], (String) m.get(varNames[i]));
+ }
+ }
+ return elements;
+ }
+ public void dispose() {
+ }
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ /**
+ * Label provider for the environment table
+ */
+ public class EnvironmentVariableLabelProvider extends LabelProvider implements ITableLabelProvider {
+ public String getColumnText(Object element, int columnIndex) {
+ String result = null;
+ if (element != null) {
+ EnvironmentVariable var = (EnvironmentVariable) element;
+ switch (columnIndex) {
+ case 0: // variable
+ result = var.getName();
+ break;
+ case 1: // value
+ result = var.getValue();
+ break;
+ }
+ }
+ return result;
+ }
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
@@ -78,42 +175,52 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
mainComposite.setLayout(layout);
mainComposite.setLayoutData(gridData);
mainComposite.setFont(parent.getFont());
+
+ createEnvironmentTable(mainComposite);
+ createButtons(mainComposite);
+ }
+
+ /**
+ * Creates and configures the table that displayed the key/value
+ * pairs that comprise the environment.
+ * @param parent the composite in which the table should be created
+ */
+ protected void createEnvironmentTable(Composite parent) {
+ Font font= parent.getFont();
// Create table composite
- Composite tableComposite = new Composite(mainComposite, SWT.NONE);
- GridLayout glayout = new GridLayout();
- glayout.marginHeight = 0;
- glayout.marginWidth = 0;
- glayout.numColumns = 1;
- GridData gdata = new GridData(GridData.FILL_HORIZONTAL);
- gdata.heightHint = 150;
- tableComposite.setLayout(glayout);
- tableComposite.setLayoutData(gdata);
+ Composite tableComposite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0;
+ layout.marginWidth = 0;
+ layout.numColumns = 1;
+ GridData gridData = new GridData(GridData.FILL_BOTH);
+ gridData.heightHint = 150;
+ tableComposite.setLayout(layout);
+ tableComposite.setLayoutData(gridData);
+ tableComposite.setFont(font);
// Create label
Label label = new Label(tableComposite, SWT.NONE);
- label.setText("Environment");
+ label.setFont(font);
+ label.setText(LaunchConfigurationsMessages.getString("EnvironmentTab.Environment_variables_to_set__3")); //$NON-NLS-1$
// Create table
environmentTable = new TableViewer(tableComposite);
Table table = environmentTable.getTable();
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
table.setHeaderVisible(true);
- gdata = new GridData(GridData.FILL_BOTH);
- environmentTable.getControl().setLayoutData(gdata);
+ table.setFont(font);
+ gridData = new GridData(GridData.FILL_BOTH);
+ environmentTable.getControl().setLayoutData(gridData);
environmentTable.setContentProvider(new EnvironmentVariableContentProvider());
environmentTable.setLabelProvider(new EnvironmentVariableLabelProvider());
environmentTable.setColumnProperties(envTableColumnProperties);
- environmentTable.addSelectionChangedListener(new ISelectionChangedListener()
- {
- public void selectionChanged(SelectionChangedEvent event)
- {
- boolean enabled = !(environmentTable.getSelection().isEmpty());
- envEditButton.setEnabled(enabled);
- envRemoveButton.setEnabled(enabled);
+ environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ handleTableSelectionChanged(event);
}
});
// Create columns
- for (int i = 0; i < envTableColumnHeaders.length; i++)
- {
+ for (int i = 0; i < envTableColumnHeaders.length; i++) {
tableLayout.addColumnData(envTableColumnLayouts[i]);
TableColumn tc = new TableColumn(table, SWT.NONE, i);
tc.setResizable(envTableColumnLayouts[i].resizable);
@@ -124,69 +231,56 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
cellEditors[0] = new TextCellEditor(table);
cellEditors[1] = new TextCellEditor(table);
environmentTable.setCellEditors(cellEditors);
- environmentTable.setCellModifier(new ICellModifier()
- {
- public boolean canModify(Object element, String property) { return true; }
- public Object getValue(Object element, String property)
- {
- String result = null;
- EnvironmentVariable var = (EnvironmentVariable) element;
- if (property.equals(P_VARIABLE))
- result = var.getName();
- else if (property.equals(P_VALUE))
- result = var.getValue();
- return result;
- }
- public void modify(Object element, String property, Object value)
- {
- TableItem ti = (TableItem) element;
- EnvironmentVariable var = (EnvironmentVariable) ti.getData();
- if (property.equals(P_VARIABLE))
- var.setName((String) value);
- else if (property.equals(P_VALUE))
- var.setValue((String) value);
- else return;
- // update viewer's display and update the dialog
- String properties[] = new String[1];
- properties[0] = property;
- environmentTable.update(var, properties);
- updateLaunchConfigurationDialog();
- }
- });
+ environmentTable.setCellModifier(new EnvironmentCellModifier());
+ }
+
+ /**
+ * Responds to a selection changed event in the environment table
+ * @param event the selection change event
+ */
+ protected void handleTableSelectionChanged(SelectionChangedEvent event) {
+ boolean enabled = !(environmentTable.getSelection().isEmpty());
+ envEditButton.setEnabled(enabled);
+ envRemoveButton.setEnabled(enabled);
+ }
+
+ /**
+ * Creates the add/edit/remove buttons for the environment table
+ * @param parent the composite in which the buttons should be created
+ */
+ protected void createButtons(Composite parent) {
// Create button composite
- Composite buttonComposite = new Composite(mainComposite, SWT.NONE);
- glayout = new GridLayout();
+ Composite buttonComposite = new Composite(parent, SWT.NONE);
+ GridLayout glayout = new GridLayout();
glayout.marginHeight = 0;
glayout.marginWidth = 0;
glayout.numColumns = 1;
- gdata = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
+ GridData gdata = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END);
buttonComposite.setLayout(glayout);
buttonComposite.setLayoutData(gdata);
+ buttonComposite.setFont(parent.getFont());
createVerticalSpacer(buttonComposite, 1);
// Create buttons
- envAddButton = createPushButton(buttonComposite, "New", null);
+ envAddButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.New_4"), null); //$NON-NLS-1$
envAddButton.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected(SelectionEvent event)
- {
+ public void widgetSelected(SelectionEvent event) {
handleEnvAddButtonSelected();
}
});
- envEditButton = createPushButton(buttonComposite, "Edit", null);
+ envEditButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.Edit_5"), null); //$NON-NLS-1$
envEditButton.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected(SelectionEvent event)
- {
+ public void widgetSelected(SelectionEvent event) {
handleEnvEditButtonSelected();
}
});
envEditButton.setEnabled(false);
- envRemoveButton = createPushButton(buttonComposite, "Remove", null);
+ envRemoveButton = createPushButton(buttonComposite, LaunchConfigurationsMessages.getString("EnvironmentTab.Remove_6"), null); //$NON-NLS-1$
envRemoveButton.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected(SelectionEvent event)
- {
+ public void widgetSelected(SelectionEvent event) {
handleEnvRemoveButtonSelected();
}
});
@@ -194,18 +288,18 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
}
/**
- * Method handleEnvAddButtonSelected.
+ * Adds a new environment variable to the table.
*/
- private void handleEnvAddButtonSelected() {
- String name = new String("variable");
- String value = new String("value");
+ protected void handleEnvAddButtonSelected() {
+ String name = new String(LaunchConfigurationsMessages.getString("EnvironmentTab.variable_7")); //$NON-NLS-1$
+ String value = new String(LaunchConfigurationsMessages.getString("EnvironmentTab.value_8")); //$NON-NLS-1$
EnvironmentVariable var = new EnvironmentVariable(name, value);
environmentTable.add(var);
environmentTable.editElement(var, 0);
}
/**
- * Method handleEnvEditButtonSelected.
+ * Creates an editor for the value of the selected environment variable.
*/
private void handleEnvEditButtonSelected() {
IStructuredSelection sel =
@@ -216,7 +310,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
}
/**
- * Method handleEnvRemoveButtonSelected.
+ * Removes the selected environment variable from the table.
*/
private void handleEnvRemoveButtonSelected() {
IStructuredSelection sel =
@@ -227,10 +321,10 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
}
/**
- * Method updateEnvironment.
+ * Updates the environment table for the given launch configuration
* @param configuration
*/
- private void updateEnvironment(ILaunchConfiguration configuration) {
+ protected void updateEnvironment(ILaunchConfiguration configuration) {
environmentTable.setInput(configuration);
}
@@ -238,7 +332,6 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
-
}
/* (non-Javadoc)
@@ -273,7 +366,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
public String getName() {
- return "Environment";
+ return LaunchConfigurationsMessages.getString("EnvironmentTab.Environment_9"); //$NON-NLS-1$
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableContentProvider.java
deleted file mode 100644
index e41262ea8..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableContentProvider.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package org.eclipse.debug.ui;
-/*******************************************************************************
- * Copyright (c) 2000, 2003 Keith Seitz and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Keith Seitz (keiths@redhat.com) - initial implementation
- * IBM Corporation - integration and code cleanup
- *******************************************************************************/
-
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class EnvironmentVariableContentProvider
- implements IStructuredContentProvider
-{
-
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
- */
- public Object[] getElements(Object inputElement)
- {
- EnvironmentVariable[] elements = new EnvironmentVariable[0];
- ILaunchConfiguration config = (ILaunchConfiguration) inputElement;
- Map m;
- try
- {
- m = config.getAttribute(IDebugUIConstants.ATTR_ENVIRONMENT_VARIABLES, (Map) null);
- }
- catch (CoreException e)
- {
- DebugUIPlugin.log(new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, "Error reading configuration", e));
- return elements;
- }
-
- if (m != null && !m.isEmpty())
- {
- elements = new EnvironmentVariable[m.size()];
- String[] varNames = new String[m.size()];
- m.keySet().toArray(varNames);
- for (int i = 0; i < m.size(); i++)
- {
- elements[i] = new EnvironmentVariable((String) varNames[i], (String) m.get(varNames[i]));
- }
- }
-
- return elements;
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose()
- {
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
- {
- }
-
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableLabelProvider.java
deleted file mode 100644
index 51c7b786c..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentVariableLabelProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.eclipse.debug.ui;
-/*******************************************************************************
- * Copyright (c) 2000, 2003 Keith Seitz and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * Keith Seitz (keiths@redhat.com) - initial implementation
- * IBM Corporation - integration and code cleanup
- *******************************************************************************/
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-
-public class EnvironmentVariableLabelProvider
- extends LabelProvider
- implements ITableLabelProvider
-{
- public String getColumnText(Object element, int columnIndex)
- {
- String result = null;
-
- if (element != null)
- {
- EnvironmentVariable var = (EnvironmentVariable) element;
- switch (columnIndex)
- {
- case 0:
- // variable
- result = var.getName();
- break;
-
- case 1:
- // value
- result = var.getValue();
- break;
- }
- }
-
- return result;
- }
-
- public Image getColumnImage(Object element, int columnIndex)
- {
- return null;
- }
-}

Back to the top