|
38 | 38 | import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl; |
39 | 39 | import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
40 | 40 | import org.eclipse.e4.ui.services.IServiceConstants; |
| 41 | +import org.eclipse.jface.action.Action; |
| 42 | +import org.eclipse.jface.action.MenuManager; |
41 | 43 | import org.eclipse.jface.dialogs.MessageDialog; |
42 | 44 | import org.eclipse.jface.layout.GridDataFactory; |
43 | 45 | import org.eclipse.jface.layout.GridLayoutFactory; |
44 | 46 | import org.eclipse.jface.layout.TableColumnLayout; |
45 | 47 | import org.eclipse.jface.layout.TreeColumnLayout; |
| 48 | +import org.eclipse.jface.notifications.NotificationPopup; |
46 | 49 | import org.eclipse.jface.viewers.CellEditor; |
47 | 50 | import org.eclipse.jface.viewers.ColumnLabelProvider; |
48 | 51 | import org.eclipse.jface.viewers.ColumnViewerEditor; |
|
89 | 92 | import org.eclipse.swt.widgets.Control; |
90 | 93 | import org.eclipse.swt.widgets.Display; |
91 | 94 | import org.eclipse.swt.widgets.Label; |
| 95 | +import org.eclipse.swt.widgets.Menu; |
92 | 96 | import org.eclipse.swt.widgets.Shell; |
93 | 97 | import org.eclipse.swt.widgets.Table; |
94 | 98 | import org.eclipse.swt.widgets.Text; |
@@ -598,6 +602,21 @@ public String getText(Object item) { |
598 | 602 | widgetsTableLayout.setColumnData(widgetClassColumn.getColumn(), new ColumnWeightData(40)); |
599 | 603 | widgetsComposite.setLayout(widgetsTableLayout); |
600 | 604 |
|
| 605 | + MenuManager menuManager = new MenuManager(); |
| 606 | + menuManager.setRemoveAllWhenShown(true); |
| 607 | + menuManager.addMenuListener(manager -> { |
| 608 | + Action copyAction = new Action(Messages.CssSpyPart_Copy_widget_info) { |
| 609 | + @Override |
| 610 | + public void run() { |
| 611 | + copyWidgetHierarchyToClipboard(); |
| 612 | + } |
| 613 | + }; |
| 614 | + copyAction.setEnabled(!widgetTreeViewer.getSelection().isEmpty()); |
| 615 | + manager.add(copyAction); |
| 616 | + }); |
| 617 | + Menu menu = menuManager.createContextMenu(widgetTreeViewer.getControl()); |
| 618 | + widgetTreeViewer.getControl().setMenu(menu); |
| 619 | + |
601 | 620 | // / HEADERS |
602 | 621 | Composite container = new Composite(sashForm, SWT.NONE); |
603 | 622 | container.setLayout(new GridLayout(2, true)); |
@@ -1002,6 +1021,8 @@ protected void copyWidgetHierarchyToClipboard() { |
1002 | 1021 | Clipboard clipboard = new Clipboard(display); |
1003 | 1022 | try { |
1004 | 1023 | clipboard.setContents(new Object[] { sb.toString() }, new Transfer[] { TextTransfer.getInstance() }); |
| 1024 | + NotificationPopup.forDisplay(display).text(Messages.CssSpyPart_Widget_hierarchy_copied_to_clipboard) |
| 1025 | + .title(Messages.CssSpyPart_Copy_widget_info, true).open(); |
1005 | 1026 | } finally { |
1006 | 1027 | clipboard.dispose(); |
1007 | 1028 | } |
|
0 commit comments