Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2015-07-07 05:43:39 -0400
committerAnton Leherbauer2015-07-07 05:43:39 -0400
commit0adbb5d3728207bbaffae19db84c0bfc214cd819 (patch)
tree6ca55029016814a80c33deb1db6113dc9b411862 /target_explorer
parent1c5c417a53fd3a5b2e7408cdc7bafb3fd016ce8a (diff)
downloadorg.eclipse.tcf-0adbb5d3728207bbaffae19db84c0bfc214cd819.tar.gz
org.eclipse.tcf-0adbb5d3728207bbaffae19db84c0bfc214cd819.tar.xz
org.eclipse.tcf-0adbb5d3728207bbaffae19db84c0bfc214cd819.zip
Target Explorer: Add "Copy to Clipboard" to path map context menu
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java58
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties1
3 files changed, 59 insertions, 1 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java
index 7758da2bd..702354dff 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/editor/tabs/PathMapTab.java
@@ -17,13 +17,23 @@ import org.eclipse.jface.dialogs.DialogSettings;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
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.Table;
import org.eclipse.tcf.internal.debug.ui.launch.TCFPathMapTab;
import org.eclipse.tcf.services.IPathMap;
import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
@@ -48,6 +58,9 @@ public class PathMapTab extends TCFPathMapTab {
/* default */ Button showAutoGeneratedRules;
+ private CheckboxTableViewer fViewer;
+ Point fLastClickLocation;
+
/**
* Constructor
*
@@ -150,6 +163,48 @@ public class PathMapTab extends TCFPathMapTab {
return false;
}
+ @Override
+ public void createControl(Composite parent) {
+ super.createControl(parent);
+
+ // add "Copy to Clipboard" item to context menu
+ final CheckboxTableViewer viewer = fViewer;
+ Menu menu = viewer.getTable().getMenu();
+ if (menu != null) {
+ @SuppressWarnings("unused")
+ MenuItem separator = new MenuItem(menu, SWT.SEPARATOR);
+ final MenuItem copyItem = new MenuItem(menu, SWT.PUSH);
+ copyItem.setText(Messages.PathMapTab_copy_menu_label);
+ copyItem.setEnabled(false);
+ copyItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Table table = viewer.getTable();
+ Point clickLoc = table.toControl(fLastClickLocation);
+ ViewerCell cell = viewer.getCell(clickLoc);
+ if (cell != null) {
+ String text = cell.getText();
+ if (text != null) {
+ Clipboard cb = new Clipboard(table.getDisplay());
+ cb.setContents(new String[] { text }, new Transfer[] { TextTransfer.getInstance() });
+ cb.dispose();
+ }
+ }
+ }
+ });
+ viewer.getTable().addListener(SWT.MouseDown, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ fLastClickLocation = event.display.getCursorLocation();
+ Table table = viewer.getTable();
+ Point clickLoc = table.toControl(fLastClickLocation);
+ ViewerCell cell = viewer.getCell(clickLoc);
+ copyItem.setEnabled(cell != null);
+ }
+ });
+ }
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.internal.debug.ui.launch.TCFPathMapTab#createCustomControls(org.eclipse.swt.widgets.Composite)
*/
@@ -185,9 +240,10 @@ public class PathMapTab extends TCFPathMapTab {
* @see org.eclipse.tcf.internal.debug.ui.launch.TCFPathMapTab#configureTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer)
*/
@Override
- protected void configureTableViewer(CheckboxTableViewer viewer) {
+ protected void configureTableViewer(final CheckboxTableViewer viewer) {
Assert.isNotNull(viewer);
super.configureTableViewer(viewer);
+ fViewer = viewer;
ClippedCellToolTip.enableFor(viewer);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java
index e5bf87c8e..b544ec11c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.java
@@ -102,6 +102,7 @@ public class Messages extends NLS {
public static String PathMapEditorPage_error_apply;
public static String PathMapEditorPage_error_title;
public static String PathMapEditorPage_showAll_label;
+ public static String PathMapTab_copy_menu_label;
public static String SourceLookupEditorPage_name;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties
index 26e182f47..5394090c5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/nls/Messages.properties
@@ -43,6 +43,7 @@ PathMapEditorPage_name=Object Paths
PathMapEditorPage_error_apply=Failed to update object paths for configuration ''{0}''.\n\nPossible cause:\n{1}
PathMapEditorPage_error_title=Error
PathMapEditorPage_showAll_label=Show auto-generated path map rules
+PathMapTab_copy_menu_label=&Copy to Clipboard
SourceLookupEditorPage_name=Source Paths

Back to the top