throw new UnsupportedOperationException();
}
+ @Override
+ public String toString(boolean explicit) {
+ return COLLAPSE_NODE_NAME + " [" + fPrevEvent + ']'; //$NON-NLS-1$
+ }
+
@Override
public ITmfFilterTreeNode clone() {
return new TmfCollapseFilter();
*/
public List<String> getValidChildren();
+ /**
+ * <h4>Returns a string representation of the filter tree node object.</h4>
+ *
+ * @param explicit
+ * true if ambiguous fields should explicitly include additional
+ * information that can differentiate them from other fields with
+ * the same name
+ *
+ * @return a string representation of the filter tree node object
+ */
+ public String toString(boolean explicit);
+
/**
* @return a clone of the node
*/
public ITmfFilterTreeNode clone();
-
}
}
@Override
- public String toString() {
+ public String toString(boolean explicit) {
StringBuffer buf = new StringBuffer();
if (fNot) {
buf.append("not "); //$NON-NLS-1$
}
for (int i = 0; i < getChildrenCount(); i++) {
ITmfFilterTreeNode node = getChildren()[i];
- buf.append(node.toString());
+ buf.append(node.toString(explicit));
if (i < getChildrenCount() - 1) {
buf.append(" and "); //$NON-NLS-1$
}
}
/**
+ * @param explicit
+ * true if the string representation should explicitly include
+ * the trace type id that can differentiate it from other aspects
+ * with the same name
+ *
* @return The string representation of the event aspect
*/
- public String getAspectLabel() {
+ public String getAspectLabel(boolean explicit) {
if (fEventAspect == null) {
return ""; //$NON-NLS-1$
}
StringBuilder sb = new StringBuilder(fEventAspect.getName());
+ if (explicit) {
+ sb.append('[');
+ sb.append(fTraceTypeId);
+ sb.append(']');
+ }
if (fEventAspect instanceof TmfEventFieldAspect) {
String field = ((TmfEventFieldAspect) fEventAspect).getFieldPath();
if (field != null && !field.isEmpty()) {
}
@Override
- public String toString() {
+ public String toString(boolean explicit) {
String result = (fResult == 0 ? "= " : fResult < 0 ? "< " : "> "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String open = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "["); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String close = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- return getAspectLabel() + (fNot ? " not " : " ") + result + open + fValue + close; //$NON-NLS-1$ //$NON-NLS-2$
+ return getAspectLabel(explicit) + (fNot ? " not " : " ") + result + open + fValue + close; //$NON-NLS-1$ //$NON-NLS-2$
}
@Override
}
@Override
- public String toString() {
- return getAspectLabel() + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ public String toString(boolean explicit) {
+ return getAspectLabel(explicit) + (fNot ? " not contains " : " contains ") + (fIgnoreCase ? "ignorecase \"" : "\"") + fValue + '\"'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Override
}
@Override
- public String toString() {
- return getAspectLabel() + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ public String toString(boolean explicit) {
+ return getAspectLabel(explicit) + (fNot ? " not equals " : " equals ") + (fIgnoreCase ? "ignorecase \"" : "\"") + fValue + '\"'; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Override
}
@Override
- public String toString() {
- return getAspectLabel() + (isNot() ? " not" : "") + " matches \"" + getRegex() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ public String toString(boolean explicit) {
+ return getAspectLabel(explicit) + (fNot ? " not matches \"" : " matches \"") + getRegex() + '\"'; //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
@Override
- public String toString() {
+ public String toString(boolean explicit) {
StringBuffer buf = new StringBuffer();
+ buf.append(fFilterName);
+ buf.append(": "); //$NON-NLS-1$
if (getChildrenCount() > 1) {
buf.append("( "); //$NON-NLS-1$
}
for (int i = 0; i < getChildrenCount(); i++) {
ITmfFilterTreeNode node = getChildren()[i];
- buf.append(node.toString());
+ buf.append(node.toString(explicit));
if (i < (getChildrenCount() - 1)) {
buf.append(" and "); //$NON-NLS-1$
}
}
@Override
- public String toString() {
+ public String toString(boolean explicit) {
StringBuffer buf = new StringBuffer();
if (fNot) {
buf.append("not "); //$NON-NLS-1$
}
for (int i = 0; i < getChildrenCount(); i++) {
ITmfFilterTreeNode node = getChildren()[i];
- buf.append(node.toString());
+ buf.append(node.toString(explicit));
if (i < getChildrenCount() - 1) {
buf.append(" or "); //$NON-NLS-1$
}
package org.eclipse.tracecompass.tmf.core.filter.model;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
}
@Override
- public String toString() {
+ public String toString(boolean explicit) {
StringBuffer buf = new StringBuffer("root"); //$NON-NLS-1$
if (getChildrenCount() > 0) {
buf.append(' ');
- buf.append(Arrays.toString(getChildren()));
+ List<String> strings = new ArrayList<>();
+ for (ITmfFilterTreeNode child : getChildren()) {
+ strings.add(child.toString(explicit));
+ }
+ buf.append(strings.toString());
}
return buf.toString();
}
}
@Override
- public String toString() {
+ public String toString(boolean explicit) {
StringBuffer buf = new StringBuffer();
buf.append("TraceType is " + fName); //$NON-NLS-1$
+ if (explicit) {
+ buf.append('[');
+ buf.append(fTraceTypeId);
+ buf.append(']');
+ }
if (getChildrenCount() > 0) {
buf.append(" and "); //$NON-NLS-1$
}
}
for (int i = 0; i < getChildrenCount(); i++) {
ITmfFilterTreeNode node = getChildren()[i];
- buf.append(node.toString());
+ buf.append(node.toString(explicit));
if (i < getChildrenCount() - 1) {
buf.append(" and "); //$NON-NLS-1$
}
return null;
}
}
+
+ @Override
+ public String toString() {
+ return toString(false);
+ }
}
package org.eclipse.tracecompass.internal.tmf.pcap.ui.stream;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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>
}
// 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(explicit) equality because equals() is not implemented
+ if (savedFilter.toString(true).equals(filter.toString(true))) {
+ 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
public ITmfFilterTreeNode clone() {
return null;
}
+
+ @Override
+ public String toString(boolean explicit) {
+ return toString();
+ }
+
+ @Override
+ public String toString() {
+ return getNodeName();
+ }
}
private static final String XMLSTUB_ID = "org.eclipse.linuxtools.tmf.core.tests.xmlstub";
TmfFilterContainsNode node = (TmfFilterContainsNode) element;
label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
- (node.getEventAspect() != null ? node.getAspectLabel() : Messages.FilterTreeLabelProvider_AspectHint) +
+ (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
' ' + node.getNodeName() +
(node.getValue() != null ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
TmfFilterEqualsNode node = (TmfFilterEqualsNode) element;
label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
- (node.getEventAspect() != null ? node.getAspectLabel() : Messages.FilterTreeLabelProvider_AspectHint) +
+ (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
' ' + node.getNodeName() +
(node.getValue() != null ? " \"" + node.getValue() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
TmfFilterMatchesNode node = (TmfFilterMatchesNode) element;
label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
- (node.getEventAspect() != null ? node.getAspectLabel() : Messages.FilterTreeLabelProvider_AspectHint) +
+ (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
' ' + node.getNodeName() +
(node.getRegex() != null ? " \"" + node.getRegex() + "\"" : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
TmfFilterCompareNode node = (TmfFilterCompareNode) element;
label = (node.isNot() ? "NOT " : "") + //$NON-NLS-1$ //$NON-NLS-2$
- (node.getEventAspect() != null ? node.getAspectLabel() : Messages.FilterTreeLabelProvider_AspectHint) +
+ (node.getEventAspect() != null ? node.getAspectLabel(false) : Messages.FilterTreeLabelProvider_AspectHint) +
(node.getResult() < 0 ? " <" : (node.getResult() > 0 ? " >" : " =")) + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
(node.getType() == Type.ALPHA ? " \"" : node.getType() == Type.TIMESTAMP ? " [" : ' ') + //$NON-NLS-1$ //$NON-NLS-2$
(node.hasValidValue() ? node.getValue() : Messages.FilterTreeLabelProvider_ValueHint) +
}
/**
- * 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(explicit) equality because equals() is not implemented
+ if (node.toString(true).equals(filter.toString(true))) {
+ fViewer.setSelection(node);
return;
}
}
root.addChild(filter);
fViewer.setInput(root);
+ fViewer.setSelection(filter);
}
/**