Export-Package: org.eclipse.linuxtools.tmf.ui,
org.eclipse.linuxtools.tmf.ui.editors,
org.eclipse.linuxtools.tmf.ui.parsers,
+ org.eclipse.linuxtools.tmf.ui.signal,
org.eclipse.linuxtools.tmf.ui.viewers,
org.eclipse.linuxtools.tmf.ui.viewers.events,
org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis,
import org.eclipse.core.runtime.CoreException;\r
import org.eclipse.core.runtime.IProgressMonitor;\r
import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;\r
-import org.eclipse.linuxtools.tmf.signal.TmfTraceClosedSignal;\r
-import org.eclipse.linuxtools.tmf.signal.TmfTraceOpenedSignal;\r
-import org.eclipse.linuxtools.tmf.signal.TmfTraceParserUpdatedSignal;\r
import org.eclipse.linuxtools.tmf.signal.TmfTraceSelectedSignal;\r
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r
import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager;\r
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal;\r
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal;\r
import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;\r
import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView;\r
import org.eclipse.swt.widgets.Composite;\r
if (fTrace != null) {\r
fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());\r
fEventsTable.setTrace(fTrace, true);\r
- broadcast(new TmfTraceOpenedSignal(this, fTrace));\r
+// FIXME: broadcast(new TmfTraceOpenedSignal(this, fTrace));\r
} else {\r
fEventsTable = new TmfEventsTable(fParent, 0);\r
}\r
if (fTrace != null) {\r
fEventsTable = createEventsTable(parent, fTrace.getCacheSize());\r
fEventsTable.setTrace(fTrace, true);\r
- broadcast(new TmfTraceOpenedSignal(this, fTrace));\r
+// FIXME: broadcast(new TmfTraceOpenedSignal(this, fTrace));\r
} else {\r
fEventsTable = new TmfEventsTable(parent, 0);\r
}\r
if (fTrace != null) {\r
fEventsTable = createEventsTable(fParent, fTrace.getCacheSize());\r
fEventsTable.setTrace(fTrace, true);\r
- broadcast(new TmfTraceOpenedSignal(this, fTrace));\r
+// FIXME:broadcast(new TmfTraceOpenedSignal(this, fTrace, fResource, fEventsTable));\r
} else {\r
fEventsTable = new TmfEventsTable(fParent, 0);\r
}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.signal;\r
+\r
+import org.eclipse.linuxtools.tmf.signal.TmfSignal;\r
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r
+\r
+/**\r
+ * <b><u>TmfTraceClosedSignal</u></b>\r
+ */\r
+public class TmfTraceClosedSignal extends TmfSignal {\r
+\r
+ private final ITmfTrace fTrace;\r
+ \r
+ public TmfTraceClosedSignal(Object source, ITmfTrace trace) {\r
+ super(source);\r
+ fTrace = trace;\r
+ }\r
+\r
+ public ITmfTrace getTrace() {\r
+ return fTrace;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "[TmfTraceClosedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.signal;\r
+\r
+import org.eclipse.core.resources.IResource;\r
+import org.eclipse.linuxtools.tmf.signal.TmfSignal;\r
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r
+import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;\r
+\r
+/**\r
+ * <b><u>TmfTraceOpenedSignal</u></b>\r
+ */\r
+public class TmfTraceOpenedSignal extends TmfSignal {\r
+\r
+ private final ITmfTrace fTrace;\r
+ private final IResource fResource;\r
+ private final ITmfEventsFilterProvider fEventsFilterProvider;\r
+ \r
+ public TmfTraceOpenedSignal(Object source, ITmfTrace trace, IResource resource, ITmfEventsFilterProvider eventsFilterProvider) {\r
+ super(source);\r
+ fTrace = trace;\r
+ fResource = resource;\r
+ fEventsFilterProvider = eventsFilterProvider;\r
+ }\r
+\r
+ public ITmfTrace getTrace() {\r
+ return fTrace;\r
+ }\r
+\r
+ public IResource getResource() {\r
+ return fResource;\r
+ }\r
+\r
+ public ITmfEventsFilterProvider getEventsFilterProvider() {\r
+ return fEventsFilterProvider;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "[TmfTraceOpenedSignal (" + fTrace.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.signal;\r
+\r
+import org.eclipse.core.resources.IResource;\r
+import org.eclipse.linuxtools.tmf.signal.TmfSignal;\r
+\r
+/**\r
+ * <b><u>TmfTraceParserUpdatedSignal</u></b>\r
+ */\r
+public class TmfTraceParserUpdatedSignal extends TmfSignal {\r
+\r
+ private final IResource fTraceResource;\r
+ \r
+ public TmfTraceParserUpdatedSignal(Object source, IResource traceResource) {\r
+ super(source);\r
+ fTraceResource = traceResource;\r
+ }\r
+\r
+ public IResource getTraceResource() {\r
+ return fTraceResource;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return "[TmfTraceParserUpdatedSignal (" + fTraceResource.getName() + ")]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.viewers.events;\r
+\r
+import org.eclipse.linuxtools.tmf.filter.ITmfFilter;\r
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r
+\r
+public interface ITmfEventsFilterListener {\r
+\r
+ public void filterApplied(ITmfFilter filter, ITmfTrace trace);\r
+ \r
+ public void searchApplied(ITmfFilter filter, ITmfTrace trace);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.viewers.events;\r
+\r
+public interface ITmfEventsFilterProvider {\r
+\r
+ public void addEventsFilterListener (ITmfEventsFilterListener listener);\r
+ \r
+ public void removeEventsFilterListener (ITmfEventsFilterListener listener);\r
+ \r
+}\r
import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;\r
import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;\r
-import org.eclipse.linuxtools.tmf.signal.TmfTraceParserUpdatedSignal;\r
import org.eclipse.linuxtools.tmf.trace.ITmfTrace;\r
import org.eclipse.linuxtools.tmf.ui.parsers.ParserProviderManager;\r
+import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceParserUpdatedSignal;\r
import org.eclipse.linuxtools.tmf.ui.views.project.ProjectView;\r
import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfExperimentNode;\r
import org.eclipse.linuxtools.tmf.ui.views.project.model.TmfTraceNode;\r
org.eclipse.linuxtools.tmf.component,
org.eclipse.linuxtools.tmf.event,
org.eclipse.linuxtools.tmf.experiment,
+ org.eclipse.linuxtools.tmf.filter,
+ org.eclipse.linuxtools.tmf.filter.model,
+ org.eclipse.linuxtools.tmf.filter.xml,
org.eclipse.linuxtools.tmf.io,
org.eclipse.linuxtools.tmf.parser,
org.eclipse.linuxtools.tmf.request,
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+\r
+public interface ITmfFilter {\r
+\r
+ /**\r
+ * Verify the filter conditions on an event\r
+ * \r
+ * @param event The event to verify.\r
+ * @return True if the event matches the filter conditions.\r
+ */\r
+ public boolean matches(TmfEvent event);\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Francois Godin (copelnug@gmail.com) - Initial API\r
+ * Yuriy Vashchuk (yvashchuk@gmail.com) - Initial implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.filter.ITmfFilter;\r
+\r
+\r
+/**\r
+ * <h4>This is Node Interface in the Filter Tree</h4>\r
+ */\r
+public interface ITmfFilterTreeNode extends ITmfFilter {\r
+ \r
+ /**\r
+ * <h4>Get the parent node of current node</h4>\r
+ * \r
+ * @return The parent node (null when the node has no parent).\r
+ */\r
+ public ITmfFilterTreeNode getParent();\r
+ \r
+ /**\r
+ * <h4>Get the current node name</h4>\r
+ * \r
+ * @return The name of the current node.\r
+ */\r
+ public String getNodeName();\r
+ \r
+ /**\r
+ * <h4>Tell if the node has children</h4> \r
+ * \r
+ * @return True if the node has children.\r
+ */\r
+ public boolean hasChildren();\r
+ \r
+ /**\r
+ * <h4>Return the number of children</h4>\r
+ * \r
+ * @return The number of children.\r
+ */\r
+ public int getChildrenCount();\r
+ \r
+ /**\r
+ * <h4>Get the array of children</h4>\r
+ * \r
+ * @return The array (possibly empty) of children nodes.\r
+ */\r
+ public ITmfFilterTreeNode[] getChildren();\r
+ \r
+ /**\r
+ * <h4>Get the node by index</h4>\r
+ * \r
+ * @param index The index of node to return.\r
+ * @return The desired node (null if the node is not exists).\r
+ */\r
+ public ITmfFilterTreeNode getChild(int index);\r
+ \r
+ /**\r
+ * <h4>Remove the node from its parent</h4>\r
+ * \r
+ * <p>Shifts all nodes after the removed one to prevent having an empty spot. \r
+ * See {@link #replaceChildren(int, ITmfFilterTreeNode)} to replace a node.</p>\r
+ * \r
+ * @return The removed node. \r
+ */\r
+ public ITmfFilterTreeNode remove();\r
+ \r
+ /**\r
+ * <h4>Remove the child from the current node</h4>\r
+ * \r
+ * <p>Shifts all nodes after the removed one to prevent having an empty spot. \r
+ * See {@link #replaceChildren(int, ITmfFilterTreeNode)} to replace a node.</p>\r
+ * \r
+ * @return The removed node. \r
+ */\r
+ public ITmfFilterTreeNode removeChild(ITmfFilterTreeNode node);\r
+ \r
+ /**\r
+ * <h4>Append a node to the current children</h4>\r
+ * \r
+ * @param node Node to append.\r
+ * @return Index of added node (-1 if the node cannot be added).\r
+ */\r
+ public int addChild(ITmfFilterTreeNode node);\r
+ \r
+ /**\r
+ * <h4>Replace a child node</h4>\r
+ * \r
+ * @param index Index of the node to replace.\r
+ * @param node Node who will replace.\r
+ * @return Node replaced.\r
+ */\r
+ public ITmfFilterTreeNode replaceChild(int index, ITmfFilterTreeNode node);\r
+\r
+ /**\r
+ * <h4>Sets the parent of current node</h4>\r
+ * \r
+ * @param parent The parent of current node.\r
+ */\r
+ public void setParent(ITmfFilterTreeNode parent);\r
+ \r
+ /**\r
+ * <h4>Gets the list of valid children node names that could be added to the node</h4>\r
+ * \r
+ * @return The list of valid children node names.\r
+ */\r
+ public List<String> getValidChildren();\r
+\r
+ public ITmfFilterTreeNode clone();\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+\r
+public class TmfFilterAndNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "AND"; //$NON-NLS-1$\r
+ public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
+ \r
+ private boolean fNot = false;\r
+ \r
+ public TmfFilterAndNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ public boolean isNot() {\r
+ return fNot;\r
+ }\r
+ \r
+ public void setNot(boolean not) {\r
+ this.fNot = not;\r
+ }\r
+ \r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ for (ITmfFilterTreeNode node : getChildren()) {\r
+ if (! node.matches(event)) {\r
+ return false ^ fNot;\r
+ }\r
+ }\r
+ return true ^ fNot;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuffer buf = new StringBuffer();\r
+ if (fNot) {\r
+ buf.append("not "); //$NON-NLS-1$\r
+ }\r
+ if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
+ buf.append("( "); //$NON-NLS-1$\r
+ }\r
+ for (int i = 0; i < getChildrenCount(); i++) {\r
+ ITmfFilterTreeNode node = getChildren()[i];\r
+ buf.append(node.toString());\r
+ if (i < getChildrenCount() - 1) {\r
+ buf.append(" and "); //$NON-NLS-1$\r
+ }\r
+ }\r
+ if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
+ buf.append(" )"); //$NON-NLS-1$\r
+ }\r
+ return buf.toString();\r
+ }\r
+ \r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.text.NumberFormat;\r
+import java.text.ParseException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+import org.eclipse.linuxtools.tmf.event.TmfNoSuchFieldException;\r
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;\r
+\r
+\r
+public class TmfFilterCompareNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "COMPARE"; //$NON-NLS-1$\r
+ public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
+ public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
+ public static final String RESULT_ATTR = "result"; //$NON-NLS-1$\r
+ public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
+ public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
+ \r
+ public static enum Type {\r
+ NUM,\r
+ ALPHA,\r
+ TIMESTAMP\r
+ }\r
+ \r
+ private boolean fNot = false;\r
+ private String fField;\r
+ private int fResult;\r
+ private Type fType = Type.NUM;\r
+ private String fValue;\r
+ private Number fValueNumber;\r
+ private TmfTimestamp fValueTimestamp;\r
+ \r
+ public TmfFilterCompareNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ public boolean isNot() {\r
+ return fNot;\r
+ }\r
+ \r
+ public void setNot(boolean not) {\r
+ this.fNot = not;\r
+ }\r
+ \r
+ public String getField() {\r
+ return fField;\r
+ }\r
+\r
+ public void setField(String field) {\r
+ this.fField = field;\r
+ }\r
+\r
+ public int getResult() {\r
+ return fResult;\r
+ }\r
+ \r
+ public void setResult(int result) {\r
+ this.fResult = result;\r
+ }\r
+ \r
+ public Type getType() {\r
+ return fType;\r
+ }\r
+\r
+ public void setType(Type type) {\r
+ this.fType = type;\r
+ setValue(fValue);\r
+ }\r
+\r
+ public String getValue() {\r
+ return fValue;\r
+ }\r
+ \r
+ public void setValue(String value) {\r
+ this.fValue = value;\r
+ fValueNumber = null;\r
+ fValueTimestamp = null;\r
+ if (value == null) {\r
+ return;\r
+ }\r
+ if (fType == Type.NUM) {\r
+ try {\r
+ fValueNumber = NumberFormat.getInstance().parse(value).doubleValue();\r
+ } catch (ParseException e) {\r
+ }\r
+ } else if (fType == Type.TIMESTAMP) {\r
+ try {\r
+ fValueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat.getInstance().parse(value.toString()).doubleValue()));\r
+ } catch (ParseException e) {\r
+ }\r
+ }\r
+ }\r
+ \r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ try {\r
+ Object value = event.getContent().getField(fField);\r
+ if (value == null) {\r
+ return false ^ fNot;\r
+ }\r
+ if (fType == Type.NUM) {\r
+ if (fValueNumber instanceof Number) {\r
+ if (value instanceof Number) {\r
+ Double valueDouble = ((Number) value).doubleValue();\r
+ return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot;\r
+ } else {\r
+ try {\r
+ Double valueDouble = NumberFormat.getInstance().parse(value.toString()).doubleValue();\r
+ return (valueDouble.compareTo(fValueNumber.doubleValue()) == fResult) ^ fNot;\r
+ } catch (ParseException e) {\r
+ }\r
+ }\r
+ }\r
+ } else if (fType == Type.ALPHA) {\r
+ String valueString = value.toString();\r
+ return (valueString.compareTo(fValue.toString()) == fResult) ^ fNot;\r
+ } else if (fType == Type.TIMESTAMP) {\r
+ if (fValueTimestamp instanceof TmfTimestamp) {\r
+ if (value instanceof TmfTimestamp) {\r
+ TmfTimestamp valueTimestamp = (TmfTimestamp) value;\r
+ return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
+ } else {\r
+ try {\r
+ TmfTimestamp valueTimestamp = new TmfTimestamp((long) (1E9 * NumberFormat.getInstance().parse(value.toString()).doubleValue()));\r
+ return (valueTimestamp.compareTo(fValueTimestamp, false) == fResult) ^ fNot;\r
+ } catch (ParseException e) {\r
+ }\r
+ }\r
+ }\r
+ }\r
+ } catch (TmfNoSuchFieldException e) {\r
+ }\r
+ return false ^ fNot;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ return new ArrayList<String>(0);\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ String result = (fResult == 0 ? "= " : fResult < 0 ? "< " : "> "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
+ String open = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "["); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
+ String close = (fType == Type.NUM ? "" : fType == Type.ALPHA ? "\"" : "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
+ return fField + (fNot ? " not " : " ") + result + open + fValue + close; //$NON-NLS-1$ //$NON-NLS-2$\r
+ }\r
+\r
+ @Override\r
+ public ITmfFilterTreeNode clone() {\r
+ TmfFilterCompareNode clone = (TmfFilterCompareNode) super.clone();\r
+ clone.fField = new String(fField);\r
+ clone.setValue(new String(fValue));\r
+ return clone;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+import org.eclipse.linuxtools.tmf.event.TmfNoSuchFieldException;\r
+\r
+\r
+public class TmfFilterContainsNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "CONTAINS"; //$NON-NLS-1$\r
+ public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
+ public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
+ public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
+ public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$\r
+ \r
+ private boolean fNot = false;\r
+ private String fField;\r
+ private String fValue;\r
+ private String fValueUpperCase;\r
+ private boolean fIgnoreCase = false;\r
+ \r
+ public TmfFilterContainsNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ public boolean isNot() {\r
+ return fNot;\r
+ }\r
+ \r
+ public void setNot(boolean not) {\r
+ this.fNot = not;\r
+ }\r
+ \r
+ public String getField() {\r
+ return fField;\r
+ }\r
+\r
+ public void setField(String field) {\r
+ this.fField = field;\r
+ }\r
+\r
+ public String getValue() {\r
+ return fValue;\r
+ }\r
+\r
+ public void setValue(String value) {\r
+ this.fValue = value;\r
+ fValueUpperCase = value.toUpperCase();\r
+ }\r
+\r
+ public boolean isIgnoreCase() {\r
+ return fIgnoreCase;\r
+ }\r
+ \r
+ public void setIgnoreCase(boolean ignoreCase) {\r
+ this.fIgnoreCase = ignoreCase;\r
+ }\r
+ \r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ try {\r
+ Object value = event.getContent().getField(fField);\r
+ if (value == null) {\r
+ return false ^ fNot;\r
+ }\r
+ String valueString = value.toString();\r
+ if (fIgnoreCase) {\r
+ return valueString.toUpperCase().contains(fValueUpperCase) ^ fNot;\r
+ } else {\r
+ return valueString.contains(fValue) ^ fNot;\r
+ }\r
+ } catch (TmfNoSuchFieldException e) {\r
+ return false ^ fNot;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ return new ArrayList<String>(0);\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return fField + (fNot ? " not" : "") + " contains \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$\r
+ }\r
+\r
+ @Override\r
+ public ITmfFilterTreeNode clone() {\r
+ TmfFilterContainsNode clone = (TmfFilterContainsNode) super.clone();\r
+ clone.fField = new String(fField);\r
+ clone.setValue(new String(fValue));\r
+ return clone;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+import org.eclipse.linuxtools.tmf.event.TmfNoSuchFieldException;\r
+\r
+\r
+public class TmfFilterEqualsNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "EQUALS"; //$NON-NLS-1$\r
+ public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
+ public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
+ public static final String VALUE_ATTR = "value"; //$NON-NLS-1$\r
+ public static final String IGNORECASE_ATTR = "ignorecase"; //$NON-NLS-1$\r
+ \r
+ private boolean fNot = false;\r
+ private String fField;\r
+ private String fValue;\r
+ private boolean fIgnoreCase = false;\r
+ \r
+ public TmfFilterEqualsNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ public boolean isNot() {\r
+ return fNot;\r
+ }\r
+ \r
+ public void setNot(boolean not) {\r
+ this.fNot = not;\r
+ }\r
+ \r
+ public String getField() {\r
+ return fField;\r
+ }\r
+\r
+ public void setField(String field) {\r
+ this.fField = field;\r
+ }\r
+\r
+ public String getValue() {\r
+ return fValue;\r
+ }\r
+\r
+ public void setValue(String value) {\r
+ this.fValue = value;\r
+ }\r
+\r
+ public boolean isIgnoreCase() {\r
+ return fIgnoreCase;\r
+ }\r
+ \r
+ public void setIgnoreCase(boolean ignoreCase) {\r
+ this.fIgnoreCase = ignoreCase;\r
+ }\r
+ \r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ try {\r
+ Object value = event.getContent().getField(fField);\r
+ if (value == null) {\r
+ return false ^ fNot;\r
+ }\r
+ String valueString = value.toString();\r
+ if (valueString == null) {\r
+ return false ^ fNot;\r
+ }\r
+ if (fIgnoreCase) {\r
+ return valueString.equalsIgnoreCase(fValue) ^ fNot;\r
+ } else {\r
+ return valueString.equals(fValue) ^ fNot;\r
+ }\r
+ } catch (TmfNoSuchFieldException e) {\r
+ return false ^ fNot;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ return new ArrayList<String>(0);\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return fField + (fNot ? " not" : "") + " equals \"" + fValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$\r
+ }\r
+\r
+ @Override\r
+ public ITmfFilterTreeNode clone() {\r
+ TmfFilterEqualsNode clone = (TmfFilterEqualsNode) super.clone();\r
+ clone.fField = new String(fField);\r
+ clone.fValue = new String(fValue);\r
+ return clone;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+\r
+public class TmfFilterEventTypeNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "EVENTTYPE"; //$NON-NLS-1$\r
+ public static final String TYPE_ATTR = "type"; //$NON-NLS-1$\r
+ public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
+ \r
+ private String fType;\r
+ private String fName;\r
+ \r
+ public TmfFilterEventTypeNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ public String getEventType() {\r
+ return fType;\r
+ }\r
+\r
+ public void setEventType(String type) {\r
+ this.fType = type;\r
+ }\r
+\r
+ public String getName() {\r
+ return fName;\r
+ }\r
+\r
+ public void setName(String name) {\r
+ this.fName = name;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ if (event.getType().getTypeId().equals(fName)) {\r
+ // There should be at most one child\r
+ for (ITmfFilterTreeNode node : getChildren()) {\r
+ if (! node.matches(event)) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ if (getChildrenCount() == 0) {\r
+ return super.getValidChildren();\r
+ } else {\r
+ return new ArrayList<String>(0); // only one child allowed\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuffer buf = new StringBuffer();\r
+ buf.append("EventType is " + fName); //$NON-NLS-1$\r
+ if (getChildrenCount() > 0) {\r
+ buf.append(" and "); //$NON-NLS-1$\r
+ }\r
+ if (getChildrenCount() > 1) {\r
+ buf.append("( "); //$NON-NLS-1$\r
+ }\r
+ for (int i = 0; i < getChildrenCount(); i++) {\r
+ ITmfFilterTreeNode node = getChildren()[i];\r
+ buf.append(node.toString());\r
+ if (i < getChildrenCount() - 1) {\r
+ buf.append(" and "); //$NON-NLS-1$\r
+ }\r
+ }\r
+ if (getChildrenCount() > 1) {\r
+ buf.append(" )"); //$NON-NLS-1$\r
+ }\r
+ return buf.toString();\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.regex.Pattern;\r
+import java.util.regex.PatternSyntaxException;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+import org.eclipse.linuxtools.tmf.event.TmfNoSuchFieldException;\r
+\r
+\r
+public class TmfFilterMatchesNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "MATCHES"; //$NON-NLS-1$\r
+ public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
+ public static final String FIELD_ATTR = "field"; //$NON-NLS-1$\r
+ public static final String REGEX_ATTR = "regex"; //$NON-NLS-1$\r
+ \r
+ private boolean fNot = false;\r
+ private String fField;\r
+ private String fRegex;\r
+ private Pattern fPattern;\r
+ \r
+ public TmfFilterMatchesNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ public boolean isNot() {\r
+ return fNot;\r
+ }\r
+ \r
+ public void setNot(boolean not) {\r
+ this.fNot = not;\r
+ }\r
+ \r
+ public String getField() {\r
+ return fField;\r
+ }\r
+\r
+ public void setField(String field) {\r
+ this.fField = field;\r
+ }\r
+\r
+ public String getRegex() {\r
+ return fRegex;\r
+ }\r
+\r
+ public void setRegex(String regex) {\r
+ this.fRegex = regex;\r
+ try {\r
+ this.fPattern = Pattern.compile(regex);\r
+ } catch (PatternSyntaxException e) {\r
+ this.fPattern = null;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ if (fPattern == null) {\r
+ return false ^ fNot;\r
+ }\r
+ try {\r
+ Object value = event.getContent().getField(fField);\r
+ if (value == null) {\r
+ return false ^ fNot;\r
+ }\r
+ String valueString = value.toString();\r
+ return fPattern.matcher(valueString).matches() ^ fNot;\r
+ } catch (TmfNoSuchFieldException e) {\r
+ return false ^ fNot;\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ return new ArrayList<String>(0);\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ return fField + (fNot ? " not" : "") + " matches \"" + fRegex + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$\r
+ }\r
+\r
+ @Override\r
+ public ITmfFilterTreeNode clone() {\r
+ TmfFilterMatchesNode clone = (TmfFilterMatchesNode) super.clone();\r
+ clone.fField = new String(fField);\r
+ clone.setRegex(new String(fRegex));\r
+ return clone;\r
+ }\r
+ \r
+ public static String regexFix(String pattern) {\r
+ // if the pattern does not contain one of the expressions .* !^\r
+ // (at the beginning) $ (at the end), then a .* is added at the\r
+ // beginning and at the end of the pattern\r
+ if (!(pattern.indexOf(".*") >= 0 || pattern.charAt(0) == '^' || pattern.charAt(pattern.length() - 1) == '$')) { //$NON-NLS-1$\r
+ pattern = ".*" + pattern + ".*"; //$NON-NLS-1$ //$NON-NLS-2$\r
+ }\r
+ return pattern;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+\r
+public class TmfFilterNode extends TmfFilterTreeNode {\r
+ \r
+ public static final String NODE_NAME = "FILTER"; //$NON-NLS-1$\r
+ public static final String NAME_ATTR = "name"; //$NON-NLS-1$\r
+ \r
+ String fFilterName;\r
+ \r
+ public TmfFilterNode(String filterName) {\r
+ super(null);\r
+ fFilterName = filterName;\r
+ }\r
+\r
+ public TmfFilterNode(ITmfFilterTreeNode parent, String filterName) {\r
+ super(parent);\r
+ fFilterName = filterName;\r
+ }\r
+\r
+ public String getFilterName() {\r
+ return fFilterName;\r
+ }\r
+\r
+ public void setFilterName(String filterName) {\r
+ fFilterName = filterName;\r
+ }\r
+\r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ // There should be at most one child\r
+ for (ITmfFilterTreeNode node : getChildren()) {\r
+ if (node.matches(event)) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ if (getChildrenCount() == 0) {\r
+ return super.getValidChildren();\r
+ } else {\r
+ return new ArrayList<String>(0); // only one child allowed\r
+ }\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuffer buf = new StringBuffer();\r
+ if (getChildrenCount() > 1) {\r
+ buf.append("( "); //$NON-NLS-1$\r
+ }\r
+ for (int i = 0; i < getChildrenCount(); i++) {\r
+ ITmfFilterTreeNode node = getChildren()[i];\r
+ buf.append(node.toString());\r
+ if (i < getChildrenCount() - 1) {\r
+ buf.append(" and "); //$NON-NLS-1$\r
+ }\r
+ }\r
+ if (getChildrenCount() > 1) {\r
+ buf.append(" )"); //$NON-NLS-1$\r
+ }\r
+ return buf.toString();\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+\r
+public class TmfFilterOrNode extends TmfFilterTreeNode {\r
+\r
+ public static final String NODE_NAME = "OR"; //$NON-NLS-1$\r
+ public static final String NOT_ATTR = "not"; //$NON-NLS-1$\r
+ \r
+ private boolean fNot = false;\r
+ \r
+ public TmfFilterOrNode(ITmfFilterTreeNode parent) {\r
+ super(parent);\r
+ }\r
+\r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ public boolean isNot() {\r
+ return fNot;\r
+ }\r
+ \r
+ public void setNot(boolean not) {\r
+ this.fNot = not;\r
+ }\r
+ \r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ for (ITmfFilterTreeNode node : getChildren()) {\r
+ if (node.matches(event)) {\r
+ return true ^ fNot;\r
+ }\r
+ }\r
+ return false & fNot;\r
+ }\r
+\r
+ @Override\r
+ public String toString() {\r
+ StringBuffer buf = new StringBuffer();\r
+ if (fNot) {\r
+ buf.append("not "); //$NON-NLS-1$\r
+ }\r
+ if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
+ buf.append("( "); //$NON-NLS-1$\r
+ }\r
+ for (int i = 0; i < getChildrenCount(); i++) {\r
+ ITmfFilterTreeNode node = getChildren()[i];\r
+ buf.append(node.toString());\r
+ if (i < getChildrenCount() - 1) {\r
+ buf.append(" or "); //$NON-NLS-1$\r
+ }\r
+ }\r
+ if (getParent() != null && !(getParent() instanceof TmfFilterRootNode) && !(getParent() instanceof TmfFilterNode)) {\r
+ buf.append(" )"); //$NON-NLS-1$\r
+ }\r
+ return buf.toString();\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Patrick Tasse - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+\r
+public class TmfFilterRootNode extends TmfFilterTreeNode {\r
+ \r
+ public static final String NODE_NAME = "ROOT"; //$NON-NLS-1$\r
+ \r
+ private static final String[] VALID_CHILDREN = {\r
+ TmfFilterNode.NODE_NAME\r
+ };\r
+ \r
+ public TmfFilterRootNode() {\r
+ super(null);\r
+ }\r
+\r
+ @Override\r
+ public String getNodeName() {\r
+ return NODE_NAME;\r
+ }\r
+\r
+ @Override\r
+ public boolean matches(TmfEvent event) {\r
+ for (ITmfFilterTreeNode node : getChildren()) {\r
+ if (! node.matches(event)) {\r
+ return false;\r
+ }\r
+ }\r
+ return true;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ return Arrays.asList(VALID_CHILDREN);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
+ * Patrick Tasse - Refactoring\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.model;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+import org.eclipse.linuxtools.tmf.event.TmfEvent;\r
+\r
+/**\r
+ * <b><u>TmfFilterTreeNode</u></b>\r
+ * <p>\r
+ * The Filter Tree node\r
+ * <p>\r
+ */\r
+public abstract class TmfFilterTreeNode implements ITmfFilterTreeNode, Cloneable {\r
+ \r
+ private static final String[] VALID_CHILDREN = {\r
+ TmfFilterEventTypeNode.NODE_NAME,\r
+ TmfFilterAndNode.NODE_NAME,\r
+ TmfFilterOrNode.NODE_NAME,\r
+ TmfFilterContainsNode.NODE_NAME,\r
+ TmfFilterEqualsNode.NODE_NAME,\r
+ TmfFilterMatchesNode.NODE_NAME,\r
+ TmfFilterCompareNode.NODE_NAME\r
+ };\r
+ \r
+ private ITmfFilterTreeNode parent = null;\r
+ private ArrayList<ITmfFilterTreeNode> children = new ArrayList<ITmfFilterTreeNode>();\r
+\r
+ public TmfFilterTreeNode(final ITmfFilterTreeNode parent) {\r
+ if (parent != null) {\r
+ parent.addChild(this);\r
+ }\r
+ }\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getParent()\r
+ */\r
+ @Override\r
+ public ITmfFilterTreeNode getParent() {\r
+ return parent;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getNodeName()\r
+ */\r
+ @Override\r
+ public abstract String getNodeName();\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#hasChildren()\r
+ */\r
+ @Override\r
+ public boolean hasChildren() {\r
+ return (children.size() > 0);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChildrenCount()\r
+ */\r
+ @Override\r
+ public int getChildrenCount() {\r
+ return children.size();\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChildren()\r
+ */\r
+ @Override\r
+ public ITmfFilterTreeNode[] getChildren() {\r
+ return children.toArray(new ITmfFilterTreeNode[0]);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getChild(int)\r
+ */\r
+ @Override\r
+ public ITmfFilterTreeNode getChild(final int index) throws IndexOutOfBoundsException {\r
+ return children.get(index);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#remove()\r
+ */\r
+ @Override\r
+ public ITmfFilterTreeNode remove() {\r
+ if (getParent() != null) {\r
+ getParent().removeChild(this);\r
+ }\r
+ return this;\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#removeChild(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
+ */\r
+ @Override\r
+ public ITmfFilterTreeNode removeChild(ITmfFilterTreeNode node) {\r
+ children.remove(node);\r
+ node.setParent(null);\r
+ return node;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#addChild(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
+ */\r
+ @Override\r
+ public int addChild(final ITmfFilterTreeNode node) {\r
+ node.setParent(this);\r
+ if(children.add(node)) {\r
+ return (children.size() - 1);\r
+ }\r
+ return -1;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#replaceChild(int, org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
+ */\r
+ @Override\r
+ public ITmfFilterTreeNode replaceChild(final int index, final ITmfFilterTreeNode node) throws IndexOutOfBoundsException {\r
+ node.setParent(this);\r
+ return children.set(index, node);\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#setParent(org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode)\r
+ */\r
+ @Override\r
+ public void setParent(final ITmfFilterTreeNode parent) {\r
+ this.parent = parent;\r
+ }\r
+\r
+ \r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#matches(org.eclipse.linuxtools.tmf.event.TmfEvent)\r
+ */\r
+ @Override\r
+ public abstract boolean matches(TmfEvent event);\r
+\r
+ /* (non-Javadoc)\r
+ * @see org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode#getValidChildren()\r
+ * \r
+ * By default, all node types are valid children. Override if different.\r
+ */\r
+ @Override\r
+ public List<String> getValidChildren() {\r
+ return Arrays.asList(VALID_CHILDREN);\r
+ }\r
+\r
+ @Override\r
+ public ITmfFilterTreeNode clone() {\r
+ try {\r
+ TmfFilterTreeNode clone = (TmfFilterTreeNode) super.clone();\r
+ clone.parent = null;\r
+ clone.children = new ArrayList<ITmfFilterTreeNode>(children.size());\r
+ for (ITmfFilterTreeNode child : getChildren()) {\r
+ clone.addChild(child.clone());\r
+ }\r
+ return clone;\r
+ } catch (CloneNotSupportedException e) {\r
+ return null;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
+ * based on http://smeric.developpez.com/java/cours/xml/sax/\r
+ * Patrick Tasse - Refactoring\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.xml;\r
+\r
+import java.util.Stack;\r
+\r
+import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterAndNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterCompareNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterCompareNode.Type;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterContainsNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterEqualsNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterEventTypeNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterMatchesNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterOrNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterRootNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterTreeNode;\r
+import org.xml.sax.Attributes;\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.helpers.DefaultHandler;\r
+\r
+/**\r
+ * <b><u>FilterContentHandler</u></b>\r
+ * <p>\r
+ * The Filter SAX Content Handler\r
+ * <p>\r
+ */\r
+public class TmfFilterContentHandler extends DefaultHandler {\r
+ \r
+ private ITmfFilterTreeNode fRoot = null;\r
+ private Stack<ITmfFilterTreeNode> fFilterTreeStack = null;\r
+\r
+ /**\r
+ * The default constructor\r
+ */ \r
+ public TmfFilterContentHandler() {\r
+ super();\r
+ fFilterTreeStack = new Stack<ITmfFilterTreeNode>();\r
+ }\r
+\r
+ /**\r
+ * Getter of tree\r
+ * \r
+ * @return The builded tree\r
+ */ \r
+ public ITmfFilterTreeNode getTree() {\r
+ return fRoot;\r
+ }\r
+ \r
+ /*\r
+ * (non-Javadoc)\r
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)\r
+ */\r
+ @Override\r
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {\r
+ ITmfFilterTreeNode node = null;\r
+ \r
+ if (localName.equalsIgnoreCase(TmfFilterRootNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterRootNode();\r
+ \r
+ } else if (localName.equals(TmfFilterNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterNode(atts.getValue(TmfFilterNode.NAME_ATTR));\r
+ \r
+ } else if (localName.equals(TmfFilterEventTypeNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterEventTypeNode(null);\r
+ ((TmfFilterEventTypeNode) node).setEventType(atts.getValue(TmfFilterEventTypeNode.TYPE_ATTR));\r
+ ((TmfFilterEventTypeNode) node).setName(atts.getValue(TmfFilterEventTypeNode.NAME_ATTR));\r
+ \r
+ } else if (localName.equals(TmfFilterAndNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterAndNode(null);\r
+ String value = atts.getValue(TmfFilterAndNode.NOT_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterAndNode) node).setNot(true);\r
+ }\r
+ \r
+ } else if (localName.equals(TmfFilterOrNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterOrNode(null);\r
+ String value = atts.getValue(TmfFilterOrNode.NOT_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterOrNode) node).setNot(true);\r
+ }\r
+ \r
+ } else if (localName.equals(TmfFilterContainsNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterContainsNode(null);\r
+ String value = atts.getValue(TmfFilterContainsNode.NOT_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterContainsNode) node).setNot(true);\r
+ }\r
+ ((TmfFilterContainsNode) node).setField(atts.getValue(TmfFilterContainsNode.FIELD_ATTR));\r
+ ((TmfFilterContainsNode) node).setValue(atts.getValue(TmfFilterContainsNode.VALUE_ATTR));\r
+ value = atts.getValue(TmfFilterContainsNode.IGNORECASE_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterContainsNode) node).setIgnoreCase(true);\r
+ }\r
+ \r
+ } else if (localName.equals(TmfFilterEqualsNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterEqualsNode(null);\r
+ String value = atts.getValue(TmfFilterEqualsNode.NOT_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterEqualsNode) node).setNot(true);\r
+ }\r
+ ((TmfFilterEqualsNode) node).setField(atts.getValue(TmfFilterEqualsNode.FIELD_ATTR));\r
+ ((TmfFilterEqualsNode) node).setValue(atts.getValue(TmfFilterEqualsNode.VALUE_ATTR));\r
+ value = atts.getValue(TmfFilterEqualsNode.IGNORECASE_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterEqualsNode) node).setIgnoreCase(true);\r
+ }\r
+ \r
+ } else if (localName.equals(TmfFilterMatchesNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterMatchesNode(null);\r
+ String value = atts.getValue(TmfFilterMatchesNode.NOT_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterMatchesNode) node).setNot(true);\r
+ }\r
+ ((TmfFilterMatchesNode) node).setField(atts.getValue(TmfFilterMatchesNode.FIELD_ATTR));\r
+ ((TmfFilterMatchesNode) node).setRegex(atts.getValue(TmfFilterMatchesNode.REGEX_ATTR));\r
+ \r
+ } else if (localName.equals(TmfFilterCompareNode.NODE_NAME)) {\r
+ \r
+ node = new TmfFilterCompareNode(null);\r
+ String value = atts.getValue(TmfFilterCompareNode.NOT_ATTR);\r
+ if (value != null && value.equalsIgnoreCase(Boolean.TRUE.toString())) {\r
+ ((TmfFilterCompareNode) node).setNot(true);\r
+ }\r
+ ((TmfFilterCompareNode) node).setField(atts.getValue(TmfFilterCompareNode.FIELD_ATTR));\r
+ value = atts.getValue(TmfFilterCompareNode.TYPE_ATTR);\r
+ if (value != null) {\r
+ ((TmfFilterCompareNode) node).setType(Type.valueOf(value));\r
+ }\r
+ value = atts.getValue(TmfFilterCompareNode.RESULT_ATTR);\r
+ if (value != null) {\r
+ if (value.equals(Integer.toString(-1))) {\r
+ ((TmfFilterCompareNode) node).setResult(-1);\r
+ } else if (value.equals(Integer.toString(1))) {\r
+ ((TmfFilterCompareNode) node).setResult(1);\r
+ } else {\r
+ ((TmfFilterCompareNode) node).setResult(0);\r
+ }\r
+ }\r
+ ((TmfFilterCompareNode) node).setValue(atts.getValue(TmfFilterCompareNode.VALUE_ATTR));\r
+ \r
+ }\r
+\r
+ fFilterTreeStack.push(node);\r
+ }\r
+\r
+ /*\r
+ * (non-Javadoc)\r
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)\r
+ */\r
+ @Override\r
+ public void endElement(String uri, String localName, String qName) throws SAXException {\r
+ ITmfFilterTreeNode node = fFilterTreeStack.pop();\r
+\r
+ if (fFilterTreeStack.isEmpty()) {\r
+ fRoot = node;\r
+ } else if (fFilterTreeStack.lastElement() instanceof TmfFilterTreeNode &&\r
+ node instanceof TmfFilterTreeNode) {\r
+ fFilterTreeStack.lastElement().addChild(node);\r
+ }\r
+ \r
+ }\r
+\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.xml;\r
+\r
+import java.io.IOException;\r
+\r
+import javax.xml.parsers.ParserConfigurationException;\r
+import javax.xml.parsers.SAXParserFactory;\r
+\r
+import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r
+\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.XMLReader;\r
+\r
+/**\r
+ * <b><u>FilterXMLParser</u></b>\r
+ * <p>\r
+ * This is SAX based XML parser\r
+ * <p>\r
+ */\r
+public class TmfFilterXMLParser {\r
+ \r
+ private static ITmfFilterTreeNode fRoot = null;\r
+ \r
+ /**\r
+ * The XMLParser constructor\r
+ * \r
+ * @param uri The XML file to parse\r
+ */ \r
+ public TmfFilterXMLParser(final String uri) throws SAXException, IOException {\r
+ \r
+ SAXParserFactory m_parserFactory = null;\r
+ if (m_parserFactory == null) { \r
+ m_parserFactory = SAXParserFactory.newInstance(); \r
+ m_parserFactory.setNamespaceAware(true); \r
+ } \r
+\r
+ XMLReader saxReader = null;\r
+ try {\r
+ \r
+ saxReader = m_parserFactory.newSAXParser().getXMLReader();\r
+ saxReader.setContentHandler(new TmfFilterContentHandler());\r
+ saxReader.parse(uri);\r
+ \r
+ fRoot = ((TmfFilterContentHandler) saxReader.getContentHandler()).getTree();\r
+ \r
+ } catch (ParserConfigurationException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Getter of tree\r
+ * \r
+ * @return The builded tree\r
+ */ \r
+ public ITmfFilterTreeNode getTree() {\r
+ return fRoot;\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ * Yuriy Vashchuk (yvashchuk@gmail.com) - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.filter.xml;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.DocumentBuilderFactory;\r
+import javax.xml.parsers.ParserConfigurationException;\r
+import javax.xml.transform.Transformer;\r
+import javax.xml.transform.TransformerConfigurationException;\r
+import javax.xml.transform.TransformerException;\r
+import javax.xml.transform.TransformerFactory;\r
+import javax.xml.transform.dom.DOMSource;\r
+import javax.xml.transform.stream.StreamResult;\r
+\r
+import org.eclipse.linuxtools.tmf.filter.model.ITmfFilterTreeNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterAndNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterCompareNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterContainsNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterEqualsNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterEventTypeNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterMatchesNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterNode;\r
+import org.eclipse.linuxtools.tmf.filter.model.TmfFilterOrNode;\r
+import org.w3c.dom.Document;\r
+import org.w3c.dom.Element;\r
+\r
+/**\r
+ * <b><u>FilterXMLParser</u></b>\r
+ * <p>\r
+ * This is SAX based XML parser\r
+ * <p>\r
+ */\r
+public class TmfFilterXMLWriter {\r
+ \r
+ private Document document = null;\r
+ \r
+ /**\r
+ * The XMLParser constructor\r
+ * \r
+ * @param uri The XML file to parse\r
+ * @throws ParserConfigurationException \r
+ */ \r
+ public TmfFilterXMLWriter(final ITmfFilterTreeNode root) throws IOException, ParserConfigurationException {\r
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();\r
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();\r
+ document = documentBuilder.newDocument();\r
+ \r
+ Element rootElement = document.createElement(root.getNodeName());\r
+ document.appendChild(rootElement);\r
+\r
+ for (ITmfFilterTreeNode node : root.getChildren()) {\r
+ buildXMLTree(document, node, rootElement);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * The Tree to XML parser\r
+ * \r
+ * @param document The XML document\r
+ * @param treenode The node to write\r
+ * @param parentElement The XML element of the parent\r
+ */ \r
+ public static void buildXMLTree(final Document document, final ITmfFilterTreeNode treenode, Element parentElement) {\r
+ Element element = document.createElement(treenode.getNodeName());\r
+ \r
+ if (treenode instanceof TmfFilterNode) {\r
+ \r
+ TmfFilterNode node = (TmfFilterNode) treenode;\r
+ element.setAttribute(TmfFilterNode.NAME_ATTR, node.getFilterName());\r
+ \r
+ } else if (treenode instanceof TmfFilterEventTypeNode) {\r
+ \r
+ TmfFilterEventTypeNode node = (TmfFilterEventTypeNode) treenode;\r
+ element.setAttribute(TmfFilterEventTypeNode.TYPE_ATTR, node.getEventType());\r
+ element.setAttribute(TmfFilterEventTypeNode.NAME_ATTR, node.getName());\r
+ \r
+ } else if (treenode instanceof TmfFilterAndNode) {\r
+ \r
+ TmfFilterAndNode node = (TmfFilterAndNode) treenode;\r
+ element.setAttribute(TmfFilterAndNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
+ \r
+ } else if (treenode instanceof TmfFilterOrNode) {\r
+ \r
+ TmfFilterOrNode node = (TmfFilterOrNode) treenode;\r
+ element.setAttribute(TmfFilterOrNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
+ \r
+ } else if (treenode instanceof TmfFilterContainsNode) {\r
+ \r
+ TmfFilterContainsNode node = (TmfFilterContainsNode) treenode;\r
+ element.setAttribute(TmfFilterContainsNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
+ element.setAttribute(TmfFilterContainsNode.FIELD_ATTR, node.getField());\r
+ element.setAttribute(TmfFilterContainsNode.VALUE_ATTR, node.getValue());\r
+ element.setAttribute(TmfFilterContainsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));\r
+ \r
+ } else if (treenode instanceof TmfFilterEqualsNode) {\r
+ \r
+ TmfFilterEqualsNode node = (TmfFilterEqualsNode) treenode;\r
+ element.setAttribute(TmfFilterEqualsNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
+ element.setAttribute(TmfFilterEqualsNode.FIELD_ATTR, node.getField());\r
+ element.setAttribute(TmfFilterEqualsNode.VALUE_ATTR, node.getValue());\r
+ element.setAttribute(TmfFilterEqualsNode.IGNORECASE_ATTR, Boolean.toString(node.isIgnoreCase()));\r
+ \r
+ } else if (treenode instanceof TmfFilterMatchesNode) {\r
+ \r
+ TmfFilterMatchesNode node = (TmfFilterMatchesNode) treenode;\r
+ element.setAttribute(TmfFilterMatchesNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
+ element.setAttribute(TmfFilterMatchesNode.FIELD_ATTR, node.getField());\r
+ element.setAttribute(TmfFilterMatchesNode.REGEX_ATTR, node.getRegex());\r
+ \r
+ } else if (treenode instanceof TmfFilterCompareNode) {\r
+ \r
+ TmfFilterCompareNode node = (TmfFilterCompareNode) treenode;\r
+ element.setAttribute(TmfFilterCompareNode.NOT_ATTR, Boolean.toString(node.isNot()));\r
+ element.setAttribute(TmfFilterCompareNode.FIELD_ATTR, node.getField());\r
+ element.setAttribute(TmfFilterCompareNode.RESULT_ATTR, Integer.toString(node.getResult()));\r
+ element.setAttribute(TmfFilterCompareNode.TYPE_ATTR, node.getType().toString());\r
+ element.setAttribute(TmfFilterCompareNode.VALUE_ATTR, node.getValue());\r
+ \r
+ }\r
+ \r
+ parentElement.appendChild(element);\r
+ \r
+ for (int i = 0; i < treenode.getChildrenCount(); i++) {\r
+ buildXMLTree(document, treenode.getChild(i), element);\r
+ }\r
+ }\r
+ \r
+ /**\r
+ * Save the tree \r
+ * \r
+ * @param uri The new Filter XML path\r
+ */ \r
+ public void saveTree(final String uri) {\r
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();\r
+ \r
+ try {\r
+ Transformer transformer = transformerFactory.newTransformer();\r
+ DOMSource source = new DOMSource(document);\r
+ StreamResult result = new StreamResult(new File(uri));\r
+ transformer.transform(source, result);\r
+ } catch (TransformerConfigurationException e) {\r
+ e.printStackTrace();\r
+ } catch (TransformerException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ \r
+}\r
import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.signal.TmfTraceOpenedSignal;
import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal;
/**
broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime)));
}
- @TmfSignalHandler
- public void handleTraceOpen(TmfTraceOpenedSignal signal) {
- ITmfTrace trace = signal.getTrace();
- if (trace == this) {
- indexTrace(false);
- }
- }
-
// ------------------------------------------------------------------------
// TmfDataProvider
// ------------------------------------------------------------------------