diff options
author | Andrew Obuchowicz | 2019-07-06 21:41:54 +0000 |
---|---|---|
committer | Andrew Obuchowicz | 2019-07-06 21:50:54 +0000 |
commit | 07064e46dde8282d6bc872a73f1936ed5643af51 (patch) | |
tree | 16349318430c16debcd22e503b6ae7edad2b5ccd | |
parent | c22842de830236a075c1df69c63db21ad4cbc7dc (diff) | |
download | eclipse.platform.debug-07064e46dde8282d6bc872a73f1936ed5643af51.tar.gz eclipse.platform.debug-07064e46dde8282d6bc872a73f1936ed5643af51.tar.xz eclipse.platform.debug-07064e46dde8282d6bc872a73f1936ed5643af51.zip |
Bug 548869 - Tabbing in Environment Variable Table unusableY20190715-0900Y20190711-2335Y20190711-0900S4_13_0_M1I20190714-1800I20190713-1800I20190713-1105I20190713-0230I20190712-1800I20190712-0625I20190711-1805I20190711-1120I20190711-0825I20190710-1800I20190710-0610I20190709-1800I20190709-0610I20190708-1800
Change-Id: I880bcf5bf73eddf944595df84d2e02875c897f9f
Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
-rw-r--r-- | org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java | 49 |
1 files changed, 42 insertions, 7 deletions
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 6feb4da3e..aa9e32b1e 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 @@ -55,6 +55,7 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.layout.PixelConverter; import org.eclipse.jface.layout.TableColumnLayout; import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ColumnViewerEditor; import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent; import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; import org.eclipse.jface.viewers.ColumnWeightData; @@ -405,7 +406,10 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { } }; - TableViewerEditor.create(environmentTable, actSupport, SWT.NONE); + int feature = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR + | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION; + + TableViewerEditor.create(environmentTable, actSupport, feature); // Setup environment variable name column final TableViewerColumn tcv1 = new TableViewerColumn(environmentTable, SWT.NONE, 0); @@ -420,12 +424,14 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { tc1.setText(envTableColumnHeaders[0]); tcv1.setEditingSupport(new TextGetSetEditingSupport<>(tcv1.getViewer(), EnvironmentVariable::getName, (EnvironmentVariable envVar, String value) -> { - if (value != null && !value.isEmpty()) { - if (!value.equals(envVar.getName())) { - // Trim environment variable names - EnvironmentVariable editedVar = new EnvironmentVariable(value.trim(), envVar.getValue()); - if (addVariable(editedVar)) { - environmentTable.remove(envVar); + // Trim environment variable names + String newName = value.trim(); + if (newName != null && !newName.isEmpty()) { + if (!newName.equals(envVar.getName())) { + if (canRenameVariable(newName)) { + envVar.setName(newName); + updateAppendReplace(); + updateLaunchConfigurationDialog(); } } } @@ -444,6 +450,7 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { tc2.setText(envTableColumnHeaders[1]); tcv2.setEditingSupport( new TextGetSetEditingSupport<>(tcv2.getViewer(), EnvironmentVariable::getValue, (envVar, value) -> { + // Don't trim environment variable values envVar.setValue(value); updateAppendReplace(); updateLaunchConfigurationDialog(); @@ -566,6 +573,34 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab { } /** + * Returns whether the environment variable can be renamed to the given variable + * name. If the name is already used for another variable, the user decides with + * a dialog whether to overwrite the existing variable + * + * @param newVariableName the chosen name to give to the variable + * @return whether the new name should be used or not + */ + private boolean canRenameVariable(String newVariableName) { + TableItem[] items = environmentTable.getTable().getItems(); + for (int i = 0; i < items.length; i++) { + EnvironmentVariable existingVariable = (EnvironmentVariable) items[i].getData(); + if (existingVariable.getName().equals(newVariableName)) { + + boolean overWrite = MessageDialog.openQuestion(getShell(), + LaunchConfigurationsMessages.EnvironmentTab_12, + MessageFormat.format(LaunchConfigurationsMessages.EnvironmentTab_13, + new Object[] { newVariableName })); + if (!overWrite) { + return false; + } + environmentTable.remove(existingVariable); + return true; + } + } + return true; + } + + /** * Attempts to add the given variable. Returns whether the variable * was added or not (as when the user answers not to overwrite an * existing variable). |