Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2015-01-27 12:28:40 +0000
committerBernd Hufmann2015-01-28 22:49:04 +0000
commitdf57b4ce721464ed9f89c72c5ab89831a62c7757 (patch)
treeef46d10d5f8d3e8f0312d2c48e6f82623e2aef2e
parent6f58a301ad8247ea5ff45e7d96b701626dc73799 (diff)
downloadorg.eclipse.linuxtools-df57b4ce721464ed9f89c72c5ab89831a62c7757.tar.gz
org.eclipse.linuxtools-df57b4ce721464ed9f89c72c5ab89831a62c7757.tar.xz
org.eclipse.linuxtools-df57b4ce721464ed9f89c72c5ab89831a62c7757.zip
tmf: fix handler activations in FiltersView (Bug 458579)
Change-Id: I51e616b53dd15c7ebc813c9df299e9b7964e3f1f Signed-off-by: Bernd Hufmann <Bernd.Hufmann@ericsson.com> Reviewed-on: https://git.eclipse.org/r/40492 Tested-by: Hudson CI Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/CopyHandler.java5
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/DeleteHandler.java4
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java7
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java12
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/PasteHandler.java3
5 files changed, 27 insertions, 4 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/CopyHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/CopyHandler.java
index 401d87937d..9ed50a41e6 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/CopyHandler.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/CopyHandler.java
@@ -38,8 +38,8 @@ public class CopyHandler extends AbstractHandler {
}
IWorkbenchPage page = window.getActivePage();
FilterView part = (FilterView) page.getActivePart();
- ISelection selection = getSelection(part);
+ ISelection selection = getSelection(part);
LocalSelectionTransfer.getTransfer().setSelection(selection);
LocalSelectionTransfer.getTransfer().setSelectionSetTime(System.currentTimeMillis());
return null;
@@ -70,7 +70,8 @@ public class CopyHandler extends AbstractHandler {
if (part instanceof FilterView) {
FilterView tcv = (FilterView) part;
ISelection selection = tcv.getSite().getSelectionProvider().getSelection();
- if (!selection.isEmpty()) {
+ // only enable if tree is in focus
+ if (!selection.isEmpty() && tcv.isTreeInFocus()) {
return true;
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/DeleteHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/DeleteHandler.java
index 00e8064db8..d0dc1d161c 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/DeleteHandler.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/DeleteHandler.java
@@ -39,6 +39,7 @@ public class DeleteHandler extends AbstractHandler {
}
IWorkbenchPage page = window.getActivePage();
FilterView part = (FilterView) page.getActivePart();
+
ISelection sel = part.getViewSite().getSelectionProvider().getSelection();
if (sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
@@ -66,7 +67,8 @@ public class DeleteHandler extends AbstractHandler {
if (part instanceof FilterView) {
FilterView tcv = (FilterView) part;
ISelection selection = tcv.getSite().getSelectionProvider().getSelection();
- if (!selection.isEmpty()) {
+ // only enable if tree is in focus
+ if (!selection.isEmpty() && tcv.isTreeInFocus()) {
return true;
}
}
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 143e9f0904..4def5201fb 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
@@ -198,6 +198,13 @@ public class FilterView extends TmfView {
}
/**
+ * @return whether the tree is in focus or not
+ */
+ boolean isTreeInFocus() {
+ return fViewer.isTreeInFocus();
+ }
+
+ /**
* Builds the menu toolbar
*/
private void contributeToActionBars() {
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 fa2456a58f..5a7e510f67 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
@@ -339,6 +339,18 @@ class FilterViewer extends Composite {
return selectedNode;
}
+ @Override
+ public boolean setFocus() {
+ return fViewer.getControl().setFocus();
+ }
+
+ /**
+ * @return whether the tree is in focus or not
+ */
+ boolean isTreeInFocus() {
+ return fViewer.getControl().isFocusControl();
+ }
+
public void addSelectionChangedListener(ISelectionChangedListener listener) {
fViewer.addSelectionChangedListener(listener);
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/PasteHandler.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/PasteHandler.java
index 84a224f5c6..24d37c2158 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/PasteHandler.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/PasteHandler.java
@@ -78,7 +78,8 @@ public class PasteHandler extends AbstractHandler {
sel = v.getFilterRoot();
}
ITmfFilterTreeNode objectToPaste = FilterEditUtils.getTransferredTreeNode();
- if (objectToPaste != null &&
+ if (v.isTreeInFocus() &&
+ objectToPaste != null &&
(sel.getValidChildren().contains(objectToPaste.getNodeName())
|| TmfFilterNode.NODE_NAME.equals(objectToPaste.getNodeName()))) {
return true;

Back to the top