Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2014-04-28 14:48:07 -0400
committerMarc-Andre Laperle2014-05-08 11:54:40 -0400
commit9fe592ba2f0e28c7c95c579057f9ba5e3a4f5fca (patch)
treec2d57d7c32d9ee138be2acd69c1ee5800f7ef25a
parentfee251095356a08b26436e4787437f30741b6720 (diff)
downloadorg.eclipse.linuxtools-9fe592ba2f0e28c7c95c579057f9ba5e3a4f5fca.tar.gz
org.eclipse.linuxtools-9fe592ba2f0e28c7c95c579057f9ba5e3a4f5fca.tar.xz
org.eclipse.linuxtools-9fe592ba2f0e28c7c95c579057f9ba5e3a4f5fca.zip
tmf: Fix Filter viewer context menu when opened from Colors view
When the filter viewer was opened from the Colors view, the context menu did not appear anymore. This is because the context menu code was moved to the FilterView from the FilterViewer so it would only be executed opening the Filters view. The fix moves the code back to the viewer and exposes the menu to the view so that it can add other menu items through extentions. Change-Id: I0fd447186342bfded6fb202590bbf0e69af6236a Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewed-on: https://git.eclipse.org/r/25689 Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java15
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java33
2 files changed, 33 insertions, 15 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java
index 29dc7455ae..4bc7677400 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java
@@ -23,8 +23,6 @@ import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
@@ -44,7 +42,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.xml.sax.SAXException;
@@ -152,17 +149,7 @@ public class FilterView extends TmfView {
});
this.getSite().setSelectionProvider(fViewer.getTreeViewer());
- // Adds root context menu
- MenuManager menuManager = new MenuManager();
- menuManager.setRemoveAllWhenShown(true);
- menuManager.addMenuListener(new IMenuListener() {
- @Override
- public void menuAboutToShow(IMenuManager manager) {
- fViewer.fillContextMenu(manager);
- }
- });
- Menu contextMenu = menuManager.createContextMenu(fViewer.getTreeViewer().getTree());
- fViewer.getTreeViewer().getTree().setMenu(contextMenu);
+ MenuManager menuManager = fViewer.getMenuManager();
this.getSite().registerContextMenu(menuManager, fViewer.getTreeViewer());
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java
index 13b5507ddf..52c84eea81 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java
@@ -21,7 +21,9 @@ import java.util.Map.Entry;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.viewers.ISelection;
@@ -45,11 +47,11 @@ import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterOrNode;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterRootNode;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterTreeNode;
+import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtEvent;
import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition;
import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomXmlEvent;
import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomXmlTraceDefinition;
-import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTraceDefinition.OutputColumn;
import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
@@ -74,6 +76,7 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.TreeItem;
@@ -85,6 +88,7 @@ class FilterViewer extends Composite {
private TreeViewer fViewer;
private Composite fComposite;
+ private MenuManager fMenuManager;
public FilterViewer(Composite parent, int style) {
super(parent, style);
@@ -108,6 +112,8 @@ class FilterViewer extends Composite {
gl.marginWidth = 0;
fComposite.setLayout(gl);
+ createContextMenu();
+
fViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
@@ -145,6 +151,31 @@ class FilterViewer extends Composite {
}
/**
+ * Create the context menu for the tree viewer
+ */
+ private void createContextMenu() {
+ // Adds root context menu
+ fMenuManager = new MenuManager();
+ fMenuManager.setRemoveAllWhenShown(true);
+ fMenuManager.addMenuListener(new IMenuListener() {
+ @Override
+ public void menuAboutToShow(IMenuManager manager) {
+ fillContextMenu(manager);
+ }
+ });
+
+ // Context
+ Menu contextMenu = fMenuManager.createContextMenu(fViewer.getTree());
+
+ // Publish it
+ fViewer.getTree().setMenu(contextMenu);
+ }
+
+ public MenuManager getMenuManager() {
+ return fMenuManager;
+ }
+
+ /**
* Fill the context menu for the tree viewer.
*
* @param manager

Back to the top