Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Obuchowicz2019-06-21 15:39:27 -0400
committerAndrew Obuchowicz2019-06-21 16:39:43 -0400
commit4f57a1774a9729e3e16c4fe77238af29dc07f252 (patch)
tree08eceb7d4efffc3c9db4a36348a51d430db5ed25 /org.eclipse.debug.ui/ui
parent4eff8d4b2f99b831a37349bf393acac911e6bea5 (diff)
downloadeclipse.platform.debug-4f57a1774a9729e3e16c4fe77238af29dc07f252.tar.gz
eclipse.platform.debug-4f57a1774a9729e3e16c4fe77238af29dc07f252.tar.xz
eclipse.platform.debug-4f57a1774a9729e3e16c4fe77238af29dc07f252.zip
Bug 548520 - Add right-click context-menu for Java environment var tabI20190623-1800
Patch ready for review. Change-Id: Ie1d939bc0bf50ca58098785bb072de980c56fbb2 Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
Diffstat (limited to 'org.eclipse.debug.ui/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java10
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties5
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/EnvironmentTab.java78
3 files changed, 93 insertions, 0 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
index 92a7edbd3..13c621aa7 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java
@@ -189,6 +189,16 @@ public class LaunchConfigurationsMessages extends NLS {
public static String EnvironmentTab_20;
public static String EnvironmentTab_AttributeLabel_AppendEnvironmentVariables;
public static String EnvironmentTab_AttributeLabel_EnvironmentVariables;
+ public static String EnvironmentTab_ContextMenu0;
+
+ public static String EnvironmentTab_ContextMenu1;
+
+ public static String EnvironmentTab_ContextMenu2;
+
+ public static String EnvironmentTab_ContextMenu3;
+
+ public static String EnvironmentTab_ContextMenu4;
+
public static String EnvironmentTab_Copy;
public static String EnvironmentTab_Paste;
public static String EnvironmentTab_Paste_Overwrite_Title;
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 68194d4dd..ef2612ebe 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
@@ -199,6 +199,11 @@ EnvironmentTab_Remove_6=Rem&ove
EnvironmentTab_Environment_7=Environment
EnvironmentTab_8=&Name:
EnvironmentTab_9=&Value:
+EnvironmentTab_ContextMenu0=Add
+EnvironmentTab_ContextMenu1=Copy
+EnvironmentTab_ContextMenu2=Paste
+EnvironmentTab_ContextMenu3=Remove
+EnvironmentTab_ContextMenu4=Remove all selected
EnvironmentTab_Copy=&Copy
EnvironmentTab_Paste=&Paste
EnvironmentTab_Paste_Overwrite_Title=Overwrite variables?
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 5e6a56568..28c6bf347 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
@@ -88,6 +88,10 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
@@ -318,6 +322,80 @@ public class EnvironmentTab extends AbstractLaunchConfigurationTab {
}
});
+ // Setup right-click context menu
+ Menu menuTable = new Menu(table);
+ table.setMenu(menuTable);
+
+ // Create add environment variable menu item
+ MenuItem miAdd = new MenuItem(menuTable, SWT.NONE);
+ miAdd.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu0);
+
+ miAdd.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvAddButtonSelected();
+ }
+ });
+
+ // Create copy environment variable menu item
+ MenuItem miCopy = new MenuItem(menuTable, SWT.NONE);
+ miCopy.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu1);
+
+ miCopy.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvCopyButtonSelected();
+ }
+ });
+
+ // Create paste environment variable menu item
+ MenuItem miPaste = new MenuItem(menuTable, SWT.NONE);
+ miPaste.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu2);
+
+ miPaste.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvPasteButtonSelected();
+ }
+ });
+
+ // Create remove environment variable menu item
+ MenuItem miRemove = new MenuItem(menuTable, SWT.NONE);
+ miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu3);
+ miRemove.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ handleEnvRemoveButtonSelected();
+ }
+ });
+
+ environmentTable.addSelectionChangedListener(new ISelectionChangedListener() {
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = environmentTable.getStructuredSelection();
+ if (selection.size() == 1) {
+ miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu3);
+ } else if (selection.size() > 1) {
+ miRemove.setText(LaunchConfigurationsMessages.EnvironmentTab_ContextMenu4);
+ }
+ }
+ });
+
+ // Disable certain context menu item's if no table item is selected
+ table.addListener(SWT.MenuDetect, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ if (table.getSelectionCount() <= 0) {
+ miRemove.setEnabled(false);
+ miCopy.setEnabled(false);
+ } else {
+ miRemove.setEnabled(true);
+ miCopy.setEnabled(true);
+ }
+ }
+ });
+
+
// Setup and create Columns
ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(environmentTable) {
@Override

Back to the top