Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model')
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java233
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfColumnDataProvider.java34
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfStatisticsColumnData.java81
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java45
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnData.java174
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnDataProvider.java189
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java262
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatistics.java126
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java170
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeRootFactory.java119
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java85
-rwxr-xr-xlttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/messages.properties2
12 files changed, 1520 insertions, 0 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java
new file mode 100755
index 0000000000..41577eaa4d
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Implementation and Initial API
+ *
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo;
+
+/**
+ * Base class for the statistics storage. It allow to implement a tree structure
+ * while avoiding the need to run through the tree each time you need to add a
+ * node at a given place.
+ *
+ * @version 2.0
+ * @author Mathieu Denis
+ * @since 2.0
+ */
+public abstract class AbsTmfStatisticsTree {
+
+ /**
+ * String builder used to merge string more efficienctly.
+ */
+ protected static final StringBuilder fBuilder = new StringBuilder();
+
+ /**
+ * Identification of the root.
+ */
+ public static final TmfFixedArray<String> ROOT = new TmfFixedArray<String>("root"); //$NON-NLS-1$
+
+ /**
+ * Function to merge many string more efficienctly.
+ *
+ * @param strings
+ * Strings to merge.
+ * @return A new string containing all the strings.
+ */
+ public synchronized static String mergeString(String... strings) {
+ fBuilder.setLength(0);
+ for (String s : strings) {
+ fBuilder.append(s);
+ }
+ return fBuilder.toString();
+ }
+
+ /**
+ * Define what children a node can have. The management and usage of this map
+ * is done by subclasses. HashSet are always faster than TreeSet for String keys.
+ */
+ protected Map<String, Set<String>> fKeys;
+
+ /**
+ * The nodes in the tree.
+ */
+ protected HashMap<TmfFixedArray<String>, TmfStatisticsTreeNode> fNodes;
+
+ /**
+ * Constructor.
+ */
+ public AbsTmfStatisticsTree() {
+ fNodes = new HashMap<TmfFixedArray<String>, TmfStatisticsTreeNode>();
+ fKeys = new HashMap<String, Set<String>>();
+ }
+
+ /**
+ * Get a node.
+ *
+ * @param path
+ * Path to the node.
+ * @return The node or null.
+ */
+ public TmfStatisticsTreeNode get(final TmfFixedArray<String> path) {
+ return fNodes.get(path);
+ }
+
+ /**
+ * Get the children of a node.
+ *
+ * @param path
+ * Path to the node.
+ * @return Collection containing the children.
+ */
+ public abstract Collection<TmfStatisticsTreeNode> getChildren(final TmfFixedArray<String> path);
+
+ /**
+ * Get every children of a node, even if it doesn't have any registered
+ * events, as opposed to getChildren
+ *
+ * @param path
+ * Path to the node.
+ * @return Collection containing all the children.
+ */
+ public abstract Collection<TmfStatisticsTreeNode> getAllChildren(final TmfFixedArray<String> path);
+
+ /**
+ * Get the map of existing elements of path classified by parent.
+ *
+ * @return The map.
+ */
+ public Map<String, Set<String>> getKeys() {
+ return fKeys;
+ }
+
+ /**
+ * Get or create a node.
+ *
+ * @param path
+ * Path to the node.
+ * @return The node.
+ */
+ public TmfStatisticsTreeNode getOrCreate(final TmfFixedArray<String> path) {
+ TmfStatisticsTreeNode current = fNodes.get(path);
+ if (current == null) {
+ registerName(path);
+ current = new TmfStatisticsTreeNode(path, this);
+ fNodes.put(path, current);
+ }
+ return current;
+ }
+
+ /**
+ * Get the parent of a node.
+ *
+ * @param path
+ * Path to the node.
+ * @return Parent node or null.
+ */
+ public TmfStatisticsTreeNode getParent(final TmfFixedArray<String> path) {
+ if (path.size() == 1) {
+ if (path.equals(ROOT)) {
+ return null;
+ }
+ return get(ROOT);
+ }
+ return get(path.subArray(0, path.size() - 1));
+ }
+
+ /**
+ * Increase any kind of counter.
+ *
+ * This method must be implemented by subclasses.
+ *
+ * @param event
+ * Current event.
+ * @param extraInfo
+ * Extra information to pass along with the event.
+ * @param values
+ * Values desired.
+ */
+ public abstract void increase(ITmfEvent event, ITmfExtraEventInfo extraInfo, int values);
+
+ /**
+ * Register an event.
+ *
+ * This method must be implemented by subclasses.
+ *
+ * @param event
+ * Current event.
+ * @param extraInfo
+ * Extra information to pass along with the event.
+ */
+ public abstract void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo);
+
+ /**
+ * Register an event within a time range.
+ *
+ * This method must be implemented by subclasses.
+ *
+ * @param event
+ * Current event.
+ * @param extraInfo
+ * Extra information to pass along with the event.
+ * @since 2.0
+ */
+ public abstract void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo);
+
+ /**
+ * Register that a new node was created.
+ *
+ * Must make sure the {@link #getChildren(TmfFixedArray)} on the parent node
+ * will return the newly created node.
+ *
+ * @param path
+ * Path of the new node.
+ */
+ protected abstract void registerName(final TmfFixedArray<String> path);
+
+ /**
+ * Reset a node.
+ *
+ * Works recursively.
+ *
+ * @param path
+ * Path to the node.
+ */
+ public void reset(final TmfFixedArray<String> path) {
+ for (TmfStatisticsTreeNode node : getAllChildren(path)) {
+ reset(node.getPath());
+ fNodes.remove(node.getPath());
+ }
+ }
+
+ /**
+ * Reset the time range value of a node.
+ *
+ * Works recursively.
+ *
+ * @param path
+ * Path to the node.
+ * @since 2.0
+ */
+ public void resetTimeRangeValue(final TmfFixedArray<String> path) {
+ for (TmfStatisticsTreeNode node : getChildren(path)) {
+ resetTimeRangeValue(node.getPath());
+ node.resetTimeRangeValue();
+ }
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfColumnDataProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfColumnDataProvider.java
new file mode 100755
index 0000000000..a63bd2b546
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfColumnDataProvider.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import java.util.List;
+
+/**
+ * Basic methods that must be implemented in a column data provider. The
+ * <code>TmfStatisticsView</code> uses classes implementing this interface to
+ * define the columns in the statistics tree viewer.
+ *
+ * @version 2.0
+ * @author Mathieu Denis
+ * @since 2.0
+ */
+public interface ITmfColumnDataProvider {
+
+ /**
+ * Return a list of the column created for the view
+ *
+ * @return columns list
+ */
+ public List<TmfBaseColumnData> getColumnData();
+} \ No newline at end of file
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfStatisticsColumnData.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfStatisticsColumnData.java
new file mode 100644
index 0000000000..86a784b731
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfStatisticsColumnData.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
+
+/**
+ * Provide the basic interface to create a statistics column for the statistics
+ * table tree.
+ *
+ * @version 2.0
+ * @since 2.0
+ * @author Mathieu Denis
+ */
+public interface ITmfStatisticsColumnData {
+
+ /**
+ * Return the column name.
+ *
+ * @return the name of the column.
+ */
+ public String getHeader();
+
+ /**
+ * Return the width of the column at the creation.
+ *
+ * @return the width of the column.
+ */
+ public int getWidth();
+
+ /**
+ * Return the alignment of the column.
+ *
+ * @see org.eclipse.swt.SWT
+ * @return an integer representing the alignment inside the column.
+ */
+ public int getAlignment();
+
+ /**
+ * Provide the text to show in the tooltip when the cursor comes over the
+ * column header.
+ *
+ * @return text to show in the tooltip
+ */
+ public String getTooltip();
+
+ /**
+ * Return the labelProvider which provides the information to put in column
+ * cells.
+ *
+ * @return a ColumnLabelProvider.
+ */
+ public ColumnLabelProvider getLabelProvider();
+
+ /**
+ * Return a ViewerComparator used to sort viewer's contents.
+ *
+ * @return the comparator.
+ */
+ public ViewerComparator getComparator();
+
+ /**
+ * Return the provider of the percentage. Used to draw bar charts in
+ * columns.
+ *
+ * @return the percentageProvider.
+ */
+ public ITmfColumnPercentageProvider getPercentageProvider();
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java
new file mode 100755
index 0000000000..08c95aeadb
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Message strings for the statistics framework.
+ *
+ * @version 2.0
+ * @author Mathieu Denis
+ * @since 2.0
+ */
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.messages"; //$NON-NLS-1$
+
+ /**
+ * CPU statistic name.
+ */
+ public static String TmfStatisticsData_CPUs;
+
+ /**
+ * Event type statistic name.
+ */
+ public static String TmfStatisticsData_EventTypes;
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnData.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnData.java
new file mode 100755
index 0000000000..c6cea95561
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnData.java
@@ -0,0 +1,174 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial Implementation
+ * Bernd Hufmann - Added Annotations
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ViewerComparator;
+
+/**
+ * Contains all the information necessary to build a column of the table.
+ *
+ * @version 2.0
+ * @author Mathieu Denis
+ * @since 2.0
+ */
+public class TmfBaseColumnData implements ITmfStatisticsColumnData {
+
+ /**
+ * Name of the column.
+ */
+ protected final String fHeader;
+
+ /**
+ * Width of the column.
+ */
+ protected final int fWidth;
+
+ /**
+ * Alignment of the column.
+ */
+ protected final int fAlignment;
+
+ /**
+ * Tooltip of the column.
+ */
+ protected final String fTooltip;
+
+ /**
+ * Adapts a StatisticsTreeNode into the content of it's corresponding cell
+ * for that column.
+ */
+ protected final ColumnLabelProvider fLabelProvider;
+
+ /**
+ * Used to sort elements of this column. Can be null.
+ */
+ protected final ViewerComparator fComparator;
+
+ /**
+ * Used to draw bar charts in this column. Can be null.
+ */
+ protected final ITmfColumnPercentageProvider fPercentageProvider;
+
+ /**
+ * Used to draw bar charts in columns.
+ */
+ public interface ITmfColumnPercentageProvider {
+
+ /**
+ * Percentage provider
+ *
+ * @param node
+ * The statistics tree node
+ * @return The value as a percentage
+ */
+ public double getPercentage(TmfStatisticsTreeNode node);
+ }
+
+ /**
+ * Constructor with parameters
+ *
+ * @param h
+ * header of the column. The name will be shown at the top of the
+ * column.
+ * @param w
+ * width of the column.
+ * @param a
+ * alignment of the text
+ * @param t
+ * text to shown as a tooltip when the cursor comes over the
+ * header
+ * @param l
+ * provide all the column element
+ * @param c
+ * used to compare element between them to be able to classify
+ * the content of the columns
+ * @param p
+ * provide the percentage of a specific element
+ */
+ public TmfBaseColumnData(String h, int w, int a, String t,
+ ColumnLabelProvider l, ViewerComparator c,
+ ITmfColumnPercentageProvider p) {
+ fHeader = h;
+ fWidth = w;
+ fAlignment = a;
+ fTooltip = t;
+ fLabelProvider = l;
+ fComparator = c;
+ fPercentageProvider = p;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getHeader()
+ */
+ @Override
+ public String getHeader() {
+ return fHeader;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getWidth()
+ */
+ @Override
+ public int getWidth() {
+ return fWidth;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getAlignment()
+ */
+ @Override
+ public int getAlignment() {
+ return fAlignment;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getTooltip()
+ */
+ @Override
+ public String getTooltip() {
+ return fTooltip;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getLabelProvider()
+ */
+ @Override
+ public ColumnLabelProvider getLabelProvider() {
+ return fLabelProvider;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getComparator()
+ */
+ @Override
+ public ViewerComparator getComparator() {
+ return fComparator;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfStatisticsColumnData#getPercentageProvider()
+ */
+ @Override
+ public ITmfColumnPercentageProvider getPercentageProvider() {
+ return fPercentageProvider;
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnDataProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnDataProvider.java
new file mode 100755
index 0000000000..29d6e4e496
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnDataProvider.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Implementation and Initial API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.Messages;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Create a basic list of columns with providers.
+ *
+ * @version 2.0
+ * @author Mathieu Denis
+ * @since 2.0
+ */
+public class TmfBaseColumnDataProvider implements ITmfColumnDataProvider {
+
+ /**
+ * Contains the list of the columns
+ */
+ protected List<TmfBaseColumnData> fColumnData = null;
+
+ /**
+ * Level column names
+ */
+ protected final static String LEVEL_COLUMN = Messages.TmfStatisticsView_LevelColumn;
+
+ /**
+ * Number of events column names
+ */
+ protected final static String EVENTS_COUNT_COLUMN = Messages.TmfStatisticsView_NbEventsColumn;
+
+ /**
+ * Number of events in time range column names
+ * @since 2.0
+ */
+ protected final static String PARTIAL_EVENTS_COUNT_COLUMN = Messages.TmfStatisticsView_NbEventsTimeRangeColumn;
+ /**
+ * Level column tooltips
+ */
+ protected final static String LEVEL_COLUMN_TIP = Messages.TmfStatisticsView_LevelColumnTip;
+
+ /**
+ * Number of events column tooltips
+ */
+ protected final static String EVENTS_COUNT_COLUMN_TIP = Messages.TmfStatisticsView_NbEventsTip;
+
+ /**
+ * Number of events in time range column tooltips
+ * @since 2.0
+ */
+ protected final static String PARTIAL_COUNT_COLUMN_TIP = Messages.TmfStatisticsView_NbEventsTimeRangeTip;
+ /**
+ * Level for which statistics should not be displayed.
+ */
+ protected Set<String> fFolderLevels = new HashSet<String>(Arrays.asList(new String[] { "Event Types" })); //$NON-NLS-1$
+
+ /**
+ * Create basic columns to represent the statistics data
+ */
+ public TmfBaseColumnDataProvider() {
+ /* List that will be used to create the table. */
+ fColumnData = new Vector<TmfBaseColumnData>();
+ /* Column showing the name of the events and its level in the tree */
+ fColumnData.add(new TmfBaseColumnData(LEVEL_COLUMN, 200, SWT.LEFT, LEVEL_COLUMN_TIP, new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ return ((TmfStatisticsTreeNode) element).getKey();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) element;
+ if (fFolderLevels.contains(node.getKey())) {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
+ }
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT);
+ }
+ }, new ViewerComparator() {
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ TmfStatisticsTreeNode n1 = (TmfStatisticsTreeNode) e1;
+ TmfStatisticsTreeNode n2 = (TmfStatisticsTreeNode) e2;
+
+ return n1.getKey().compareTo(n2.getKey());
+ }
+ }, null));
+
+ /* Column showing the total number of events */
+ fColumnData.add(new TmfBaseColumnData(EVENTS_COUNT_COLUMN, 140, SWT.LEFT, EVENTS_COUNT_COLUMN_TIP, new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) element;
+ if (!fFolderLevels.contains(node.getKey())) {
+ return Long.toString(node.getValue().getTotal());
+ }
+ return ""; //$NON-NLS-1$
+ }
+ }, new ViewerComparator() {
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ TmfStatisticsTreeNode n1 = (TmfStatisticsTreeNode) e1;
+ TmfStatisticsTreeNode n2 = (TmfStatisticsTreeNode) e2;
+
+ return (int) (n1.getValue().getTotal() - n2.getValue().getTotal());
+ }
+ }, new ITmfColumnPercentageProvider() {
+
+ @Override
+ public double getPercentage(TmfStatisticsTreeNode node) {
+ TmfStatisticsTreeNode parent = node;
+ do {
+ parent = parent.getParent();
+ } while (parent != null && parent.getValue().getTotal() == 0);
+
+ if (parent == null) {
+ return 0;
+ }
+ return (double) node.getValue().getTotal() / parent.getValue().getTotal();
+ }
+ }));
+
+ /* Column showing the number of events within the selected time range */
+ fColumnData.add(new TmfBaseColumnData(PARTIAL_EVENTS_COUNT_COLUMN, 140, SWT.LEFT, PARTIAL_COUNT_COLUMN_TIP,
+ new ColumnLabelProvider() {
+ @Override
+ public String getText(Object element) {
+ TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) element;
+ if (!fFolderLevels.contains(node.getKey())) {
+ return Long.toString(node.getValue().getPartial());
+ }
+ return ""; //$NON-NLS-1$
+ }
+ }, new ViewerComparator() {
+ @Override
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ TmfStatisticsTreeNode n1 = (TmfStatisticsTreeNode) e1;
+ TmfStatisticsTreeNode n2 = (TmfStatisticsTreeNode) e2;
+
+ return (int) (n1.getValue().getPartial() - n2.getValue().getPartial());
+ }
+ }, new ITmfColumnPercentageProvider() {
+
+ @Override
+ public double getPercentage(TmfStatisticsTreeNode node) {
+ TmfStatisticsTreeNode parent = node;
+ do {
+ parent = parent.getParent();
+ } while (parent != null && parent.getValue().getPartial() == 0);
+
+ if (parent == null) {
+ return 0;
+ }
+ return (double) node.getValue().getPartial() / parent.getValue().getPartial();
+ }
+ }));
+ }
+
+ /**
+ * Provide the columns to represent statistics data
+ */
+ @Override
+ public List<TmfBaseColumnData> getColumnData() {
+ return fColumnData;
+ }
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java
new file mode 100755
index 0000000000..0d85447da1
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java
@@ -0,0 +1,262 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and Implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
+import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo;
+
+/**
+ * Store information about base statistics data.
+ *
+ * This class provides a way to represent statistics data that is compatible
+ * with every type of trace.
+ *
+ * @version 2.0
+ * @author Mathieu Denis
+ * @since 2.0
+ */
+public class TmfBaseStatisticsTree extends AbsTmfStatisticsTree {
+
+ /**
+ * Header for the event type categories.
+ */
+ public static final String HEADER_EVENT_TYPES = Messages.TmfStatisticsData_EventTypes;
+
+ /**
+ * Indicate that it's a value.
+ *
+ * Used when checking the possible child node for a node.
+ *
+ * It differentiate a category of a value by being appended to a value.
+ */
+ protected static final String NODE = "z"; //$NON-NLS-1$
+
+ /**
+ * Root node key.
+ */
+ protected static final String ROOT_NODE_KEY = mergeString(ROOT.get(0), NODE);
+
+ /**
+ * Default constructor. Creates base statistics tree for counting total
+ * number of events and number of events per event type.
+ */
+ public TmfBaseStatisticsTree() {
+ super();
+ Map<String, Set<String>> keys = getKeys();
+
+ // //////////// Adding category sets
+ // common
+ keys.put(HEADER_EVENT_TYPES, new HashSet<String>());
+
+ // /////////// Adding value sets
+ // Under a trace
+ Set<String> temp = new HashSet<String>(8);
+ temp.add(HEADER_EVENT_TYPES);
+ keys.put(ROOT_NODE_KEY, temp);
+ // Under an event type
+ temp = new HashSet<String>(16);
+ keys.put(mergeString(HEADER_EVENT_TYPES, NODE), temp);
+
+ // //////////// CREATE root
+ keys.put(ROOT.get(0), new HashSet<String>(2)); // 1 trace at the time
+ getOrCreate(ROOT);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree#getChildren
+ * (org.eclipse.linuxtools.tmf.core.util.TmfFixedArray)
+ */
+ @Override
+ public Collection<TmfStatisticsTreeNode> getChildren(TmfFixedArray<String> path) {
+ LinkedList<TmfStatisticsTreeNode> result = new LinkedList<TmfStatisticsTreeNode>();
+
+ if (path.size() % 2 == 0) { // if we are at a Category
+ TmfStatisticsTreeNode current = null;
+ for (String value : getKeys().get(path.get(path.size() - 1))) {
+ current = get(path.append(value));
+ if (current != null && current.getValue().getTotal() != 0) {
+ result.add(current);
+ }
+ }
+ } else if (path.size() == 1) { // Special case.
+ if (path.equals(ROOT)) {
+ for (String value : getKeys().get(ROOT.get(0))) {
+ result.add(getOrCreate(new TmfFixedArray<String>(value)));
+ }
+ } else {
+ // Get value under the root
+ for (String value : getKeys().get(ROOT_NODE_KEY)) {
+ result.add(getOrCreate(path.append(value)));
+ }
+ }
+ } else {// If we are at a value
+ for (String value : getKeys().get(mergeString(path.get(path.size() - 2), NODE))) {
+ // Search the parent name + NODE
+ result.add(getOrCreate(path.append(value)));
+ }
+ }
+
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree#getAllChildren
+ * (org.eclipse.linuxtools.tmf.core.util.TmfFixedArray)
+ */
+ @Override
+ public Collection<TmfStatisticsTreeNode> getAllChildren(TmfFixedArray<String> path) {
+ LinkedList<TmfStatisticsTreeNode> result = new LinkedList<TmfStatisticsTreeNode>();
+
+ if (path.size() % 2 == 0) { // if we are at a Category
+ TmfStatisticsTreeNode current = null;
+ for (String value : getKeys().get(path.get(path.size() - 1))) {
+ current = get(path.append(value));
+ if (current != null) {
+ result.add(current);
+ }
+ }
+ } else if (path.size() == 1) { // Special case.
+ if (path.equals(ROOT)) {
+ for (String value : getKeys().get(ROOT.get(0))) {
+ result.add(getOrCreate(new TmfFixedArray<String>(value)));
+ }
+ } else {
+ // Get value under the root
+ for (String value : getKeys().get(ROOT_NODE_KEY)) {
+ result.add(getOrCreate(path.append(value)));
+ }
+ }
+ } else {// If we are at a value
+ for (String value : getKeys().get(mergeString(path.get(path.size() - 2), NODE))) {
+ // Search the parent name + NODE
+ result.add(getOrCreate(path.append(value)));
+ }
+ }
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree#increase
+ * (org.eclipse.linuxtools.tmf.core.event.ITmfEvent, org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo, int)
+ */
+ @Override
+ public void increase(ITmfEvent event, ITmfExtraEventInfo extraInfo, int values) {
+ // Do nothing
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree#registerEvent
+ * (org.eclipse.linuxtools.tmf.core.event.ITmfEvent, org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo)
+ */
+ @Override
+ public void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo) {
+ TmfFixedArray<String>[] paths = getNormalPaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementTotal();
+ }
+
+ paths = getTypePaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementTotal();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree#registerEventInTimeRange
+ * (org.eclipse.linuxtools.tmf.core.event.ITmfEvent, org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo)
+ */
+ @Override
+ public void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo) {
+ TmfFixedArray<String>[] paths = getNormalPaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementPartial();
+ }
+
+ paths = getTypePaths(event, extraInfo);
+ for (TmfFixedArray<String> path : paths) {
+ getOrCreate(path).getValue().incrementPartial();
+ }
+ }
+
+ /**
+ * Get the event types paths.
+ *
+ * @param event
+ * Event to get the path for.
+ * @param extraInfo
+ * Extra information to pass along with the event
+ * @return Array of FixedArray representing the paths.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ protected TmfFixedArray<String>[] getTypePaths(ITmfEvent event, ITmfExtraEventInfo extraInfo) {
+ String trace = extraInfo.getTraceName();
+ // String type = event.getType().getTypeId(); // Add too much
+ // informations
+ String type = event.getType().toString();
+
+ TmfFixedArray[] paths = { new TmfFixedArray<String>(trace, HEADER_EVENT_TYPES, type) };
+
+ return paths;
+ }
+
+ /**
+ * Get the standard paths for an event.
+ *
+ * @param event
+ * Event to get the path for.
+ * @param extraInfo
+ * Extra information to pass along with the event
+ * @return Array of FixedArray representing the paths.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ protected TmfFixedArray<String>[] getNormalPaths(ITmfEvent event, ITmfExtraEventInfo extraInfo) {
+ String trace = extraInfo.getTraceName();
+
+ TmfFixedArray[] paths = { new TmfFixedArray<String>(trace) };
+ return paths;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree#registerName
+ * (org.eclipse.linuxtools.tmf.core.util.TmfFixedArray)
+ */
+ @Override
+ protected void registerName(TmfFixedArray<String> path) {
+ if (path.size() == 1) {
+ if (!path.equals(ROOT)) {
+ getKeys().get(ROOT.get(0)).add(path.get(0));
+ }
+ } else if (path.size() % 2 != 0) {
+ getKeys().get(path.get(path.size() - 2)).add(path.get(path.size() - 1));
+ }
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatistics.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatistics.java
new file mode 100755
index 0000000000..a6fffd5cc9
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatistics.java
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Intial API and Implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+/**
+ * Primitive container for Statistics data
+ *
+ * Contains information about statistics that can be retrieved with any type of
+ * traces
+ *
+ * There are two counters : one for the total number of events in the trace and
+ * another for the number of events in the selected time range
+ *
+ * @version 2.0
+ * @version 2.0
+ * @since 2.0
+ * @author Mathieu Denis
+ */
+public class TmfStatistics {
+
+ /**
+ * Total number of events.
+ *
+ * @since 2.0
+ */
+ protected long fNbEvents = 0;
+
+ /**
+ * Number of events within a time range (Partial event count).
+ *
+ * @since 2.0
+ */
+ protected long fNbEventsInTimeRange = 0;
+
+ /**
+ * @return the total events count
+ * @since 2.0
+ */
+ public long getTotal() {
+ return fNbEvents;
+ }
+
+ /**
+ * @return the partial events count within a time range
+ * @since 2.0
+ */
+ public long getPartial() {
+ return fNbEventsInTimeRange;
+ }
+
+ /**
+ * Increments by one the total number of events.
+ *
+ * @since 2.0
+ */
+ public void incrementTotal() {
+ ++fNbEvents;
+ }
+
+ /**
+ * Increments <b>nb</b> times the total number of events.
+ *
+ * @param nb
+ * Amount that will be added to the total events count. Ignored
+ * if negative.
+ * @since 2.0
+ */
+ public void incrementTotal(int nb) {
+ if (nb > 0) {
+ fNbEvents += nb;
+ }
+ }
+
+ /**
+ * Increments by one the number of events within a time range (partial events
+ * count).
+ *
+ * @since 2.0
+ */
+ public void incrementPartial() {
+ ++fNbEventsInTimeRange;
+ }
+
+ /**
+ * Increments <b>nb</b> times the number of events within a time range
+ * (partial events count).
+ *
+ * @param nb
+ * Amount that will be added to the partial events count. Ignored
+ * if negative.
+ * @since 2.0
+ */
+ public void incrementPartial(int nb) {
+ if (nb > 0) {
+ fNbEventsInTimeRange += nb;
+ }
+ }
+
+ /**
+ * Resets the total number of events.
+ *
+ * @since 2.0
+ */
+ public void resetTotalCount() {
+ fNbEvents = 0;
+ }
+
+ /**
+ * Resets the number of events within a time range (partial events count).
+ *
+ * @since 2.0
+ */
+ public void resetPartialCount() {
+ fNbEventsInTimeRange = 0;
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java
new file mode 100755
index 0000000000..95a4dcd011
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java
@@ -0,0 +1,170 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Yann N. Dauphin <dhaemon@gmail.com> - Implementation for stats
+ * Francois Godin <copelnug@gmail.com> - Re-design for new stats structure
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Re-design for new stats structure (2)
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import java.util.Collection;
+
+import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray;
+
+/**
+ * A tree where nodes can be accessed efficiently using paths.
+ *
+ * It works like file systems. Each node is identified by a key. A path is an
+ * array ({@link TmfFixedArray}) of String. The elements of the array represent
+ * the path from the root to this node.
+ *
+ * @version 2.0
+ * @since 2.0
+ * @author Mathieu Denis
+ */
+public class TmfStatisticsTreeNode {
+
+ /**
+ * Value of the node.
+ */
+ protected TmfStatistics fValue;
+
+ /**
+ * Path of the node.
+ */
+ protected TmfFixedArray<String> fPath;
+
+ /**
+ * Corresponding StatisticsData.
+ */
+ protected AbsTmfStatisticsTree fNodes;
+
+ /**
+ * Constructor.
+ *
+ * @param path
+ * Path to the node.
+ * @param nodes
+ * Corresponding StatisticsData.
+ */
+ public TmfStatisticsTreeNode(final TmfFixedArray<String> path,
+ AbsTmfStatisticsTree nodes) {
+ fPath = path;
+ fNodes = nodes;
+ fValue = new TmfStatistics();
+ }
+
+ /**
+ * Test if a node contain the specified child.
+ *
+ * @param key
+ * Name of the child.
+ * @return true: if child with given key is present, false: if no child
+ * exists with given key name
+ */
+ public boolean containsChild(String key) {
+ if (AbsTmfStatisticsTree.ROOT.equals(fPath)) {
+ return fNodes.get(new TmfFixedArray<String>(key)) != null;
+ }
+ return (fNodes.get(fPath.append(key)) != null);
+ }
+
+ /**
+ * Get the children of this node.
+ *
+ * @return Direct children of this node.
+ */
+ public Collection<TmfStatisticsTreeNode> getChildren() {
+ return fNodes.getChildren(fPath);
+ }
+
+ /**
+ * Get the children of this node.
+ *
+ * @return Direct children of this node.
+ */
+ public Collection<TmfStatisticsTreeNode> getAllChildren() {
+ return fNodes.getAllChildren(fPath);
+ }
+
+ /**
+ * Get the key for this node.
+ *
+ * @return Key associated with this node.
+ */
+ public String getKey() {
+ return fPath.get(fPath.size() - 1);
+ }
+
+ /**
+ * Get the number of children this node have.
+ *
+ * @return Number of direct children of this node.
+ */
+ public int getNbChildren() {
+ return fNodes.getChildren(fPath).size();
+ }
+
+ /**
+ * Return the parent node.
+ *
+ * @return Parent node.
+ */
+ public TmfStatisticsTreeNode getParent() {
+ return fNodes.getParent(fPath);
+ }
+
+ /**
+ * Get the path of the node.
+ *
+ * @return The path of the node.
+ */
+ public TmfFixedArray<String> getPath() {
+ return fPath;
+ }
+
+ /**
+ * Get the value of this node.
+ *
+ * @return Value associated with this node.
+ */
+ public TmfStatistics getValue() {
+ return fValue;
+ }
+
+ /**
+ * Indicate if the node have children.
+ *
+ * @return True if the node has children.
+ */
+ public boolean hasChildren() {
+ return !fNodes.getChildren(fPath).isEmpty();
+ }
+
+ /**
+ * Start from creation time i.e. keep key and parent but new statistics and
+ * no children.
+ */
+ public void reset() {
+ fValue = new TmfStatistics();
+ fNodes.reset(fPath);
+ }
+
+ /**
+ * Resets the number of events in the time range. It doesn't remove any node
+ * and doesn't modify the global event count.
+ *
+ * @since 2.0
+ */
+ public void resetTimeRangeValue() {
+ getValue().resetPartialCount();
+ fNodes.resetTimeRangeValue(fPath);
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeRootFactory.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeRootFactory.java
new file mode 100755
index 0000000000..1e7eca4c1a
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeRootFactory.java
@@ -0,0 +1,119 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Factory class to create and store TMF statistic trees.
+ *
+ * Based on a given tree node ID a TMF statistic tree is stored internally. A
+ * root node is created for each tree. Using the tree node ID the statistics
+ * tree can be retrieved.
+ *
+ * @version 2.0
+ * @since 2.0
+ * @author Mathieu Denis
+ */
+public class TmfStatisticsTreeRootFactory {
+
+ /**
+ * Contains the experiment name as the key and the traces data
+ */
+ private static final Map<String, AbsTmfStatisticsTree> fTreeInstances = new HashMap<String, AbsTmfStatisticsTree>();
+
+ /**
+ * Provide a statisticsTree instance per trace
+ *
+ * @param traceUniqueId
+ * Unique ID for the trace
+ * @return the corresponding trace statistics tree
+ */
+ public static TmfStatisticsTreeNode getStatTreeRoot(String traceUniqueId) {
+
+ AbsTmfStatisticsTree tree = getStatTree(traceUniqueId);
+ if (tree == null) {
+ return null;
+ }
+ return tree.getOrCreate(AbsTmfStatisticsTree.ROOT);
+ }
+
+ /**
+ * Get the tree that's being used for statistics
+ *
+ * @param traceUniqueId
+ * Unique ID for the trace
+ * @return the corresponding trace statistics tree
+ */
+ public static AbsTmfStatisticsTree getStatTree(String traceUniqueId) {
+ if (traceUniqueId == null) {
+ return null;
+ }
+
+ AbsTmfStatisticsTree tree = fTreeInstances.get(traceUniqueId);
+ return tree;
+ }
+
+ /**
+ * Add the new trace statistics data in the tree. Can be used later on if
+ * the same traces is selected back.
+ *
+ * @param traceUniqueId
+ * The name of the trace which will be used as a key to store the
+ * data. Must be different for each traces, otherwise the traces
+ * might be overwritten which would trigger a reload of the same
+ * trace.
+ * @param statsData
+ * The information about the trace
+ */
+ public static void addStatsTreeRoot(String traceUniqueId, AbsTmfStatisticsTree statsData) {
+ if (traceUniqueId == null || statsData == null) {
+ return;
+ }
+
+ fTreeInstances.put(traceUniqueId, statsData);
+ // if called for the first time, create the root node
+ statsData.getOrCreate(AbsTmfStatisticsTree.ROOT);
+ }
+
+ /**
+ * Return if the given trace is currently known by the statistics manager.
+ *
+ * @param traceUniqueId
+ * The unique ID of the trace
+ * @return true if the trace id is known
+ */
+ public static boolean containsTreeRoot(String traceUniqueId) {
+ return fTreeInstances.containsKey(traceUniqueId);
+ }
+
+ /**
+ * Remove previously registered statistics tree.
+ *
+ * @param traceUniqueId
+ * The unique ID of the trace
+ */
+ public static void removeStatTreeRoot(String traceUniqueId) {
+ if (traceUniqueId != null && fTreeInstances.containsKey(traceUniqueId)) {
+ fTreeInstances.remove(traceUniqueId);
+ }
+ }
+
+ /**
+ * Remove all tree and root instances
+ */
+ public static void removeAll() {
+ fTreeInstances.clear();
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java
new file mode 100755
index 0000000000..d6bc3cf32a
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.viewers.statistics.model;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Adapter TreeViewers can use to interact with StatisticsTreeNode objects.
+ *
+ * @version 2.0
+ * @since 2.0
+ * @author Mathieu Denis
+ * @see org.eclipse.jface.viewers.ITreeContentProvider
+ */
+public class TmfTreeContentProvider implements ITreeContentProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ return ((TmfStatisticsTreeNode) parentElement).getChildren().toArray();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object element) {
+ return ((TmfStatisticsTreeNode) element).getParent();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ return ((TmfStatisticsTreeNode) element).hasChildren();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/messages.properties
new file mode 100755
index 0000000000..442d278a76
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/messages.properties
@@ -0,0 +1,2 @@
+TmfStatisticsData_CPUs=CPUs
+TmfStatisticsData_EventTypes=Event Types \ No newline at end of file

Back to the top