Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2015-01-15 20:58:35 +0000
committerPatrick Tasse2015-01-19 15:33:42 +0000
commit441afd93cd3bf5bba757dab1289bb704ccd61cb3 (patch)
tree34454685d3f1a3f3af1741c627e6b4ac69dc27dd
parent157a89b4592ea5223a66cc162740672a44758aff (diff)
downloadorg.eclipse.linuxtools-441afd93cd3bf5bba757dab1289bb704ccd61cb3.tar.gz
org.eclipse.linuxtools-441afd93cd3bf5bba757dab1289bb704ccd61cb3.tar.xz
org.eclipse.linuxtools-441afd93cd3bf5bba757dab1289bb704ccd61cb3.zip
tmf: Bug 457502: Prevent duplication of Stream List view filters
Change-Id: I80e3b9633a9d6a41ff23ae5992d28d1c14039d7b Reviewed-on: https://git.eclipse.org/r/39711 Tested-by: Hudson CI Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com> Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.pcap.ui/src/org/eclipse/linuxtools/internal/tmf/pcap/ui/stream/StreamListView.java21
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterView.java14
5 files changed, 27 insertions, 14 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
index 39e9323fdf..85238f6ec2 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterContainsNode.java
@@ -129,7 +129,7 @@ public class TmfFilterContainsNode extends TmfFilterTreeNode {
@Override
public String toString() {
- return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return fField + (fNot ? " not contains " : " contains ") + (fIgnoreCase ? "ignorecase \"" : "\"") + fValue + '\"'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
index 946d0c7494..e19c7068dd 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterEqualsNode.java
@@ -128,7 +128,7 @@ public class TmfFilterEqualsNode extends TmfFilterTreeNode {
@Override
public String toString() {
- return fField + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ return fField + (fNot ? " not equals " : " equals ") + (fIgnoreCase ? "ignorecase \"" : "\"") + fValue + '\"'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Override
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
index d69256a138..c9127da724 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterNode.java
@@ -89,6 +89,8 @@ public class TmfFilterNode extends TmfFilterTreeNode {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
+ buf.append(fFilterName);
+ buf.append(": "); //$NON-NLS-1$
if (getChildrenCount() > 1) {
buf.append("( "); //$NON-NLS-1$
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.pcap.ui/src/org/eclipse/linuxtools/internal/tmf/pcap/ui/stream/StreamListView.java b/lttng/org.eclipse.linuxtools.tmf.pcap.ui/src/org/eclipse/linuxtools/internal/tmf/pcap/ui/stream/StreamListView.java
index b55e2ea213..ba5d0b525e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.pcap.ui/src/org/eclipse/linuxtools/internal/tmf/pcap/ui/stream/StreamListView.java
+++ b/lttng/org.eclipse.linuxtools.tmf.pcap.ui/src/org/eclipse/linuxtools/internal/tmf/pcap/ui/stream/StreamListView.java
@@ -12,7 +12,6 @@
package org.eclipse.linuxtools.internal.tmf.pcap.ui.stream;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -63,6 +62,8 @@ import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import com.google.common.collect.Lists;
+
/**
* Class that represents the Stream List View. Such a view lists all the
* available streams from the current experiment. <br>
@@ -413,14 +414,18 @@ public class StreamListView extends TmfView {
}
// Update XML
- List<ITmfFilterTreeNode> newFilters = new ArrayList<>();
- ITmfFilterTreeNode[] oldFilters = FilterManager.getSavedFilters();
- for (int i = 0; i < oldFilters.length; i++) {
- newFilters.add(oldFilters[i]);
+ List<ITmfFilterTreeNode> filters = Lists.newArrayList(FilterManager.getSavedFilters());
+ boolean newFilter = true;
+ for (ITmfFilterTreeNode savedFilter : filters) {
+ // Use toString() equality because equals() is not implemented
+ if (savedFilter.toString().equals(filter.toString())) {
+ newFilter = false;
+ break;
+ }
}
- if (!(newFilters.contains(filter))) {
- newFilters.add(filter);
- FilterManager.setSavedFilters(newFilters.toArray(new ITmfFilterTreeNode[newFilters.size()]));
+ if (newFilter) {
+ filters.add(filter);
+ FilterManager.setSavedFilters(filters.toArray(new ITmfFilterTreeNode[filters.size()]));
}
// Update Filter View
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 3bd9d8b9fc..143e9f0904 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
@@ -110,23 +110,29 @@ public class FilterView extends TmfView {
}
/**
- * Add a filter to the FilterView. This does not modify the XML, which must
- * be done manually. If the filter is already in the FilterView, this is a
- * no-op.
+ * Add a filter to the FilterView and select it. This does not modify the
+ * XML, which must be done manually. If an equivalent filter is already in
+ * the FilterView, it is not added.
*
* @param filter
* The filter to add.
* @since 3.1
*/
public void addFilter(ITmfFilterTreeNode filter) {
+ if (filter == null) {
+ return;
+ }
ITmfFilterTreeNode root = fViewer.getInput();
for (ITmfFilterTreeNode node : root.getChildren()) {
- if (node.equals(filter)) {
+ // Use toString() equality because equals() is not implemented
+ if (node.toString().equals(filter.toString())) {
+ fViewer.setSelection(node);
return;
}
}
root.addChild(filter);
fViewer.setInput(root);
+ fViewer.setSelection(filter);
}
/**

Back to the top