Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeneviève Bastien2019-08-05 14:27:54 -0400
committerGenevieve Bastien2019-08-06 09:07:00 -0400
commitd064efd83b98977b9b1e518b5d709987d1edc2a8 (patch)
tree3470f3ce4d2891bbd72a874b5a09a4205f81f81b
parent1b3eaec1f86cd8b18df528399e2844a8c7b6316d (diff)
downloadorg.eclipse.tracecompass.incubator-d064efd83b98977b9b1e518b5d709987d1edc2a8.tar.gz
org.eclipse.tracecompass.incubator-d064efd83b98977b9b1e518b5d709987d1edc2a8.tar.xz
org.eclipse.tracecompass.incubator-d064efd83b98977b9b1e518b5d709987d1edc2a8.zip
filters: Edit active filter on double-click
Double-clicking a filter in the Active or Saved areas bring it back to the edition box. If the filter was in the Active area, it is moved to the Saved one and the filter is unapplied. Also, since filters are per trace, when a new trace is selected, the active filters are replaced by this trace's filters. Change-Id: I0acd84ca08ea218b4de4cbe073b8b73888bc929e Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net> Reviewed-on: https://git.eclipse.org/r/147076 Tested-by: CI Bot Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
-rw-r--r--analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterView.java21
-rw-r--r--analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterViewer.java70
2 files changed, 89 insertions, 2 deletions
diff --git a/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterView.java b/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterView.java
index 06500cae..4d5a8d5c 100644
--- a/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterView.java
+++ b/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterView.java
@@ -10,6 +10,7 @@
package org.eclipse.tracecompass.incubator.internal.filters.ui.views.global;
import java.util.Collection;
+import java.util.Collections;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.action.Action;
@@ -17,9 +18,12 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters.TmfFilterAppliedSignal;
+import org.eclipse.tracecompass.internal.provisional.tmf.core.model.filters.TraceCompassFilter;
import org.eclipse.tracecompass.internal.tmf.ui.Activator;
import org.eclipse.tracecompass.internal.tmf.ui.ITmfImageConstants;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.ui.views.TmfView;
/**
@@ -93,6 +97,23 @@ public class GlobalFilterView extends TmfView {
applySearchOrFilter(signal.getFilter().getRegexes());
}
+ /**
+ * Remove current filters and apply the trace's current filters
+ *
+ * @param signal
+ * The trace selection signal
+ */
+ @TmfSignalHandler
+ public void traceSelected(TmfTraceSelectedSignal signal) {
+ ITmfTrace trace = signal.getTrace();
+ if (trace == null) {
+ applySearchOrFilter(Collections.emptyList());
+ return;
+ }
+ TraceCompassFilter filter = TraceCompassFilter.getFilterForTrace(trace);
+ applySearchOrFilter(filter == null ? Collections.emptyList() : filter.getRegexes());
+ }
+
private void applySearchOrFilter(Collection<String> regexes) {
GlobalFilterViewer viewer = fViewer;
if (viewer == null) {
diff --git a/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterViewer.java b/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterViewer.java
index 2c6e7dc0..4b266e6f 100644
--- a/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterViewer.java
+++ b/analyses/org.eclipse.tracecompass.incubator.filters.ui/src/org/eclipse/tracecompass/incubator/internal/filters/ui/views/global/GlobalFilterViewer.java
@@ -27,6 +27,8 @@ import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
@@ -111,10 +113,15 @@ public class GlobalFilterViewer extends Composite {
@Override
public void validFilter() {
String text = Objects.requireNonNull(fLspFilterTextbox.getText());
+ text = Objects.requireNonNull(text.trim());
fLspFilterTextbox.setText(""); //$NON-NLS-1$
- if (fEnabledFilters.contains(text) || fDisabledFilters.contains(text)) {
+ if (text.isEmpty() || fEnabledFilters.contains(text)) {
return;
}
+ if (fDisabledFilters.contains(text)) {
+ // Bring the filter back to enabled
+ fDisabledFilters.remove(text);
+ }
fEnabledFilters.add(text);
fSavedArea.removeAll();
fDisabledFilters.forEach(string -> fSavedArea.add(string));
@@ -146,6 +153,65 @@ public class GlobalFilterViewer extends Composite {
fActive.setExpanded(true);
fSaved.setExpanded(true);
+ // Edit filters on double-clicks
+ fActiveArea.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(@Nullable MouseEvent e) {
+ String[] selection = fActiveArea.getSelection();
+ if (selection.length <= 0) {
+ return;
+ }
+ // Edit the first element of the selection
+ String toEdit = selection[0];
+ if (toEdit == null) {
+ return;
+ }
+ fLspFilterTextbox.setText(toEdit);
+ fEnabledFilters.remove(toEdit);
+ fDisabledFilters.add(toEdit);
+ filtersUpdated();
+ }
+
+ @Override
+ public void mouseDown(@Nullable MouseEvent e) {
+ // Nothing to do
+ }
+
+ @Override
+ public void mouseUp(@Nullable MouseEvent e) {
+ // Nothing to do
+ }
+
+ });
+
+ fSavedArea.addMouseListener(new MouseListener() {
+
+ @Override
+ public void mouseDoubleClick(@Nullable MouseEvent e) {
+ String[] selection = fSavedArea.getSelection();
+ if (selection.length <= 0) {
+ return;
+ }
+ // Edit the first element of the selection
+ String toEdit = selection[0];
+ fLspFilterTextbox.setText(toEdit);
+ filtersUpdated();
+ }
+
+ @Override
+ public void mouseDown(@Nullable MouseEvent e) {
+ // Nothing to do
+ }
+
+ @Override
+ public void mouseUp(@Nullable MouseEvent e) {
+ // Nothing to do
+ }
+
+ });
+
+
DragSource activeSource = new DragSource(fActiveArea, DND.DROP_MOVE);
activeSource.setTransfer(TextTransfer.getInstance());
activeSource.addDragListener(new DragSourceListener() {
@@ -333,7 +399,7 @@ public class GlobalFilterViewer extends Composite {
}
void eventFilterApplied(Collection<String> regexes) {
- if (fEnabledFilters.containsAll(regexes)) {
+ if (!regexes.isEmpty() && fEnabledFilters.containsAll(regexes)) {
// regex already present, ignore
return;
}

Back to the top