aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Perot2014-07-18 17:44:31 (EDT)
committerPatrick Tasse2014-07-24 12:54:16 (EDT)
commit02fd8997d2a0db96565b5c169ab4d1f2a79e3af2 (patch)
tree13aa5bb03486618f526a403c1fc1d9de268209a2
parentabf232b1e18889c0b8b0b87a3ba323a13cf1143a (diff)
downloadorg.eclipse.linuxtools-02fd8997d2a0db96565b5c169ab4d1f2a79e3af2.zip
org.eclipse.linuxtools-02fd8997d2a0db96565b5c169ab4d1f2a79e3af2.tar.gz
org.eclipse.linuxtools-02fd8997d2a0db96565b5c169ab4d1f2a79e3af2.tar.bz2
tmf: add subfield filteringrefs/changes/52/30152/8
Change-Id: I4e7b8ba2ffaf99d95639129ac8b33f673d0673e9 Signed-off-by: Vincent Perot <vincent.perot@ericsson.com> Reviewed-on: https://git.eclipse.org/r/30152 Tested-by: Hudson CI Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java63
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/filter/FilterViewer.java6
4 files changed, 70 insertions, 1 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
index d6e90d9..6f6c5ef 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/filter/model/TmfFilterTreeNode.java
@@ -9,6 +9,7 @@
* Contributors:
* Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation
* Patrick Tasse - Refactoring
+ * Vincent Perot - Add subfield filtering
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.filter.model;
@@ -29,6 +30,9 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
*/
public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable {
+ private static final char SLASH = '/';
+ private static final char BACKSLASH = '\\';
+
private static final String[] VALID_CHILDREN = {
TmfFilterEventTypeNode.NODE_NAME,
TmfFilterAndNode.NODE_NAME,
@@ -42,6 +46,9 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
private ITmfFilterTreeNode parent = null;
private ArrayList<ITmfFilterTreeNode> children = new ArrayList<>();
+ private String fPathAsString = null;
+ private String[] fPathAsArray = null;
+
/**
* @param parent
* the parent node
@@ -141,7 +148,17 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
value = event.getReference();
}
else {
- ITmfEventField eventField = event.getContent().getField(field);
+ if (field == null) {
+ return null;
+ }
+ ITmfEventField eventField;
+ if (field.isEmpty() || field.charAt(0) != SLASH) {
+ eventField = event.getContent().getField(field);
+ } else {
+ String[] array = getPathArray(field);
+ eventField = event.getContent().getSubField(array);
+ }
+
if (eventField != null) {
value = eventField.getValue();
}
@@ -149,6 +166,50 @@ public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable
return value;
}
+ private String[] getPathArray(String field) {
+
+ // Check if last request was not the same string.
+ if (field.equals(fPathAsString)) {
+ return fPathAsArray;
+ }
+
+ // Generate the new path array
+ StringBuilder sb = new StringBuilder();
+ List<String> list = new ArrayList<>();
+
+ // We start at 1 since the first character is a slash that we want to
+ // ignore.
+ for (int i = 1; i < field.length(); i++) {
+ char charAt = field.charAt(i);
+ if (charAt == SLASH) {
+ // char is slash. Cut here.
+ list.add(sb.toString());
+ sb = new StringBuilder();
+ } else if (charAt == BACKSLASH && i < field.length() - 1 && field.charAt(i + 1) == SLASH) {
+ // Uninterpreted slash. Add it.
+ sb.append(SLASH);
+ i++;
+ } else {
+ // Any other character. Add.
+ sb.append(charAt);
+ }
+ }
+
+ // Last block. Add it to list.
+ list.add(sb.toString());
+
+ // Transform to array
+ String[] array = new String[list.size()];
+ list.toArray(array);
+
+ // Save new values.
+ // Array first for solving concurrency issues
+ fPathAsArray = array;
+ fPathAsString = field;
+
+ return array;
+ }
+
@Override
public List<String> getValidChildren() {
return Arrays.asList(VALID_CHILDREN);
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
index 0540eb3..ffc3bca 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
@@ -254,6 +254,7 @@ public class Messages extends NLS {
public static String FilterViewer_RegexHint;
public static String FilterViewer_RegexLabel;
public static String FilterViewer_ResultLabel;
+ public static String FilterViewer_Subfilter_ToolTip;
public static String FilterViewer_TimestampButtonText;
public static String FilterViewer_TypeLabel;
public static String FilterViewer_ValueHint;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
index d480ef7..1afd7b1 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
@@ -253,6 +253,7 @@ FilterViewer_NumButtonText=Num
FilterViewer_RegexHint=type regular expression
FilterViewer_RegexLabel=regex:
FilterViewer_ResultLabel=result:
+FilterViewer_Subfilter_ToolTip=Prefix with '/' to enter a path where subfields are separated by '/'. For an uninterpreted slash use '\/'.
FilterViewer_TimestampButtonText=Timestamp
FilterViewer_TypeLabel=type:
FilterViewer_ValueHint=type value
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 5bd954e..836505e 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
@@ -9,6 +9,7 @@
* Contributors:
* Patrick Tasse - Initial API and implementation
* Xavier Raynaud - add cut/copy/paste/dnd support
+ * Vincent Perot - Add subfield filtering
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.views.filter;
@@ -348,6 +349,7 @@ class FilterViewer extends Composite {
/**
* Gets the TreeViewer displaying filters
+ *
* @return a {@link TreeViewer}
*/
TreeViewer getTreeViewer() {
@@ -689,6 +691,7 @@ class FilterViewer extends Composite {
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
+ fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip);
if (fNode.getField() != null) {
fFieldCombo.setText(fNode.getField());
}
@@ -789,6 +792,7 @@ class FilterViewer extends Composite {
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
+ fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip);
if (fNode.getField() != null) {
fFieldCombo.setText(fNode.getField());
}
@@ -888,6 +892,7 @@ class FilterViewer extends Composite {
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
+ fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip);
if (fNode.getField() != null) {
fFieldCombo.setText(fNode.getField());
}
@@ -978,6 +983,7 @@ class FilterViewer extends Composite {
fFieldCombo = new Combo(this, SWT.DROP_DOWN);
fFieldCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
fFieldCombo.setItems(getFieldsList(fNode));
+ fFieldCombo.setToolTipText(Messages.FilterViewer_Subfilter_ToolTip);
if (fNode.getField() != null) {
fFieldCombo.setText(fNode.getField());
}