diff options
author | Jan Opacki | 2012-01-18 19:54:45 +0000 |
---|---|---|
committer | Mike Rennie | 2012-01-18 19:54:45 +0000 |
commit | 960c355261b433b7fbf35a96e8d9bf09cb851142 (patch) | |
tree | abe8e33f924aab3901ed3ba172872b807a6f4399 | |
parent | d9d41e2e943e7dce0b059d5e9bcd690db7551bc8 (diff) | |
download | eclipse.platform.debug-960c355261b433b7fbf35a96e8d9bf09cb851142.tar.gz eclipse.platform.debug-960c355261b433b7fbf35a96e8d9bf09cb851142.tar.xz eclipse.platform.debug-960c355261b433b7fbf35a96e8d9bf09cb851142.zip |
Bug 307139 - [launch] Editing mulit-line environment variables
3 files changed, 91 insertions, 8 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java index 51c6753b4..640ec2f2a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/MultipleInputDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. + * Copyright (c) 2003, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Jan Opacki (jan.opacki@gmail.com) bug 307139 *******************************************************************************/ package org.eclipse.debug.internal.ui; @@ -26,6 +27,8 @@ import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.TraverseEvent; +import org.eclipse.swt.events.TraverseListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -41,6 +44,7 @@ public class MultipleInputDialog extends Dialog { protected static final int TEXT = 100; protected static final int BROWSE = 101; protected static final int VARIABLE = 102; + protected static final int MULTILINE_VARIABLE = 103; protected Composite panel; @@ -104,6 +108,9 @@ public class MultipleInputDialog extends Dialog { case VARIABLE: createVariablesField(field.name, field.initialValue, field.allowsEmpty); break; + case MULTILINE_VARIABLE: + createMultilineVariablesField(field.name, field.initialValue, field.allowsEmpty); + break; } } @@ -121,7 +128,10 @@ public class MultipleInputDialog extends Dialog { public void addVariablesField(String labelText, String initialValue, boolean allowsEmpty) { fieldList.add(new FieldSummary(VARIABLE, labelText, initialValue, allowsEmpty)); } - + public void addMultilinedVariablesField(String labelText, String initialValue, boolean allowsEmpty) { + fieldList.add(new FieldSummary(MULTILINE_VARIABLE, labelText, initialValue, allowsEmpty)); + } + protected void createTextField(String labelText, String initialValue, boolean allowEmpty) { Label label = new Label(panel, SWT.NONE); label.setText(labelText); @@ -275,6 +285,72 @@ public class MultipleInputDialog extends Dialog { } + public void createMultilineVariablesField(String labelText, String initialValue, boolean allowEmpty) { + Label label = new Label(panel, SWT.NONE); + label.setText(labelText); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalSpan = 2; + label.setLayoutData(gd); + + final Text text = new Text(panel, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL); + gd = new GridData(GridData.FILL_BOTH); + gd.widthHint = 300; + gd.heightHint = 4 * text.getLineHeight(); + gd.horizontalSpan = 2; + text.setLayoutData(gd); + text.setData(FIELD_NAME, labelText); + + text.addTraverseListener(new TraverseListener () { + public void keyTraversed(TraverseEvent e) { + if(e.detail == SWT.TRAVERSE_RETURN && e.stateMask == SWT.SHIFT) { + e.doit = true; + } + } + }); + + // make sure rows are the same height on both panels. + label.setSize(label.getSize().x, text.getSize().y); + + if (initialValue != null) { + text.setText(initialValue); + } + + if (!allowEmpty) { + validators.add(new Validator() { + public boolean validate() { + return !text.getText().equals(IInternalDebugCoreConstants.EMPTY_STRING); + } + }); + + text.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validateFields(); + } + }); + } + Composite comp = SWTFactory.createComposite(panel, panel.getFont(), 1, 2, GridData.HORIZONTAL_ALIGN_END); + GridLayout ld = (GridLayout)comp.getLayout(); + ld.marginHeight = 1; + ld.marginWidth = 0; + ld.horizontalSpacing = 0; + Button button = createButton(comp, IDialogConstants.IGNORE_ID, DebugUIMessages.MultipleInputDialog_8, false); + + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); + int code = dialog.open(); + if (code == IDialogConstants.OK_ID) { + String variable = dialog.getVariableExpression(); + if (variable != null) { + text.insert(variable); + } + } + } + }); + + controlList.add(text); + } + /* (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#okPressed() */ diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTFactory.java index c6b56f2d8..89ce8e033 100755 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTFactory.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/SWTFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -571,6 +571,7 @@ public class SWTFactory { * Creates a Composite widget * @param parent the parent composite to add this composite to * @param font the font to set on the control + * @param style the style bits for the composite. See {@link Composite} for details on supported style bits * @param columns the number of columns within the composite * @param hspan the horizontal span the composite should take up on the parent * @param fill the style for how this composite should fill into its parent 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 ae825ced2..47cfce0b8 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 Keith Seitz and others. + * Copyright (c) 2000, 2012 Keith Seitz and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,6 +8,7 @@ * Contributors: * Keith Seitz (keiths@redhat.com) - initial implementation * IBM Corporation - integration and code cleanup + * Jan Opacki (jan.opacki@gmail.com) bug 307139 *******************************************************************************/ package org.eclipse.debug.ui; @@ -83,7 +84,7 @@ import com.ibm.icu.text.MessageFormat; * This class may be instantiated. * </p> * @since 3.0 - * @noextend This class is not intended to be subclassed by clients. + * @noextend This class is not intended to be sub-classed by clients. */ public class EnvironmentTab extends AbstractLaunchConfigurationTab { @@ -447,7 +448,12 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { String value= var.getValue(); MultipleInputDialog dialog= new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_11); dialog.addTextField(NAME_LABEL, originalName, false); - dialog.addVariablesField(VALUE_LABEL, value, true); + if(value != null && value.indexOf(System.getProperty("line.separator")) > -1) { + dialog.addMultilinedVariablesField(VALUE_LABEL, value, true); + } + else { + dialog.addVariablesField(VALUE_LABEL, value, true); + } if (dialog.open() != Window.OK) { return; @@ -473,7 +479,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { environmentTable.getControl().setRedraw(false); for (Iterator i = sel.iterator(); i.hasNext(); ) { EnvironmentVariable var = (EnvironmentVariable) i.next(); - environmentTable.remove(var); + environmentTable.remove(var); } environmentTable.getControl().setRedraw(true); updateAppendReplace(); @@ -591,7 +597,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { - // do nothing when de-activated + // do nothing when deactivated } /** |