From 1f0bb2ddf8727c4631810c7b835db28f835ff4a7 Mon Sep 17 00:00:00 2001 From: Mathieu Denis Date: Tue, 31 Jul 2012 17:32:48 -0400 Subject: tmf: Generalization of the statistics view The creation of the statistics view is now based on the type of the trace selected and his plugin definition. Thus, it is easier to provide a new implementation of the statistics for a different kind of trace. Change-Id: If105007a5f349565c14cdf6e5e084a4ab5d227b3 Signed-off-by: Mathieu Denis Reviewed-on: https://git.eclipse.org/r/7041 Reviewed-by: Alexandre Montplaisir IP-Clean: Alexandre Montplaisir Tested-by: Alexandre Montplaisir Reviewed-by: Bernd Hufmann IP-Clean: Bernd Hufmann --- .../statistics/TmfBaseColumnDataProviderTest.java | 18 +- .../ui/tests/statistics/TmfBaseColumnDataTest.java | 8 +- .../statistics/TmfBaseStatisticsDataTest.java | 10 +- .../statistics/TmfStatisticsTreeNodeTest.java | 10 +- .../TmfStatisticsTreeRootFactoryTest.java | 8 +- .../statistics/TmfTreeContentProviderTest.java | 12 +- .../META-INF/MANIFEST.MF | 3 +- .../org.eclipse.linuxtools.tmf.ui.tracetype.exsd | 23 + .../tmf/ui/project/model/TmfTraceType.java | 20 +- .../ui/viewers/statistics/ITmfExtraEventInfo.java | 32 ++ .../tmf/ui/viewers/statistics/Messages.java | 72 +++ .../ui/viewers/statistics/TmfStatisticsViewer.java | 323 +++++++++++ .../tmf/ui/viewers/statistics/messages.properties | 7 + .../statistics/model/AbsTmfStatisticsTree.java | 233 ++++++++ .../statistics/model/ITmfColumnDataProvider.java | 34 ++ .../statistics/model/ITmfStatisticsColumnData.java | 81 +++ .../tmf/ui/viewers/statistics/model/Messages.java | 45 ++ .../statistics/model/TmfBaseColumnData.java | 174 ++++++ .../model/TmfBaseColumnDataProvider.java | 189 +++++++ .../statistics/model/TmfBaseStatisticsTree.java | 262 +++++++++ .../ui/viewers/statistics/model/TmfStatistics.java | 126 +++++ .../statistics/model/TmfStatisticsTreeNode.java | 170 ++++++ .../model/TmfStatisticsTreeRootFactory.java | 119 ++++ .../statistics/model/TmfTreeContentProvider.java | 85 +++ .../viewers/statistics/model/messages.properties | 2 + .../ui/views/statistics/ITmfExtraEventInfo.java | 31 -- .../tmf/ui/views/statistics/Messages.java | 62 --- .../ui/views/statistics/TmfStatisticsRequest.java | 21 +- .../tmf/ui/views/statistics/TmfStatisticsView.java | 608 +++++++++------------ .../tmf/ui/views/statistics/messages.properties | 7 - .../statistics/model/AbsTmfStatisticsTree.java | 232 -------- .../statistics/model/ITmfColumnDataProvider.java | 33 -- .../statistics/model/ITmfStatisticsColumnData.java | 80 --- .../tmf/ui/views/statistics/model/Messages.java | 44 -- .../views/statistics/model/TmfBaseColumnData.java | 173 ------ .../model/TmfBaseColumnDataProvider.java | 188 ------- .../statistics/model/TmfBaseStatisticsTree.java | 256 --------- .../ui/views/statistics/model/TmfStatistics.java | 122 ----- .../statistics/model/TmfStatisticsTreeNode.java | 169 ------ .../model/TmfStatisticsTreeRootFactory.java | 119 ---- .../statistics/model/TmfTreeContentProvider.java | 83 --- .../ui/views/statistics/model/messages.properties | 2 - 42 files changed, 2308 insertions(+), 1988 deletions(-) create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/ITmfExtraEventInfo.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java create mode 100644 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/messages.properties create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/AbsTmfStatisticsTree.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfColumnDataProvider.java create mode 100644 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/ITmfStatisticsColumnData.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/Messages.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnData.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseColumnDataProvider.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfBaseStatisticsTree.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatistics.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeNode.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfStatisticsTreeRootFactory.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/TmfTreeContentProvider.java create mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/model/messages.properties delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/ITmfExtraEventInfo.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/messages.properties delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfColumnDataProvider.java delete mode 100644 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfStatisticsColumnData.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/Messages.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnData.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseStatisticsTree.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatistics.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatisticsTreeNode.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatisticsTreeRootFactory.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfTreeContentProvider.java delete mode 100755 lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/messages.properties diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java index 49a3a3aa3a..1586ea5beb 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataProviderTest.java @@ -24,13 +24,13 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; -import org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfExtraEventInfo; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.Messages; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnData; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnDataProvider; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnDataProvider; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; /** * TmfBaseColumnDataProvider test cases. @@ -41,8 +41,8 @@ public class TmfBaseColumnDataProviderTest extends TestCase { // ------------------------------------------------------------------------ // Fields // ------------------------------------------------------------------------ - private final static String LEVEL_COLUMN = org.eclipse.linuxtools.tmf.ui.views.statistics.Messages.TmfStatisticsView_LevelColumn; - private final static String EVENTS_COUNT_COLUMN = org.eclipse.linuxtools.tmf.ui.views.statistics.Messages.TmfStatisticsView_NbEventsColumn; + private final static String LEVEL_COLUMN = org.eclipse.linuxtools.tmf.ui.viewers.statistics.Messages.TmfStatisticsView_LevelColumn; + private final static String EVENTS_COUNT_COLUMN = org.eclipse.linuxtools.tmf.ui.viewers.statistics.Messages.TmfStatisticsView_NbEventsColumn; private TmfBaseColumnDataProvider provider; diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java index 89bef92cc3..4746d4d7dc 100755 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseColumnDataTest.java @@ -18,10 +18,10 @@ import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnData; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java index 2ed137a4c2..95399ab91f 100755 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfBaseStatisticsDataTest.java @@ -25,11 +25,11 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; -import org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfExtraEventInfo; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.Messages; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; /** * TmfBaseStatistics Test Cases. diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java index e329df91c0..4a6e12ddae 100755 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeNodeTest.java @@ -25,11 +25,11 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; -import org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfExtraEventInfo; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.Messages; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; /** * TmfStatisticsTreeNode Test Cases. diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeRootFactoryTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeRootFactoryTest.java index ca8512c027..1b35472a83 100755 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeRootFactoryTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfStatisticsTreeRootFactoryTest.java @@ -15,10 +15,10 @@ package org.eclipse.linuxtools.tmf.ui.tests.statistics; import junit.framework.TestCase; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeRootFactory; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeRootFactory; /** * TmfStatisticsTreeRootFactory Test Case. diff --git a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java index 8f81c9e168..8410505da5 100755 --- a/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui.tests/src/org/eclipse/linuxtools/tmf/ui/tests/statistics/TmfTreeContentProviderTest.java @@ -25,12 +25,12 @@ import org.eclipse.linuxtools.tmf.core.event.TmfEventField; import org.eclipse.linuxtools.tmf.core.event.TmfEventType; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.util.TmfFixedArray; -import org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfExtraEventInfo; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.Messages; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfTreeContentProvider; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.Messages; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfTreeContentProvider; /** * TmfTreeContentProvider Test Cases. diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF index 79751e3689..536752a6b3 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF +++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF @@ -30,6 +30,8 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l org.eclipse.linuxtools.tmf.ui.project.wizards, org.eclipse.linuxtools.tmf.ui.signal, org.eclipse.linuxtools.tmf.ui.viewers.events, + org.eclipse.linuxtools.tmf.ui.viewers.statistics, + org.eclipse.linuxtools.tmf.ui.viewers.statistics.model, org.eclipse.linuxtools.tmf.ui.views, org.eclipse.linuxtools.tmf.ui.views.colors, org.eclipse.linuxtools.tmf.ui.views.distribution.model, @@ -38,7 +40,6 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l org.eclipse.linuxtools.tmf.ui.views.filter, org.eclipse.linuxtools.tmf.ui.views.histogram, org.eclipse.linuxtools.tmf.ui.views.statistics, - org.eclipse.linuxtools.tmf.ui.views.statistics.model, org.eclipse.linuxtools.tmf.ui.views.timechart, org.eclipse.linuxtools.tmf.ui.views.uml2sd, org.eclipse.linuxtools.tmf.ui.views.uml2sd.core, diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd b/lttng/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd index 758a884e2f..14ec4cb376 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd +++ b/lttng/org.eclipse.linuxtools.tmf.ui/schema/org.eclipse.linuxtools.tmf.ui.tracetype.exsd @@ -72,6 +72,7 @@ + @@ -171,6 +172,28 @@ If empty, the default events table will be used. + + + + The statistics viewer to use for this trace type. +If omitted, the default statistics viewer will be used. + + + + + + + The fully qualified name of a class that extends <samp>TmfStatisticsViewer</samp> . +If empty, the default statistics viewer will be used. + + + + + + + + + diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java index 667496c23e..dc0c206496 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/project/model/TmfTraceType.java @@ -1,11 +1,11 @@ /******************************************************************************* * 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: * Patrick Tasse - Initial API and implementation *******************************************************************************/ @@ -20,7 +20,7 @@ import org.eclipse.core.runtime.Platform; /** * Utility class for accessing TMF trace type extensions from the platform's extensions registry. - * + * * @version 1.0 * @author Patrick Tasse * @@ -41,13 +41,19 @@ public class TmfTraceType { */ public static final String TYPE_ELEM = "type"; //$NON-NLS-1$ /** - * Extension point element 'Default editor' + * Extension point element 'Default editor' */ public static final String DEFAULT_EDITOR_ELEM = "defaultEditor"; //$NON-NLS-1$ /** * Extension point element 'Events table type' */ public static final String EVENTS_TABLE_TYPE_ELEM = "eventsTableType"; //$NON-NLS-1$ + /** + * Extension point element 'Statistics viewer type' + * + * @since 2.0 + */ + public static final String STATISTICS_VIEWER_ELEM = "statisticsViewerType"; //$NON-NLS-1$ /** * Extension point attribute 'ID' @@ -95,10 +101,10 @@ public class TmfTraceType { } /** - * Retrieves all configuration elements from the platform extension registry + * Retrieves all configuration elements from the platform extension registry * for the trace type extension. - * - * @return an array of trace type configuration elements + * + * @return an array of trace type configuration elements */ public static IConfigurationElement[] getTypeElements() { IConfigurationElement[] elements = Platform.getExtensionRegistry() diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/ITmfExtraEventInfo.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/ITmfExtraEventInfo.java new file mode 100755 index 0000000000..0a507ebb82 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/ITmfExtraEventInfo.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * 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 - Initial design and implementation + * Bernd Hufmann - Changed interface and class name + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.viewers.statistics; + +/** + * This interface provides an extension for updating the data model and to pass + * along more information beside events. + * + * @version 2.0 + * @author Mathieu Denis + * @since 2.0 + */ +public interface ITmfExtraEventInfo { + + /** + * Returns the trace name. + * + * @return the name of the trace. + */ + public String getTraceName(); +} diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java new file mode 100755 index 0000000000..a27be40859 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/Messages.java @@ -0,0 +1,72 @@ +/******************************************************************************* + * 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 - Initial API and Implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.viewers.statistics; + +import org.eclipse.osgi.util.NLS; + +/** + * Messages file for statistics view strings. + * + * @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.messages"; //$NON-NLS-1$ + + /** + * Level column name + */ + public static String TmfStatisticsView_LevelColumn; + + /** + * Level column tool tip. + */ + public static String TmfStatisticsView_LevelColumnTip; + + /** + * Number of events column name. + */ + public static String TmfStatisticsView_NbEventsColumn; + + /** + * Number of events column tool tip. + */ + public static String TmfStatisticsView_NbEventsTip; + + /** + * Partial number of events column. + * @since 2.0 + */ + public static String TmfStatisticsView_NbEventsTimeRangeColumn; + + /** + * Partial number of events column tool tip. + * @since 2.0 + */ + public static String TmfStatisticsView_NbEventsTimeRangeTip; + + /** + * String for unknown trace name. + */ + public static String TmfStatisticsView_UnknownTraceName; + + 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/TmfStatisticsViewer.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java new file mode 100644 index 0000000000..103913cf61 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java @@ -0,0 +1,323 @@ +/******************************************************************************* + * Copyright (c) 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 - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.linuxtools.tmf.ui.viewers.statistics; + +import java.util.List; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.TreeViewerColumn; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.linuxtools.tmf.core.component.TmfComponent; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.ITmfColumnDataProvider; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnData; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseColumnDataProvider; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfBaseStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeRootFactory; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfTreeContentProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Cursor; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; + +/** + * A basic viewer to display statistics in the statistics view. + * + * @author Mathieu Denis + * @version 2.0 + * @since 2.0 + */ +public class TmfStatisticsViewer extends TmfComponent { + + /** + * Refresh frequency + */ + protected static final Long STATS_INPUT_CHANGED_REFRESH = 5000L; + + /** + * The actual tree viewer to display + */ + protected TreeViewer fTreeViewer; + + /** + * View instance counter (for multiple statistic views) + */ + private static int fCountInstance = 0; + + /** + * Number of this instance. Used as an instance ID. + */ + private int fInstanceNb; + + /** + * Object to store the cursor while waiting for the experiment to load + */ + private Cursor fWaitCursor = null; + + /** + * Default constructor + * + * @param parent + * The parent of this viewer + */ + public TmfStatisticsViewer(Composite parent) { + // Increment a counter to make sure the tree ID is unique. + fCountInstance++; + fInstanceNb = fCountInstance; + + final List columnDataList = getColumnDataProvider().getColumnData(); + parent.setLayout(new FillLayout()); + + fTreeViewer = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + fTreeViewer.setContentProvider(new TmfTreeContentProvider()); + fTreeViewer.getTree().setHeaderVisible(true); + fTreeViewer.setUseHashlookup(true); + + // Creates the columns defined by the column data provider + for (final TmfBaseColumnData columnData : columnDataList) { + final TreeViewerColumn treeColumn = new TreeViewerColumn(fTreeViewer, columnData.getAlignment()); + treeColumn.getColumn().setText(columnData.getHeader()); + treeColumn.getColumn().setWidth(columnData.getWidth()); + treeColumn.getColumn().setToolTipText(columnData.getTooltip()); + + if (columnData.getComparator() != null) { // A comparator is defined. + // Adds a listener on the columns header for sorting purpose. + treeColumn.getColumn().addSelectionListener(new SelectionAdapter() { + + private ViewerComparator reverseComparator; + + @Override + public void widgetSelected(SelectionEvent e) { + // Initializes the reverse comparator once. + if (reverseComparator == null) { + reverseComparator = new ViewerComparator() { + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + return -1 * columnData.getComparator().compare(viewer, e1, e2); + } + }; + } + + if (fTreeViewer.getTree().getSortDirection() == SWT.UP + || fTreeViewer.getTree().getSortColumn() != treeColumn.getColumn()) { + /* + * Puts the descendant order if the old order was + * up or if the selected column has changed. + */ + fTreeViewer.setComparator(columnData.getComparator()); + fTreeViewer.getTree().setSortDirection(SWT.DOWN); + } else { + /* + * Puts the ascendant ordering if the selected + * column hasn't changed. + */ + fTreeViewer.setComparator(reverseComparator); + fTreeViewer.getTree().setSortDirection(SWT.UP); + } + fTreeViewer.getTree().setSortColumn(treeColumn.getColumn()); + } + }); + } + treeColumn.setLabelProvider(columnData.getLabelProvider()); + } + + // Handler that will draw the bar charts. + fTreeViewer.getTree().addListener(SWT.EraseItem, new Listener() { + @Override + public void handleEvent(Event event) { + if (columnDataList.get(event.index).getPercentageProvider() != null) { + TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) event.item.getData(); + + double percentage = columnDataList.get(event.index).getPercentageProvider().getPercentage(node); + if (percentage == 0) { // No bar to draw + return; + } + + if ((event.detail & SWT.SELECTED) > 0) { // The item is selected. + // Draws our own background to avoid overwritten the bar. + event.gc.fillRectangle(event.x, event.y, event.width, event.height); + event.detail &= ~SWT.SELECTED; + } + + int barWidth = (int) ((fTreeViewer.getTree().getColumn(event.index).getWidth() - 8) * percentage); + int oldAlpha = event.gc.getAlpha(); + Color oldForeground = event.gc.getForeground(); + Color oldBackground = event.gc.getBackground(); + /* + * Draws a transparent gradient rectangle from the color of + * foreground and background. + */ + event.gc.setAlpha(64); + event.gc.setForeground(event.item.getDisplay().getSystemColor(SWT.COLOR_BLUE)); + event.gc.setBackground(event.item.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); + event.gc.fillGradientRectangle(event.x, event.y, barWidth, event.height, true); + event.gc.drawRectangle(event.x, event.y, barWidth, event.height); + // Restores old values + event.gc.setForeground(oldForeground); + event.gc.setBackground(oldBackground); + event.gc.setAlpha(oldAlpha); + event.detail &= ~SWT.BACKGROUND; + } + } + }); + + // Initializes the comparator parameters + fTreeViewer.setComparator(columnDataList.get(0).getComparator()); + fTreeViewer.getTree().setSortColumn(fTreeViewer.getTree().getColumn(0)); + fTreeViewer.getTree().setSortDirection(SWT.DOWN); + } + + /** + * Refreshes this viewer completely with information freshly obtained from + * this viewer's model. + */ + public void refresh() { + fTreeViewer.refresh(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.tmf.core.component.TmfComponent#dispose() + */ + @Override + public void dispose() { + if (fWaitCursor != null) { + fWaitCursor.dispose(); + } + fTreeViewer.getControl().dispose(); + super.dispose(); + // clean the model + TmfStatisticsTreeRootFactory.removeAll(); + } + + /** + * Focus on the statistics tree of the viewer + */ + public void setFocus() { + fTreeViewer.getTree().setFocus(); + } + + /** + * Sets or clears the input for this viewer. + * + * @param input + * The input of this viewer, or null if none + */ + public void setInput(TmfStatisticsTreeNode input) { + fTreeViewer.setInput(input); + } + + /** + * Returns the quantity of data to retrieve before a refresh of the view is + * performed + * + * @return the quantity of data to retrieve before a refresh of the view is + * performed. + */ + public long getInputChangedRefresh() { + return STATS_INPUT_CHANGED_REFRESH; + } + + /** + * This method can be overridden to implement another way to represent the + * statistics data and to retrieve the information for display. + * + * @return a TmfStatisticsData object. + */ + public AbsTmfStatisticsTree getStatisticData() { + return new TmfBaseStatisticsTree(); + } + + /** + * Get the input of the viewer + * + * @return an object representing the input of the statistics viewer + */ + public Object getInput() { + return fTreeViewer.getInput(); + } + + /** + * Returns the primary control associated with this viewer. + * + * @return the SWT control which displays this viewer's content + */ + public Control getControl() { + return fTreeViewer.getControl(); + } + + /** + * When the experiment is loading the cursor will be different so the user + * know the processing is not finished yet. + * + * @param waitInd + * Indicates if we need to show the waiting cursor, or the + * default one + */ + public void waitCursor(final boolean waitInd) { + if ((fTreeViewer == null) || (fTreeViewer.getTree().isDisposed())) { + return; + } + + Display display = fTreeViewer.getControl().getDisplay(); + if (fWaitCursor == null) { + fWaitCursor = new Cursor(display, SWT.CURSOR_WAIT); + } + + // Perform the updates on the UI thread + display.asyncExec(new Runnable() { + @Override + public void run() { + if ((fTreeViewer != null) + && (!fTreeViewer.getTree().isDisposed())) { + Cursor cursor = null; /* indicates default */ + if (waitInd) { + cursor = fWaitCursor; + } + fTreeViewer.getControl().setCursor(cursor); + } + } + }); + } + + /** + * Constructs the ID based on the experiment name and the instance number + * + * @param name + * The name of the trace to show in the view + * @return a view ID + */ + public String getTreeID(String name) { + return name + fInstanceNb; + } + + /** + * This method can be overridden to change the representation of the data in + * the columns. + * + * @return an object implementing ITmfBaseColumnDataProvider. + */ + protected ITmfColumnDataProvider getColumnDataProvider() { + return new TmfBaseColumnDataProvider(); + } +} diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/messages.properties new file mode 100755 index 0000000000..2542d73b09 --- /dev/null +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/messages.properties @@ -0,0 +1,7 @@ +TmfStatisticsView_LevelColumn=Level +TmfStatisticsView_LevelColumnTip=Level at which statistics apply. +TmfStatisticsView_NbEventsColumn=Global event count +TmfStatisticsView_NbEventsTip=Total amount of events that are tied to given resource. +TmfStatisticsView_NbEventsTimeRangeColumn=Partial event count +TmfStatisticsView_NbEventsTimeRangeTip=Number of events in the selected time range +TmfStatisticsView_UnknownTraceName=Unknown_Trace 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 - 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 ROOT = new TmfFixedArray("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> fKeys; + + /** + * The nodes in the tree. + */ + protected HashMap, TmfStatisticsTreeNode> fNodes; + + /** + * Constructor. + */ + public AbsTmfStatisticsTree() { + fNodes = new HashMap, TmfStatisticsTreeNode>(); + fKeys = new HashMap>(); + } + + /** + * Get a node. + * + * @param path + * Path to the node. + * @return The node or null. + */ + public TmfStatisticsTreeNode get(final TmfFixedArray 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 getChildren(final TmfFixedArray 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 getAllChildren(final TmfFixedArray path); + + /** + * Get the map of existing elements of path classified by parent. + * + * @return The map. + */ + public Map> getKeys() { + return fKeys; + } + + /** + * Get or create a node. + * + * @param path + * Path to the node. + * @return The node. + */ + public TmfStatisticsTreeNode getOrCreate(final TmfFixedArray 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 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 path); + + /** + * Reset a node. + * + * Works recursively. + * + * @param path + * Path to the node. + */ + public void reset(final TmfFixedArray 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 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 - 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 + * TmfStatisticsView 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 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 - 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 - 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 - 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 - 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 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 fFolderLevels = new HashSet(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(); + /* 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 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 - 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> keys = getKeys(); + + // //////////// Adding category sets + // common + keys.put(HEADER_EVENT_TYPES, new HashSet()); + + // /////////// Adding value sets + // Under a trace + Set temp = new HashSet(8); + temp.add(HEADER_EVENT_TYPES); + keys.put(ROOT_NODE_KEY, temp); + // Under an event type + temp = new HashSet(16); + keys.put(mergeString(HEADER_EVENT_TYPES, NODE), temp); + + // //////////// CREATE root + keys.put(ROOT.get(0), new HashSet(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 getChildren(TmfFixedArray path) { + LinkedList result = new LinkedList(); + + 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(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 getAllChildren(TmfFixedArray path) { + LinkedList result = new LinkedList(); + + 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(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[] paths = getNormalPaths(event, extraInfo); + for (TmfFixedArray path : paths) { + getOrCreate(path).getValue().incrementTotal(); + } + + paths = getTypePaths(event, extraInfo); + for (TmfFixedArray 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[] paths = getNormalPaths(event, extraInfo); + for (TmfFixedArray path : paths) { + getOrCreate(path).getValue().incrementPartial(); + } + + paths = getTypePaths(event, extraInfo); + for (TmfFixedArray 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[] 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(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[] getNormalPaths(ITmfEvent event, ITmfExtraEventInfo extraInfo) { + String trace = extraInfo.getTraceName(); + + TmfFixedArray[] paths = { new TmfFixedArray(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 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 - 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 nb 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 nb 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 - Implementation for stats + * Francois Godin - Re-design for new stats structure + * Mathieu Denis - 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 fPath; + + /** + * Corresponding StatisticsData. + */ + protected AbsTmfStatisticsTree fNodes; + + /** + * Constructor. + * + * @param path + * Path to the node. + * @param nodes + * Corresponding StatisticsData. + */ + public TmfStatisticsTreeNode(final TmfFixedArray 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(key)) != null; + } + return (fNodes.get(fPath.append(key)) != null); + } + + /** + * Get the children of this node. + * + * @return Direct children of this node. + */ + public Collection getChildren() { + return fNodes.getChildren(fPath); + } + + /** + * Get the children of this node. + * + * @return Direct children of this node. + */ + public Collection 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 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 - 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 fTreeInstances = new HashMap(); + + /** + * 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 - 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 diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/ITmfExtraEventInfo.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/ITmfExtraEventInfo.java deleted file mode 100755 index 0ebc8c3783..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/ITmfExtraEventInfo.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * 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 - Initial design and implementation - * Bernd Hufmann - Changed interface and class name - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.statistics; - -/** - * This interface provides an extension for updating the data model and to pass - * along more information beside events. - * - * @version 1.0 - * @author Mathieu Denis - */ -public interface ITmfExtraEventInfo { - - /** - * Returns the trace name. - * - * @return the name of the trace. - */ - public String getTraceName(); -} diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java deleted file mode 100755 index 9d9b9295c9..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/Messages.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * 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 - Initial API and Implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.statistics; - -import org.eclipse.osgi.util.NLS; - -/** - * Messages file for statistics view strings. - * - * @version 2.0 - * @author Mathieu Denis - */ -public class Messages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.statistics.messages"; //$NON-NLS-1$ - /** - * Level column name - */ - public static String TmfStatisticsView_LevelColumn; - /** - * Level column tool tip. - */ - public static String TmfStatisticsView_LevelColumnTip; - /** - * Number of events column name. - */ - public static String TmfStatisticsView_NbEventsColumn; - /** - * Number of events column tool tip. - */ - public static String TmfStatisticsView_NbEventsTip; - /** - * Partial number of events column. - * @since 2.0 - */ - public static String TmfStatisticsView_NbEventsTimeRangeColumn; - /** - * Partial number of events column tool tip. - * @since 2.0 - */ - public static String TmfStatisticsView_NbEventsTimeRangeTip; - /** - * String for unknown trace name. - */ - public static String TmfStatisticsView_UnknownTraceName; - 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/views/statistics/TmfStatisticsRequest.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsRequest.java index 735586b2ec..980b523397 100644 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsRequest.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsRequest.java @@ -17,8 +17,11 @@ import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest; import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeRootFactory; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.ITmfExtraEventInfo; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.Messages; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.TmfStatisticsViewer; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.AbsTmfStatisticsTree; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeRootFactory; /** * Class for the TMF event requests specific to the statistics view. @@ -31,6 +34,11 @@ class TmfStatisticsRequest extends TmfEventRequest { */ private final TmfStatisticsView fSender; + /** + * The viewer that displays the statistics data + */ + private TmfStatisticsViewer fViewer; + /** * The experiment for which to send the request */ @@ -63,11 +71,12 @@ class TmfStatisticsRequest extends TmfEventRequest { * Is this for a global statistics request (true), or a partial * one (false)? */ - TmfStatisticsRequest(TmfStatisticsView sender, TmfExperiment experiment, TmfTimeRange range, long index, ExecutionType prio, boolean global) { + TmfStatisticsRequest(TmfStatisticsView sender, TmfStatisticsViewer viewer, TmfExperiment experiment, TmfTimeRange range, long index, ExecutionType prio, boolean global) { super(ITmfEvent.class, range, index, TmfDataRequest.ALL_DATA, sender.getIndexPageSize(), prio); - String treeID = sender.getTreeID(experiment.getName()); + String treeID = viewer.getTreeID(experiment.getName()); fSender = sender; + fViewer = viewer; fExperiment = experiment; fGlobal = global; fStatisticsData = TmfStatisticsTreeRootFactory.getStatTree(treeID); @@ -94,7 +103,7 @@ class TmfStatisticsRequest extends TmfEventRequest { } fStatisticsData.increase(data, extraInfo, 1); // Refresh view - if ((getNbRead() % fSender.getInputChangedRefresh()) == 0) { + if ((getNbRead() % fViewer.getInputChangedRefresh()) == 0) { fSender.modelInputChanged(false); } } @@ -105,7 +114,7 @@ class TmfStatisticsRequest extends TmfEventRequest { super.handleSuccess(); fSender.modelInputChanged(true); if (fGlobal) { - fSender.waitCursor(false); + fViewer.waitCursor(false); } } diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java index 40f4f6d65c..efe0608215 100755 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java +++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java @@ -10,17 +10,21 @@ * Mathieu Denis - Generalized version based on LTTng * Bernd Hufmann - Updated to use trace reference in TmfEvent and streaming * Mathieu Denis - New request added to update the statistics from the selected time range + * Mathieu Denis - Generalization of the view to instantiate a viewer specific to a trace type * *******************************************************************************/ package org.eclipse.linuxtools.tmf.ui.views.statistics; -import java.util.List; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.TreeViewerColumn; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.linuxtools.internal.tmf.ui.Activator; +import org.eclipse.linuxtools.tmf.core.TmfCommonConstants; import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp; import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType; @@ -33,25 +37,14 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal; import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler; import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; import org.eclipse.linuxtools.tmf.core.trace.TmfExperiment; +import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceType; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.TmfStatisticsViewer; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeNode; +import org.eclipse.linuxtools.tmf.ui.viewers.statistics.model.TmfStatisticsTreeRootFactory; import org.eclipse.linuxtools.tmf.ui.views.TmfView; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfColumnDataProvider; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnData; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnDataProvider; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseStatisticsTree; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeNode; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsTreeRootFactory; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfTreeContentProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Control; +import org.osgi.framework.Bundle; /** * The generic Statistics View displays statistics for any kind of traces. @@ -77,14 +70,14 @@ public class TmfStatisticsView extends TmfView { public static final String TMF_STATISTICS_VIEW = "StatisticsView"; //$NON-NLS-1$ /** - * Refresh frequency + * Stores the request to the experiment */ - protected static final Long STATS_INPUT_CHANGED_REFRESH = 5000L; + protected ITmfEventRequest fRequest = null; /** - * Default PAGE_SIZE for background requests + * The viewer that builds the columns to show the statistics */ - protected static final int PAGE_SIZE = 50000; + private TmfStatisticsViewer fStatsViewer; /** * The initial window span (in nanoseconds) @@ -101,14 +94,24 @@ public class TmfStatisticsView extends TmfView { public static final byte TIME_SCALE = -9; /** - * The actual tree viewer to display + * Stores a reference to the parent composite of this view */ - protected TreeViewer fTreeViewer; + private Composite fParent; /** - * Stores the global request to the experiment + * Stores a reference to the experiment */ - protected ITmfEventRequest fRequest = null; + private TmfExperiment fExperiment; + + /** + * Flag to force request the data from trace + */ + protected boolean fRequestData = false; + + /** + * Default PAGE_SIZE for background requests + */ + protected static final int PAGE_SIZE = 50000; /** * Stores the ranged request to the experiment @@ -139,36 +142,13 @@ public class TmfStatisticsView extends TmfView { */ protected final Object fStatisticsUpdateSyncObj = new Object(); - /** - * Flag to force request the data from trace - */ - protected boolean fRequestData = false; - - /** - * Object to store the cursor while waiting for the experiment to load - */ - private Cursor fWaitCursor = null; - - /** - * View instance counter (for multiple statistic views) - */ - private static int fCountInstance = 0; - - /** - * Number of this instance. Used as an instance ID. - */ - private final int fInstanceNb; - /** * Constructor of a statistics view. * - * @param viewName - * The name to give to the view. + * @param viewName The name to give to the view. */ public TmfStatisticsView(String viewName) { super(viewName); - fCountInstance++; - fInstanceNb = fCountInstance; } /** @@ -186,104 +166,35 @@ public class TmfStatisticsView extends TmfView { */ @Override public void createPartControl(Composite parent) { - final List columnDataList = getColumnDataProvider().getColumnData(); - parent.setLayout(new FillLayout()); - - fTreeViewer = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); - fTreeViewer.setContentProvider(new TmfTreeContentProvider()); - fTreeViewer.getTree().setHeaderVisible(true); - fTreeViewer.setUseHashlookup(true); - - for (final TmfBaseColumnData columnData : columnDataList) { - final TreeViewerColumn treeColumn = new TreeViewerColumn(fTreeViewer, columnData.getAlignment()); - treeColumn.getColumn().setText(columnData.getHeader()); - treeColumn.getColumn().setWidth(columnData.getWidth()); - treeColumn.getColumn().setToolTipText(columnData.getTooltip()); - - if (columnData.getComparator() != null) { - treeColumn.getColumn().addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - if (fTreeViewer.getTree().getSortDirection() == SWT.UP || fTreeViewer.getTree().getSortColumn() != treeColumn.getColumn()) { - fTreeViewer.setComparator(columnData.getComparator()); - fTreeViewer.getTree().setSortDirection(SWT.DOWN); - } else { - fTreeViewer.setComparator(new ViewerComparator() { - @Override - public int compare(Viewer viewer, Object e1, Object e2) { - return -1 * columnData.getComparator().compare(viewer, e1, e2); - } - }); - fTreeViewer.getTree().setSortDirection(SWT.UP); - } - fTreeViewer.getTree().setSortColumn(treeColumn.getColumn()); - } - }); - } - treeColumn.setLabelProvider(columnData.getLabelProvider()); - } - - // Handler that will draw the bar charts. - fTreeViewer.getTree().addListener(SWT.EraseItem, new Listener() { - @Override - public void handleEvent(Event event) { - if (columnDataList.get(event.index).getPercentageProvider() != null) { - TmfStatisticsTreeNode node = (TmfStatisticsTreeNode) event.item.getData(); - - double percentage = columnDataList.get(event.index).getPercentageProvider().getPercentage(node); - if (percentage == 0) { - return; - } - - if ((event.detail & SWT.SELECTED) > 0) { - Color oldForeground = event.gc.getForeground(); - event.gc.setForeground(event.item.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION)); - event.gc.fillRectangle(event.x, event.y, event.width, event.height); - event.gc.setForeground(oldForeground); - event.detail &= ~SWT.SELECTED; - } - - int barWidth = (int) ((fTreeViewer.getTree().getColumn(event.index).getWidth() - 8) * percentage); - int oldAlpha = event.gc.getAlpha(); - Color oldForeground = event.gc.getForeground(); - Color oldBackground = event.gc.getBackground(); - event.gc.setAlpha(64); - event.gc.setForeground(event.item.getDisplay().getSystemColor(SWT.COLOR_BLUE)); - event.gc.setBackground(event.item.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); - event.gc.fillGradientRectangle(event.x, event.y, barWidth, event.height, true); - event.gc.drawRectangle(event.x, event.y, barWidth, event.height); - event.gc.setForeground(oldForeground); - event.gc.setBackground(oldBackground); - event.gc.setAlpha(oldAlpha); - event.detail &= ~SWT.BACKGROUND; - } - } - }); - - fTreeViewer.setComparator(columnDataList.get(0).getComparator()); - fTreeViewer.getTree().setSortColumn(fTreeViewer.getTree().getColumn(0)); - fTreeViewer.getTree().setSortDirection(SWT.DOWN); - + fParent = parent; + TmfExperiment currentExperiment = TmfExperiment.getCurrentExperiment(); // Read current data if any available - TmfExperiment experiment = TmfExperiment.getCurrentExperiment(); - if (experiment != null) { + if (currentExperiment != null) { fRequestData = true; // Insert the statistics data into the tree - TmfExperimentSelectedSignal signal = new TmfExperimentSelectedSignal(this, experiment); + TmfExperimentSelectedSignal signal = new TmfExperimentSelectedSignal(this, currentExperiment); experimentSelected(signal); + return; } + fStatsViewer = createStatisticsViewer(); + /* + * Updates the experiment field only at the end because + * experimentSelected signal verifies the old selected experiment to + * avoid reloading the same trace. + */ + fExperiment = currentExperiment; } - /* - * (non-Javadoc) + /** + * Handles the signal about disposal of the current experiment. * - * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#dispose() + * @param signal + * The disposed signal */ - @Override - public void dispose() { - super.dispose(); - if (fWaitCursor != null) { - fWaitCursor.dispose(); + @TmfSignalHandler + public void experimentDisposed(TmfExperimentDisposedSignal signal) { + if (signal.getExperiment() != TmfExperiment.getCurrentExperiment()) { + return; } /* @@ -292,37 +203,124 @@ public class TmfStatisticsView extends TmfView { */ cancelOngoingRequest(fRequestRange); cancelOngoingRequest(fRequest); - // clean the model - TmfStatisticsTreeRootFactory.removeAll(); } - /* - * (non-Javadoc) + /** + * Handler called when an experiment is selected. Checks if the experiment + * has changed and requests the selected experiment if it has not yet been + * cached. * - * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + * @param signal + * Contains the information about the selection. */ - @Override - public void setFocus() { - fTreeViewer.getTree().setFocus(); + @TmfSignalHandler + public void experimentSelected(TmfExperimentSelectedSignal signal) { + if (signal != null) { + // Does not reload the same trace if already opened + if (fExperiment == null + || signal.getExperiment().toString().compareTo(fExperiment.toString()) != 0) { + /* + * Dispose the current viewer and adapt the new one to the trace + * type of the experiment selected + */ + if (fStatsViewer != null) { + fStatsViewer.dispose(); + } + // Update the current experiment + fExperiment = signal.getExperiment(); + fStatsViewer = createStatisticsViewer(); + fParent.layout(); + + String experimentName = fExperiment.getName(); + String treeID = fStatsViewer.getTreeID(experimentName); + + setInput(treeID, fExperiment.getTraces()); + + if (fRequestData) { + requestData(fExperiment, fExperiment.getTimeRange()); + fRequestData = false; + } + } + } + } + + /** + * Initialize the viewer with the information received. + * + * @param treeID + * The unique ID of the tree that is returned by + * {@link TmfStatisticsViewer#getTreeID(String)} + * @param traces + * The list of the traces to add in the tree. + * @since 2.0 + */ + public void setInput(String treeID, ITmfTrace[] traces) { + if (TmfStatisticsTreeRootFactory.containsTreeRoot(treeID)) { + // The experiment root is already present + TmfStatisticsTreeNode experimentTreeNode = TmfStatisticsTreeRootFactory.getStatTreeRoot(treeID); + + // check if there is partial data loaded in the experiment + int numTraces = traces.length; + int numNodeTraces = experimentTreeNode.getNbChildren(); + + if (numTraces == numNodeTraces) { + boolean same = true; + /* + * Detect if the experiment contains the same traces as when + * previously selected + */ + for (int i = 0; i < numTraces; i++) { + String traceName = traces[i].getName(); + if (!experimentTreeNode.containsChild(traceName)) { + same = false; + break; + } + } + + if (same) { + // no need to reload data, all traces are already loaded + fStatsViewer.setInput(experimentTreeNode); + + resetUpdateSynchronization(); + + return; + } + experimentTreeNode.reset(); + } + } else { + TmfStatisticsTreeRootFactory.addStatsTreeRoot(treeID, fStatsViewer.getStatisticData()); + } + + resetUpdateSynchronization(); + + TmfStatisticsTreeNode treeModelRoot = TmfStatisticsTreeRootFactory.getStatTreeRoot(treeID); + + // if the model has contents, clear to start over + if (treeModelRoot.hasChildren()) { + treeModelRoot.reset(); + } + + // set input to a clean data model + fStatsViewer.setInput(treeModelRoot); } /** * Refresh the view. * - * @param complete - * Should a pending update be sent afterwards or not + * @param complete Should a pending update be sent afterwards or not */ public void modelInputChanged(boolean complete) { + Control viewerControl = fStatsViewer.getControl(); // Ignore update if disposed - if (fTreeViewer.getTree().isDisposed()) { + if (viewerControl.isDisposed()) { return; } - fTreeViewer.getTree().getDisplay().asyncExec(new Runnable() { + fStatsViewer.getControl().getDisplay().asyncExec(new Runnable() { @Override public void run() { - if (!fTreeViewer.getTree().isDisposed()) { - fTreeViewer.refresh(); + if (!fStatsViewer.getControl().isDisposed()) { + fStatsViewer.refresh(); } } }); @@ -340,111 +338,19 @@ public class TmfStatisticsView extends TmfView { * The experiment name */ public void modelIncomplete(String name) { - Object input = fTreeViewer.getInput(); + Object input = fStatsViewer.getInput(); if (input != null && input instanceof TmfStatisticsTreeNode) { /* * The data from this experiment is invalid and shall be removed to * refresh upon next selection */ - TmfStatisticsTreeRootFactory.removeStatTreeRoot(getTreeID(name)); + TmfStatisticsTreeRootFactory.removeStatTreeRoot(fStatsViewer.getTreeID(name)); // Reset synchronization information resetUpdateSynchronization(); modelInputChanged(false); } - waitCursor(false); - } - - /** - * Handles the signal about disposal of the current experiment. - * - * @param signal - * The disposed signal - */ - @TmfSignalHandler - public void experimentDisposed(TmfExperimentDisposedSignal signal) { - if (signal.getExperiment() != TmfExperiment.getCurrentExperiment()) { - return; - } - /* - * The range request must be cancelled first, since the global one removes - * the statistics tree - */ - cancelOngoingRequest(fRequestRange); - cancelOngoingRequest(fRequest); - resetTimeRangeValue(); - } - - /** - * Handler called when an experiment is selected. Checks if the experiment - * has changed and requests the selected experiment if it has not yet been - * cached. - * - * @param signal - * Contains the information about the selection. - */ - @TmfSignalHandler - public void experimentSelected(TmfExperimentSelectedSignal signal) { - if (signal != null) { - TmfExperiment experiment = signal.getExperiment(); - String experimentName = experiment.getName(); - - if (TmfStatisticsTreeRootFactory.containsTreeRoot(getTreeID(experimentName))) { - // The experiment root is already present - String treeID = getTreeID(experimentName); - TmfStatisticsTreeNode experimentTreeNode = TmfStatisticsTreeRootFactory.getStatTreeRoot(treeID); - - ITmfTrace[] traces = experiment.getTraces(); - - // check if there is partial data loaded in the experiment - int numTraces = experiment.getTraces().length; - int numNodeTraces = experimentTreeNode.getNbChildren(); - - if (numTraces == numNodeTraces) { - boolean same = true; - /* - * Detect if the experiment contains the same traces as when - * previously selected - */ - for (int i = 0; i < numTraces; i++) { - String traceName = traces[i].getName(); - if (!experimentTreeNode.containsChild(traceName)) { - same = false; - break; - } - } - - if (same) { - // no need to reload data, all traces are already loaded - fTreeViewer.setInput(experimentTreeNode); - - resetUpdateSynchronization(); - - return; - } - experimentTreeNode.reset(); - } - } else { - TmfStatisticsTreeRootFactory.addStatsTreeRoot(getTreeID(experimentName), getStatisticData()); - } - - resetUpdateSynchronization(); - - TmfStatisticsTreeNode treeModelRoot = TmfStatisticsTreeRootFactory.getStatTreeRoot(getTreeID(experiment.getName())); - - // if the model has contents, clear to start over - if (treeModelRoot.hasChildren()) { - treeModelRoot.reset(); - } - - // set input to a clean data model - fTreeViewer.setInput(treeModelRoot); - - if (fRequestData) { - requestData(experiment, experiment.getTimeRange()); - fRequestData = false; - } - } + fStatsViewer.waitCursor(false); } /** @@ -461,7 +367,7 @@ public class TmfStatisticsView extends TmfView { return; } - // Calculate the selected timerange for the request + // Calculate the selected timerange to request long startTime = signal.getRange().getStartTime().normalize(0, TIME_SCALE).getValue(); TmfTimestamp startTS = new TmfTimestamp(startTime, TIME_SCALE); TmfTimestamp endTS = new TmfTimestamp(startTime + INITIAL_WINDOW_SPAN, TIME_SCALE); @@ -471,6 +377,36 @@ public class TmfStatisticsView extends TmfView { requestData(experiment, signal.getRange()); } + /* + * (non-Javadoc) + * + * @see org.eclipse.linuxtools.tmf.ui.views.TmfView#dispose() + */ + @Override + public void dispose() { + super.dispose(); + fStatsViewer.dispose(); + + /* + * Make sure there is no request running before removing the statistics + * tree. + */ + cancelOngoingRequest(fRequestRange); + cancelOngoingRequest(fRequest); + // clean the model + TmfStatisticsTreeRootFactory.removeAll(); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.part.WorkbenchPart#setFocus() + */ + @Override + public void setFocus() { + fStatsViewer.setFocus(); + } + /** * Handles the experiment updated signal. This will detect new events in * case the indexing is not coalesced with a statistics request. @@ -488,7 +424,7 @@ public class TmfStatisticsView extends TmfView { } int nbEvents = 0; - for (TmfStatisticsTreeNode node : ((TmfStatisticsTreeNode) fTreeViewer.getInput()).getChildren()) { + for (TmfStatisticsTreeNode node : ((TmfStatisticsTreeNode) fStatsViewer.getInput()).getChildren()) { nbEvents += (int) node.getValue().getTotal(); } @@ -503,7 +439,7 @@ public class TmfStatisticsView extends TmfView { } /** - * Handles the time range updated signal. It updates the time range + * * Handles the time range updated signal. It updates the time range * statistics. * * @param signal @@ -517,95 +453,79 @@ public class TmfStatisticsView extends TmfView { * processing */ cancelOngoingRequest(fRequestRange); - resetTimeRangeValue(); requestTimeRangeData(TmfExperiment.getCurrentExperiment(), signal.getCurrentRange()); } /** - * Return the size of the request when performing background request. - * - * @return the block size for background request. - */ - protected int getIndexPageSize() { - return PAGE_SIZE; - } - - /** - * Returns the quantity of data to retrieve before a refresh of the view is - * performed - * - * @return the quantity of data to retrieve before a refresh of the view is - * performed. - */ - protected long getInputChangedRefresh() { - return STATS_INPUT_CHANGED_REFRESH; - } - - /** - * This method can be overridden to implement another way to represent the - * statistics data and to retrieve the information for display. - * - * @return a TmfStatisticsData object. - */ - protected AbsTmfStatisticsTree getStatisticData() { - return new TmfBaseStatisticsTree(); - } - - /** - * This method can be overridden to change the representation of the data in - * the columns. - * - * @return an object implementing ITmfBaseColumnDataProvider. - */ - protected ITmfColumnDataProvider getColumnDataProvider() { - return new TmfBaseColumnDataProvider(); - } - - /** - * Constructs the ID based on the experiment name and - * fInstanceNb - * - * @param experimentName - * the name of the trace name to show in the view - * @return a view ID - */ - protected String getTreeID(String experimentName) { - return experimentName + fInstanceNb; - } - - /** - * When the experiment is loading the cursor will be different so the user - * knows the processing is not finished yet. + * Get the statistics viewer for an experiment. If all traces in the + * experiment are of the same type, use the extension point specified. * - * @param waitInd - * Indicates if we need to show the waiting cursor, or the - * default one + * @return a statistics viewer of the appropriate type + * @since 2.0 */ - protected void waitCursor(final boolean waitInd) { - if ((fTreeViewer == null) || (fTreeViewer.getTree().isDisposed())) { - return; - } - - Display display = fTreeViewer.getControl().getDisplay(); - if (fWaitCursor == null) { - fWaitCursor = new Cursor(display, SWT.CURSOR_WAIT); + protected TmfStatisticsViewer createStatisticsViewer() { + if (fExperiment == null) { + return new TmfStatisticsViewer(fParent); } - - // Perform the updates on the UI thread - display.asyncExec(new Runnable() { - @Override - public void run() { - if ((fTreeViewer != null) - && (!fTreeViewer.getTree().isDisposed())) { - Cursor cursor = null; /* indicates default */ - if (waitInd) { - cursor = fWaitCursor; + String commonTraceType = null; + try { + /* + * Determine if the traces of the experiment are of the same type. + * If not, it uses the most generic one. + */ + for (ITmfTrace trace : fExperiment.getTraces()) { + IResource resource = trace.getResource(); + if (resource == null) { + return new TmfStatisticsViewer(fParent); + } + String traceType = resource.getPersistentProperty(TmfCommonConstants.TRACETYPE); + if (commonTraceType != null && !commonTraceType.equals(traceType)) { + return new TmfStatisticsViewer(fParent); + } + commonTraceType = traceType; + } + if (commonTraceType == null) { + return new TmfStatisticsViewer(fParent); + } + /* + * Search in the configuration if there is any viewer specified for + * this kind of trace type. + */ + for (IConfigurationElement ce : TmfTraceType.getTypeElements()) { + if (ce.getAttribute(TmfTraceType.ID_ATTR).equals(commonTraceType)) { + IConfigurationElement[] statisticsViewerCE = ce.getChildren(TmfTraceType.STATISTICS_VIEWER_ELEM); + if (statisticsViewerCE.length != 1) { + break; } - fTreeViewer.getControl().setCursor(cursor); + String statisticsViewer = statisticsViewerCE[0].getAttribute(TmfTraceType.CLASS_ATTR); + if (statisticsViewer == null || statisticsViewer.length() == 0) { + break; + } + Bundle bundle = Platform.getBundle(ce.getContributor().getName()); + Class c = bundle.loadClass(statisticsViewer); + Class[] constructorArgs = new Class[] { Composite.class }; + Constructor constructor = c.getConstructor(constructorArgs); + Object[] args = new Object[] { fParent }; + return (TmfStatisticsViewer) constructor.newInstance(args); } } - }); + } catch (CoreException e) { + Activator.getDefault().logError("Error creating statistics viewer : cannot find the property TmfCommonConstants.TRACETYPE", e); //$NON-NLS-1$ + } catch (ClassNotFoundException e) { + Activator.getDefault().logError("Error creating statistics viewer : cannot load the statistics viewer class", e); //$NON-NLS-1$ + } catch (NoSuchMethodException e) { + Activator.getDefault().logError("Error creating statistics viewer : constructor of the viewer doesn't exist", e); //$NON-NLS-1$ + } catch (InstantiationException e) { + Activator.getDefault().logError("Error creating statistics viewer : cannot instantiate the statistics viewer", e); //$NON-NLS-1$ + } catch (IllegalAccessException e) { + Activator.getDefault().logError("Error creating statistics viewer : cannot access the constructor of the viewer", e); //$NON-NLS-1$ + } catch (IllegalArgumentException e) { + Activator.getDefault().logError("Error creating statistics viewer : argument(s) sent to the constructor are illegal", e); //$NON-NLS-1$ + } catch (InvocationTargetException e) { + Activator.getDefault().logError("Error creating statistics viewer : the constructor of the viewer sent an exception", e); //$NON-NLS-1$ + } + return new TmfStatisticsViewer(fParent); } /** @@ -626,15 +546,15 @@ public class TmfStatisticsView extends TmfView { } int index = 0; - for (TmfStatisticsTreeNode node : ((TmfStatisticsTreeNode) fTreeViewer.getInput()).getChildren()) { + for (TmfStatisticsTreeNode node : ((TmfStatisticsTreeNode) fStatsViewer.getInput()).getChildren()) { index += (int) node.getValue().getTotal(); } // Prepare the global event request - fRequest = new TmfStatisticsRequest(this, experiment, timeRange, index, ExecutionType.BACKGROUND, true); + fRequest = new TmfStatisticsRequest(this, fStatsViewer, experiment, timeRange, index, ExecutionType.BACKGROUND, true); experiment.sendRequest(fRequest); - waitCursor(true); + fStatsViewer.waitCursor(true); } } @@ -650,9 +570,9 @@ public class TmfStatisticsView extends TmfView { */ protected void requestTimeRangeData(final TmfExperiment experiment, TmfTimeRange timeRange) { if (experiment != null) { - + resetTimeRangeValue(); // Prepare the partial event request - fRequestRange = new TmfStatisticsRequest(this, experiment, timeRange, 0, ExecutionType.FOREGROUND, false); + fRequestRange = new TmfStatisticsRequest(this, fStatsViewer, experiment, timeRange, 0, ExecutionType.FOREGROUND, false); experiment.sendRequest(fRequestRange); } } @@ -664,13 +584,22 @@ public class TmfStatisticsView extends TmfView { */ protected void resetTimeRangeValue() { // Reset the number of events in the time range - String treeID = getTreeID(TmfExperiment.getCurrentExperiment().getName()); + String treeID = fStatsViewer.getTreeID(TmfExperiment.getCurrentExperiment().getName()); TmfStatisticsTreeNode treeModelRoot = TmfStatisticsTreeRootFactory.getStatTreeRoot(treeID); if (treeModelRoot.hasChildren()) { treeModelRoot.resetTimeRangeValue(); } } + /** + * Return the size of the request when performing background request. + * + * @return the block size for background request. + */ + protected int getIndexPageSize() { + return PAGE_SIZE; + } + /** * Cancels the current ongoing request * @@ -731,5 +660,4 @@ public class TmfStatisticsView extends TmfView { } } } - } diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/messages.properties deleted file mode 100755 index 2542d73b09..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/messages.properties +++ /dev/null @@ -1,7 +0,0 @@ -TmfStatisticsView_LevelColumn=Level -TmfStatisticsView_LevelColumnTip=Level at which statistics apply. -TmfStatisticsView_NbEventsColumn=Global event count -TmfStatisticsView_NbEventsTip=Total amount of events that are tied to given resource. -TmfStatisticsView_NbEventsTimeRangeColumn=Partial event count -TmfStatisticsView_NbEventsTimeRangeTip=Number of events in the selected time range -TmfStatisticsView_UnknownTraceName=Unknown_Trace diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java deleted file mode 100755 index 7938047029..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/AbsTmfStatisticsTree.java +++ /dev/null @@ -1,232 +0,0 @@ -/******************************************************************************* - * 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 - Implementation and Initial API - * - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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.views.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 - */ -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 ROOT = new TmfFixedArray("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> fKeys; - - /** - * The nodes in the tree. - */ - protected HashMap, TmfStatisticsTreeNode> fNodes; - - /** - * Constructor. - */ - public AbsTmfStatisticsTree() { - fNodes = new HashMap, TmfStatisticsTreeNode>(); - fKeys = new HashMap>(); - } - - /** - * Get a node. - * - * @param path - * Path to the node. - * @return The node or null. - */ - public TmfStatisticsTreeNode get(final TmfFixedArray 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 getChildren(final TmfFixedArray 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 getAllChildren(final TmfFixedArray path); - - /** - * Get the map of existing elements of path classified by parent. - * - * @return The map. - */ - public Map> getKeys() { - return fKeys; - } - - /** - * Get or create a node. - * - * @param path - * Path to the node. - * @return The node. - */ - public TmfStatisticsTreeNode getOrCreate(final TmfFixedArray 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 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 path); - - /** - * Reset a node. - * - * Works recursively. - * - * @param path - * Path to the node. - */ - public void reset(final TmfFixedArray 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 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/views/statistics/model/ITmfColumnDataProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfColumnDataProvider.java deleted file mode 100755 index 35cd206dfe..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfColumnDataProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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 - Initial API and Implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.statistics.model; - -import java.util.List; - -/** - * Basic methods that must be implemented in a column data provider. The - * TmfStatisticsView uses classes implementing this interface to - * define the columns in the statistics tree viewer. - * - * @version 1.0 - * @author Mathieu Denis - */ -public interface ITmfColumnDataProvider { - - /** - * Return a list of the column created for the view - * - * @return columns list - */ - public List getColumnData(); -} \ No newline at end of file diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfStatisticsColumnData.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfStatisticsColumnData.java deleted file mode 100644 index 236423aab0..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/ITmfStatisticsColumnData.java +++ /dev/null @@ -1,80 +0,0 @@ -/******************************************************************************* - * 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 - Initial API and Implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.statistics.model; - -import org.eclipse.jface.viewers.ColumnLabelProvider; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfBaseColumnData.ITmfColumnPercentageProvider; - -/** - * Provide the basic interface to create a statistics column for the statistics - * table tree. - * - * @version 1.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/views/statistics/model/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/Messages.java deleted file mode 100755 index 18e9ebed7c..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/Messages.java +++ /dev/null @@ -1,44 +0,0 @@ -/******************************************************************************* - * 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 - Initial API and Implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.statistics.model; - -import org.eclipse.osgi.util.NLS; - -/** - * Message strings for the statistics framework. - * - * @version 1.0 - * @author Mathieu Denis - */ -public class Messages extends NLS { - - private static final String BUNDLE_NAME = "org.eclipse.linuxtools.tmf.ui.views.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/views/statistics/model/TmfBaseColumnData.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnData.java deleted file mode 100755 index 7d9662a513..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnData.java +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************************* - * 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 - Initial Implementation - * Bernd Hufmann - Added Annotations - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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 1.0 - * @author Mathieu Denis - */ -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.views.statistics.model.ITmfStatisticsColumnData#getHeader() - */ - @Override - public String getHeader() { - return fHeader; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getWidth() - */ - @Override - public int getWidth() { - return fWidth; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getAlignment() - */ - @Override - public int getAlignment() { - return fAlignment; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getTooltip() - */ - @Override - public String getTooltip() { - return fTooltip; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getLabelProvider() - */ - @Override - public ColumnLabelProvider getLabelProvider() { - return fLabelProvider; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.ITmfStatisticsColumnData#getComparator() - */ - @Override - public ViewerComparator getComparator() { - return fComparator; - } - - /* - * (non-Javadoc) - * @see org.eclipse.linuxtools.tmf.ui.views.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/views/statistics/model/TmfBaseColumnDataProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java deleted file mode 100755 index aee9f6071c..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseColumnDataProvider.java +++ /dev/null @@ -1,188 +0,0 @@ -/******************************************************************************* - * 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 - Implementation and Initial API - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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.views.statistics.Messages; -import org.eclipse.linuxtools.tmf.ui.views.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 - */ -public class TmfBaseColumnDataProvider implements ITmfColumnDataProvider { - - /** - * Contains the list of the columns - */ - protected List 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 fFolderLevels = new HashSet(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(); - /* 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 getColumnData() { - return fColumnData; - } - -} diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseStatisticsTree.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseStatisticsTree.java deleted file mode 100755 index d64bf263bb..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfBaseStatisticsTree.java +++ /dev/null @@ -1,256 +0,0 @@ -/******************************************************************************* - * 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 - Initial API and Implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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.views.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 - */ -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> keys = getKeys(); - - // //////////// Adding category sets - // common - keys.put(HEADER_EVENT_TYPES, new HashSet()); - - // /////////// Adding value sets - // Under a trace - Set temp = new HashSet(8); - temp.add(HEADER_EVENT_TYPES); - keys.put(ROOT_NODE_KEY, temp); - // Under an event type - temp = new HashSet(16); - keys.put(mergeString(HEADER_EVENT_TYPES, NODE), temp); - - // //////////// CREATE root - keys.put(ROOT.get(0), new HashSet(2)); // 1 trace at the time - getOrCreate(ROOT); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsData#getChildren(org.eclipse.linuxtools.tmf.util.TmfFixedArray) - */ - @Override - public Collection getChildren(TmfFixedArray path) { - LinkedList result = new LinkedList(); - - 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(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.views.statistics.model.TmfStatisticsData#getAllChildren(org.eclipse.linuxtools.tmf.util.TmfFixedArray) - */ - @Override - public Collection getAllChildren(TmfFixedArray path) { - LinkedList result = new LinkedList(); - - 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(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.views.statistics.model.TmfStatisticsData#increase(org.eclipse.linuxtools.tmf.event.TmfEvent, org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfEventInfo, int) - */ - @Override - public void increase(ITmfEvent event, ITmfExtraEventInfo extraInfo, int values) { - // Do nothing - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsData#registerEvent(org.eclipse.linuxtools.tmf.event.TmfEvent, org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfEventInfo) - */ - @Override - public void registerEvent(ITmfEvent event, ITmfExtraEventInfo extraInfo) { - TmfFixedArray[] paths = getNormalPaths(event, extraInfo); - for (TmfFixedArray path : paths) { - getOrCreate(path).getValue().incrementTotal(); - } - - paths = getTypePaths(event, extraInfo); - for (TmfFixedArray path : paths) { - getOrCreate(path).getValue().incrementTotal(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.AbsTmfStatisticsTree#registerEventInTimeRange(org.eclipse.linuxtools.tmf.core.event.ITmfEvent, org.eclipse.linuxtools.tmf.ui.views.statistics.ITmfExtraEventInfo) - */ - @Override - public void registerEventInTimeRange(ITmfEvent event, ITmfExtraEventInfo extraInfo) { - TmfFixedArray[] paths = getNormalPaths(event, extraInfo); - for (TmfFixedArray path : paths) { - getOrCreate(path).getValue().incrementPartial(); - } - - paths = getTypePaths(event, extraInfo); - for (TmfFixedArray 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[] 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(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[] getNormalPaths(ITmfEvent event, ITmfExtraEventInfo extraInfo) { - String trace = extraInfo.getTraceName(); - - TmfFixedArray[] paths = { new TmfFixedArray(trace) }; - return paths; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfStatisticsData#registerName - * (org.eclipse.linuxtools.tmf.ui.views.statistics.model.TmfFixedArray) - */ - @Override - protected void registerName(TmfFixedArray 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/views/statistics/model/TmfStatistics.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatistics.java deleted file mode 100755 index 49f618b906..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatistics.java +++ /dev/null @@ -1,122 +0,0 @@ -/******************************************************************************* - * 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 - Intial API and Implementation - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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 - * @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 nb 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 nb 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/views/statistics/model/TmfStatisticsTreeNode.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatisticsTreeNode.java deleted file mode 100755 index 4f3d084f18..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatisticsTreeNode.java +++ /dev/null @@ -1,169 +0,0 @@ -/******************************************************************************* - * 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 - Implementation for stats - * Francois Godin - Re-design for new stats structure - * Mathieu Denis - Re-design for new stats structure (2) - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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 - * @author Mathieu Denis - */ -public class TmfStatisticsTreeNode { - - /** - * Value of the node. - */ - protected TmfStatistics fValue; - - /** - * Path of the node. - */ - protected TmfFixedArray fPath; - - /** - * Corresponding StatisticsData. - */ - protected AbsTmfStatisticsTree fNodes; - - /** - * Constructor. - * - * @param path - * Path to the node. - * @param nodes - * Corresponding StatisticsData. - */ - public TmfStatisticsTreeNode(final TmfFixedArray 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(key)) != null; - } - return (fNodes.get(fPath.append(key)) != null); - } - - /** - * Get the children of this node. - * - * @return Direct children of this node. - */ - public Collection getChildren() { - return fNodes.getChildren(fPath); - } - - /** - * Get the children of this node. - * - * @return Direct children of this node. - */ - public Collection 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 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/views/statistics/model/TmfStatisticsTreeRootFactory.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatisticsTreeRootFactory.java deleted file mode 100755 index ff8d2f49e1..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfStatisticsTreeRootFactory.java +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************* - * 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 - Initial API - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.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 1.0 - * @author Mathieu Denis - * - */ -public class TmfStatisticsTreeRootFactory { - - /** - * Contains the experiment name as the key and the traces data - */ - private static final Map fTreeInstances = new HashMap(); - - /** - * 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/views/statistics/model/TmfTreeContentProvider.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfTreeContentProvider.java deleted file mode 100755 index 614be4fcee..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/TmfTreeContentProvider.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * 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 - Initial API - *******************************************************************************/ - -package org.eclipse.linuxtools.tmf.ui.views.statistics.model; - -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; - -/** - * Adapter TreeViewers can use to interact with StatisticsTreeNode objects. - * - * @version 1.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/views/statistics/model/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/messages.properties deleted file mode 100755 index 442d278a76..0000000000 --- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/model/messages.properties +++ /dev/null @@ -1,2 +0,0 @@ -TmfStatisticsData_CPUs=CPUs -TmfStatisticsData_EventTypes=Event Types \ No newline at end of file -- cgit v1.2.3