Move legacy time analysis widget to lttng.ui and create initial copy in
authorPatrick Tasse <patrick.tasse@gmail.com>
Wed, 11 Apr 2012 22:17:53 +0000 (18:17 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Thu, 3 May 2012 18:43:25 +0000 (14:43 -0400)
tmf.ui.

101 files changed:
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/model/trange/ItemContainer.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/model/trange/TimeRangeComponent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/model/trange/TimeRangeComposite.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/model/trange/TimeRangeEvent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/model/trange/TimeRangeViewerProvider.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/GridUtil.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeFilterSelectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeScaleSelectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeSelectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/Messages.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeFilterSelectionEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeScaleSelectionEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeSelectionEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfViewerFactory.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/dialogs/TmfTimeFilterDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/dialogs/TmfTimeLegend.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/messages.properties [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/ITimeEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/TimeEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/ITimeDataProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/PlainSelection.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TraceColorScheme.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TraceCtrl.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/Utils.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/common/AbsTimeUpdateView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/common/ParamsUpdater.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/controlflow/ControlFlowView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/resources/ResourcesView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/views/statistics/StatisticsView.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/adaption/TsfImplProvider.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/EventImpl.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/model/TraceImpl.java
org.eclipse.linuxtools.tmf.ui.tests/widgetStubs/org/eclipse/linuxtools/tmf/ui/widgets/timeAnalysis/test/stub/views/TsfTraceAnalysisView.java
org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/ITmfViewer.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/TmfViewerFactory.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/GridUtil.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeFilterSelectionListener.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeScaleSelectionListener.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeSelectionListener.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeFilterSelectionEvent.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeScaleSelectionEvent.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeSelectionEvent.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/dialogs/TmfTimeFilterDialog.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/dialogs/TmfTimeLegend.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITimeEvent.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/TimeEvent.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/ITimeDataProvider.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/PlainSelection.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TraceColorScheme.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TraceCtrl.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/Utils.java [deleted file]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorSetting.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorSettingsManager.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/ColorsView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/colors/TickColorDialog.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisEntry.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartAnalysisProvider.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartEvent.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/timechart/TimeChartView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/dialogs/SDPrintDialogUI.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/GridUtil.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeAnalysisViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeFilterSelectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeScaleSelectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeSelectionListener.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeAnalysisProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeAnalysisViewer.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeFilterSelectionEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeScaleSelectionEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeSelectionEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfViewerFactory.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TmfTimeFilterDialog.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TmfTimeLegend.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITimeEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITmfTimeAnalysisEntry.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/TimeEvent.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/PlainSelection.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeScaleCtrl.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TmfTimeStatesCtrl.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TmfTimeTipHandler.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TraceColorScheme.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TraceCtrl.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java [new file with mode: 0644]

index 6349e9753260614bcb24b0729c945ca55056c55b..c1c8a1fa68637eee68ea31c7e395d541f39b32fc 100644 (file)
@@ -1,6 +1,6 @@
 package org.eclipse.linuxtools.internal.lttng.ui.model.trange;
 
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 
 public interface ItemContainer<T extends ITmfTimeAnalysisEntry> {
 
index 28be1aefc9f60be377468df8e901596292a9a5d6..0253076bc2e748d7c61598fb6044fd8df231fdd0 100644 (file)
@@ -11,8 +11,8 @@
  *******************************************************************************/
 package org.eclipse.linuxtools.internal.lttng.ui.model.trange;
 
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 
 
 /**
index 86ebac3fdf1ea16d3cc459c3f7283fb6f6169d41..850a4ec407220b0c3acfec8cefca17c49416427c 100644 (file)
@@ -14,8 +14,8 @@ package org.eclipse.linuxtools.internal.lttng.ui.model.trange;
 import java.util.Iterator;
 import java.util.Vector;
 
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 
 public class TimeRangeComposite extends TimeRangeComponent implements
 ITmfTimeAnalysisEntry {
index e04fd81c6e2e6eb587db3ce009f38d753ec67064..77b9b443d7469bb3422c9d7e560c19fd365d2aa9 100644 (file)
@@ -12,8 +12,8 @@
 \r
 package org.eclipse.linuxtools.internal.lttng.ui.model.trange;\r
 \r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
 \r
 /**\r
  * @author alvaro\r
index 1cab1bf466c58cbf959f74e006dfb4680ac35b72..4dfbf5c11dc3846348e1e5f82c174f6833f2f575 100644 (file)
@@ -22,10 +22,10 @@ import org.eclipse.linuxtools.internal.lttng.core.state.StateStrings.IRQMode;
 import org.eclipse.linuxtools.internal.lttng.core.state.StateStrings.ProcessStatus;\r
 import org.eclipse.linuxtools.internal.lttng.core.state.StateStrings.SoftIRQMode;\r
 import org.eclipse.linuxtools.internal.lttng.core.state.StateStrings.TrapMode;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.ParamsUpdater;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
 \r
 public class TimeRangeViewerProvider extends TmfTimeAnalysisProvider {\r
 \r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/GridUtil.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/GridUtil.java
new file mode 100644 (file)
index 0000000..2fcfe0f
--- /dev/null
@@ -0,0 +1,45 @@
+/**********************************************************************\r
+ * Copyright (c) 2005, 2006 IBM Corporation and others.\r
+ * All rights reserved.   This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * $Id: GridUtil.java,v 1.3 2006/09/20 19:49:13 ewchan Exp $\r
+ * \r
+ * Contributors: \r
+ * IBM - Initial API and implementation\r
+ **********************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.GridData;\r
+\r
+/**\r
+ * A utility class to create convenient grid data objects.\r
+ */ \r
+public class GridUtil\r
+{\r
+       /**\r
+        * Creates a grid data object that occupies vertical and horizontal\r
+        * space.\r
+        */\r
+       static public GridData createFill() \r
+       {\r
+               return new GridData(SWT.FILL, SWT.FILL, true, true);\r
+       }\r
+       /**\r
+        * Creates a grid data object that occupies horizontal space.\r
+        */\r
+       static public GridData createHorizontalFill() \r
+       {               \r
+               return new GridData(SWT.FILL, SWT.DEFAULT, true, false);                \r
+       }\r
+       /**\r
+        * Creates a grid data object that occupies vertical space.\r
+        */\r
+       static public GridData createVerticalFill() \r
+       {\r
+               return new GridData(SWT.DEFAULT, SWT.FILL, false, true);\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java
new file mode 100644 (file)
index 0000000..e113850
--- /dev/null
@@ -0,0 +1,195 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009, 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+ package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.TimeEvent;\r
+import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.ScrollBar;\r
+\r
+/**\r
+ * <b><u>ITimeAnalysisWidget</u></b>\r
+ * <p>\r
+ *\r
+ * TODO: Implement me. Please.\r
+ */\r
+public interface ITimeAnalysisViewer extends ITmfViewer {\r
+\r
+    public enum TimeFormat {\r
+               RELATIVE, ABSOLUTE\r
+       };\r
+\r
+       /**\r
+        * @param e\r
+        */\r
+       public void controlResized(ControlEvent e);\r
+\r
+       /**\r
+        * \r
+        * @param traceArr\r
+        * @param start\r
+        *            Specifies a fixed start time to the information to be\r
+        *            displayed\r
+        * @param end\r
+        *            Specifies a fixed end time to the information to be displayed\r
+        * @param updateTimeBounds\r
+        *            If True - Time Range boundaries update is required\r
+        */\r
+       public abstract void display(ITmfTimeAnalysisEntry[] traceArr, long start,\r
+                       long end, boolean updateTimeBounds);\r
+\r
+       /**\r
+        * The start and End time are taken from the limits used by the children\r
+        * events\r
+        * \r
+        * @param traceArr\r
+        */\r
+       public abstract void display(ITmfTimeAnalysisEntry[] traceArr);\r
+\r
+       public void addWidgetSelectionListner(ITmfTimeSelectionListener listener);\r
+\r
+       public void addWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener);\r
+\r
+       public void filterTraces();\r
+\r
+       public ITmfTimeAnalysisEntry getSelectedTrace();\r
+\r
+       public ISelection getSelection();\r
+\r
+       public void groupTraces(boolean on);\r
+\r
+       public boolean isInFocus();\r
+\r
+       public void removeWidgetSelectionListner(ITmfTimeSelectionListener listener);\r
+\r
+       public void removeWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener);\r
+\r
+       public void resetStartFinishTime();\r
+\r
+       public void selectNextEvent();\r
+\r
+       public void selectPrevEvent();\r
+\r
+       public void selectNextTrace();\r
+\r
+       public void selectPrevTrace();\r
+\r
+       public void showLegend();\r
+\r
+       public void zoomIn();\r
+\r
+       public void zoomOut();\r
+\r
+       public void setSelectedTime(long time, boolean ensureVisible, Object source);\r
+\r
+       public void setSelectedEvent(ITimeEvent event, Object Source);\r
+\r
+       public void setSelectedTraceTime(ITmfTimeAnalysisEntry trace, long time, Object Source);\r
+\r
+       public void setSelectVisTimeWindow(long time0, long time1, Object Source);\r
+\r
+       public void setAcceptSelectionAPIcalls(boolean acceptCalls);\r
+\r
+       public void setTimeCalendarFormat(boolean toAbsoluteCaltime);\r
+\r
+       public boolean isCalendarFormat();\r
+\r
+       public boolean isVisibleVerticalScroll();\r
+\r
+       public void setVisibleVerticalScroll(boolean visibleVerticalScroll);\r
+\r
+       public int getBorderWidth();\r
+\r
+       public void setBorderWidth(int borderWidth);\r
+\r
+       public int getHeaderHeight();\r
+\r
+       public void setHeaderHeight(int headerHeight);\r
+\r
+       public int getItemHeight();\r
+\r
+       public void setItemHeight(int rowHeight);\r
+\r
+    public void setMinimumItemWidth(int width);\r
+\r
+       public void resizeControls();\r
+\r
+       public void setSelectedTrace(ITmfTimeAnalysisEntry trace);\r
+\r
+       public ISelection getSelectionTrace();\r
+\r
+       public void setNameWidthPref(int width);\r
+\r
+       public int getNameWidthPref(int width);\r
+\r
+       public void addFilterSelectionListner(ITmfTimeFilterSelectionListener listener);\r
+\r
+       public void removeFilterSelectionListner(\r
+                       ITmfTimeFilterSelectionListener listener);\r
+\r
+       public int getTimeSpace();\r
+\r
+       public void itemUpdate(ITmfTimeAnalysisEntry parent, TimeEvent item);\r
+\r
+       public Control getControl();\r
+\r
+       public ISelectionProvider getSelectionProvider();\r
+\r
+       /**\r
+        * <p>\r
+        * Provide the possibility to control the wait cursor externally\r
+        * </p>\r
+        * <p>\r
+        * e.g. data requests in progress\r
+        * </p>\r
+        * \r
+        * @param waitInd\r
+        *            - true change to wait cursor\r
+        */\r
+       public void waitCursor(boolean waitInd);\r
+\r
+    public void setFocus();\r
+\r
+    /**\r
+     * Update the time bounds without changing the visible range\r
+     * \r
+     * @param beginTime\r
+     * @param endTime\r
+     */\r
+    public void setTimeBounds(long beginTime, long endTime);\r
+\r
+    /**\r
+     * Get the horizontal scrollbar\r
+     * @return the horizontal scrollbar\r
+     */\r
+    public ScrollBar getHorizontalBar();\r
+\r
+    /**\r
+     * Get the vertical scrollbar\r
+     * @return the vertical scrollbar\r
+     */\r
+    public ScrollBar getVerticalBar();\r
+\r
+    /**\r
+     * Set the top index\r
+     * @param index the top index\r
+     */\r
+    public void setTopIndex(int index);\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeFilterSelectionListener.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeFilterSelectionListener.java
new file mode 100644 (file)
index 0000000..a79c792
--- /dev/null
@@ -0,0 +1,19 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.EventListener;\r
+\r
+public interface ITmfTimeFilterSelectionListener extends EventListener {\r
+       public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event);\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeScaleSelectionListener.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeScaleSelectionListener.java
new file mode 100644 (file)
index 0000000..faeacc4
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.EventListener;\r
+\r
+/**\r
+ * Implemented by any user of TmfTime in order to be notified of available events,\r
+ * upon registration\r
+ * \r
+ */\r
+public interface ITmfTimeScaleSelectionListener extends EventListener {\r
+       public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event);\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeSelectionListener.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfTimeSelectionListener.java
new file mode 100644 (file)
index 0000000..32e1e4a
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.EventListener;\r
+\r
+/**\r
+ * Implemented by any user of TsfTm in order to be notified of available events,\r
+ * upon registration\r
+ * \r
+ */\r
+public interface ITmfTimeSelectionListener extends EventListener {\r
+       public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event);\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfViewer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/ITmfViewer.java
new file mode 100644 (file)
index 0000000..ffa567e
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;
+
+/**
+ * <b><u>ITmfWidget</u></b>
+ * <p>
+ *
+ * TODO: Implement me. Please.
+ */
+public interface ITmfViewer {
+
+}
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/Messages.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/Messages.java
new file mode 100644 (file)
index 0000000..afe0e81
--- /dev/null
@@ -0,0 +1,54 @@
+/*******************************************************************************\r
+ * Copyright (c) 2012 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Patrick Tasse - Extracted from org.eclipse.linuxtools.tmf.ui\r
+ *******************************************************************************/\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import org.eclipse.osgi.util.NLS;\r
+\r
+/**\r
+ * Returns localized strings from the resource bundle (i.e. "messages.properties").\r
+ */\r
+public class Messages extends NLS {\r
+\r
+    private static final String BUNDLE_NAME = "org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.messages"; //$NON-NLS-1$\r
+\r
+    public static String TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS;\r
+    public static String TmfTimeFilterDialog_TRACE_FILTER;\r
+    public static String TmfTimeFilterDialog_TRACE_FILTER_DESC;\r
+    public static String TmfTimeFilterDialog_TRACE_ID;\r
+    public static String TmfTimeFilterDialog_TRACE_NAME;\r
+    public static String TmfTimeLegend_LEGEND;\r
+    public static String TmfTimeLegend_TRACE_STATES;\r
+    public static String TmfTimeLegend_TRACE_STATES_TITLE;\r
+    public static String TmfTimeLegend_WINDOW_TITLE;\r
+\r
+    public static String TimeScaleCtrl_Timescale;\r
+    public static String TmfTimeStatesCtrl_TRACE_GROUP_LABEL;\r
+    public static String TmfTimeStatesCtrl_UNDEFINED_GROUP;\r
+    public static String TmfTimeTipHandler_DURATION;\r
+    public static String TmfTimeTipHandler_NUMBER_OF_TRACES;\r
+    public static String TmfTimeTipHandler_TRACE_CLASS_NAME;\r
+    public static String TmfTimeTipHandler_TRACE_DATE;\r
+    public static String TmfTimeTipHandler_TRACE_EVENT_TIME;\r
+    public static String TmfTimeTipHandler_TRACE_GROUP_NAME;\r
+    public static String TmfTimeTipHandler_TRACE_NAME;\r
+    public static String TmfTimeTipHandler_TRACE_START_TIME;\r
+    public static String TmfTimeTipHandler_TRACE_STATE;\r
+    public static String TmfTimeTipHandler_TRACE_STOP_TIME;\r
+\r
+    static {\r
+        // initialize resource bundle\r
+        NLS.initializeMessages(BUNDLE_NAME, Messages.class);\r
+    }\r
+\r
+    private Messages() {\r
+    }\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java
new file mode 100644 (file)
index 0000000..bdabbcd
--- /dev/null
@@ -0,0 +1,328 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009, 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+\r
+public abstract class TmfTimeAnalysisProvider {\r
+    \r
+       static public final int IMG_THREAD_RUNNING = 0;\r
+       static public final int IMG_THREAD_SUSPENDED = 1;\r
+       static public final int IMG_THREAD_STOPPED = 2;\r
+       static public final int IMG_METHOD_RUNNING = 3;\r
+       static public final int IMG_METHOD = 4;\r
+       static public final int IMG_NUM = 5;\r
+\r
+       public enum StateColor {\r
+               GREEN, DARK_BLUE, RED, GOLD, ORANGE, GRAY, BLACK, DARK_GREEN, DARK_YELLOW, MAGENTA3, PURPLE1, PINK1, AQUAMARINE, LIGHT_BLUE, CADET_BLUE, OLIVE;\r
+\r
+               private String stateName;\r
+\r
+               StateColor() {\r
+                       String undef = "Undefined"; //$NON-NLS-1$\r
+                       this.stateName = undef;\r
+               }\r
+\r
+               public String getStateName() {\r
+                       return stateName;\r
+               }\r
+\r
+               public void setStateName(String stateName) {\r
+                       this.stateName = stateName;\r
+               }\r
+       }\r
+\r
+       // static private String _externalPath[] = {\r
+       // "icons/full/obj16/thread_obj.gif", // running thread\r
+       // "icons/full/obj16/threads_obj.gif", // suspended\r
+       // "icons/full/obj16/threadt_obj.gif", // stopped\r
+       // "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
+       // "icons/full/obj16/stckframe_obj.gif", // stack frame\r
+       // };\r
+       //\r
+       // static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
+       // "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
+       // "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
+       //\r
+       // static private Image getImage(int idx) {\r
+       // if (idx < 0 || idx >= IMG_NUM)\r
+       // SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
+       // String key = "trace.img." + idx;\r
+       // Image img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
+       // if (null == img) {\r
+       // ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
+       // _externalPlugin[idx], _externalPath[idx]);\r
+       // TmfUiPlugin.getDefault().getImageRegistry().put(key, desc);\r
+       // img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
+       // }\r
+       // return img;\r
+       // }\r
+\r
+       public void drawState(TraceColorScheme colors, ITimeEvent event,\r
+                       Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
+                       boolean timeSelected) {\r
+               int colorIdx = getEventColorVal(event);\r
+               drawState(colors, colorIdx, rect, gc, selected, rectBound, timeSelected);\r
+\r
+       }\r
+\r
+       public void drawState(TraceColorScheme colors, int colorIdx,\r
+                       Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
+                       boolean timeSelected) {\r
+\r
+               boolean visible = rect.width == 0 ? false : true;\r
+               int colorIdx1 = colorIdx;\r
+               \r
+               timeSelected = timeSelected && selected;\r
+               if (timeSelected) {\r
+                       colorIdx1 = colorIdx + TraceColorScheme.STATES_SEL0\r
+                                       - TraceColorScheme.STATES0;\r
+               }\r
+\r
+               if (visible) {\r
+                       // fill all rect area\r
+                       if (rect.isEmpty())\r
+                               return;\r
+\r
+                       gc.setBackground(colors.getColor(colorIdx1));\r
+                       gc.fillRectangle(rect);\r
+                       colorIdx1 = colorIdx + TraceColorScheme.STATES_BORDER0\r
+                                       - TraceColorScheme.STATES0;\r
+                       gc.setForeground(colors.getColor(colorIdx1));\r
+\r
+                       // draw bounds\r
+                       if (!timeSelected) {\r
+                               if (rectBound && rect.width >= 3) {\r
+                                       gc.drawRectangle(rect.x, rect.y, rect.width - 1,\r
+                                                       rect.height - 1);\r
+                               } else {\r
+                                       // Draw the top and bottom borders i.e. no side borders\r
+                                       // top\r
+                                       gc\r
+                                                       .drawLine(rect.x, rect.y, rect.x + rect.width - 1,\r
+                                                                       rect.y);\r
+                                       // bottom\r
+                                       gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x\r
+                                                       + rect.width - 1, rect.y + rect.height - 1);\r
+                               }\r
+                       }\r
+                       // draw decoration middle line\r
+                       // int mindy = rect.y + rect.height / 2;\r
+                       // if (TraceColorScheme.GOLD_STATE == colorIdx\r
+                       // || TraceColorScheme.ORANGE_STATE == colorIdx) {\r
+                       // int s = gc.getLineStyle();\r
+                       // int w = gc.getLineWidth();\r
+                       // gc.setLineStyle(SWT.LINE_DOT);\r
+                       // gc.setLineWidth(2);\r
+                       // gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy);\r
+                       // gc.setLineStyle(s);\r
+                       // gc.setLineWidth(w);\r
+                       // } else if (TraceColorScheme.RED_STATE == colorIdx\r
+                       // || TraceColorScheme.GRAY_STATE == colorIdx) {\r
+                       // int w = gc.getLineWidth();\r
+                       // gc.setLineWidth(2);\r
+                       // gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy);\r
+                       // gc.setLineWidth(w);\r
+                       // }\r
+                       // // draw selection bounds\r
+                       // if (timeSelected) {\r
+                       // gc.setForeground(colors\r
+                       // .getColor(TraceColorScheme.SELECTED_TIME));\r
+                       // if (rect.width >= 3) {\r
+                       // gc.drawRectangle(rect.x, rect.y, rect.width - 1,\r
+                       // rect.height - 1);\r
+                       // // gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3,\r
+                       // // rect.height - 3);\r
+                       // } else {\r
+                       // gc\r
+                       // .drawLine(rect.x, rect.y, rect.x + rect.width - 1,\r
+                       // rect.y);\r
+                       // gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x\r
+                       // + rect.width - 1, rect.y + rect.height - 1);\r
+                       // }\r
+                       // gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width - 1,\r
+                       // rect.y + 1);\r
+                       // gc.drawLine(rect.x, rect.y + rect.height - 2, rect.x\r
+                       // + rect.width - 1, rect.y + rect.height - 2);\r
+                       // }\r
+               } else {\r
+                       // selected rectangle area is not visible but can be represented\r
+                       // with a broken vertical line of specified width.\r
+                       int width = 2;\r
+                       rect.width = width;\r
+                       // check if height is greater than zero.\r
+                       if (rect.isEmpty())\r
+                               return;\r
+                       // colorIdx1 = TraceColorScheme.BLACK;\r
+                       gc.setForeground(colors.getColor(colorIdx));\r
+                       int s = gc.getLineStyle();\r
+                       int w = gc.getLineWidth();\r
+                       gc.setLineStyle(SWT.LINE_DOT);\r
+                       gc.setLineWidth(width);\r
+                       // Trace.debug("Reactangle not visible, drawing vertical line with: "\r
+                       // + rect.x + "," + rect.y + "," + rect.x + "," + rect.y\r
+                       // + rect.height);\r
+                       gc.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height);\r
+                       gc.setLineStyle(s);\r
+                       gc.setLineWidth(w);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Uses the abstract method getEventcolor to obtain an enum value and\r
+        * convert it to an internal color index\r
+        * \r
+        * @param event\r
+        * @return the internal color index\r
+        */\r
+       public int getEventColorVal(ITimeEvent event) {\r
+               StateColor colors = getEventColor(event);\r
+               if (colors == StateColor.GREEN) {\r
+                       return TraceColorScheme.GREEN_STATE;\r
+               } else if (colors == StateColor.DARK_BLUE) {\r
+                       return TraceColorScheme.DARK_BLUE_STATE;\r
+               } else if (colors == StateColor.RED) {\r
+                       return TraceColorScheme.RED_STATE;\r
+               } else if (colors == StateColor.GOLD) {\r
+                       return TraceColorScheme.GOLD_STATE;\r
+               } else if (colors == StateColor.ORANGE) {\r
+                       return TraceColorScheme.ORANGE_STATE;\r
+               } else if (colors == StateColor.GRAY) {\r
+                       return TraceColorScheme.GRAY_STATE;\r
+               } else if (colors == StateColor.DARK_GREEN) {\r
+                       return TraceColorScheme.DARK_GREEN_STATE;\r
+               } else if (colors == StateColor.DARK_YELLOW) {\r
+                       return TraceColorScheme.DARK_YELLOW_STATE;\r
+               } else if (colors == StateColor.MAGENTA3) {\r
+                       return TraceColorScheme.MAGENTA3_STATE;\r
+               } else if (colors == StateColor.PURPLE1) {\r
+                       return TraceColorScheme.PURPLE1_STATE;\r
+               } else if (colors == StateColor.PINK1) {\r
+                       return TraceColorScheme.PINK1_STATE;\r
+               } else if (colors == StateColor.AQUAMARINE) {\r
+                       return TraceColorScheme.AQUAMARINE_STATE;\r
+               } else if (colors == StateColor.LIGHT_BLUE) {\r
+                       return TraceColorScheme.LIGHT_BLUE_STATE;\r
+               } else if (colors == StateColor.CADET_BLUE) {\r
+                       return TraceColorScheme.CADET_BLUE_STATE_SEL;\r
+               } else if (colors == StateColor.OLIVE) {\r
+                       return TraceColorScheme.OLIVE_STATE;\r
+               }\r
+\r
+               return TraceColorScheme.BLACK_STATE;\r
+       }\r
+\r
+       /**\r
+        * Select the color for the different internal variants of events.\r
+        * \r
+        * @param event\r
+        * @return the corresponding event color\r
+        */\r
+       public abstract StateColor getEventColor(ITimeEvent event);\r
+\r
+       /**\r
+        * This values is appended between braces to the right of Trace Name e.g.\r
+        * Trace And Error Log [Board 17] or for a Thread trace e.g. State Server\r
+        * [java.lang.Thread]\r
+        * \r
+        * @param trace\r
+        * @return the trace class name\r
+        */\r
+       public abstract String getTraceClassName(ITmfTimeAnalysisEntry trace);\r
+\r
+       public String getEventName(ITimeEvent event) {\r
+               return getEventName(event, true, false);\r
+       }\r
+\r
+       /**\r
+        * Specify a Name for the event depending on its type or state e.g. blocked,\r
+        * running, etc..\r
+        * \r
+        * @param event\r
+        * @param upper\r
+        *            True return String value in Upper case\r
+        * @param extInfo\r
+        *            Verbose, add additional information if applicable\r
+        * @return the event name\r
+        */\r
+       public abstract String getEventName(ITimeEvent event, boolean upper,\r
+                       boolean extInfo);\r
+\r
+       public String composeTraceName(ITmfTimeAnalysisEntry trace, boolean inclState) {\r
+               String name = trace.getName();\r
+               String threadClass = getTraceClassName(trace);\r
+               if (threadClass != null && threadClass.length() > 0) {\r
+                       name += " [" + threadClass + "]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+               }\r
+               /*\r
+                * Check if this is still necessary!\r
+               if (inclState) {\r
+                       List<TimeEvent> list = trace.getTraceEvents();\r
+                       if (null != list && list.size() > 0) {\r
+                               ITimeEvent event = (ITimeEvent) list.get(list.size() - 1);\r
+                               name += " (" + getEventName(event, false, true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$\r
+                       }\r
+               }\r
+               */\r
+               return name;\r
+       }\r
+\r
+       public String composeEventName(ITimeEvent event) {\r
+               String name = event.getEntry().getName();\r
+               String threadClass = getTraceClassName(event.getEntry());\r
+               if (threadClass != null && threadClass.length() > 0) {\r
+                       name += " [" + threadClass + "]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+               }\r
+               name += " (" + getEventName(event, false, true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$\r
+               return name;\r
+       }\r
+\r
+       public abstract Map<String, String> getEventHoverToolTipInfo(\r
+                       ITimeEvent event);\r
+\r
+       /**\r
+        * Provides the image icon for a given Event or Trace e.g. customize to use\r
+        * different icons according to specific event /state combination\r
+        * \r
+        * @param obj\r
+        * @return the image icon\r
+        */\r
+       public Image getItemImage(Object obj) {\r
+           /*\r
+               if (obj instanceof ITmfTimeAnalysisEntry) {\r
+                       List<TimeEvent> list = ((ITmfTimeAnalysisEntry) obj).getTraceEvents();\r
+                       if (null != list && list.size() > 0)\r
+                               obj = list.get(list.size() - 1);\r
+                       else if (((ITmfTimeAnalysisEntry) obj).getStopTime() > 0)\r
+                               return getImage(IMG_THREAD_STOPPED);\r
+                       else\r
+                               return getImage(IMG_THREAD_RUNNING);\r
+               }\r
+               if (obj instanceof TimeEvent) {\r
+                       return getImage(IMG_THREAD_RUNNING);\r
+               }\r
+               */\r
+               return null;\r
+       }\r
+\r
+       public abstract String getStateName(StateColor color);\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java
new file mode 100644 (file)
index 0000000..2c9bfe0
--- /dev/null
@@ -0,0 +1,959 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008, 2009, 2010 Intel Corporation, Ericsson\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alexander N. Alexeev, Intel - Add monitors statistics support\r
+ *    Alvaro Sanchez-Leon - Adapted for TMF\r
+ *\r
+ * $Id: ThreadStatesView.java,v 1.7 2008/05/19 15:07:21 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.dialogs.TmfTimeFilterDialog;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.dialogs.TmfTimeLegend;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.TimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.ITimeDataProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.TimeScaleCtrl;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.TmfTimeStatesCtrl;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.TmfTimeTipHandler;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.Utils;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ControlAdapter;\r
+import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.ScrollBar;\r
+\r
+public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProvider, SelectionListener {\r
+\r
+       /** vars */\r
+       private long _minTimeInterval;\r
+       private long _selectedTime;\r
+       private long _beginTime;\r
+       private long _endTime;\r
+       private long _time0;\r
+       private long _time1;\r
+       private long _time0_;\r
+       private long _time1_;\r
+       private long _time0_extSynch = 0;\r
+       private long _time1_extSynch = 0;\r
+       private boolean _timeRangeFixed;\r
+       private int _nameWidthPref = 200;\r
+       private int _minNameWidth = 6;\r
+       private int _nameWidth;\r
+       private Composite _dataViewer;\r
+\r
+       private TmfTimeStatesCtrl _stateCtrl;\r
+       private TimeScaleCtrl _timeScaleCtrl;\r
+       private TmfTimeTipHandler _threadTip;\r
+       private TraceColorScheme _colors;\r
+       private TmfTimeAnalysisProvider _utilImplm;\r
+\r
+       private boolean _acceptSetSelAPICalls = false;\r
+       Vector<ITmfTimeSelectionListener> widgetSelectionListners = new Vector<ITmfTimeSelectionListener>();\r
+       Vector<ITmfTimeScaleSelectionListener> widgetTimeScaleSelectionListners = new Vector<ITmfTimeScaleSelectionListener>();\r
+       Vector<ITmfTimeFilterSelectionListener> widgetFilterSelectionListeners = new Vector<ITmfTimeFilterSelectionListener>();\r
+\r
+       // Calender Time format, using Epoch reference or Relative time\r
+       // format(default\r
+       private boolean calendarTimeFormat = false;\r
+       private int borderWidth = 4;\r
+       private int timeScaleHeight = 22;\r
+\r
+       /** ctor */\r
+       public TmfTimeAnalysisViewer(Composite parent, TmfTimeAnalysisProvider provider) {\r
+        createDataViewer(parent, provider);\r
+       }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.ITimeAnalysisWidget#display(org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.model.TmfTaTrace[])\r
+     */\r
+    @Override\r
+       public void display(ITmfTimeAnalysisEntry[] traceArr) {\r
+        modelUpdate(traceArr);\r
+    }\r
+\r
+       @Override\r
+       public void display(ITmfTimeAnalysisEntry[] traceArr, long start, long end,\r
+                       boolean updateTimeBounds) {\r
+               modelUpdate(traceArr, start, end, updateTimeBounds);\r
+    }\r
+\r
+    public void controlMoved(ControlEvent e) {\r
+       }\r
+\r
+       @Override\r
+       public void controlResized(ControlEvent e) {\r
+               resizeControls();\r
+       }\r
+\r
+       // called from the display order in the API\r
+       public void modelUpdate(ITmfTimeAnalysisEntry[] traces) {\r
+               if (null != _stateCtrl) {\r
+                       //loadOptions();\r
+                       updateInternalData(traces);\r
+                       _stateCtrl.redraw();\r
+                       _timeScaleCtrl.redraw();\r
+               }\r
+       }\r
+\r
+       // called from the display order in the API\r
+       public void modelUpdate(ITmfTimeAnalysisEntry[] traces, long start,\r
+                       long end, boolean updateTimeBounds) {\r
+               if (null != _stateCtrl) {\r
+                       //loadOptions();\r
+                       updateInternalData(traces, start, end);\r
+                       if (updateTimeBounds) {\r
+                               _timeRangeFixed = true;\r
+                               // set window to match limits\r
+                               setStartFinishTime(_time0_, _time1_);\r
+                       } else {\r
+                               _stateCtrl.redraw();\r
+                               _timeScaleCtrl.redraw();\r
+                       }\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void itemUpdate(ITmfTimeAnalysisEntry parent, TimeEvent item) {\r
+               if (null != parent && null != item) {\r
+                       _stateCtrl.refreshPartial(parent, item);\r
+                       _stateCtrl.redraw();\r
+                       _timeScaleCtrl.redraw();\r
+               }\r
+       }\r
+\r
+       public void selectionChanged() {\r
+       }\r
+\r
+       protected String getViewTypeStr() {\r
+               return "viewoption.threads"; //$NON-NLS-1$\r
+       }\r
+\r
+       int getMarginWidth(int idx) {\r
+               return 0;\r
+       }\r
+\r
+       int getMarginHeight(int idx) {\r
+               return 0;\r
+       }\r
+\r
+       void loadOptions() {\r
+               _minTimeInterval = 1;\r
+               _selectedTime = -1;\r
+               _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$\r
+                               _nameWidthPref, _minNameWidth, 1000);\r
+       }\r
+\r
+       void saveOptions() {\r
+               Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$\r
+       }\r
+\r
+       protected Control createDataViewer(Composite parent,\r
+                       TmfTimeAnalysisProvider utilImplm) {\r
+               loadOptions();\r
+               _utilImplm = utilImplm;\r
+               _colors = new TraceColorScheme();\r
+               _dataViewer = new Composite(parent, SWT.NULL);\r
+               _dataViewer.setLayoutData(GridUtil.createFill());\r
+               GridLayout gl = new GridLayout();\r
+               gl.marginHeight = borderWidth;\r
+               gl.marginWidth = 0;\r
+               gl.verticalSpacing = 0;\r
+               gl.horizontalSpacing = 0;\r
+               _dataViewer.setLayout(gl);\r
+\r
+               _timeScaleCtrl = new TimeScaleCtrl(_dataViewer, _colors);\r
+               _timeScaleCtrl.setTimeProvider(this);\r
+               _timeScaleCtrl.setLayoutData(GridUtil.createHorizontalFill());\r
+               _timeScaleCtrl.setHeight(timeScaleHeight);\r
+\r
+               _stateCtrl = new TmfTimeStatesCtrl(_dataViewer, _colors, _utilImplm);\r
+\r
+               _stateCtrl.setTimeProvider(this);\r
+               _stateCtrl.addSelectionListener(this);\r
+               _stateCtrl.setLayoutData(GridUtil.createFill());\r
+               _dataViewer.addControlListener(new ControlAdapter() {\r
+                       @Override\r
+                       public void controlResized(ControlEvent event) {\r
+                               resizeControls();\r
+                       }\r
+               });\r
+               resizeControls();\r
+               _dataViewer.update();\r
+               _threadTip = new TmfTimeTipHandler(parent.getShell(), _utilImplm, this);\r
+               _threadTip.activateHoverHelp(_stateCtrl);\r
+               return _dataViewer;\r
+       }\r
+\r
+       public void dispose() {\r
+               saveOptions();\r
+               _stateCtrl.dispose();\r
+               _dataViewer.dispose();\r
+               _colors.dispose();\r
+       }\r
+\r
+       @Override\r
+       public void resizeControls() {\r
+               Rectangle r = _dataViewer.getClientArea();\r
+               if (r.isEmpty())\r
+                       return;\r
+\r
+               int width = r.width;\r
+               if (_nameWidth > width - _minNameWidth)\r
+                       _nameWidth = width - _minNameWidth;\r
+               if (_nameWidth < _minNameWidth)\r
+                       _nameWidth = _minNameWidth;\r
+       }\r
+\r
+       /** Tries to set most convenient time range for display. */\r
+       void setTimeRange(Object traces[]) {\r
+               _endTime = 0;\r
+               _beginTime = -1;\r
+//             ITimeEvent event;\r
+               for (int i = 0; i < traces.length; i++) {\r
+                       ITmfTimeAnalysisEntry entry = (ITmfTimeAnalysisEntry) traces[i];\r
+                       if (entry.getStopTime() >= entry.getStartTime() && entry.getStopTime() > 0) {\r
+                           if (_beginTime < 0 || entry.getStartTime() < _beginTime) {\r
+                               _beginTime = entry.getStartTime();\r
+                           }\r
+                           if (entry.getStopTime() > _endTime) {\r
+                               _endTime = entry.getStopTime();\r
+                           }\r
+                       }\r
+                       /*\r
+                        * This is not needed if entry startTime and stopTime are properly set!\r
+                       List<TimeEvent> list = entry.getTraceEvents();\r
+                       int len = list.size();\r
+                       if (len > 0) {\r
+                event = (ITimeEvent) list.get(0);\r
+                if (_beginTime < 0 || event.getTime() < _beginTime) {\r
+                    _beginTime = event.getTime();\r
+                }\r
+                               event = (ITimeEvent) list.get(list.size() - 1);\r
+                               long eventEndTime = event.getTime() + (event.getDuration() > 0 ? event.getDuration() : 0);\r
+                               if (eventEndTime > _endTime) {\r
+                                       _endTime = eventEndTime;\r
+                               }\r
+                       }\r
+                       */\r
+               }\r
+\r
+               if (_beginTime < 0)\r
+                       _beginTime = 0;\r
+       }\r
+\r
+       void setTimeBounds() {\r
+               //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
+           _time0_ = _beginTime;\r
+               if (_time0_ < 0)\r
+                       _time0_ = 0;\r
+               // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;\r
+               _time1_ = _endTime;\r
+               // _time0_ = Math.floor(_time0_);\r
+               // _time1_ = Math.ceil(_time1_);\r
+               if (!_timeRangeFixed) {\r
+                       _time0 = _time0_;\r
+                       _time1 = _time1_;\r
+               }\r
+        if (_time1 - _time0 < _minTimeInterval) {\r
+            _time1 = _time0 + _minTimeInterval;\r
+        }\r
+       }\r
+\r
+       /**\r
+        * @param traces\r
+        */\r
+       void updateInternalData(ITmfTimeAnalysisEntry[] traces) {\r
+               if (null == traces)\r
+                       traces = new ITmfTimeAnalysisEntry[0];\r
+               setTimeRange(traces);\r
+               refreshAllData(traces);\r
+       }\r
+\r
+       /**\r
+        * @param traces\r
+        * @param start\r
+        * @param end\r
+        */\r
+       void updateInternalData(ITmfTimeAnalysisEntry[] traces, long start, long end) {\r
+               if (null == traces)\r
+                       traces = new ITmfTimeAnalysisEntry[0];\r
+               if ((start == 0 && end == 0) || start < 0 || end < 0) {\r
+                       // Start and end time are unspecified and need to be determined from\r
+                       // individual processes\r
+                       setTimeRange(traces);\r
+               } else {\r
+                       _beginTime = start;\r
+                       _endTime = end;\r
+               }\r
+\r
+               refreshAllData(traces);\r
+       }\r
+\r
+       /**\r
+        * @param traces\r
+        */\r
+       private void refreshAllData(ITmfTimeAnalysisEntry[] traces) {\r
+               setTimeBounds();\r
+               if (_selectedTime < _beginTime) {\r
+                   _selectedTime = _beginTime;\r
+               } else if (_selectedTime > _endTime) {\r
+            _selectedTime = _endTime;\r
+               }\r
+               _stateCtrl.refreshData(traces);\r
+               filterOutNotification();\r
+       }\r
+\r
+       @Override\r
+       public void setFocus() {\r
+               if (null != _stateCtrl)\r
+                       _stateCtrl.setFocus();\r
+       }\r
+\r
+       @Override\r
+       public boolean isInFocus() {\r
+               return _stateCtrl.isInFocus();\r
+       }\r
+\r
+       @Override\r
+       public ITmfTimeAnalysisEntry getSelectedTrace() {\r
+               return _stateCtrl.getSelectedTrace();\r
+       }\r
+\r
+       @Override\r
+       public ISelection getSelection() {\r
+               return _stateCtrl.getSelection();\r
+       }\r
+\r
+       @Override\r
+       public ISelection getSelectionTrace() {\r
+               return _stateCtrl.getSelectionTrace();\r
+       }\r
+\r
+       @Override\r
+       public long getTime0() {\r
+               return _time0;\r
+       }\r
+\r
+       @Override\r
+       public long getTime1() {\r
+               return _time1;\r
+       }\r
+\r
+       @Override\r
+       public long getMinTimeInterval() {\r
+               return _minTimeInterval;\r
+       }\r
+\r
+       @Override\r
+       public int getNameSpace() {\r
+               return _nameWidth;\r
+       }\r
+\r
+       @Override\r
+       public void setNameSpace(int width) {\r
+               _nameWidth = width;\r
+               width = _stateCtrl.getClientArea().width;\r
+               if (_nameWidth > width - 6)\r
+                       _nameWidth = width - 6;\r
+               if (_nameWidth < 6)\r
+                       _nameWidth = 6;\r
+               _stateCtrl.adjustScrolls();\r
+               _stateCtrl.redraw();\r
+               _timeScaleCtrl.redraw();\r
+       }\r
+\r
+       @Override\r
+       public int getTimeSpace() {\r
+               int w = _stateCtrl.getClientArea().width;\r
+               return w - _nameWidth;\r
+       }\r
+\r
+       @Override\r
+       public long getSelectedTime() {\r
+               return _selectedTime;\r
+       }\r
+\r
+       @Override\r
+       public long getBeginTime() {\r
+               return _beginTime;\r
+       }\r
+\r
+       @Override\r
+       public long getEndTime() {\r
+               return _endTime;\r
+       }\r
+\r
+       @Override\r
+       public long getMaxTime() {\r
+               return _time1_;\r
+       }\r
+\r
+       @Override\r
+       public long getMinTime() {\r
+               return _time0_;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
+        * #setStartFinishTimeNotify(long, long)\r
+        */\r
+       @Override\r
+       public void setStartFinishTimeNotify(long time0, long time1) {\r
+               setStartFinishTime(time0, time1);\r
+               notifyStartFinishTimeSelectionListeners(time0, time1);\r
+       }\r
+\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()\r
+     */\r
+    @Override\r
+       public void notifyStartFinishTime() {\r
+        notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
+    }\r
+\r
+    /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
+        * #setStartFinishTime(long, long)\r
+        */\r
+       @Override\r
+       public void setStartFinishTime(long time0, long time1) {\r
+               _time0 = time0;\r
+        if (_time0 < _time0_)\r
+            _time0 = _time0_;\r
+        if (_time0 > _time1_)\r
+            _time0 = _time1_;\r
+               _time1 = time1;\r
+        if (_time1 < _time0_)\r
+            _time1 = _time0_;\r
+        if (_time1 > _time1_)\r
+            _time1 = _time1_;\r
+               if (_time1 - _time0 < _minTimeInterval)\r
+                   _time1 = _time0 + _minTimeInterval;\r
+               _timeRangeFixed = true;\r
+               _stateCtrl.adjustScrolls();\r
+               _stateCtrl.redraw();\r
+               _timeScaleCtrl.redraw();\r
+       }\r
+\r
+       @Override\r
+       public void setTimeBounds(long beginTime, long endTime) {\r
+           _beginTime = beginTime;\r
+           _endTime = endTime;\r
+           _time0_ = beginTime;\r
+           _time1_ = endTime;\r
+           _stateCtrl.adjustScrolls();\r
+           _stateCtrl.redraw();\r
+           _timeScaleCtrl.redraw();\r
+       }\r
+\r
+       @Override\r
+       public void resetStartFinishTime() {\r
+               setStartFinishTimeNotify(_time0_, _time1_);\r
+               _timeRangeFixed = false;\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTimeInt(long time, boolean ensureVisible) {\r
+               // Trace.debug("currentTime:" + _selectedTime + " new time:" + time);\r
+               _selectedTime = time;\r
+               if (_selectedTime > _endTime) {\r
+                       _endTime = _selectedTime;\r
+                       _time1_ = _selectedTime;\r
+               }\r
+               if (_selectedTime < _beginTime) {\r
+                       _beginTime = _selectedTime;\r
+                       _time0_ = _selectedTime;\r
+               }\r
+               long time0 = _time0;\r
+               long time1 = _time1;\r
+               if (ensureVisible) {\r
+                       double timeSpace = (_time1 - _time0) * .02;\r
+                       double timeMid = (_time1 - _time0) * .1;\r
+                       if (_selectedTime < _time0 + timeSpace) {\r
+                               long dt = (long) (_time0 - _selectedTime + timeMid);\r
+                               _time0 -= dt;\r
+                               _time1 -= dt;\r
+                       } else if (_selectedTime > _time1 - timeSpace) {\r
+                               long dt = (long) (_selectedTime - _time1 + timeMid);\r
+                               _time0 += dt;\r
+                               _time1 += dt;\r
+                       }\r
+                       if (_time0 < _time0_) {\r
+                               _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0));\r
+                               _time0 = _time0_;\r
+                       } else if (_time1 > _time1_) {\r
+                               _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_));\r
+                               _time1 = _time1_;\r
+                       }\r
+               }\r
+               if (_time1 - _time0 < _minTimeInterval) {\r
+                       _time1 = _time0 + _minTimeInterval;\r
+               }\r
+               _stateCtrl.adjustScrolls();\r
+               _stateCtrl.redraw();\r
+               _timeScaleCtrl.redraw();\r
+               if (time0 != _time0 || time1 != _time1) {\r
+                       notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void widgetDefaultSelected(SelectionEvent e) {\r
+               // TODO: Opening call stack shall be replaced to a configurable view\r
+               // new OpenCallStackViewAction().openView(false);\r
+               // Replaced by event notification\r
+               // updateModelSelection();\r
+               notifySelectionListeners(TmfTimeSelectionEvent.Type.WIDGET_DEF_SEL);\r
+       }\r
+\r
+       @Override\r
+       public void widgetSelected(SelectionEvent e) {\r
+               // Replace by event notification\r
+               // updateModelSelection();\r
+               notifySelectionListeners(TmfTimeSelectionEvent.Type.WIDGET_SEL);\r
+       }\r
+\r
+       @Override\r
+       public void selectNextEvent() {\r
+               _stateCtrl.selectNextEvent();\r
+       }\r
+\r
+       @Override\r
+       public void selectPrevEvent() {\r
+               _stateCtrl.selectPrevEvent();\r
+       }\r
+\r
+       @Override\r
+       public void selectNextTrace() {\r
+               _stateCtrl.selectNextTrace();\r
+       }\r
+\r
+       @Override\r
+       public void selectPrevTrace() {\r
+               _stateCtrl.selectPrevTrace();\r
+       }\r
+\r
+       @Override\r
+       public void groupTraces(boolean on) {\r
+               _stateCtrl.groupTraces(on);\r
+       }\r
+\r
+       @Override\r
+       public void filterTraces() {\r
+               if (_dataViewer == null || _dataViewer.isDisposed())\r
+                       return;\r
+\r
+               if (TmfTimeFilterDialog.getTraceFilter(_dataViewer.getShell(), _stateCtrl\r
+                               .getTraces(), _stateCtrl.getTraceFilter())) {\r
+                       _stateCtrl.refreshData();\r
+                       filterOutNotification();\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void showLegend() {\r
+               if (_dataViewer == null || _dataViewer.isDisposed())\r
+                       return;\r
+\r
+               TmfTimeLegend.open(_dataViewer.getShell(), _utilImplm);\r
+       }\r
+\r
+       public void toggleThreadsInteractionDrawing() {\r
+               _stateCtrl.toggleTraceInteractionDrawing();\r
+       }\r
+\r
+       public void setThreadJoinDrawing(boolean on) {\r
+               _stateCtrl.setTraceJoinDrawing(on);\r
+       }\r
+\r
+       public void setThreadWaitDrawing(boolean on) {\r
+               _stateCtrl.setTraceWaitDrawing(on);\r
+       }\r
+\r
+       public void setThreadReleaseDrawing(boolean on) {\r
+               _stateCtrl.setTraceReleaseDrawing(on);\r
+       }\r
+\r
+       public boolean getThreadInteractionDrawing() {\r
+               return _stateCtrl.getTracesInteractionDrawing();\r
+       }\r
+\r
+       public boolean getThreadJoinDrawing() {\r
+               return _stateCtrl.getTraceJoinDrawing();\r
+       }\r
+\r
+       public boolean getThreadWaitDrawing() {\r
+               return _stateCtrl.getTraceWaitDrawing();\r
+       }\r
+\r
+       public boolean getThreadReleaseDrawing() {\r
+               return _stateCtrl.getTraceReleaseDrawing();\r
+       }\r
+\r
+       protected void select(Object obj) {\r
+               if (obj == null)\r
+                       return;\r
+               // TODO: ThreadDetails Adaption removed, might need replacement\r
+               // if (obj instanceof ThreadDetails) {\r
+               // obj = ((ThreadDetails) obj).getThread();\r
+               // }\r
+               if (obj instanceof ITmfTimeAnalysisEntry) {\r
+                       // _stateCtrl.selectThread((TsfTmTrace) obj);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void zoomIn() {\r
+               _stateCtrl.zoomIn();\r
+       }\r
+\r
+       @Override\r
+       public void zoomOut() {\r
+               _stateCtrl.zoomOut();\r
+       }\r
+\r
+       private String getPreferenceString(String string) {\r
+               return getViewTypeStr() + "." + string; //$NON-NLS-1$\r
+       }\r
+\r
+       @Override\r
+       public void addWidgetSelectionListner(ITmfTimeSelectionListener listener) {\r
+               widgetSelectionListners.add(listener);\r
+       }\r
+\r
+       @Override\r
+       public void removeWidgetSelectionListner(ITmfTimeSelectionListener listener) {\r
+               widgetSelectionListners.removeElement(listener);\r
+       }\r
+\r
+       @Override\r
+       public void addWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener) {\r
+               widgetTimeScaleSelectionListners.add(listener);\r
+       }\r
+\r
+       @Override\r
+       public void removeWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener) {\r
+               widgetTimeScaleSelectionListners.removeElement(listener);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTime(long time, boolean ensureVisible, Object source) {\r
+               if (_acceptSetSelAPICalls == false || this == source) {\r
+                       return;\r
+               }\r
+\r
+               setSelectedTimeInt(time, ensureVisible);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedEvent(ITimeEvent event, Object source) {\r
+               if (_acceptSetSelAPICalls == false || event == null || source == this) {\r
+                       return;\r
+               }\r
+               ITmfTimeAnalysisEntry trace = event.getEntry();\r
+               if (trace != null) {\r
+                       _stateCtrl.selectItem(trace, false);\r
+               }\r
+\r
+               setSelectedTimeInt(event.getTime(), true);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTraceTime(ITmfTimeAnalysisEntry trace, long time, Object source) {\r
+               if (_acceptSetSelAPICalls == false || trace == null || source == this) {\r
+                       return;\r
+               }\r
+\r
+               if (trace != null) {\r
+                       _stateCtrl.selectItem(trace, false);\r
+               }\r
+\r
+               setSelectedTimeInt(time, true);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTrace(ITmfTimeAnalysisEntry trace) {\r
+               if (trace == null) {\r
+                       return;\r
+               }\r
+\r
+               _stateCtrl.selectItem(trace, false);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
+        * #setSelectVisTimeWindow(long, long, java.lang.Object)\r
+        */\r
+       @Override\r
+       public void setSelectVisTimeWindow(long time0, long time1, Object source) {\r
+               if (_acceptSetSelAPICalls == false || source == this) {\r
+                       return;\r
+               }\r
+\r
+               setStartFinishTime(time0, time1);\r
+\r
+               // update notification time values since we are now in synch with the\r
+               // external application\r
+               updateExtSynchTimers();\r
+       }\r
+\r
+       @Override\r
+       public void setAcceptSelectionAPIcalls(boolean acceptCalls) {\r
+               _acceptSetSelAPICalls = acceptCalls;\r
+       }\r
+\r
+       private synchronized void notifySelectionListeners(\r
+                       TmfTimeSelectionEvent.Type rtype) {\r
+               // Any listeners out there ?\r
+               if (widgetSelectionListners.size() > 0) {\r
+                       // Locate the event selected\r
+                       ISelection selection = getSelection();\r
+                       Object sel = null;\r
+                       if (selection != null && !selection.isEmpty()) {\r
+                               sel = ((IStructuredSelection) selection).getFirstElement();\r
+                       }\r
+\r
+                       if (sel != null) {\r
+                               // Notify Selection Listeners\r
+                               TmfTimeSelectionEvent event = new TmfTimeSelectionEvent(this,\r
+                                               rtype, sel, getSelectedTime());\r
+\r
+                               for (Iterator<ITmfTimeSelectionListener> iter = widgetSelectionListners\r
+                                               .iterator(); iter.hasNext();) {\r
+                                       ITmfTimeSelectionListener listener = (ITmfTimeSelectionListener) iter\r
+                                                       .next();\r
+                                       listener.tsfTmProcessSelEvent(event);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       public void notifyStartFinishTimeSelectionListeners(long _time0, long _time1) {\r
+               if (widgetTimeScaleSelectionListners.size() > 0) {\r
+                       // Check if the time has actually changed from last notification\r
+                       if (_time0 != _time0_extSynch || _time1 != _time1_extSynch) {\r
+                               // Notify Time Scale Selection Listeners\r
+                               TmfTimeScaleSelectionEvent event = new TmfTimeScaleSelectionEvent(\r
+                                               this, _time0, _time1, getTimeSpace(), getSelectedTime());\r
+\r
+                               for (Iterator<ITmfTimeScaleSelectionListener> iter = widgetTimeScaleSelectionListners\r
+                                               .iterator(); iter.hasNext();) {\r
+                                       ITmfTimeScaleSelectionListener listener = (ITmfTimeScaleSelectionListener) iter\r
+                                                       .next();\r
+                                       listener.tsfTmProcessTimeScaleEvent(event);\r
+                               }\r
+\r
+                               // update external synch timers\r
+                               updateExtSynchTimers();\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * update the cache timers used to identify the need to send a time window\r
+        * update to external registered listeners\r
+        */\r
+       private void updateExtSynchTimers() {\r
+               // last time notification cache\r
+               _time0_extSynch = _time0;\r
+               _time1_extSynch = _time1;\r
+       }\r
+\r
+       @Override\r
+       public void setTimeCalendarFormat(boolean toAbsoluteCaltime) {\r
+               calendarTimeFormat = toAbsoluteCaltime;\r
+       }\r
+\r
+       @Override\r
+       public boolean isCalendarFormat() {\r
+               return calendarTimeFormat;\r
+       }\r
+\r
+       @Override\r
+       public int getBorderWidth() {\r
+               return borderWidth;\r
+       }\r
+\r
+       @Override\r
+       public void setBorderWidth(int borderWidth) {\r
+               if (borderWidth > -1) {\r
+            this.borderWidth = borderWidth;\r
+            GridLayout gl = (GridLayout)_dataViewer.getLayout();\r
+            gl.marginHeight = borderWidth;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public int getHeaderHeight() {\r
+               return timeScaleHeight;\r
+       }\r
+\r
+       @Override\r
+       public void setHeaderHeight(int headerHeight) {\r
+               if (headerHeight > -1) {\r
+                       this.timeScaleHeight = headerHeight;\r
+                       _timeScaleCtrl.setHeight(headerHeight);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public int getItemHeight() {\r
+               if (_stateCtrl != null) {\r
+                       return _stateCtrl.getItemHeight();\r
+               }\r
+               return 0;\r
+       }\r
+\r
+       @Override\r
+       public void setItemHeight(int rowHeight) {\r
+               if (_stateCtrl != null) {\r
+                       _stateCtrl.setItemHeight(rowHeight);\r
+               }\r
+       }\r
+\r
+    @Override\r
+    public void setMinimumItemWidth(int width) {\r
+        if (_stateCtrl != null) {\r
+            _stateCtrl.setMinimumItemWidth(width);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public boolean isVisibleVerticalScroll() {\r
+               if (_stateCtrl != null) {\r
+                       _stateCtrl.isVisibleVerticalScroll();\r
+               }\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public void setVisibleVerticalScroll(boolean visibleVerticalScroll) {\r
+               if (_stateCtrl != null) {\r
+                       _stateCtrl.setVisibleVerticalScroll(visibleVerticalScroll);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void setNameWidthPref(int width) {\r
+               _nameWidthPref = width;\r
+               if (width == 0) {\r
+                       _minNameWidth = 0;\r
+            _nameWidth = 0;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public int getNameWidthPref(int width) {\r
+               return _nameWidthPref;\r
+       }\r
+\r
+       @Override\r
+       public void addFilterSelectionListner(ITmfTimeFilterSelectionListener listener) {\r
+               widgetFilterSelectionListeners.add(listener);\r
+       }\r
+\r
+       @Override\r
+       public void removeFilterSelectionListner(\r
+                       ITmfTimeFilterSelectionListener listener) {\r
+               widgetFilterSelectionListeners.remove(listener);\r
+       }\r
+\r
+       private void filterOutNotification() {\r
+               TmfTimeFilterSelectionEvent event = new TmfTimeFilterSelectionEvent(this);\r
+               event.setFilteredOut(_stateCtrl.getFilteredOut());\r
+               for (ITmfTimeFilterSelectionListener listener : widgetFilterSelectionListeners) {\r
+                       listener.tmfTaProcessFilterSelection(event);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * needed in case there's a need to associate a context menu\r
+        * \r
+        * @return the state control (selection provider)\r
+        */\r
+       @Override\r
+       public Control getControl() {\r
+               return _stateCtrl;\r
+       }\r
+\r
+       /**\r
+        * Get the selection provider\r
+        * \r
+     * @return the selection provider\r
+        */\r
+       @Override\r
+       public ISelectionProvider getSelectionProvider() {\r
+               return _stateCtrl;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
+        * #waitCursor(boolean)\r
+        */\r
+       @Override\r
+       public void waitCursor(boolean waitInd) {\r
+               _stateCtrl.waitCursor(waitInd);\r
+       }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#getHorizontalBar()\r
+     */\r
+    @Override\r
+    public ScrollBar getHorizontalBar() {\r
+        return _stateCtrl.getHorizontalBar();\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#getVerticalBar()\r
+     */\r
+    @Override\r
+    public ScrollBar getVerticalBar() {\r
+        return _stateCtrl.getVerticalBar();\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#setTopIndex(int)\r
+     */\r
+    @Override\r
+    public void setTopIndex(int index) {\r
+        _stateCtrl.setTopIndex(index);\r
+    }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeFilterSelectionEvent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeFilterSelectionEvent.java
new file mode 100644 (file)
index 0000000..483406d
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.EventObject;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+\r
+public class TmfTimeFilterSelectionEvent extends EventObject {\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = -150960748016449093L;\r
+\r
+       Vector<ITmfTimeAnalysisEntry> filteredOut = null;\r
+\r
+       public TmfTimeFilterSelectionEvent(Object source) {\r
+               super(source);\r
+       }\r
+\r
+       public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
+               return filteredOut;\r
+       }\r
+\r
+       public void setFilteredOut(Vector<ITmfTimeAnalysisEntry> rfilteredOut) {\r
+               this.filteredOut = rfilteredOut;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeScaleSelectionEvent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeScaleSelectionEvent.java
new file mode 100644 (file)
index 0000000..d42c499
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.EventObject;\r
+\r
+public class TmfTimeScaleSelectionEvent extends EventObject {\r
+\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = -4177428788761351379L;\r
+\r
+       \r
+       long time0 = 0;\r
+       long time1 = 0;\r
+       long selectedTime = 0;\r
+       int width = 0;\r
+\r
+       /**\r
+        * \r
+        * @param arg0\r
+        *            source of event\r
+        * @param time0\r
+        *            time0 the start time\r
+        * @param time1\r
+        * @param width\r
+        *            pixels used to draw the width of the time space\r
+        * @param selTime\r
+        *            carries the selected time if available otherwise is 0\r
+        */\r
+       public TmfTimeScaleSelectionEvent(Object arg0, long time0, long time1,\r
+                       int width, long selTime) {\r
+               super(arg0);\r
+               this.time0 = time0;\r
+               this.time1 = time1;\r
+               this.width = width;\r
+               this.selectedTime = selTime;\r
+       }\r
+       \r
+       /**\r
+        * @return the start time\r
+        */\r
+       public long getTime0() {\r
+               return time0;\r
+       }\r
+       \r
+       /**\r
+        * @return the end time\r
+        */\r
+       public long getTime1() {\r
+               return time1;\r
+       }\r
+\r
+       /**\r
+        * @return the selection width\r
+        */\r
+       public int getWidth() {\r
+               return width;\r
+       }\r
+\r
+       /**\r
+        * @return the selected time\r
+        */\r
+       public long getSelectedTime() {\r
+               return selectedTime;\r
+       }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeSelectionEvent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfTimeSelectionEvent.java
new file mode 100644 (file)
index 0000000..5b36d72
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import java.util.EventObject;\r
+\r
+public class TmfTimeSelectionEvent extends EventObject {\r
+\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = 1L;\r
+       \r
+       public enum Type {WIDGET_DEF_SEL, WIDGET_SEL}\r
+       Type dType;\r
+       Object selection = null;\r
+       long selTime = 0;\r
+       int index = 0;\r
+       \r
+       public TmfTimeSelectionEvent(Object arg0, Type rType, Object sel, long selectedTime) {\r
+               super(arg0);\r
+               dType = rType;\r
+               selection = sel;\r
+               selTime = selectedTime;\r
+       }\r
+       \r
+       public Type getDType() {\r
+               return dType;\r
+       }\r
+       \r
+       public Object getSelection() {\r
+               return selection;\r
+       }\r
+       \r
+       public long getSelectedTime() {\r
+               return selTime;\r
+       }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfViewerFactory.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/TmfViewerFactory.java
new file mode 100644 (file)
index 0000000..c8f1ae9
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+/**\r
+ * <b><u>TmfWidgetFactory</u></b>\r
+ * <p>\r
+ *\r
+ * TODO: Generalize when extension points are introduced\r
+ * TODO: Today, it is specific for the TimeAnalysis widget\r
+ */\r
+public class TmfViewerFactory {\r
+\r
+//    public static ITmfWidget createWidget(String id, Composite parent) {\r
+//        return null;\r
+//    }\r
+    \r
+    public static ITimeAnalysisViewer createViewer(Composite parent,\r
+            TmfTimeAnalysisProvider provider) {\r
+        return new TmfTimeAnalysisViewer(parent, provider);\r
+    }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/dialogs/TmfTimeFilterDialog.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/dialogs/TmfTimeFilterDialog.java
new file mode 100644 (file)
index 0000000..ea3b434
--- /dev/null
@@ -0,0 +1,222 @@
+/*****************************************************************************\r
+ * Copyright (c) 2008 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *\r
+ * $Id: ThreadFilterDialog.java,v 1.2 2008/03/05 17:31:07 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.dialogs;\r
+\r
+import java.util.Arrays;\r
+\r
+import org.eclipse.jface.dialogs.TitleAreaDialog;\r
+import org.eclipse.jface.viewers.CheckStateChangedEvent;\r
+import org.eclipse.jface.viewers.CheckboxTableViewer;\r
+import org.eclipse.jface.viewers.ICheckStateListener;\r
+import org.eclipse.jface.viewers.IStructuredContentProvider;\r
+import org.eclipse.jface.viewers.ITableLabelProvider;\r
+import org.eclipse.jface.viewers.LabelProvider;\r
+import org.eclipse.jface.viewers.Viewer;\r
+import org.eclipse.jface.viewers.ViewerComparator;\r
+import org.eclipse.jface.window.Window;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.Messages;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+\r
+public class TmfTimeFilterDialog extends TitleAreaDialog {\r
+       private CheckboxTableViewer viewer;\r
+       private Object[] threads;\r
+       private boolean[] filter;\r
+       private ViewContentProvider viewContentProvider;\r
+       private TraceComparator viewTraceComparator;\r
+       private ViewLabelProvider viewViewLabelProvider;\r
+\r
+       public TmfTimeFilterDialog(Shell parentShell, Object[] threads,\r
+                       boolean[] filter) {\r
+               super(parentShell);\r
+\r
+               this.threads = (threads != null) ? Arrays.copyOf(threads, threads.length) : null;\r
+               if (filter != null)\r
+                       this.filter = (boolean[]) filter.clone();\r
+               \r
+               viewContentProvider = new ViewContentProvider();\r
+               viewTraceComparator = new TraceComparator();\r
+               viewViewLabelProvider = new ViewLabelProvider();\r
+       }\r
+\r
+       public static boolean getTraceFilter(Shell parentShell, Object[] threads,\r
+                       boolean[] filter) {\r
+               TmfTimeFilterDialog dlg = new TmfTimeFilterDialog(parentShell, threads,\r
+                               filter);\r
+               if (dlg.open() != Window.OK)\r
+                       return false;\r
+\r
+               boolean f[] = dlg.getFilter();\r
+               if (java.util.Arrays.equals(f, filter))\r
+                       return false;\r
+               for (int i = f.length - 1; i >= 0; i--)\r
+                       filter[i] = f[i];\r
+\r
+               return true;\r
+       }\r
+\r
+       @Override\r
+       protected Control createDialogArea(Composite parent) {\r
+               Composite composite = (Composite) super.createDialogArea(parent);\r
+\r
+               viewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER\r
+                               | SWT.V_SCROLL);\r
+\r
+               Table table = viewer.getTable();\r
+               table.setLayoutData(new GridData(GridData.FILL_BOTH));\r
+               table.setBackground(parent.getBackground());\r
+               createColumns(table);\r
+\r
+               //Assign providers to the viewer.\r
+               viewer.setContentProvider(viewContentProvider);\r
+               viewer.setComparator(viewTraceComparator);\r
+               viewer.setLabelProvider(viewViewLabelProvider);\r
+               \r
+               viewer.setInput(new Object());\r
+\r
+               viewer.addCheckStateListener(new ICheckStateListener() {\r
+                       @Override\r
+                       public void checkStateChanged(CheckStateChangedEvent event) {\r
+                               Object o = event.getElement();\r
+                               for (int i = threads.length - 1; i >= 0; i--) {\r
+                                       if (threads[i].equals(o))\r
+                                               filter[i] = event.getChecked();\r
+                               }\r
+                       }\r
+               });\r
+\r
+               if (filter != null) {\r
+                       for (int i = 0; i < filter.length; i++)\r
+                               viewer.setChecked(threads[i], filter[i]);\r
+               }\r
+\r
+               setMessage(Messages.TmfTimeFilterDialog_TRACE_FILTER_DESC);\r
+               setTitle(Messages.TmfTimeFilterDialog_TRACE_FILTER);\r
+               setDialogHelpAvailable(false);\r
+               setHelpAvailable(false);\r
+\r
+//             setTitleImage(org.eclipse.hyades.trace.internal.ui.PDPluginImages.DESC_IMG_UI_WZ_EDITPROFSET\r
+//                             .createImage());\r
+\r
+               return composite;\r
+       }\r
+\r
+       private void createColumns(Table table) {\r
+               table.setHeaderVisible(true);\r
+\r
+               String headers[] = { "", Messages.TmfTimeFilterDialog_TRACE_ID, Messages.TmfTimeFilterDialog_TRACE_NAME }; //$NON-NLS-1$\r
+               int width[] = { 20, 80, 400 };\r
+\r
+               for (int i = 0; i < headers.length; i++) {\r
+                       TableColumn tc = new TableColumn(table, SWT.NONE, i);\r
+                       tc.setResizable(true);\r
+                       tc.setText(headers[i]);\r
+                       tc.setWidth(width[i]);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       protected void configureShell(Shell shell) {\r
+               super.configureShell(shell);\r
+               shell.setText(Messages.TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS);\r
+       }\r
+\r
+       public boolean[] getFilter() {\r
+               return (filter != null) ? Arrays.copyOf(filter, filter.length) : null;\r
+       }\r
+\r
+       /**\r
+        * @param viewContentProvider\r
+        */\r
+       public void setViewContentProvider(ViewContentProvider viewContentProvider) {\r
+               this.viewContentProvider = viewContentProvider;\r
+       }\r
+\r
+       /**\r
+        * @param viewThreadComparator\r
+        */\r
+       public void setViewThreadComparator(TraceComparator viewThreadComparator) {\r
+               this.viewTraceComparator = viewThreadComparator;\r
+       }\r
+\r
+       /**\r
+        * @param viewViewLabelProvider\r
+        */\r
+       public void setViewViewLabelProvider(ViewLabelProvider viewViewLabelProvider) {\r
+               this.viewViewLabelProvider = viewViewLabelProvider;\r
+       }\r
+       \r
+       class ViewContentProvider implements IStructuredContentProvider {\r
+               @Override\r
+               public void dispose() {\r
+               }\r
+\r
+               @Override\r
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
+               }\r
+\r
+               @Override\r
+               public Object[] getElements(Object input) {\r
+                       return threads;\r
+               }\r
+       }\r
+\r
+       private static class ViewLabelProvider extends LabelProvider implements\r
+                       ITableLabelProvider {\r
+               @Override\r
+               public Image getImage(Object obj) {\r
+                       return null;\r
+               }\r
+\r
+               @Override\r
+               public Image getColumnImage(Object element, int columnIndex) {\r
+                       return null;\r
+               }\r
+\r
+               @Override\r
+               public String getColumnText(Object element, int columnIndex) {\r
+                       // TODO: AA: Provide Label Provider externally\r
+                       ITmfTimeAnalysisEntry t = (ITmfTimeAnalysisEntry) element;\r
+\r
+                       if (columnIndex == 1)\r
+                               return String.valueOf(t.getId());\r
+                       else if (columnIndex == 2)\r
+                               return t.getName();\r
+                       else\r
+                               return ""; //$NON-NLS-1$\r
+               }\r
+       }\r
+\r
+       private static class TraceComparator extends ViewerComparator {\r
+               @Override\r
+               public int compare(Viewer viewer, Object e1, Object e2) {\r
+                       // TODO: AA: Provide comparator externally\r
+                       int id1 = ((ITmfTimeAnalysisEntry) e1).getId();\r
+                       int id2 = ((ITmfTimeAnalysisEntry) e2).getId();\r
+\r
+                       if (id1 == id2)\r
+                               return 0;\r
+\r
+                       return (id1 < id2) ? -1 : 1;\r
+                       // return 0;\r
+               }\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/dialogs/TmfTimeLegend.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/dialogs/TmfTimeLegend.java
new file mode 100644 (file)
index 0000000..e185071
--- /dev/null
@@ -0,0 +1,279 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.dialogs;\r
+\r
+import org.eclipse.jface.dialogs.IDialogConstants;\r
+import org.eclipse.jface.dialogs.TitleAreaDialog;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.Messages;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider.StateColor;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Canvas;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Shell;\r
+\r
+\r
+public class TmfTimeLegend extends TitleAreaDialog {\r
+\r
+       // public static final String stateNames[] = {\r
+       // UIMessages._Unknown, // "Unknown",\r
+       // UIMessages._Running, // "Running",\r
+       // UIMessages._Sleeping, // "Sleeping",\r
+       // UIMessages._Waiting, // "Waiting",\r
+       // UIMessages._Blocked, // "Blocked",\r
+       // UIMessages._Deadlocked, // "Deadlock",\r
+       // UIMessages._Stopped, // "Stopped",\r
+       // };\r
+\r
+       // public static final String interactionNames[] = {\r
+       // UIMessages._START_THREAD,\r
+       // UIMessages._JOIN_TERMINATE,\r
+       // UIMessages._WAIT_NOTIFY,\r
+       // UIMessages._INTERRUPT,\r
+       // UIMessages._RELEASE_ACQUIRE\r
+       // };\r
+\r
+       public static final int interactionColors[] = {\r
+                       TraceColorScheme.TI_START_THREAD,\r
+                       TraceColorScheme.TI_NOTIFY_JOINED, TraceColorScheme.TI_NOTIFY,\r
+                       TraceColorScheme.TI_INTERRUPT, TraceColorScheme.TI_HANDOFF_LOCK };\r
+\r
+       protected TraceColorScheme colors;\r
+       private TmfTimeAnalysisProvider ifUtil;\r
+\r
+       public static void open(Shell parent, TmfTimeAnalysisProvider rifUtil) {\r
+               (new TmfTimeLegend(parent, rifUtil)).open();\r
+       }\r
+\r
+       public TmfTimeLegend(Shell parent, TmfTimeAnalysisProvider rifUtil) {\r
+               super(parent);\r
+               colors = new TraceColorScheme();\r
+               this.ifUtil = rifUtil;\r
+       }\r
+\r
+       @Override\r
+       protected Control createDialogArea(Composite parent) {\r
+               Composite dlgArea = (Composite) super.createDialogArea(parent);\r
+               Composite composite = new Composite(dlgArea, SWT.NONE);\r
+\r
+               GridLayout layout = new GridLayout();\r
+               layout.numColumns = 2;\r
+               composite.setLayout(layout);\r
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
+               composite.setLayoutData(gd);\r
+\r
+               createThreadStatesGroup(composite);\r
+               // createThreadInteractionsGroup(composite);\r
+\r
+               setMessage(Messages.TmfTimeLegend_LEGEND);\r
+               setTitle(Messages.TmfTimeLegend_TRACE_STATES_TITLE);\r
+               setDialogHelpAvailable(false);\r
+               setHelpAvailable(false);\r
+\r
+               //setTitleImage(org.eclipse.hyades.trace.internal.ui.PDPluginImages.DESC_IMG_UI_WZ_EDITPROFSET.createImage());\r
+\r
+               return composite;\r
+       }\r
+\r
+       private void createThreadStatesGroup(Composite composite) {\r
+               Group gs = new Group(composite, SWT.NONE);\r
+               gs.setText(Messages.TmfTimeLegend_TRACE_STATES);\r
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
+               gs.setLayoutData(gd);\r
+\r
+               GridLayout layout = new GridLayout();\r
+               layout.numColumns = 2;\r
+               layout.marginWidth = 20;\r
+               layout.marginBottom = 10;\r
+               gs.setLayout(layout);\r
+\r
+               // Go through all the defined colors and only add the ones you need. \r
+               // This will not handle several colors assigned to a color, we have \r
+               // 16 mil colors, and should not pick two to mean the same thing. \r
+               for (int i = 0; i <  TraceColorScheme.getStateColors().length; i++) {\r
+                       //Get the color enum related to the index\r
+                       StateColor stateColor = TraceColorScheme.getStateColors()[i];\r
+                       //Get the given name, provided by the interface to the application\r
+                       String stateName = ifUtil.getStateName(stateColor);\r
+                       if( stateName != "Not mapped" ) { //$NON-NLS-1$\r
+                               Bar bar = new Bar(gs, i);\r
+                               gd = new GridData();\r
+                               gd.widthHint = 40;\r
+                               gd.heightHint = 20;\r
+                               gd.verticalIndent = 8;\r
+                               bar.setLayoutData(gd);\r
+                               Label name = new Label(gs, SWT.NONE);\r
+                               name.setText(stateName);\r
+                               gd = new GridData();\r
+                               gd.horizontalIndent = 10;\r
+                               gd.verticalIndent = 8;\r
+                               name.setLayoutData(gd);\r
+                       }\r
+               }\r
+       }\r
+\r
+       // private void createThreadInteractionsGroup(Composite composite) {\r
+       // Group g = new Group (composite, SWT.NONE);\r
+       // g.setText(UIMessages._THREAD_INTERACTIONS);\r
+       // GridData gd = new GridData (SWT.FILL, SWT.FILL, true, true);\r
+       // g.setLayoutData(gd);\r
+       //\r
+       // GridLayout layout = new GridLayout();\r
+       // layout.numColumns = 2;\r
+       // layout.marginWidth = 20;\r
+       // layout.marginBottom = 10;\r
+       // g.setLayout(layout);\r
+       //              \r
+       // for (int i=0; i<5; i++) {\r
+       // Arrow a = new Arrow(g, interactionColors[i]);\r
+       // gd = new GridData();\r
+       // gd.widthHint = 10;\r
+       // gd.heightHint = 20;\r
+       // gd.verticalIndent = 8;\r
+       // a.setLayoutData(gd);\r
+       //              \r
+       // Label name = new Label (g, SWT.NONE);\r
+       // name.setText(interactionNames[i]);\r
+       // gd = new GridData ();\r
+       // gd.horizontalIndent = 4;\r
+       // gd.verticalIndent = 8;\r
+       // name.setLayoutData(gd);\r
+       // }\r
+       //\r
+       // Mark m = new Mark(g, TraceColorScheme.TI_WAIT_EXCEEDED);\r
+       // gd = new GridData();\r
+       // gd.widthHint = 10;\r
+       // gd.heightHint = 20;\r
+       // gd.verticalIndent = 8;\r
+       // m.setLayoutData(gd);\r
+       //              \r
+       // Label name = new Label (g, SWT.NONE);\r
+       // name.setText(UIMessages._WAIT_TIMEOUT_EXCEED);\r
+       // gd = new GridData ();\r
+       // gd.horizontalIndent = 4;\r
+       // gd.verticalIndent = 8;\r
+       // name.setLayoutData(gd);\r
+       // }\r
+\r
+       @Override\r
+       protected void configureShell(Shell shell) {\r
+               super.configureShell(shell);\r
+               shell.setText(Messages.TmfTimeLegend_WINDOW_TITLE);\r
+       }\r
+\r
+       @Override\r
+       protected void createButtonsForButtonBar(Composite parent) {\r
+               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\r
+                               true);\r
+       }\r
+\r
+       class Bar extends Canvas {\r
+               private Color color;\r
+\r
+               public Bar(Composite parent, int colorIdx) {\r
+                       super(parent, SWT.NONE);\r
+\r
+                       color = colors.getColor(colorIdx);\r
+                       addListener(SWT.Paint, new Listener() {\r
+                               @Override\r
+                               public void handleEvent(Event event) {\r
+                                       draw(event.gc);\r
+                               }\r
+                       });\r
+               }\r
+\r
+               private void draw(GC gc) {\r
+                       Rectangle r = getClientArea();\r
+                       gc.setBackground(color);\r
+                       gc.fillRectangle(r);\r
+                       gc.setForeground(colors.getColor(TraceColorScheme.BLACK));\r
+                       gc.drawRectangle(0, 0, r.width - 1, r.height - 1);\r
+               }\r
+       }\r
+\r
+       class Arrow extends Canvas {\r
+               public final static int HEIGHT = 12;\r
+               public final static int DX = 3;\r
+\r
+               private Color color;\r
+\r
+               public Arrow(Composite parent, int colorIdx) {\r
+                       super(parent, SWT.NONE);\r
+\r
+                       color = colors.getColor(colorIdx);\r
+                       addListener(SWT.Paint, new Listener() {\r
+                               @Override\r
+                               public void handleEvent(Event event) {\r
+                                       draw(event.gc);\r
+                               }\r
+                       });\r
+               }\r
+\r
+               private void draw(GC gc) {\r
+                       Rectangle r = getClientArea();\r
+                       gc.setForeground(color);\r
+\r
+                       int y0, y1;\r
+                       if (r.height > HEIGHT) {\r
+                               y0 = (r.height - HEIGHT) / 2;\r
+                               y1 = y0 + HEIGHT;\r
+                       } else {\r
+                               y0 = 0;\r
+                               y1 = r.height;\r
+                       }\r
+\r
+                       gc.drawLine(DX, y0, DX, y1);\r
+\r
+                       gc.drawLine(0, y0 + 3, DX, y0);\r
+                       gc.drawLine(2 * DX, y0 + 3, DX, y0);\r
+               }\r
+       }\r
+\r
+       class Mark extends Canvas {\r
+               public final static int DX = 3;\r
+\r
+               private Color color;\r
+\r
+               public Mark(Composite parent, int colorIdx) {\r
+                       super(parent, SWT.NONE);\r
+\r
+                       color = colors.getColor(colorIdx);\r
+                       addListener(SWT.Paint, new Listener() {\r
+                               @Override\r
+                               public void handleEvent(Event event) {\r
+                                       draw(event.gc);\r
+                               }\r
+                       });\r
+               }\r
+\r
+               private void draw(GC gc) {\r
+                       Rectangle r = getClientArea();\r
+                       gc.setBackground(color);\r
+\r
+                       int y = (r.height - DX) / 2;\r
+                       int c[] = { 0, y, DX, y + DX, 2 * DX, y };\r
+                       gc.fillPolygon(c);\r
+               }\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/messages.properties b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/messages.properties
new file mode 100644 (file)
index 0000000..bfdb2ec
--- /dev/null
@@ -0,0 +1,38 @@
+#*******************************************************************************\r
+# Copyright (c) 2012 Ericsson\r
+#  \r
+# All rights reserved. This program and the accompanying materials are\r
+# made available under the terms of the Eclipse Public License v1.0 which\r
+# accompanies this distribution, and is available at\r
+# http://www.eclipse.org/legal/epl-v10.html\r
+#  \r
+# Contributors:\r
+#   Patrick Tasse - Extracted from org.eclipse.linuxtools.tmf.ui\r
+# *******************************************************************************/\r
+\r
+# org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs\r
+TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS=Edit Profiling Options\r
+TmfTimeFilterDialog_TRACE_FILTER=Trace Filter\r
+TmfTimeFilterDialog_TRACE_FILTER_DESC=Define the filter set\r
+TmfTimeFilterDialog_TRACE_ID=Trace Id\r
+TmfTimeFilterDialog_TRACE_NAME=Trace Name\r
+TmfTimeLegend_LEGEND=Legend\r
+TmfTimeLegend_TRACE_STATES=Trace states\r
+TmfTimeLegend_TRACE_STATES_TITLE=States Transition Visualizer\r
+TmfTimeLegend_WINDOW_TITLE=Trace Visualizer's Legend\r
+\r
+# org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets\r
+TimeScaleCtrl_Timescale=Time scale\r
+TmfTimeStatesCtrl_TRACE_GROUP_LABEL=Trace Group [{0}]\r
+TmfTimeStatesCtrl_UNDEFINED_GROUP=<undefined>\r
+TmfTimeTipHandler_DURATION=Duration\r
+TmfTimeTipHandler_NUMBER_OF_TRACES=Number of traces\r
+TmfTimeTipHandler_TRACE_CLASS_NAME=Class Name\r
+TmfTimeTipHandler_TRACE_DATE=Date\r
+TmfTimeTipHandler_TRACE_EVENT_TIME=Event Time\r
+TmfTimeTipHandler_TRACE_GROUP_NAME=Group Name\r
+TmfTimeTipHandler_TRACE_NAME=Trace Name\r
+TmfTimeTipHandler_TRACE_START_TIME=Start Time\r
+TmfTimeTipHandler_TRACE_STATE=State\r
+TmfTimeTipHandler_TRACE_STOP_TIME=Stop Time\r
+\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/ITimeEvent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/ITimeEvent.java
new file mode 100644 (file)
index 0000000..08409bf
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model;\r
+\r
+public interface ITimeEvent {\r
+\r
+       public ITmfTimeAnalysisEntry getEntry();\r
+\r
+       public long getTime();\r
+\r
+       /**\r
+        * @return\r
+        * <list>\r
+        * <li>-1: Considers duration to be from current event till the next</li>\r
+        * <li>0: Duration is not relevant e.g. a Burst / no state associated</li>\r
+        * <li>>0: Valid duration value specified</li>\r
+        * </list>\r
+        * <p>\r
+        */\r
+       public long getDuration();\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java
new file mode 100644 (file)
index 0000000..dfa1971
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+public interface ITmfTimeAnalysisEntry {\r
+       \r
+    public String getGroupName();\r
+\r
+       public int getId();\r
+\r
+       public String getName();\r
+\r
+       public long getStartTime();\r
+\r
+       public long getStopTime();\r
+\r
+    /**\r
+     * Get a vector containing all events\r
+     * @deprecated replaced by {@link #getTraceEventsIterator()}\r
+     */\r
+    @Deprecated public <T extends ITimeEvent> Vector<T> getTraceEvents();\r
+    \r
+    /**\r
+     * Get an iterator which returns all events\r
+     */\r
+    public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator();\r
+    \r
+    /**\r
+     * Get an iterator which only returns events that fall within the start time and the stop time.\r
+     * The visible duration is the event duration below which further detail is not discernible.\r
+     * If no such iterator is implemented, provide a basic iterator which returns all events.\r
+     * \r
+     * @param startTime start time in nanoseconds\r
+     * @param stopTime stop time in nanoseconds\r
+     * @param visibleDuration duration of one pixel in nanoseconds\r
+     */\r
+    public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator(long startTime, long stopTime, long visibleDuration);\r
+    \r
+    public <T extends ITimeEvent> void addTraceEvent(T event);\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/TimeEvent.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/model/TimeEvent.java
new file mode 100644 (file)
index 0000000..aae487a
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model;\r
+\r
+public abstract class TimeEvent implements ITimeEvent {\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTrace()\r
+        */\r
+       @Override\r
+       public abstract ITmfTimeAnalysisEntry getEntry();\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTime()\r
+        */\r
+       @Override\r
+       public abstract long getTime();\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getDuration()\r
+        */\r
+       @Override\r
+       public long getDuration() {\r
+               return -1;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/ITimeDataProvider.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/ITimeDataProvider.java
new file mode 100644 (file)
index 0000000..1944cf5
--- /dev/null
@@ -0,0 +1,68 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2010 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Updated for TMF\r
+ *\r
+ * $Id: ITimeDataProvider.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+public interface ITimeDataProvider {\r
+\r
+       long getSelectedTime();\r
+\r
+       long getBeginTime();\r
+\r
+       long getEndTime();\r
+\r
+       long getMinTime();\r
+\r
+       long getMaxTime();\r
+\r
+       long getTime0();\r
+\r
+       long getTime1();\r
+\r
+       long getMinTimeInterval();\r
+\r
+       /**\r
+        * Updates the time range and notify registered listeners\r
+        * \r
+        * @param time0\r
+        * @param time1\r
+        */\r
+       void setStartFinishTimeNotify(long time0, long time1);\r
+\r
+       /**\r
+        * Update the time range but do not trigger event notification\r
+        * \r
+        * @param time0\r
+        * @param time1\r
+        */\r
+       void setStartFinishTime(long time0, long time1);\r
+\r
+    /**\r
+     * Notify registered listeners without updating the time range\r
+     */\r
+    void notifyStartFinishTime();\r
+\r
+       void setSelectedTimeInt(long time, boolean ensureVisible);\r
+\r
+       void resetStartFinishTime();\r
+\r
+       int getNameSpace();\r
+\r
+       void setNameSpace(int width);\r
+\r
+       int getTimeSpace();\r
+       \r
+       boolean isCalendarFormat();\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/PlainSelection.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/PlainSelection.java
new file mode 100644 (file)
index 0000000..8b50e97
--- /dev/null
@@ -0,0 +1,71 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: PlainSelection.java,v 1.1 2007/04/20 13:06:49 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+\r
+public class PlainSelection implements IStructuredSelection {\r
+\r
+       List<Object> list = new ArrayList<Object>();\r
+\r
+       public PlainSelection() {\r
+       }\r
+\r
+       public PlainSelection(Object sel) {\r
+               add(sel);\r
+       }\r
+\r
+       public void add(Object sel) {\r
+               if (null != sel && !list.contains(sel))\r
+                       list.add(sel);\r
+       }\r
+\r
+       @Override\r
+       public Object getFirstElement() {\r
+               if (!list.isEmpty())\r
+                       return list.get(0);\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public Iterator<Object> iterator() {\r
+               return list.iterator();\r
+       }\r
+\r
+       @Override\r
+       public int size() {\r
+               return list.size();\r
+       }\r
+\r
+       @Override\r
+       public Object[] toArray() {\r
+               return list.toArray();\r
+       }\r
+\r
+       @Override\r
+       public List<Object> toList() {\r
+               return list;\r
+       }\r
+\r
+       @Override\r
+       public boolean isEmpty() {\r
+               return list.isEmpty();\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java
new file mode 100644 (file)
index 0000000..58da2cb
--- /dev/null
@@ -0,0 +1,790 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008, 2010 Intel Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: TimeScaleCtrl.java,v 1.5 2008/06/16 21:04:49 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.GregorianCalendar;\r
+import java.util.TimeZone;\r
+\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.Messages;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.Utils.Resolution;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.events.MouseMoveListener;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+public class TimeScaleCtrl extends TraceCtrl implements MouseListener,\r
+               MouseMoveListener {\r
+\r
+       public TimeScaleCtrl(Composite parent, TraceColorScheme colors) {\r
+               super(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS\r
+                               | SWT.DOUBLE_BUFFERED);\r
+               addMouseListener(this);\r
+               addMouseMoveListener(this);\r
+       }\r
+\r
+    private static final long SEC_IN_NS = 1000000000;\r
+    private static final long MIN_IN_NS = 60 * SEC_IN_NS;\r
+    private static final long HOUR_IN_NS = 60 * MIN_IN_NS;\r
+    private static final long DAY_IN_NS = 24 * HOUR_IN_NS;\r
+    private static final long MONTH_IN_NS = 31 * DAY_IN_NS; // upper limit\r
+    private static final long YEAR_IN_NS = 366 * DAY_IN_NS; // upper limit\r
+    \r
+    private static final double LOG10_1 = Math.log10(1);\r
+    private static final double LOG10_2 = Math.log10(2);\r
+    private static final double LOG10_3 = Math.log10(3);\r
+    private static final double LOG10_5 = Math.log10(5);\r
+    \r
+    private static final Calendar GREGORIAN_CALENDAR = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+    \r
+       private ITimeDataProvider _timeProvider;\r
+       private int _dragState = 0;\r
+       private int _dragX0 = 0;\r
+       private int _dragX = 0;\r
+       private long _time0bak;\r
+       private long _time1bak;\r
+       private boolean _isInUpdate;\r
+       private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
+    private int _height;\r
+\r
+       public void setTimeProvider(ITimeDataProvider timeProvider) {\r
+               _timeProvider = timeProvider;\r
+       }\r
+\r
+       private long _timeDelta;\r
+\r
+       @Override\r
+    public Point computeSize(int wHint, int hHint, boolean changed) {\r
+        return super.computeSize(wHint, _height, changed);\r
+    }\r
+\r
+    public void setHeight(int height) {\r
+        this._height = height;\r
+    }\r
+    \r
+    private void calcTimeDelta(int width, double pixelsPerNanoSec) {\r
+        double minDelta = (double) ((pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec);\r
+        long unit = 1;\r
+        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            if (minDelta > 6 * MONTH_IN_NS) {\r
+                unit = YEAR_IN_NS;\r
+            } else if (minDelta > 3 * MONTH_IN_NS) {\r
+                unit = 6 * MONTH_IN_NS;\r
+            } else if (minDelta > 10 * DAY_IN_NS) {\r
+                unit = MONTH_IN_NS;\r
+            } else if (minDelta > 12 * HOUR_IN_NS) {\r
+                unit = DAY_IN_NS;\r
+            } else if (minDelta > 3 * HOUR_IN_NS) {\r
+                unit = 6 * HOUR_IN_NS;\r
+            } else if (minDelta > 30 * MIN_IN_NS) {\r
+                unit = HOUR_IN_NS;\r
+            } else if (minDelta > 10 * MIN_IN_NS) {\r
+                unit = 15 * MIN_IN_NS;\r
+            } else if (minDelta > 30 * SEC_IN_NS) {\r
+                unit = MIN_IN_NS;\r
+            } else if (minDelta > 20 * SEC_IN_NS) {\r
+                unit = 30 * SEC_IN_NS;\r
+            } else if (minDelta <= 1) {\r
+                _timeDelta = 1;\r
+                return;\r
+            }\r
+        }\r
+        double log = Math.log10((double) minDelta / unit);\r
+        long pow10 = (long) log;\r
+        double remainder = log - pow10;\r
+        if (remainder < LOG10_1) {\r
+            _timeDelta = (long) Math.pow(10, pow10) * unit;\r
+        } else if (remainder < LOG10_2) {\r
+            _timeDelta = 2 * (long) Math.pow(10, pow10) * unit;\r
+        } else if (remainder < LOG10_3 && unit >= HOUR_IN_NS && unit < YEAR_IN_NS) {\r
+            _timeDelta = 3 * (long) Math.pow(10, pow10) * unit;\r
+        } else if (remainder < LOG10_5) {\r
+            _timeDelta = 5 * (long) Math.pow(10, pow10) * unit;\r
+        } else {\r
+            _timeDelta = 10 * (long) Math.pow(10, pow10) * unit;\r
+        }\r
+    }\r
+\r
+    private static TimeDraw TIMEDRAW_NANOSEC = new TimeDrawNanosec();\r
+    private static TimeDraw TIMEDRAW_MICROSEC = new TimeDrawMicrosec();\r
+    private static TimeDraw TIMEDRAW_MILLISEC = new TimeDrawMillisec();\r
+    private static TimeDraw TIMEDRAW_SEC = new TimeDrawSec();\r
+    private static TimeDraw TIMEDRAW_ABS_NANOSEC = new TimeDrawAbsNanoSec();\r
+    private static TimeDraw TIMEDRAW_ABS_MICROSEC = new TimeDrawAbsMicroSec();\r
+    private static TimeDraw TIMEDRAW_ABS_MILLISEC = new TimeDrawAbsMillisec();\r
+    private static TimeDraw TIMEDRAW_ABS_SEC = new TimeDrawAbsSec();\r
+    private static TimeDraw TIMEDRAW_ABS_MIN = new TimeDrawAbsMin();\r
+    private static TimeDraw TIMEDRAW_ABS_HRS = new TimeDrawAbsHrs();\r
+    private static TimeDraw TIMEDRAW_ABS_DAY = new TimeDrawAbsDay();\r
+    private static TimeDraw TIMEDRAW_ABS_MONTH = new TimeDrawAbsMonth();\r
+    private static TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();\r
+\r
+       TimeDraw getTimeDraw(long timeDelta) {\r
+               TimeDraw timeDraw;\r
+               if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            if (timeDelta >= YEAR_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_YEAR;\r
+            else if (timeDelta >= MONTH_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_MONTH;\r
+            else if (timeDelta >= DAY_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_DAY;\r
+            else if (timeDelta >= HOUR_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_HRS;\r
+            else if (timeDelta >= MIN_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_MIN;\r
+            else if (timeDelta >= SEC_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_SEC;\r
+                       else if (timeDelta >= 1000000)\r
+                               timeDraw = TIMEDRAW_ABS_MILLISEC;\r
+                       else if (timeDelta >= 1000)\r
+                               timeDraw = TIMEDRAW_ABS_MICROSEC;\r
+                       else\r
+                               timeDraw = TIMEDRAW_ABS_NANOSEC;\r
+                       return timeDraw;\r
+               }\r
+               if (timeDelta >= 1000000000)\r
+                       timeDraw = TIMEDRAW_SEC;\r
+               else if (timeDelta >= 1000000)\r
+                       timeDraw = TIMEDRAW_MILLISEC;\r
+               else if (timeDelta >= 1000)\r
+                       timeDraw = TIMEDRAW_MICROSEC;\r
+               else\r
+                       timeDraw = TIMEDRAW_NANOSEC;\r
+               return timeDraw;\r
+       }\r
+\r
+       @Override\r
+       void paint(Rectangle rect, PaintEvent e) {\r
+\r
+               if (_isInUpdate || null == _timeProvider)\r
+                       return;\r
+\r
+               GC gc = e.gc;\r
+               gc.fillRectangle(rect);\r
+               \r
+               long time0 = _timeProvider.getTime0();\r
+               long time1 = _timeProvider.getTime1();\r
+               long selectedTime = _timeProvider.getSelectedTime();\r
+               int leftSpace = _timeProvider.getNameSpace();\r
+               int timeSpace = _timeProvider.getTimeSpace();\r
+               \r
+               gc.setBackground(_colors.getColor(TraceColorScheme.TOOL_BACKGROUND));\r
+               gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND));\r
+               Utils.init(_rect0, rect);\r
+               \r
+               // draw top left area\r
+               _rect0.width = leftSpace;\r
+               _rect0.x += 4;\r
+               _rect0.width -= 4;\r
+               if (_rect0.width > 0) {\r
+                   Utils.drawText(gc, Messages.TimeScaleCtrl_Timescale + ":", _rect0, true); //$NON-NLS-1$\r
+               }\r
+               int messageWidth = gc.stringExtent(Messages.TimeScaleCtrl_Timescale + ":").x + 4; //$NON-NLS-1$\r
+               Rectangle absHeaderRect = new Rectangle(_rect0.x + messageWidth, _rect0.y, _rect0.width - messageWidth, _rect0.height);\r
+               _rect0.x -= 4;\r
+               _rect0.width += 4;\r
+               \r
+               // prepare and draw right rect of the timescale\r
+               _rect0.x += leftSpace;\r
+               _rect0.width = rect.width - leftSpace;\r
+               \r
+               // draw bottom border and erase all other area\r
+               gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1,\r
+                       rect.y + rect.height - 1);\r
+               _rect0.height--;\r
+               gc.fillRectangle(_rect0);\r
+               \r
+               if (time1 <= time0 || timeSpace < 2) {\r
+                   return;\r
+               }\r
+               \r
+               int numDigits = calculateDigits(time0, time1);\r
+               \r
+               int labelWidth = gc.getCharWidth('0') * numDigits;\r
+               double pixelsPerNanoSec = (timeSpace <= RIGHT_MARGIN) ? 0 :\r
+                   (double) (timeSpace - RIGHT_MARGIN) / (time1 - time0);\r
+               calcTimeDelta(labelWidth, pixelsPerNanoSec);\r
+               \r
+               TimeDraw timeDraw = getTimeDraw(_timeDelta);\r
+\r
+               // draw zoom rectangle\r
+        if (3 == _dragState && null != _timeProvider) {\r
+            if (_dragX0 < _dragX) {\r
+                gc.drawRectangle(leftSpace + _dragX0, rect.y, _dragX - _dragX0 - 1, rect.height - 8);\r
+            } else if (_dragX0 > _dragX) {\r
+                gc.drawRectangle(leftSpace + _dragX, rect.y, _dragX0 - _dragX - 1, rect.height - 8);\r
+            }\r
+        }\r
+\r
+               if (_rect0.isEmpty())\r
+                       return;\r
+\r
+               // draw selected time\r
+               int x = _rect0.x + (int) ((double)(selectedTime - time0) * pixelsPerNanoSec);\r
+               if (x >= _rect0.x && x < _rect0.x + _rect0.width) {\r
+                       gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+                       gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y\r
+                                       + _rect0.height);\r
+                       gc\r
+                                       .setForeground(_colors\r
+                                                       .getColor(TraceColorScheme.TOOL_FOREGROUND));\r
+               }\r
+\r
+               // draw time scale ticks\r
+               _rect0.y = rect.y;\r
+               _rect0.height = rect.height - 4;\r
+               _rect0.width = labelWidth;\r
+               \r
+               long time;\r
+        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            time = floorToCalendar(time0, _timeDelta);\r
+        } else {\r
+            time = (long) (Math.ceil((double) time0 / _timeDelta) * _timeDelta);\r
+        }\r
+               \r
+               // long t = (long) (time * 1000000000);\r
+               int y = _rect0.y + _rect0.height;\r
+\r
+        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            timeDraw.drawAbsHeader(gc, time, absHeaderRect);\r
+        }\r
+               \r
+               while (true) {\r
+                       x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));\r
+                       if (x >= rect.x + leftSpace + rect.width - _rect0.width) {\r
+                               break;\r
+                       }\r
+                       if (x >= rect.x + leftSpace) {\r
+                               gc.drawLine(x, y, x, y + 4);\r
+                               _rect0.x = x;\r
+                               if (x + _rect0.width <= rect.x + rect.width)\r
+                                       timeDraw.draw(gc, time, _rect0);\r
+                       }\r
+                       if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - _timeDelta || _timeDelta == 0) {\r
+                           break;\r
+                       }\r
+                       time += _timeDelta;\r
+            if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+                if (_timeDelta >= YEAR_IN_NS) {\r
+                    GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+                    GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
+                    GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
+                    time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+                } else if (_timeDelta >= MONTH_IN_NS) {\r
+                    GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+                    GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
+                    time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+                }\r
+            }\r
+               }\r
+       }\r
+\r
+       private long floorToCalendar(long time, long timeDelta) {\r
+        if (_timeDelta >= YEAR_IN_NS) {\r
+            GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+            int year = GREGORIAN_CALENDAR.get(Calendar.YEAR);\r
+            int yearDelta = (int) (timeDelta / YEAR_IN_NS);\r
+            year = (year / yearDelta) * yearDelta;\r
+            GREGORIAN_CALENDAR.set(Calendar.YEAR, year);\r
+            GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
+            GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
+            GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
+            time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+        } else if (_timeDelta >= MONTH_IN_NS) {\r
+            GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+            int month = GREGORIAN_CALENDAR.get(Calendar.MONTH);\r
+            int monthDelta = (int) (timeDelta / MONTH_IN_NS);\r
+            month = (month / monthDelta) * monthDelta;\r
+            GREGORIAN_CALENDAR.set(Calendar.MONTH, month);\r
+            GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
+            GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
+            time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+        } else {\r
+            time = (time / timeDelta) * timeDelta;\r
+        }\r
+        return time;\r
+       }\r
+       \r
+       private int calculateDigits(long time0, long time1) {\r
+               int numDigits = 5;\r
+               long timeRange = time1 - time0;\r
+\r
+               if (_timeProvider.isCalendarFormat()) {\r
+                       // Calculate the number of digits to represent the minutes provided\r
+                       // 11:222\r
+                       // HH:mm:ss\r
+                       numDigits += 8;\r
+                       if (timeRange < 10000) {\r
+                               // HH:11:222:333:444__\r
+                               numDigits += 10;\r
+                       } else if (timeRange < 10000000) {\r
+                               // HH:11:222:333__\r
+                               numDigits += 6;\r
+                       }\r
+               } else {\r
+                       // Calculate the number of digits to represent the minutes provided\r
+                       long min = (long) ((time1 * 1E-9) / 60); // to sec then to minutes\r
+                       String strMinutes = String.valueOf(min);\r
+                       // 11:222\r
+                       if (strMinutes != null) {\r
+                               numDigits += strMinutes.length();\r
+                       } else {\r
+                               numDigits += 2;\r
+                       }\r
+                       if (timeRange < 10000) {\r
+                               // 11:222:333:444__\r
+                               numDigits += 8;\r
+                       } else if (timeRange < 10000000) {\r
+                               // 11:222:333__\r
+                               numDigits += 4;\r
+                       }\r
+               }\r
+\r
+//             Trace.debug("timeRange: " + timeRange + " numDigits: " + numDigits);\r
+               return numDigits;\r
+       }\r
+\r
+       @Override\r
+       public void mouseDown(MouseEvent e) {\r
+           if (_dragState == 0 && null != _timeProvider) {\r
+               if (1 == e.button) {\r
+                   setCapture(true);\r
+                   _dragState = 1;\r
+               } else if (3 == e.button) {\r
+                   _dragState = 3;\r
+               }\r
+               int x = e.x - _timeProvider.getNameSpace();\r
+               if (x < 0) {\r
+                   x = 0;\r
+               } else if (x > getSize().x - _timeProvider.getNameSpace()) {\r
+                   x = getSize().x - _timeProvider.getNameSpace();\r
+               }\r
+               _dragX = _dragX0 = x;\r
+               _time0bak = _timeProvider.getTime0();\r
+               _time1bak = _timeProvider.getTime1();\r
+           }\r
+       }\r
+\r
+       @Override\r
+       public void mouseUp(MouseEvent e) {\r
+               if (e.button == 1 && _dragState == 1) {\r
+                       setCapture(false);\r
+                       _dragState = 0;\r
+                       \r
+               // Notify time provider to check the need for listener notification\r
+                       if (_dragX != _dragX0) {\r
+                           _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
+                       }\r
+               } else if (e.button == 3 && _dragState == 3 && null != _timeProvider) {\r
+                   _dragState = 0;\r
+                       if (_dragX0 == _dragX) {\r
+                               return;\r
+                       }\r
+                       int timeSpace = _timeProvider.getTimeSpace();\r
+                       int leftSpace = _timeProvider.getNameSpace();\r
+                       int x = e.x - leftSpace;\r
+                       if (timeSpace > 0) {\r
+                               _dragX = x;\r
+                               if (_dragX0 > _dragX) { // drag right to left\r
+                                   _dragX = _dragX0;\r
+                                   _dragX0 = x;\r
+                               }\r
+                               long time0 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / timeSpace));\r
+                               long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX / timeSpace));\r
+\r
+                               _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+                   _time0bak = _timeProvider.getTime0();\r
+                   _time1bak = _timeProvider.getTime1();\r
+                       }\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void mouseMove(MouseEvent e) {\r
+               if (_dragX0 < 0 || _dragState == 0 || _timeProvider == null) {\r
+                       return;\r
+               }\r
+               Point size = getSize();\r
+               int leftSpace = _timeProvider.getNameSpace();\r
+               int timeSpace = _timeProvider.getTimeSpace();\r
+               int x = e.x - leftSpace;\r
+               if (1 == _dragState) {\r
+                       if (x > 0 && size.x > leftSpace && _dragX != x) {\r
+                               _dragX = x;\r
+                               long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / _dragX));\r
+                               _timeProvider.setStartFinishTime(_time0bak, time1);\r
+                       }\r
+               } else if (3 == _dragState) {\r
+                   if (x < 0) {\r
+                       _dragX = 0;\r
+                   } else if (x > timeSpace) {\r
+                       _dragX = timeSpace;\r
+                   } else {\r
+                _dragX = x;\r
+            }\r
+                   redraw();\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void mouseDoubleClick(MouseEvent e) {\r
+               if (null != _timeProvider) {\r
+                       _timeProvider.resetStartFinishTime();\r
+            _time0bak = _timeProvider.getTime0();\r
+            _time1bak = _timeProvider.getTime1();\r
+               }\r
+       }\r
+}\r
+\r
+abstract class TimeDraw {\r
+       static String S   = ":"  ; //$NON-NLS-1$\r
+       static String S0  = ":0" ; //$NON-NLS-1$\r
+       static String S00 = ":00"; //$NON-NLS-1$\r
+    protected static final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");          //$NON-NLS-1$\r
+    protected static final SimpleDateFormat stimeformatheader = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sminformat = new SimpleDateFormat("HH:mm");              //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sminformatheader = new SimpleDateFormat("yyyy MMM dd");  //$NON-NLS-1$\r
+    protected static final SimpleDateFormat shrsformat = new SimpleDateFormat("MMM dd HH:mm");              //$NON-NLS-1$\r
+    protected static final SimpleDateFormat shrsformatheader = new SimpleDateFormat("yyyy");         //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sdayformat = new SimpleDateFormat("MMM dd");             //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sdayformatheader = new SimpleDateFormat("yyyy");         //$NON-NLS-1$\r
+    protected static final SimpleDateFormat smonthformat = new SimpleDateFormat("yyyy MMM");         //$NON-NLS-1$\r
+    protected static final SimpleDateFormat syearformat = new SimpleDateFormat("yyyy");              //$NON-NLS-1$\r
+    static {\r
+        stimeformat.setTimeZone(TimeZone.getTimeZone("GMT"));       //$NON-NLS-1$\r
+        stimeformatheader.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+        sminformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
+        sminformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
+        shrsformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
+        shrsformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
+        sdayformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
+        sdayformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
+        smonthformat.setTimeZone(TimeZone.getTimeZone("GMT"));      //$NON-NLS-1$\r
+        syearformat.setTimeZone(TimeZone.getTimeZone("GMT"));       //$NON-NLS-1$\r
+    }\r
+       \r
+       static String pad(long n) {\r
+               String s = S;\r
+               if (n < 10)\r
+                       s = S00;\r
+               else if (n < 100)\r
+                       s = S0;\r
+               return s + n;\r
+       }\r
+\r
+    public abstract void draw(GC gc, long time, Rectangle rect);\r
+\r
+    public void drawAbsHeader(GC gc, long time, Rectangle absHeaderRect) {\r
+        // Override to draw absolute time header\r
+        // This is for the time information not shown in the draw of each tick\r
+    }\r
+    \r
+       public abstract String hint();\r
+}\r
+\r
+class TimeDrawSec extends TimeDraw {\r
+       static String _hint = "sec"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               time /= 1000000000;\r
+               Utils.drawText(gc, time + "", rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawMillisec extends TimeDraw {\r
+       static String _hint = "s:ms"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               time /= 1000000;\r
+               long ms = time % 1000;\r
+               time /= 1000;\r
+               Utils.drawText(gc, time + pad(ms), rect, true);\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawMicrosec extends TimeDraw {\r
+       static String _hint = "s:ms:mcs"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               time /= 1000;\r
+               long mcs = time % 1000;\r
+               time /= 1000;\r
+               long ms = time % 1000;\r
+               time /= 1000;\r
+               Utils.drawText(gc, time + pad(ms) + pad(mcs), rect, true);\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawNanosec extends TimeDraw {\r
+       static String _hint = "s:ms:mcs:ns"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               long ns = time % 1000;\r
+               time /= 1000;\r
+               long mcs = time % 1000;\r
+               time /= 1000;\r
+               long ms = time % 1000;\r
+               time /= 1000;\r
+               Utils.drawText(gc, time + pad(ms) + pad(mcs) + pad(ns), rect, true);\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawAbsYear extends TimeDraw {\r
+    static String _hint = "YYYY"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = syearformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsMonth extends TimeDraw {\r
+    static String _hint = "YYYY Mmm"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = smonthformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsDay extends TimeDraw {\r
+    static String _hint = "Mmm dd"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = sdayformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = sdayformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsHrs extends TimeDraw {\r
+    static String _hint = "Mmm dd HH:mm"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = shrsformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = shrsformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsMin extends TimeDraw {\r
+    static String _hint = "HH:mm"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = sminformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = sminformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsSec extends TimeDraw {\r
+    static String _hint = "HH:mm:ss"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsMillisec extends TimeDraw {\r
+       static String _hint = "HH:ss:ms"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+               String ns = Utils.formatNs(time, Resolution.MILLISEC);\r
+\r
+               Utils.drawText(gc, stime + " " + ns, rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawAbsMicroSec extends TimeDraw {\r
+       static String _hint = "HH:ss:ms:mcs"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+               String micr = Utils.formatNs(time, Resolution.MICROSEC);\r
+               Utils.drawText(gc, stime + " " + micr, rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawAbsNanoSec extends TimeDraw {\r
+       static String _hint = "HH:ss:ms:mcs:ns"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+               String ns = Utils.formatNs(time, Resolution.NANOSEC);\r
+               Utils.drawText(gc, stime + " " + ns, rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java
new file mode 100644 (file)
index 0000000..71cedd3
--- /dev/null
@@ -0,0 +1,2173 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: ThreadStatesCtrl.java,v 1.15 2008/07/11 13:49:01 aalexeev Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionChangedListener;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.Messages;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.TimeEvent;\r
+import org.eclipse.osgi.util.NLS;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.events.ControlListener;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.events.MouseMoveListener;\r
+import org.eclipse.swt.events.MouseTrackListener;\r
+import org.eclipse.swt.events.MouseWheelListener;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.events.TraverseEvent;\r
+import org.eclipse.swt.events.TraverseListener;\r
+import org.eclipse.swt.graphics.Cursor;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.ScrollBar;\r
+\r
+/**\r
+ * @author alvaro\r
+ * \r
+ */\r
+public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider {\r
+\r
+    private static final int DRAG_NONE = 0;\r
+    private static final int DRAG_TRACE_ITEM = 1;\r
+    private static final int DRAG_GROUP_ITEM = 2;\r
+    private static final int DRAG_SPLIT_LINE = 3;\r
+    public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;\r
+    public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;\r
+    public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;\r
+    public static final int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;\r
+\r
+    private static final double zoomCoeff = 1.5;\r
+\r
+    private ITimeDataProvider _timeProvider;\r
+    private boolean _isInFocus = false;\r
+    private boolean _isDragCursor3 = false;\r
+    private boolean _isWaitCursor = true;\r
+    private boolean _mouseHover = false;\r
+    private int _itemHeightDefault = 19;\r
+    private int _itemHeight = _itemHeightDefault;\r
+    private int _minimumItemWidth = 0;\r
+    private int _topItem = 0;\r
+    private int _dragState = DRAG_NONE;\r
+    private int _hitIdx = 0;\r
+    private int _dragX0 = 0;\r
+    private int _dragX = 0;\r
+    private int _idealNameWidth = 0;\r
+    // private double _timeStep = 10000000;\r
+    private long _time0bak;\r
+    private long _time1bak;\r
+    private TmfTimeAnalysisProvider utilImpl = null;\r
+    private ItemData _data = null;\r
+    private List<SelectionListener> _selectionListeners;\r
+    private List<ISelectionChangedListener> _selectionChangedListeners = new ArrayList<ISelectionChangedListener>();\r
+    private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
+    private Rectangle _rect1 = new Rectangle(0, 0, 0, 0);\r
+    private Cursor _dragCursor3;\r
+    private Cursor _WaitCursor;\r
+    private boolean drawTracesInteraction = false;\r
+    private boolean drawTraceJoins = DEFAULT_DRAW_THREAD_JOIN;\r
+    private boolean drawTraceWaits = DEFAULT_DRAW_THREAD_WAIT;\r
+    private boolean drawTraceReleases = DEFAULT_DRAW_THREAD_RELEASE;\r
+\r
+    // Vertical formatting formatting for the state control view\r
+    private boolean _visibleVerticalScroll = true;\r
+    private int _borderWidth = 0;\r
+    private int _headerHeight = 0;\r
+\r
+    private Listener mouseScrollFilterListener;\r
+\r
+    public TmfTimeStatesCtrl(Composite parent, TraceColorScheme colors, TmfTimeAnalysisProvider rutilImp) {\r
+\r
+        super(parent, colors, SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL | SWT.DOUBLE_BUFFERED);\r
+\r
+        this.utilImpl = rutilImp;\r
+        _data = new ItemData(utilImpl);\r
+\r
+        addFocusListener(this);\r
+        addMouseListener(this);\r
+        addMouseMoveListener(this);\r
+        addMouseTrackListener(this);\r
+        addMouseWheelListener(this);\r
+        addTraverseListener(this);\r
+        addKeyListener(this);\r
+        addControlListener(this);\r
+        ScrollBar scrollVer = getVerticalBar();\r
+        ScrollBar scrollHor = getHorizontalBar();\r
+        if (scrollVer != null) {\r
+            scrollVer.addSelectionListener(this);\r
+            scrollVer.setVisible(_visibleVerticalScroll);\r
+        }\r
+\r
+        if (scrollHor != null) {\r
+            scrollHor.addSelectionListener(this);\r
+        }\r
+\r
+        _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);\r
+        _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        super.dispose();\r
+        _dragCursor3.dispose();\r
+        _WaitCursor.dispose();\r
+    }\r
+\r
+    public void setTimeProvider(ITimeDataProvider timeProvider) {\r
+        _timeProvider = timeProvider;\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void addSelectionListener(SelectionListener listener) {\r
+        if (listener == null)\r
+            SWT.error(SWT.ERROR_NULL_ARGUMENT);\r
+        if (null == _selectionListeners)\r
+            _selectionListeners = new ArrayList<SelectionListener>();\r
+        _selectionListeners.add(listener);\r
+    }\r
+\r
+    public void removeSelectionListener(SelectionListener listener) {\r
+        if (null != _selectionListeners)\r
+            _selectionListeners.remove(listener);\r
+    }\r
+\r
+    public void fireSelectionChanged() {\r
+        if (null != _selectionListeners) {\r
+            Iterator<SelectionListener> it = _selectionListeners.iterator();\r
+            while (it.hasNext()) {\r
+                SelectionListener listener = it.next();\r
+                listener.widgetSelected(null);\r
+            }\r
+        }\r
+    }\r
+\r
+    public void fireDefaultSelection() {\r
+        if (null != _selectionListeners) {\r
+            Iterator<SelectionListener> it = _selectionListeners.iterator();\r
+            while (it.hasNext()) {\r
+                SelectionListener listener = it.next();\r
+                listener.widgetDefaultSelected(null);\r
+            }\r
+        }\r
+    }\r
+\r
+    public Object[] getTraces() {\r
+        return _data.getTraces();\r
+    }\r
+\r
+    public boolean[] getTraceFilter() {\r
+        return _data.getTraceFilter();\r
+    }\r
+\r
+    public void refreshData() {\r
+        _data.refreshData();\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void refreshData(Object traces[]) {\r
+        _data.refreshData(traces);\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void refreshPartial(ITmfTimeAnalysisEntry parent, TimeEvent item) {\r
+        _data.refreshPartial(parent, item);\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void adjustScrolls() {\r
+        if (null == _timeProvider) {\r
+            getVerticalBar().setValues(0, 1, 1, 1, 1, 1);\r
+            getHorizontalBar().setValues(0, 1, 1, 1, 1, 1);\r
+            return;\r
+        }\r
+\r
+        // Vertical scroll bar\r
+        int page = countPerPage();\r
+        if (_topItem + page > _data._items.length)\r
+            _topItem = _data._items.length - page;\r
+        if (_topItem < 0)\r
+            _topItem = 0;\r
+        getVerticalBar().setValues(_topItem, 0, _data._items.length, page, 1, page);\r
+\r
+        // HORIZONTAL BAR\r
+        // Visible window\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        // Time boundaries\r
+        long timeMin = _timeProvider.getMinTime();\r
+        long timeMax = _timeProvider.getMaxTime();\r
+\r
+        long delta = timeMax - timeMin;\r
+\r
+        int timePos = 0;\r
+        int thumb = H_SCROLLBAR_MAX;\r
+\r
+        if (delta != 0) {\r
+            // Thumb size (page size)\r
+            thumb = Math.max(1, (int) (H_SCROLLBAR_MAX * ((double) (time1 - time0) / delta)));\r
+            // At the beginning of visible window\r
+            timePos = (int) (H_SCROLLBAR_MAX * ((double) (time0 - timeMin) / delta));\r
+        }\r
+\r
+        // position, minimum, maximum, thumb size, increment (half page)t, page\r
+        // increment size (full page)\r
+        getHorizontalBar().setValues(timePos, 0, H_SCROLLBAR_MAX, thumb, Math.max(1, thumb / 2), Math.max(2, thumb));\r
+    }\r
+\r
+    boolean ensureVisibleItem(int idx, boolean redraw) {\r
+        boolean changed = false;\r
+        if (idx < 0) {\r
+            for (idx = 0; idx < _data._items.length; idx++) {\r
+                if (((Item) _data._items[idx])._selected)\r
+                    break;\r
+            }\r
+        }\r
+        if (idx >= _data._items.length)\r
+            return changed;\r
+        if (idx < _topItem) {\r
+            _topItem = idx;\r
+            getVerticalBar().setSelection(_topItem);\r
+            if (redraw)\r
+                redraw();\r
+            changed = true;\r
+        } else {\r
+            int page = countPerPage();\r
+            if (idx >= _topItem + page) {\r
+                _topItem = idx - page + 1;\r
+                getVerticalBar().setSelection(_topItem);\r
+                if (redraw)\r
+                    redraw();\r
+                changed = true;\r
+            }\r
+        }\r
+        return changed;\r
+    }\r
+\r
+    public void setTopIndex(int idx) {\r
+        idx = Math.min(idx, _data._items.length - countPerPage());\r
+        idx = Math.max(0,  idx);\r
+        _topItem = idx;\r
+        getVerticalBar().setSelection(_topItem);\r
+        redraw();\r
+    }\r
+\r
+    @Override\r
+    public ISelection getSelection() {\r
+        PlainSelection sel = new PlainSelection();\r
+        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
+        if (null != trace && null != _timeProvider) {\r
+            long selectedTime = _timeProvider.getSelectedTime();\r
+            ITimeEvent event = Utils.findEvent(trace, selectedTime, 0);\r
+            if (event != null)\r
+                sel.add(event);\r
+            else\r
+                sel.add(trace);\r
+        }\r
+        return sel;\r
+    }\r
+\r
+    public ISelection getSelectionTrace() {\r
+        PlainSelection sel = new PlainSelection();\r
+        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
+        if (null != trace) {\r
+            sel.add(trace);\r
+        }\r
+        return sel;\r
+    }\r
+\r
+    public void selectTrace(int n) {\r
+        if (n != 1 && n != -1)\r
+            return;\r
+        boolean changed = false;\r
+        int lastSelection = -1;\r
+        for (int i = 0; i < _data._items.length; i++) {\r
+            Item item = (Item) _data._items[i];\r
+            if (item._selected) {\r
+                lastSelection = i;\r
+                if (1 == n && i < _data._items.length - 1) {\r
+                    item._selected = false;\r
+                    if (item._hasChildren)\r
+                        _data.expandItem(i, true);\r
+                    item = (Item) _data._items[i + 1];\r
+                    if (item._hasChildren) {\r
+                        _data.expandItem(i + 1, true);\r
+                        item = (Item) _data._items[i + 2];\r
+                    }\r
+                    item._selected = true;\r
+                    changed = true;\r
+                } else if (-1 == n && i > 0) {\r
+                    i--;\r
+                    Item prevItem = (Item) _data._items[i];\r
+                    if (prevItem._hasChildren) {\r
+                        if (prevItem._expanded) {\r
+                            if (i > 0) {\r
+                                i--;\r
+                                prevItem = (Item) _data._items[i];\r
+                            }\r
+                        }\r
+                        if (!prevItem._expanded) {\r
+                            int added = _data.expandItem(i, true);\r
+                            prevItem = (Item) _data._items[i + added];\r
+                            item._selected = false;\r
+                            prevItem._selected = true;\r
+                            changed = true;\r
+                        }\r
+                    } else {\r
+                        item._selected = false;\r
+                        prevItem._selected = true;\r
+                        changed = true;\r
+                    }\r
+                }\r
+                break;\r
+            }\r
+        }\r
+        if (lastSelection < 0 && _data._items.length > 0) {\r
+            Item item = (Item) _data._items[0];\r
+            if (item._hasChildren) {\r
+                _data.expandItem(0, true);\r
+                item = (Item) _data._items[1];\r
+                item._selected = true;\r
+                changed = true;\r
+            } else {\r
+                item._selected = true;\r
+                changed = true;\r
+            }\r
+        }\r
+        if (changed) {\r
+            ensureVisibleItem(-1, false);\r
+            redraw();\r
+            fireSelectionChanged();\r
+        }\r
+    }\r
+\r
+    public void selectEvent(int n) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
+        if (trace == null)\r
+            return;\r
+        long selectedTime = _timeProvider.getSelectedTime();\r
+        long endTime = _timeProvider.getEndTime();\r
+        ITimeEvent nextEvent;\r
+        if (-1 == n && selectedTime > endTime)\r
+            nextEvent = Utils.findEvent(trace, selectedTime, 0);\r
+        else\r
+            nextEvent = Utils.findEvent(trace, selectedTime, n);\r
+        if (null == nextEvent && -1 == n)\r
+            nextEvent = Utils.getFirstEvent(trace);\r
+        if (null != nextEvent) {\r
+            long nextTime = nextEvent.getTime();\r
+            // If last event detected e.g. going back or not moving to a next\r
+            // event\r
+            if (nextTime <= selectedTime && n == 1) {\r
+                // Select to the end of this last event\r
+                nextTime = nextEvent.getTime() + nextEvent.getDuration();\r
+                // but not beyond the end of the trace\r
+                if (nextTime > endTime) {\r
+                    nextTime = endTime;\r
+                }\r
+            }\r
+            _timeProvider.setSelectedTimeInt(nextTime, true);\r
+            fireSelectionChanged();\r
+        } else if (1 == n) {\r
+            _timeProvider.setSelectedTimeInt(endTime, true);\r
+            fireSelectionChanged();\r
+        }\r
+    }\r
+\r
+    public void selectNextEvent() {\r
+        selectEvent(1);\r
+        // Notify if visible time window has been adjusted\r
+        _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
+    }\r
+\r
+    public void selectPrevEvent() {\r
+        selectEvent(-1);\r
+        // Notify if visible time window has been adjusted\r
+        _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
+    }\r
+\r
+    public void selectNextTrace() {\r
+        selectTrace(1);\r
+    }\r
+\r
+    public void selectPrevTrace() {\r
+        selectTrace(-1);\r
+    }\r
+\r
+    /**\r
+     * Zooming based on mouse cursor location with mouse scrolling\r
+     * \r
+     * @param zoomIn\r
+     */\r
+    public void zoom(boolean zoomIn) {\r
+        int globalX = getDisplay().getCursorLocation().x;\r
+        Point p = toControl(globalX, 0);\r
+        int nameSpace = _timeProvider.getNameSpace();\r
+        int timeSpace = _timeProvider.getTimeSpace();\r
+        int xPos = Math.max(nameSpace, Math.min(nameSpace + timeSpace, p.x));\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        long interval = time1 - time0;\r
+        if (interval == 0) {\r
+            interval = 1;\r
+        } // to allow getting out of single point interval\r
+        long newInterval;\r
+        if (zoomIn) {\r
+            newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());\r
+        } else {\r
+            newInterval = (long) Math.ceil((double) interval * 1.25);\r
+        }\r
+        long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));\r
+        long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);\r
+        long newTime1 = newTime0 + newInterval;\r
+        _timeProvider.setStartFinishTime(newTime0, newTime1);\r
+    }\r
+\r
+    /**\r
+     * zoom in using single click\r
+     */\r
+    public void zoomIn() {\r
+        long _time0 = _timeProvider.getTime0();\r
+        long _time1 = _timeProvider.getTime1();\r
+        long _range = _time1 - _time0;\r
+        long selTime = _timeProvider.getSelectedTime();\r
+        if (selTime <= _time0 || selTime >= _time1) {\r
+            selTime = (_time0 + _time1) / 2;\r
+        }\r
+        long time0 = selTime - (long) ((selTime - _time0) / zoomCoeff);\r
+        long time1 = selTime + (long) ((_time1 - selTime) / zoomCoeff);\r
+\r
+        long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);\r
+\r
+        // Trace.debug("selTime:" + selTime + " time0:" + time0 + " time1:"\r
+        // + time1 + " inaccuracy:" + inaccuracy);\r
+\r
+        if (inaccuracy > 0 && inaccuracy < 100) {\r
+            _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());\r
+            return;\r
+        }\r
+\r
+        long m = _timeProvider.getMinTimeInterval();\r
+        if ((time1 - time0) < m) {\r
+            time0 = selTime - (long) ((selTime - _time0) * m / _range);\r
+            time1 = time0 + m;\r
+        }\r
+\r
+        _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+    }\r
+\r
+    /**\r
+     * zoom out using single click\r
+     */\r
+    public void zoomOut() {\r
+        long _time0 = _timeProvider.getTime0();\r
+        long _time1 = _timeProvider.getTime1();\r
+        long selTime = _timeProvider.getSelectedTime();\r
+        if (selTime <= _time0 || selTime >= _time1) {\r
+            selTime = (_time0 + _time1) / 2;\r
+        }\r
+        long time0 = (long) (selTime - (selTime - _time0) * zoomCoeff);\r
+        long time1 = (long) (selTime + (_time1 - selTime) * zoomCoeff);\r
+\r
+        long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);\r
+        if (inaccuracy > 0 && inaccuracy < 100) {\r
+            _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());\r
+            return;\r
+        }\r
+\r
+        _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+    }\r
+\r
+    public void groupTraces(boolean on) {\r
+        _data.groupTraces(on);\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void toggleTraceInteractionDrawing() {\r
+        drawTracesInteraction = !drawTracesInteraction;\r
+        redraw();\r
+    }\r
+\r
+    public void setTraceJoinDrawing(boolean on) {\r
+        drawTraceJoins = on;\r
+        drawTracesInteraction = true;\r
+        redraw();\r
+    }\r
+\r
+    public void setTraceWaitDrawing(boolean on) {\r
+        drawTraceWaits = on;\r
+        drawTracesInteraction = true;\r
+        redraw();\r
+    }\r
+\r
+    public void setTraceReleaseDrawing(boolean on) {\r
+        drawTraceReleases = on;\r
+        drawTracesInteraction = true;\r
+        redraw();\r
+    }\r
+\r
+    public boolean getTracesInteractionDrawing() {\r
+        return drawTracesInteraction;\r
+    }\r
+\r
+    public boolean getTraceJoinDrawing() {\r
+        return drawTraceJoins;\r
+    }\r
+\r
+    public boolean getTraceWaitDrawing() {\r
+        return drawTraceWaits;\r
+    }\r
+\r
+    public boolean getTraceReleaseDrawing() {\r
+        return drawTraceReleases;\r
+    }\r
+\r
+    public ITmfTimeAnalysisEntry getSelectedTrace() {\r
+        ITmfTimeAnalysisEntry trace = null;\r
+        int idx = getSelectedIndex();\r
+        if (idx >= 0 && _data._items[idx] instanceof TraceItem)\r
+            trace = ((TraceItem) _data._items[idx])._trace;\r
+        return trace;\r
+    }\r
+\r
+    public int getSelectedIndex() {\r
+        int idx = -1;\r
+        for (int i = 0; i < _data._items.length; i++) {\r
+            Item item = (Item) _data._items[i];\r
+            if (item._selected) {\r
+                idx = i;\r
+                break;\r
+            }\r
+        }\r
+        return idx;\r
+    }\r
+\r
+    boolean toggle(int idx) {\r
+        boolean toggled = false;\r
+        if (idx >= 0 && idx < _data._items.length) {\r
+            Item item = (Item) _data._items[idx];\r
+            if (item._hasChildren) {\r
+                item._expanded = !item._expanded;\r
+                _data.updateItems();\r
+                adjustScrolls();\r
+                redraw();\r
+                toggled = true;\r
+            }\r
+        }\r
+        return toggled;\r
+    }\r
+\r
+    int hitTest(int x, int y) {\r
+        if (x < 0 || y < 0)\r
+            return -1;\r
+        int hit = -1;\r
+        int idx = y / _itemHeight;\r
+        idx += _topItem;\r
+        if (idx < _data._items.length)\r
+            hit = idx;\r
+        return hit;\r
+    }\r
+\r
+    int hitSplitTest(int x, int y) {\r
+        if (x < 0 || y < 0 || null == _timeProvider)\r
+            return -1;\r
+        int w = 4;\r
+        int hit = -1;\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+        if (x > nameWidth - w && x < nameWidth + w)\r
+            hit = 1;\r
+        return hit;\r
+    }\r
+\r
+    Item getItem(Point pt) {\r
+        int idx = hitTest(pt.x, pt.y);\r
+        return idx >= 0 ? (Item) _data._items[idx] : null;\r
+    }\r
+\r
+    long hitTimeTest(int x) {\r
+        if (null == _timeProvider)\r
+            return -1;\r
+        long hitTime = -1;\r
+        Point size = getCtrlSize();\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+        x -= nameWidth;\r
+        if (x >= 0 && size.x >= nameWidth) {\r
+            if (time1 - time0 > size.x - nameWidth - RIGHT_MARGIN) {\r
+                // get the last possible time represented by the pixel position\r
+                // by taking the time of the next pixel position minus 1\r
+                // nanosecond\r
+                hitTime = time0 + (long) ((time1 - time0) * ((double) (x + 1) / (size.x - nameWidth - RIGHT_MARGIN))) - 1;\r
+            } else {\r
+                hitTime = time0 + (long) ((time1 - time0) * ((double) (x) / (size.x - nameWidth - RIGHT_MARGIN)));\r
+            }\r
+        }\r
+        return hitTime;\r
+    }\r
+\r
+    void selectItem(int idx, boolean addSelection) {\r
+        boolean changed = false;\r
+        if (addSelection) {\r
+            if (idx >= 0 && idx < _data._items.length) {\r
+                Item item = (Item) _data._items[idx];\r
+                changed = (item._selected == false);\r
+                item._selected = true;\r
+            }\r
+        } else {\r
+            for (int i = 0; i < _data._items.length; i++) {\r
+                Item item = (Item) _data._items[i];\r
+                if (i == idx && item._selected == false) {\r
+                    changed = true;\r
+                }\r
+                item._selected = i == idx;\r
+            }\r
+        }\r
+        changed |= ensureVisibleItem(idx, true);\r
+        if (changed)\r
+            redraw();\r
+    }\r
+\r
+    public void selectItem(ITmfTimeAnalysisEntry trace, boolean addSelection) {\r
+        Integer idx = _data.findTraceItemIndex(trace);\r
+        if (idx != null) {\r
+            selectItem(idx, addSelection);\r
+        }\r
+    }\r
+\r
+    public int countPerPage() {\r
+        int height = getCtrlSize().y;\r
+        int count = 0;\r
+        if (height > 0)\r
+            count = height / _itemHeight;\r
+        return count;\r
+    }\r
+\r
+    public int getTopIndex() {\r
+        int idx = -1;\r
+        if (_data._items.length > 0)\r
+            idx = 0;\r
+        return idx;\r
+    }\r
+\r
+    public int getBottomIndex() {\r
+        int idx = _data._items.length - 1;\r
+        return idx;\r
+    }\r
+\r
+    Point getCtrlSize() {\r
+        Point size = getSize();\r
+        if (getVerticalBar().isVisible()) {\r
+            size.x -= getVerticalBar().getSize().x;\r
+        }\r
+        if (getHorizontalBar().isVisible()) {\r
+            size.y -= getHorizontalBar().getSize().y;\r
+        }\r
+        return size;\r
+    }\r
+\r
+    void getNameRect(Rectangle rect, Rectangle bound, int idx, int nameWidth) {\r
+        idx -= _topItem;\r
+        rect.x = bound.x;\r
+        rect.y = bound.y + idx * _itemHeight;\r
+        rect.width = nameWidth;\r
+        rect.height = _itemHeight;\r
+    }\r
+\r
+    void getStatesRect(Rectangle rect, Rectangle bound, int idx, int nameWidth) {\r
+        idx -= _topItem;\r
+        rect.x = bound.x + nameWidth;\r
+        rect.y = bound.y + idx * _itemHeight;\r
+        rect.width = bound.width - rect.x;\r
+        rect.height = _itemHeight;\r
+    }\r
+\r
+    // private int getTraceNumber(int tid) {\r
+    // int num = -1;\r
+    //\r
+    // Object[] items = _data._items;\r
+    // for (int i = _topItem; i < items.length; i++) {\r
+    // Item item = (Item) items[i];\r
+    // if ((item instanceof TraceItem)) {\r
+    // TsfTmTrace trace = ((TraceItem) item)._trace;\r
+    // if (trace != null && trace.getId() == tid) {\r
+    // num = i;\r
+    // break;\r
+    // }\r
+    // }\r
+    // }\r
+    //\r
+    // return num;\r
+    // }\r
+\r
+    // private void drawArrow(GC gc, int x0, int y0, int x1, int y1, Color c) {\r
+    // gc.setForeground(c);\r
+    // gc.drawLine(x0, y0, x1, y1);\r
+    //\r
+    // if (y1 > y0) {\r
+    // gc.drawLine(x1 - 3, y1 - 3, x1, y1);\r
+    // gc.drawLine(x1 + 3, y1 - 3, x1, y1);\r
+    // } else {\r
+    // gc.drawLine(x1 - 3, y1 + 3, x1, y1);\r
+    // gc.drawLine(x1 + 3, y1 + 3, x1, y1);\r
+    // }\r
+    // }\r
+\r
+    // TODO: CC: used in the removed functionality to draw thread interactions.\r
+    // private void drawTraceThreadEvent(Rectangle bound, TsfTmEvent e,\r
+    // TsfTmTrace trace, int nItem, int color, GC gc) {\r
+    // if (trace == null)\r
+    // return;\r
+    //\r
+    // int tid = trace.getId();\r
+    // if (tid < 0 || getTraceNumber(tid) == -1)\r
+    // return;\r
+    //\r
+    // int nameWidth = _timeProvider.getNameSpace();\r
+    //\r
+    // double time0 = _timeProvider.getTime0();\r
+    // double time1 = _timeProvider.getTime1();\r
+    // if (time0 == time1)\r
+    // return;\r
+    //\r
+    // int xr = bound.x + nameWidth;\r
+    // double K = (double) (bound.width - xr) / (time1 - time0);\r
+    //\r
+    // int x0 = xr + (int) ((e.getTime() - time0) * K);\r
+    // if (x0 < xr)\r
+    // x0 = xr;\r
+    //\r
+    // int x1 = xr + (int) ((trace.getStartTime() - time0) * K);\r
+    // if (x1 < xr)\r
+    // return;\r
+    //\r
+    // int y0 = bound.y + (nItem - _topItem) * _itemHeight + 3\r
+    // + (_itemHeight - 6) / 2;\r
+    // int y1 = bound.y + (getTraceNumber(tid) - _topItem) * _itemHeight + 3\r
+    // + (_itemHeight - 6) / 2;\r
+    //\r
+    // drawArrow(gc, x0, y0, x1, y1, _colors.getColor(color));\r
+    // }\r
+\r
+    public void drawTraceEvent(Rectangle bound, ITimeEvent e, int nItem, int color, GC gc) {\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        if (time0 == time1)\r
+            return;\r
+\r
+        int xr = bound.x + nameWidth;\r
+        double pixelsPerNanoSec = (bound.width - xr <= RIGHT_MARGIN) ? 0 : (double) (bound.width - xr - RIGHT_MARGIN) / (time1 - time0);\r
+\r
+        int x0 = xr + (int) ((e.getTime() - time0) * pixelsPerNanoSec);\r
+        if (x0 < xr)\r
+            return;\r
+\r
+        int y0 = bound.y + (nItem - _topItem) * _itemHeight + 3;\r
+\r
+        gc.setBackground(_colors.getColor(color));\r
+        int c[] = { x0 - 3, y0 - 3, x0, y0, x0 + 3, y0 - 3 };\r
+        gc.fillPolygon(c);\r
+    }\r
+\r
+    // TODO: CC:\r
+    // private void drawExecEvent(Rectangle bound, TsfTmTraceExecEventImpl e,\r
+    // int nitem, int color, GC gc) {\r
+    // List runnings = e.getRunningEvents();\r
+    // if (runnings == null)\r
+    // return;\r
+    //\r
+    // int nameWidth = _timeProvider.getNameSpace();\r
+    //\r
+    // double time0 = _timeProvider.getTime0();\r
+    // double time1 = _timeProvider.getTime1();\r
+    // if (time0 == time1)\r
+    // return;\r
+    //\r
+    // int xr = bound.x + nameWidth;\r
+    // double K = (double) (bound.width - xr) / (time1 - time0);\r
+    //\r
+    // int x0 = xr + (int) ((e.getTime() - time0) * K);\r
+    // if (x0 < xr)\r
+    // x0 = xr;\r
+    //\r
+    // Iterator it = runnings.iterator();\r
+    // while (it.hasNext()) {\r
+    // TsfTmTraceRunningEventImpl re = (TsfTmTraceRunningEventImpl) it\r
+    // .next();\r
+    // int tid = re.getThread().getId();\r
+    // if (tid < 0 || getThreadNumber(tid) == -1)\r
+    // continue;\r
+    //\r
+    // int x1 = xr + (int) ((re.getTime() - time0) * K);\r
+    // if (x1 < xr)\r
+    // continue;\r
+    //\r
+    // int y0 = bound.y + (nitem - _topItem) * _itemHeight + 3\r
+    // + (_itemHeight - 6) / 2;\r
+    // int y1 = bound.y + (getThreadNumber(tid) - _topItem) * _itemHeight\r
+    // + 3 + (_itemHeight - 6) / 2;\r
+    //\r
+    // drawArrow(gc, x0, y0, x1, y1, _colors.getColor(color));\r
+    // }\r
+    // }\r
+\r
+    public void drawTraceInteractions(Rectangle bound, GC gc) {\r
+        // int nameWidth = _timeProvider.getNameSpace();\r
+        // Object[] items = _data._items;\r
+        //\r
+        // double time0 = _timeProvider.getTime0();\r
+        // double time1 = _timeProvider.getTime1();\r
+        //\r
+        // if (time0 == time1)\r
+        // return;\r
+        //\r
+        // int xr = bound.x + nameWidth;\r
+        // double K = (double) (bound.width - xr) / (time1 - time0);\r
+\r
+        // for (int i = 0; i < items.length; i++) {\r
+        // Item item = (Item) items[i];\r
+        // if (!(item instanceof TraceItem))\r
+        // continue;\r
+        //\r
+        // TsfTmTrace trace = ((TraceItem) item)._trace;\r
+        // if (trace == null)\r
+        // continue;\r
+        //\r
+        // List<TsfTmEvent> list = trace.getTraceEvents();\r
+        // Iterator<TsfTmEvent> it = list.iterator();\r
+        // while (it.hasNext()) {\r
+        // TsfTmEvent te = (TsfTmEvent) it.next();\r
+        // TODO: CC: Thread Interactions,\r
+        // This needs to be accessed externally via a specific\r
+        // implementation.\r
+        // if (te instanceof TsfTmTraceStartThreadEventImpl) {\r
+        // TsfTmTrace child = ((TsfTmTraceStartThreadEventImpl) te)\r
+        // .getStartedThread();\r
+        // drawThreadThreadEvent(bound, te, child, i,\r
+        // TraceColorScheme.TI_START_THREAD, gc);\r
+        // } else if (te instanceof TsfTmTraceHandoffLockEventImpl) {\r
+        // if (drawThreadReleases)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_HANDOFF_LOCK, gc);\r
+        // } else if (te instanceof TsfTmTraceNotifyAllEventImpl) {\r
+        // if (drawThreadWaits)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_NOTIFY_ALL, gc);\r
+        // } else if (te instanceof TsfTmTraceNotifyEventImpl) {\r
+        // if (drawThreadWaits)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_NOTIFY, gc);\r
+        // } else if (te instanceof\r
+        // TsfTmTraceDeadAndNotifyJoinedEventImpl) {\r
+        // if (drawThreadJoins)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_NOTIFY_JOINED, gc);\r
+        // } else if (te instanceof TsfTmTraceInterruptThreadEventImpl)\r
+        // {\r
+        // if (drawThreadWaits)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_INTERRUPT, gc);\r
+        // } else if (te instanceof\r
+        // TsfTmTraceWaitTimeoutExceedEventImpl) {\r
+        // drawThreadEvent(bound, te, i,\r
+        // TraceColorScheme.TI_WAIT_EXCEEDED, gc);\r
+        // }\r
+        // }\r
+        // }\r
+    }\r
+\r
+    @Override\r
+    void paint(Rectangle bound, PaintEvent e) {\r
+        GC gc = e.gc;\r
+        gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND));\r
+        drawBackground(gc, bound.x, bound.y, bound.width, bound.height);\r
+\r
+        if (bound.width < 2 || bound.height < 2 || null == _timeProvider)\r
+            return;\r
+\r
+        _idealNameWidth = 0;\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        long endTime = _timeProvider.getEndTime();\r
+        long selectedTime = _timeProvider.getSelectedTime();\r
+        // draw trace states\r
+        Object[] items = _data._items;\r
+        for (int i = _topItem; i < items.length; i++) {\r
+            Item item = (Item) items[i];\r
+\r
+            getNameRect(_rect0, bound, i, nameWidth);\r
+            if (_rect0.y >= bound.y + bound.height)\r
+                break;\r
+\r
+            if (item instanceof GroupItem) {\r
+                getStatesRect(_rect1, bound, i, nameWidth);\r
+                _rect0.width += _rect1.width;\r
+                drawName(item, _rect0, gc);\r
+            } else {\r
+                drawName(item, _rect0, gc);\r
+            }\r
+            getStatesRect(_rect0, bound, i, nameWidth);\r
+            drawItemDataDurations(item, _rect0, time0, time1, endTime, selectedTime, gc);\r
+        }\r
+\r
+        if (drawTracesInteraction)\r
+            drawTraceInteractions(bound, e.gc);\r
+\r
+        // draw empty name space background\r
+        if (_itemHeight * items.length < bound.height) {\r
+            gc.setBackground(_colors.getBkColor(false, false, true));\r
+            drawBackground(gc, bound.x, _itemHeight * items.length, nameWidth, bound.height - _itemHeight * items.length);\r
+        }\r
+\r
+        // draw drag line, no line if name space is 0.\r
+        if (DRAG_SPLIT_LINE == _dragState) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.BLACK));\r
+            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);\r
+        } else if (DRAG_NONE == _dragState && _mouseHover && _timeProvider.getNameSpace() > 0) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.RED));\r
+            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);\r
+        }\r
+    }\r
+\r
+    void drawName(Item item, Rectangle rect, GC gc) {\r
+        // No name to be drawn\r
+        if (_timeProvider.getNameSpace() == 0)\r
+            return;\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        int elemHeight = rect.height / 2;\r
+        int elemWidth = elemHeight;\r
+        String name = item._name;\r
+        if (group) {\r
+            gc.setBackground(_colors.getBkColorGroup(item._selected, _isInFocus));\r
+            gc.fillRectangle(rect);\r
+            if (item._selected && _isInFocus) {\r
+                gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, false));\r
+                gc.drawRectangle(rect.x, rect.y, rect.width - 2, rect.height - 2);\r
+            }\r
+            gc.setForeground(_colors.getBkColor(false, false, false));\r
+            gc.drawLine(rect.x, rect.y + rect.height - 1, rect.width - 1, rect.y + rect.height - 1);\r
+            gc.setForeground(_colors.getFgColorGroup(false, false));\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            Utils.init(_rect1, rect);\r
+            _rect1.x += MARGIN;\r
+            _rect1.y += (rect.height - elemHeight) / 2;\r
+            _rect1.width = elemWidth;\r
+            _rect1.height = elemHeight;\r
+            // Get the icon rectangle in the group items\r
+            gc.fillRectangle(_rect1);\r
+            gc.drawRectangle(_rect1.x, _rect1.y, _rect1.width - 1, _rect1.height - 1);\r
+            int p = _rect1.y + _rect1.height / 2;\r
+            gc.drawLine(_rect1.x + 2, p, _rect1.x + _rect1.width - 3, p);\r
+            if (!item._expanded) {\r
+                p = _rect1.x + _rect1.width / 2;\r
+                gc.drawLine(p, _rect1.y + 2, p, _rect1.y + _rect1.height - 3);\r
+            }\r
+            gc.setForeground(_colors.getFgColorGroup(item._selected, _isInFocus));\r
+            elemWidth += MARGIN;\r
+        } else {\r
+            gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, true));\r
+            gc.setForeground(_colors.getFgColor(item._selected, _isInFocus));\r
+            gc.fillRectangle(rect);\r
+            Utils.init(_rect1, rect);\r
+            _rect1.x += MARGIN;\r
+            // draw icon\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+            Image img = utilImpl.getItemImage(trace);\r
+            if (null != img) {\r
+                _rect1.y += (rect.height - img.getImageData().height) / 2;\r
+                gc.drawImage(img, _rect1.x, _rect1.y);\r
+            }\r
+            elemWidth = SMALL_ICON_SIZE;\r
+            // cut long string with "..."\r
+            Point size = gc.stringExtent(name);\r
+            if (_idealNameWidth < size.x)\r
+                _idealNameWidth = size.x;\r
+            int width = rect.width - MARGIN - MARGIN - elemWidth;\r
+            int cuts = 0;\r
+            while (size.x > width && name.length() > 1) {\r
+                cuts++;\r
+                name = name.substring(0, name.length() - 1);\r
+                size = gc.stringExtent(name + "..."); //$NON-NLS-1$\r
+            }\r
+            if (cuts > 0)\r
+                name += "..."; //$NON-NLS-1$\r
+            elemWidth += MARGIN;\r
+        }\r
+        Utils.init(_rect1, rect);\r
+        int leftMargin = MARGIN + elemWidth;\r
+        _rect1.x += leftMargin;\r
+        _rect1.width -= leftMargin;\r
+        int textWidth = 0;\r
+        // draw text\r
+        if (_rect1.width > 0) {\r
+            _rect1.y += 2;\r
+            textWidth = Utils.drawText(gc, name, _rect1, true) + 8;\r
+            _rect1.y -= 2;\r
+        }\r
+        // draw middle line\r
+        if (_rect1.width > 0 && !group) {\r
+            Utils.init(_rect1, rect);\r
+            _rect1.x += leftMargin + textWidth;\r
+            _rect1.width -= textWidth;\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));\r
+            int midy = _rect1.y + _rect1.height / 2;\r
+            gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
+        }\r
+        // gc.drawLine(_rect1.x + _rect1.width - 1, _rect1.y, _rect1.x +\r
+        // _rect1.width - 1, _rect1.y + _rect1.height);\r
+    }\r
+\r
+    void drawItemData(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
+        if (rect.isEmpty())\r
+            return;\r
+        if (time1 <= time0) {\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            gc.fillRectangle(rect);\r
+            return;\r
+        }\r
+\r
+        Utils.init(_rect1, rect);\r
+        boolean selected = item._selected;\r
+        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        if (group) {\r
+            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
+            // gc.fillRectangle(rect);\r
+        } else if (item instanceof TraceItem) {\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+\r
+            int x0 = rect.x;\r
+            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();\r
+            ITimeEvent lastEvent = null;\r
+            if (iterator.hasNext()) {\r
+                ITimeEvent currEvent = iterator.next();\r
+                ITimeEvent nextEvent = null;\r
+                long currEventTime = currEvent.getTime();\r
+                long nextEventTime = currEventTime;\r
+                x0 = rect.x + (int) ((currEventTime - time0) * pixelsPerNanoSec);\r
+                int xEnd = rect.x + (int) ((time1 - time0) * pixelsPerNanoSec);\r
+                int x1 = -1;\r
+\r
+                // reduce rect\r
+                _rect1.y += 3;\r
+                _rect1.height -= 6;\r
+                fillSpace(rect, gc, selected);\r
+\r
+                // draw event states\r
+                while (x0 <= xEnd && null != currEvent) {\r
+                    boolean stopped = false;// currEvent instanceof\r
+                    // TsfTmTraceDeadEvent;\r
+                    if (iterator.hasNext()) {\r
+                        nextEvent = iterator.next();\r
+                        nextEventTime = nextEvent.getTime();\r
+                    } else if (stopped) {\r
+                        nextEvent = null;\r
+                        nextEventTime = time1;\r
+                    } else {\r
+                        nextEvent = null;\r
+                        nextEventTime = endTime;\r
+                    }\r
+                    x1 = rect.x + (int) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    if (x1 >= rect.x) {\r
+                        _rect1.x = x0 >= rect.x ? x0 : rect.x;\r
+                        _rect1.width = (x1 <= xEnd ? x1 : xEnd) - _rect1.x;\r
+                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
+                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
+                        // + _rect1.y + "," + _rect1.height + ", "\r
+                        // + _rect1.width + "-->"\r
+                        // + ((int) _rect1.x + (int) _rect1.width));\r
+                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
+                    }\r
+                    lastEvent = currEvent;\r
+                    currEvent = nextEvent;\r
+                    currEventTime = nextEventTime;\r
+                    x0 = x1;\r
+                }\r
+            }\r
+\r
+            // fill space after last event\r
+            int xEnd = rect.x + rect.width;\r
+            if (x0 < xEnd) {\r
+                _rect1.x = x0 >= rect.x ? x0 : rect.x;\r
+                _rect1.width = xEnd - _rect1.x;\r
+                gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
+                gc.fillRectangle(_rect1);\r
+                // draw middle line\r
+                gc.setForeground(_colors.getColor(utilImpl.getEventColorVal(lastEvent)));\r
+                int midy = _rect1.y + _rect1.height / 2;\r
+                int lw = gc.getLineWidth();\r
+                gc.setLineWidth(2);\r
+                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
+                gc.setLineWidth(lw);\r
+            }\r
+        }\r
+\r
+        // draw selected time\r
+        int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
+        if (x >= rect.x && x < rect.x + rect.width) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+            if (group)\r
+                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
+            else\r
+                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Represent the event in series of bursts rather than sequence of states\r
+     * \r
+     * @param item\r
+     * @param rect\r
+     *            - The container rectangle to be colored to different states\r
+     * @param time0\r
+     *            - Base time of all events\r
+     * @param time1\r
+     *            - End time of all events\r
+     * @param endTime\r
+     * @param selectedTime\r
+     * @param gc\r
+     */\r
+    void drawItemDataBurst(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
+        if (rect.isEmpty())\r
+            return;\r
+        if (time1 <= time0) {\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            gc.fillRectangle(rect);\r
+            return;\r
+        }\r
+\r
+        // Initialize _rect1 to same values as enclosing rectangle rect\r
+        Utils.init(_rect1, rect);\r
+        boolean selected = item._selected;\r
+        // K pixels per second\r
+        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
+        // Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
+        // + time0 + " time1:" + time1 + " endTime: " + endTime);\r
+\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        if (group) {\r
+            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
+            // gc.fillRectangle(rect);\r
+            // if (Trace.isDEBUG()) {\r
+            // Trace.debug("Group");\r
+            // }\r
+        } else if (item instanceof TraceItem) {\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+\r
+            double x0 = rect.x;\r
+            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();\r
+            ITimeEvent lastEvent = null;\r
+            // Trace.debug("count is: " + count);\r
+            if (iterator.hasNext()) {\r
+                ITimeEvent currEvent = iterator.next();\r
+                ITimeEvent nextEvent = null;\r
+                long currEventTime = currEvent.getTime();\r
+                long nextEventTime = currEventTime;\r
+                // x0 - Points to the beginning of the event being drawn\r
+                double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
+                x0 = rect.x + step;\r
+                // xEnd - Points to the end of the events rectangle\r
+                double xEnd = rect.x + (double) ((time1 - time0) * pixelsPerNanoSec);\r
+                double x1 = -1;\r
+                //double xNext = 0;\r
+\r
+                // Drawing rectangle is smaller than reserved space\r
+                _rect1.y += 3;\r
+                _rect1.height -= 6;\r
+\r
+                // Clean up to empty line to draw on top\r
+                fillSpace(rect, gc, selected);\r
+                // draw event states\r
+                while (x0 <= xEnd && null != currEvent) {\r
+                    boolean stopped = false;// currEvent instanceof\r
+                    // TsfTmTraceDeadEvent;\r
+                    if (iterator.hasNext()) {\r
+                        nextEvent = iterator.next();\r
+                        nextEventTime = nextEvent.getTime();\r
+                    } else if (stopped) {\r
+                        nextEvent = null;\r
+                        nextEventTime = time1;\r
+                    } else {\r
+                        nextEvent = null;\r
+                        nextEventTime = endTime;\r
+                        // Trace\r
+                        // .debug("nexEventTime is endTime: "\r
+                        // + nextEventTime);\r
+                    }\r
+\r
+                    // Draw it as a burst, one unit of width.\r
+                    x1 = x0 + (int) 2;\r
+                    if (x1 >= rect.x && x0 <= xEnd) {\r
+                        // Fill with space until x0\r
+                        _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
+                        _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - _rect1.x);\r
+                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
+                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
+                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
+                        // + _rect1.y + "," + _rect1.height + ", "\r
+                        // + _rect1.width + "-->"\r
+                        // + ((int) _rect1.x + (int) _rect1.width));\r
+                        // Advance rectangle to next start position and Fill\r
+                        // with space until next event\r
+                        _rect1.x += _rect1.width;\r
+                        x0 = x1;\r
+                        //xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    }\r
+                    // Fill space till next event\r
+                    fillSpace(rect, gc, selected);\r
+\r
+                    lastEvent = currEvent;\r
+                    currEvent = nextEvent;\r
+                    currEventTime = nextEventTime;\r
+                    // Move x0 to the beginning of next event\r
+                    x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    // Trace.debug("rect.x: " + rect.x + " + " +\r
+                    // "(nextEvenTime: "\r
+                    // + nextEventTime + "- time0: " + time0 + ") * K: "\r
+                    // + K + " = " + x0);\r
+                }\r
+            }\r
+\r
+            // fill space after last event\r
+            int xEnd = rect.x + rect.width;\r
+            if (x0 < xEnd) {\r
+                // Trace.debug("Space after last event, x0: " + x0 + ", xEnd: "\r
+                // + xEnd);\r
+                _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
+                _rect1.width = xEnd - _rect1.x;\r
+                gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
+                gc.fillRectangle(_rect1);\r
+                // draw middle line\r
+                gc.setForeground(_colors.getColor(utilImpl.getEventColorVal(lastEvent)));\r
+                int midy = _rect1.y + _rect1.height / 2;\r
+                int lw = gc.getLineWidth();\r
+                gc.setLineWidth(2);\r
+                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
+                gc.setLineWidth(lw);\r
+            }\r
+        }\r
+\r
+        // draw selected time\r
+        int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
+        if (x >= rect.x && x < rect.x + rect.width) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+            if (group)\r
+                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
+            else\r
+                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Represent the series of events with specified durations\r
+     * \r
+     * @param item\r
+     * @param rect\r
+     *            - The container rectangle to be colored to different states\r
+     * @param time0\r
+     *            - Base time of all events - start of visible window\r
+     * @param time1\r
+     *            - End time of visible events - end time of visible window\r
+     * @param endTime\r
+     *            - End time of all events - may not be visible in selected\r
+     *            visible window\r
+     * @param selectedTime\r
+     * @param gc\r
+     */\r
+    void drawItemDataDurations(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
+        if (rect.isEmpty())\r
+            return;\r
+        if (time1 <= time0) {\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            gc.fillRectangle(rect);\r
+            return;\r
+        }\r
+\r
+        // Initialize _rect1 to same values as enclosing rectangle rect\r
+        Utils.init(_rect1, rect);\r
+        boolean selected = item._selected;\r
+        // K pixels per second\r
+        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
+        // Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
+        // + time0 + " time1:" + time1 + " endTime: " + endTime);\r
+\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        if (group) {\r
+            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
+            // gc.fillRectangle(rect);\r
+        } else if (item instanceof TraceItem) {\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+\r
+            double x0 = rect.x;\r
+            long maxDuration = (_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace();\r
+            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(_timeProvider.getTime0(), _timeProvider.getTime1(), maxDuration);\r
+            // ITimeEvent lastEvent = null;\r
+            // if (Trace.isDEBUG()) {\r
+            // Trace.debug("\n\t\t\tTrace: " + trace.getName()\r
+            // + utilImpl.getTraceClassName(trace));\r
+            // }\r
+            // Trace.debug("count is: " + count);\r
+            // Drawing rectangle is smaller than reserved space\r
+            _rect1.y += 3;\r
+            _rect1.height -= 6;\r
+\r
+            // Clean up to empty line to draw on top\r
+            int xEnd = rect.x + rect.width;\r
+            fillSpace(rect, gc, selected);\r
+            if (iterator.hasNext()) {\r
+                ITimeEvent currEvent = iterator.next();\r
+                ITimeEvent nextEvent = null;\r
+                long currEventTime = currEvent.getTime();\r
+                long currEventDuration = currEvent.getDuration();\r
+                // initial value\r
+                long nextEventTime = currEventTime;\r
+                // x0 - Points to the beginning of the event being drawn\r
+                double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
+                x0 = rect.x + step;\r
+                // xEnd - Points to the end of the events rectangle\r
+                double x1 = -1;\r
+                double xNext = 0;\r
+\r
+                // draw event states\r
+                while (/* x0 <= xEnd && */null != currEvent) {\r
+                    boolean stopped = false;// currEvent instanceof\r
+                    // refresh current event duration as the loop moves\r
+                    currEventDuration = currEvent.getDuration();\r
+                    // TsfTmTraceDeadEvent;\r
+                    if (iterator.hasNext()) {\r
+                        nextEvent = iterator.next();\r
+                        nextEventTime = nextEvent.getTime();\r
+                    } else if (stopped) {\r
+                        nextEvent = null;\r
+                        nextEventTime = time1;\r
+                    } else {\r
+                        nextEvent = null;\r
+                        nextEventTime = endTime;\r
+                        // Trace\r
+                        // .debug("nexEventTime is endTime: "\r
+                        // + nextEventTime);\r
+                    }\r
+\r
+                    // Calculate position to next event\r
+                    xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+\r
+                    // Calculate end position of current event\r
+                    if (currEventDuration < 0) {\r
+                        x1 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    } else if (currEventDuration == 0) {\r
+                        x1 = x0;\r
+                    } else {\r
+                        x1 = x0 + (double) ((currEventDuration) * pixelsPerNanoSec);\r
+                    }\r
+\r
+                    // If event end position x1 further away than start position\r
+                    // of\r
+                    // next event, cut width till next event\r
+                    // Trace.debug("Next Event Pos: " + xNext\r
+                    // + " End Of Current at: " + x1 + " Event Duration: "\r
+                    // + currEventDuration);\r
+                    if (currEventDuration != 0) {\r
+                        x1 = x1 > xNext ? xNext : x1;\r
+                    }\r
+                    // if event end boundary is within time range\r
+                    if (x1 >= rect.x && x0 <= xEnd) {\r
+                        if (currEventDuration != 0) {\r
+                            x0 = (double) (x0 >= rect.x ? x0 : rect.x);\r
+                            _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0);\r
+                        } else {\r
+                            _rect1.width = 1;\r
+                        }\r
+                        _rect1.width = Math.max(_minimumItemWidth, _rect1.width);\r
+                        _rect1.x = (int) x0;\r
+                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
+                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
+                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
+                        // + _rect1.y + "," + _rect1.height + ", "\r
+                        // + _rect1.width + "-->"\r
+                        // + ((int) _rect1.x + (int) _rect1.width));\r
+                        // Advance rectangle to next start position and Fill\r
+                        // with space until next event\r
+                        _rect1.x += _rect1.width;\r
+                        x0 = _rect1.x;\r
+                    }\r
+\r
+                    // Fill space till next event\r
+                    // fillSpace(rect, gc, selected, x0, xNext, xEnd);\r
+\r
+                    // lastEvent = currEvent;\r
+                    currEvent = nextEvent;\r
+                    currEventTime = nextEventTime;\r
+                    // Move x0 to the beginning of next event\r
+                    x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    // Trace.debug("rect.x: " + rect.x + " + " +\r
+                    // "(nextEvenTime: "\r
+                    // + nextEventTime + "- time0: " + time0 + ") * K: "\r
+                    // + K + " = " + x0);\r
+                }\r
+            }\r
+        }\r
+\r
+        // draw selected time\r
+        int x = rect.x + (int) ((double) (selectedTime - time0) * pixelsPerNanoSec);\r
+        if (x >= rect.x && x < rect.x + rect.width) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+            if (group)\r
+                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
+            else\r
+                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
+        }\r
+    }\r
+\r
+    private void fillSpace(Rectangle rect, GC gc, boolean selected) {\r
+        gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
+        gc.fillRectangle(rect);\r
+        // draw middle line\r
+        gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));\r
+        int midy = rect.y + rect.height / 2;\r
+        gc.drawLine(rect.x, midy, rect.x + rect.width, midy);\r
+    }\r
+\r
+    @Override\r
+    public void keyTraversed(TraverseEvent e) {\r
+        if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))\r
+            e.doit = true;\r
+    }\r
+\r
+    @Override\r
+    public void keyPressed(KeyEvent e) {\r
+        int idx = -1;\r
+        if (SWT.HOME == e.keyCode) {\r
+            idx = getTopIndex();\r
+        } else if (SWT.END == e.keyCode) {\r
+            idx = getBottomIndex();\r
+        } else if (SWT.ARROW_DOWN == e.keyCode) {\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            else if (idx < _data._items.length - 1)\r
+                idx++;\r
+        } else if (SWT.ARROW_UP == e.keyCode) {\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            else if (idx > 0)\r
+                idx--;\r
+        } else if (SWT.ARROW_LEFT == e.keyCode) {\r
+            selectPrevEvent();\r
+        } else if (SWT.ARROW_RIGHT == e.keyCode) {\r
+            selectNextEvent();\r
+        } else if (SWT.PAGE_DOWN == e.keyCode) {\r
+            int page = countPerPage();\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            idx += page;\r
+            if (idx >= _data._items.length)\r
+                idx = _data._items.length - 1;\r
+        } else if (SWT.PAGE_UP == e.keyCode) {\r
+            int page = countPerPage();\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            idx -= page;\r
+            if (idx < 0)\r
+                idx = 0;\r
+        } else if (SWT.CR == e.keyCode) {\r
+            idx = getSelectedIndex();\r
+            if (idx >= 0) {\r
+                if (_data._items[idx] instanceof TraceItem)\r
+                    fireDefaultSelection();\r
+                else if (_data._items[idx] instanceof GroupItem)\r
+                    toggle(idx);\r
+            }\r
+            idx = -1;\r
+        }\r
+        if (idx >= 0) {\r
+            selectItem(idx, false);\r
+            fireSelectionChanged();\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void keyReleased(KeyEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void focusGained(FocusEvent e) {\r
+        _isInFocus = true;\r
+        redraw();\r
+    }\r
+\r
+    @Override\r
+    public void focusLost(FocusEvent e) {\r
+        _isInFocus = false;\r
+        if (DRAG_NONE != _dragState) {\r
+            setCapture(false);\r
+            _dragState = DRAG_NONE;\r
+        }\r
+        redraw();\r
+    }\r
+\r
+    public boolean isInFocus() {\r
+        return _isInFocus;\r
+    }\r
+\r
+    @Override\r
+    public void mouseMove(MouseEvent e) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        Point size = getCtrlSize();\r
+        if (DRAG_TRACE_ITEM == _dragState) {\r
+            int nameWidth = _timeProvider.getNameSpace();\r
+            int x = e.x - nameWidth;\r
+            if (x > 0 && size.x > nameWidth && _dragX != x) {\r
+                _dragX = x;\r
+                double pixelsPerNanoSec = (size.x - nameWidth <= RIGHT_MARGIN) ? 0 : (double) (size.x - nameWidth - RIGHT_MARGIN) / (_time1bak - _time0bak);\r
+                long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((_dragX - _dragX0) / pixelsPerNanoSec));\r
+                long time1 = _time1bak - timeDelta;\r
+                long maxTime = _timeProvider.getMaxTime();\r
+                if (time1 > maxTime)\r
+                    time1 = maxTime;\r
+                long time0 = time1 - (_time1bak - _time0bak);\r
+                if (time0 < _timeProvider.getMinTime()) {\r
+                    time0 = _timeProvider.getMinTime();\r
+                    time1 = time0 + (_time1bak - _time0bak);\r
+                }\r
+                _timeProvider.setStartFinishTime(time0, time1);\r
+            }\r
+        } else if (DRAG_SPLIT_LINE == _dragState) {\r
+            _dragX = e.x;\r
+            _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0);\r
+        } else if (DRAG_NONE == _dragState) {\r
+            boolean mouseHover = hitSplitTest(e.x, e.y) > 0;\r
+            if (_mouseHover != mouseHover)\r
+                redraw();\r
+            _mouseHover = mouseHover;\r
+            // Make sure any time changes are notified to the application e.g.\r
+            // getting back from the horizontal scroll bar or zoomed using the\r
+            // mouse wheel\r
+            _timeProvider.notifyStartFinishTime();\r
+        }\r
+        updateCursor(e.x, e.y);\r
+    }\r
+\r
+    @Override\r
+    public void mouseDoubleClick(MouseEvent e) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        if (1 == e.button) {\r
+            int idx = hitSplitTest(e.x, e.y);\r
+            if (idx >= 0) {\r
+                _timeProvider.setNameSpace(_idealNameWidth + 3 * MARGIN + SMALL_ICON_SIZE);\r
+                return;\r
+            }\r
+            idx = hitTest(e.x, e.y);\r
+            if (idx >= 0) {\r
+                selectItem(idx, false);\r
+                if (_data._items[idx] instanceof TraceItem) {\r
+                    fireDefaultSelection();\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * <p>\r
+     * If the x, y position is over the vertical split line (name to time\r
+     * ranges), then change the cursor to a drag cursor to indicate the user the\r
+     * possibility of resizing\r
+     * </p>\r
+     * \r
+     * @param x\r
+     * @param y\r
+     */\r
+    void updateCursor(int x, int y) {\r
+        // if Wait cursor not active, check for the need to change to a drag\r
+        // cursor\r
+        if (_isWaitCursor == false) {\r
+            int idx = hitSplitTest(x, y);\r
+            // No dragcursor is name space is fixed to zero\r
+            if (idx > 0 && !_isDragCursor3 && _timeProvider.getNameSpace() > 0) {\r
+                setCursor(_dragCursor3);\r
+                _isDragCursor3 = true;\r
+            } else if (idx <= 0 && _isDragCursor3) {\r
+                setCursor(null);\r
+                _isDragCursor3 = false;\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Provide the possibilty to control the wait cursor externally e.g. data\r
+     * requests in progress\r
+     * \r
+     * @param waitInd\r
+     */\r
+    public void waitCursor(boolean waitInd) {\r
+        // Update cursor as indicated\r
+        if (waitInd) {\r
+            setCursor(_WaitCursor);\r
+            _isWaitCursor = true;\r
+        } else {\r
+            setCursor(null);\r
+            _isWaitCursor = false;\r
+        }\r
+\r
+        // Get ready for next mouse move\r
+        _isDragCursor3 = false;\r
+    }\r
+\r
+    @Override\r
+    public void mouseDown(MouseEvent e) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        int idx;\r
+        if (1 == e.button) {\r
+            int namewidth = _timeProvider.getNameSpace();\r
+            if (namewidth != 0) {\r
+                idx = hitSplitTest(e.x, e.y);\r
+                if (idx > 0) {\r
+                    _dragState = DRAG_SPLIT_LINE;\r
+                    _dragX = _dragX0 = e.x;\r
+                    _hitIdx = _timeProvider.getNameSpace();\r
+                    ;\r
+                    _time0bak = _timeProvider.getTime0();\r
+                    _time1bak = _timeProvider.getTime1();\r
+                    redraw();\r
+                    return;\r
+                }\r
+            }\r
+\r
+            idx = hitTest(e.x, e.y);\r
+            if (idx >= 0) {\r
+                if (_data._items[idx] instanceof TraceItem) {\r
+                    long hitTime = hitTimeTest(e.x);\r
+                    if (hitTime >= 0) {\r
+                        // _timeProvider.setSelectedTimeInt(hitTime, false);\r
+                        setCapture(true);\r
+                        _dragState = DRAG_TRACE_ITEM;\r
+                        _dragX = _dragX0 = e.x - _timeProvider.getNameSpace();\r
+                        _hitIdx = idx;\r
+                        _time0bak = _timeProvider.getTime0();\r
+                        _time1bak = _timeProvider.getTime1();\r
+                        return;\r
+                    }\r
+                } else if (_data._items[idx] instanceof GroupItem) {\r
+                    _dragX0 = e.x;\r
+                    _dragState = DRAG_GROUP_ITEM;\r
+                }\r
+                selectItem(idx, false);\r
+                fireSelectionChanged();\r
+            } else {\r
+                selectItem(idx, false); // clear selection\r
+                redraw();\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseUp(MouseEvent e) {\r
+        if (DRAG_NONE != _dragState) {\r
+            setCapture(false);\r
+            if (DRAG_TRACE_ITEM == _dragState) {\r
+                // Notify time provider to check the need for listener\r
+                // notification\r
+                _timeProvider.notifyStartFinishTime();\r
+                if (_dragX == _dragX0) { // click without drag\r
+                    long time = hitTimeTest(e.x);\r
+                    _timeProvider.setSelectedTimeInt(time, false);\r
+                    selectItem(_hitIdx, false);\r
+                    fireSelectionChanged();\r
+                }\r
+            } else if (DRAG_GROUP_ITEM == _dragState) {\r
+                if (e.x == _dragX0) // click without drag\r
+                    toggle(_hitIdx);\r
+            } else if (DRAG_SPLIT_LINE == _dragState) {\r
+                redraw();\r
+            }\r
+            _dragState = DRAG_NONE;\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void controlMoved(ControlEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void controlResized(ControlEvent e) {\r
+        adjustScrolls();\r
+    }\r
+\r
+    @Override\r
+    public void widgetDefaultSelected(SelectionEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void widgetSelected(SelectionEvent e) {\r
+        if (e.widget == getVerticalBar()) {\r
+            _topItem = getVerticalBar().getSelection();\r
+            if (_topItem < 0)\r
+                _topItem = 0;\r
+            redraw();\r
+        } else if (e.widget == getHorizontalBar() && null != _timeProvider) {\r
+            int start = getHorizontalBar().getSelection();\r
+            long time0 = _timeProvider.getTime0();\r
+            long time1 = _timeProvider.getTime1();\r
+            long timeMin = _timeProvider.getMinTime();\r
+            long timeMax = _timeProvider.getMaxTime();\r
+            long delta = timeMax - timeMin;\r
+\r
+            long range = time1 - time0;\r
+            // _timeRangeFixed = true;\r
+            time0 = timeMin + (long) (delta * ((double) start / H_SCROLLBAR_MAX));\r
+            time1 = time0 + range;\r
+\r
+            // TODO: Follow-up with Bug 310310\r
+            // In Linux SWT.DRAG is the only value received\r
+            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310310\r
+            if (e.detail == SWT.DRAG) {\r
+                _timeProvider.setStartFinishTime(time0, time1);\r
+            } else {\r
+                _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseEnter(MouseEvent e) {\r
+        if (mouseScrollFilterListener == null) {\r
+            mouseScrollFilterListener = new Listener() {\r
+                // This filter is used to prevent scrolling of the view when the\r
+                // mouse wheel is used to zoom\r
+                @Override\r
+                public void handleEvent(Event event) {\r
+                    event.doit = false;\r
+                }\r
+            };\r
+            getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseExit(MouseEvent e) {\r
+        if (mouseScrollFilterListener != null) {\r
+            getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
+            mouseScrollFilterListener = null;\r
+        }\r
+        if (_mouseHover) {\r
+            _mouseHover = false;\r
+            redraw();\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseHover(MouseEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void mouseScrolled(MouseEvent e) {\r
+        if ((mouseScrollFilterListener == null) || _dragState != DRAG_NONE)\r
+            return;\r
+        if (e.count > 0) {\r
+            zoom(true);\r
+        } else if (e.count < 0) {\r
+            zoom(false);\r
+        }\r
+    }\r
+\r
+    public boolean isVisibleVerticalScroll() {\r
+        return _visibleVerticalScroll;\r
+    }\r
+\r
+    public void setVisibleVerticalScroll(boolean visibleVerticalScroll) {\r
+        ScrollBar scrollVer = getVerticalBar();\r
+        if (scrollVer != null) {\r
+            scrollVer.setVisible(visibleVerticalScroll);\r
+        }\r
+        this._visibleVerticalScroll = visibleVerticalScroll;\r
+    }\r
+\r
+    @Override\r
+    public int getBorderWidth() {\r
+        return _borderWidth;\r
+    }\r
+\r
+    public void setBorderWidth(int borderWidth) {\r
+        this._borderWidth = borderWidth;\r
+    }\r
+\r
+    public int getHeaderHeight() {\r
+        return _headerHeight;\r
+    }\r
+\r
+    public void setHeaderHeight(int headerHeight) {\r
+        this._headerHeight = headerHeight;\r
+    }\r
+\r
+    public int getItemHeight() {\r
+        return _itemHeight;\r
+    }\r
+\r
+    public void setItemHeight(int rowHeight) {\r
+        this._itemHeight = rowHeight;\r
+    }\r
+\r
+    public void setMinimumItemWidth(int width) {\r
+        this._minimumItemWidth = width;\r
+    }\r
+\r
+    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
+        return _data.getFilteredOut();\r
+    }\r
+\r
+    // @Override\r
+    @Override\r
+    public void addSelectionChangedListener(ISelectionChangedListener listener) {\r
+        if (listener != null) {\r
+            if (!_selectionChangedListeners.contains(listener)) {\r
+                _selectionChangedListeners.add(listener);\r
+            }\r
+        }\r
+    }\r
+\r
+    // @Override\r
+    @Override\r
+    public void removeSelectionChangedListener(ISelectionChangedListener listener) {\r
+        if (listener != null) {\r
+            _selectionChangedListeners.remove(listener);\r
+        }\r
+    }\r
+\r
+    // @Override\r
+    @Override\r
+    public void setSelection(ISelection selection) {\r
+        if (selection instanceof PlainSelection) {\r
+            PlainSelection sel = (PlainSelection) selection;\r
+            Object ob = sel.getFirstElement();\r
+            if (ob instanceof ITmfTimeAnalysisEntry) {\r
+                ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) ob;\r
+                selectItem(trace, false);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
+\r
+class Item {\r
+    public boolean _expanded;\r
+    public boolean _selected;\r
+    public boolean _hasChildren;\r
+    public String _name;\r
+\r
+    Item(String name) {\r
+        _name = name;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return _name;\r
+    }\r
+}\r
+\r
+class TraceItem extends Item {\r
+    public ITmfTimeAnalysisEntry _trace;\r
+\r
+    TraceItem(ITmfTimeAnalysisEntry trace, String name) {\r
+        super(name);\r
+        _trace = trace;\r
+    }\r
+}\r
+\r
+class GroupItem extends Item {\r
+    public List<ITmfTimeAnalysisEntry> _traces;\r
+\r
+    GroupItem(String name) {\r
+        super(name);\r
+        _traces = new ArrayList<ITmfTimeAnalysisEntry>();\r
+        _hasChildren = true;\r
+    }\r
+\r
+    void add(ITmfTimeAnalysisEntry trace) {\r
+        _traces.add(trace);\r
+    }\r
+}\r
+\r
+class ItemData {\r
+    public Object[] _items = new Object[0];\r
+    private Object _traces[] = new Object[0];\r
+    private boolean traceFilter[] = new boolean[0];\r
+    private Map<String, GroupItem> _groupTable = new HashMap<String, GroupItem>();\r
+    private boolean _flatList = false;\r
+    private TmfTimeAnalysisProvider utilsImp;\r
+    private Vector<ITmfTimeAnalysisEntry> filteredOut = new Vector<ITmfTimeAnalysisEntry>();\r
+\r
+    public ItemData(TmfTimeAnalysisProvider utils) {\r
+        this.utilsImp = utils;\r
+    }\r
+\r
+    protected void groupTraces(boolean on) {\r
+        if (_flatList == on) {\r
+            _flatList = !on;\r
+            updateItems();\r
+        }\r
+    }\r
+\r
+    void clearGroups() {\r
+        Iterator<GroupItem> it = _groupTable.values().iterator();\r
+        while (it.hasNext()) {\r
+            GroupItem group = it.next();\r
+            group._traces.clear();\r
+        }\r
+    }\r
+\r
+    void deleteEmptyGroups() {\r
+        Iterator<GroupItem> it = _groupTable.values().iterator();\r
+        while (it.hasNext()) {\r
+            GroupItem group = it.next();\r
+            if (group._traces.size() == 0)\r
+                it.remove();\r
+        }\r
+    }\r
+\r
+    TraceItem findTraceItem(ITmfTimeAnalysisEntry trace) {\r
+        if (trace == null)\r
+            return null;\r
+\r
+        int traceId = trace.getId();\r
+        TraceItem traceItem = null;\r
+\r
+        for (int i = 0; i < _items.length; i++) {\r
+            Object item = _items[i];\r
+            if (item instanceof TraceItem) {\r
+                TraceItem ti = (TraceItem) item;\r
+                if (ti._trace.getId() == traceId) {\r
+                    traceItem = ti;\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+\r
+        return traceItem;\r
+    }\r
+\r
+    Integer findTraceItemIndex(ITmfTimeAnalysisEntry trace) {\r
+        if (trace == null)\r
+            return null;\r
+\r
+        for (int i = 0; i < _items.length; i++) {\r
+            Object item = _items[i];\r
+            if (item instanceof TraceItem) {\r
+                TraceItem ti = (TraceItem) item;\r
+                if (ti._trace == trace) {\r
+                    return i;\r
+                }\r
+            }\r
+        }\r
+\r
+        return null;\r
+    }\r
+\r
+    public void updateItems() {\r
+        List<Item> itemList = new ArrayList<Item>();\r
+        String name = ""; //$NON-NLS-1$\r
+\r
+        Iterator<GroupItem> it = _groupTable.values().iterator();\r
+        while (it.hasNext()) {\r
+            GroupItem group = it.next();\r
+            if (!_flatList)\r
+                itemList.add(group);\r
+\r
+            if (_flatList || group._expanded) {\r
+                Iterator<ITmfTimeAnalysisEntry> it2 = group._traces.iterator();\r
+                while (it2.hasNext()) {\r
+                    ITmfTimeAnalysisEntry trace = it2.next();\r
+                    TraceItem traceItem = findTraceItem(trace);\r
+                    name = utilsImp.composeTraceName(trace, false);\r
+                    traceItem = new TraceItem(trace, name);\r
+                    itemList.add(traceItem);\r
+                }\r
+            }\r
+        }\r
+        _items = itemList.toArray();\r
+    }\r
+\r
+    public int expandItem(int idx, boolean expand) {\r
+        if (idx < 0 || idx >= _items.length)\r
+            return 0;\r
+        int ret = 0;\r
+        Item item = (Item) _items[idx];\r
+        if (item._hasChildren && !item._expanded) {\r
+            item._expanded = expand;\r
+            ret = _items.length;\r
+            updateItems();\r
+            ret = _items.length - ret;\r
+        }\r
+        return ret;\r
+    }\r
+\r
+    public void refreshData(Object traces[]) {\r
+        if (traces == null || traces.length == 0) {\r
+            traceFilter = null;\r
+        } else if (traceFilter == null || traces.length != traceFilter.length) {\r
+            traceFilter = new boolean[traces.length];\r
+            java.util.Arrays.fill(traceFilter, true);\r
+        }\r
+\r
+        _traces = traces;\r
+        refreshData();\r
+    }\r
+\r
+    /**\r
+     * Allows to update the GUI from a stream of events handling addition one by\r
+     * one over known TmfTaTrace parents.\r
+     * \r
+     * @param parent\r
+     * @param childItem\r
+     */\r
+    public void refreshPartial(ITmfTimeAnalysisEntry parent, TimeEvent childItem) {\r
+        // Find the Trace item within the current list\r
+//        TraceItem item = findTraceItem(parent);\r
+\r
+        // This method is not used (yet) so this code can be commented out for\r
+        // now\r
+        // FIXME: Arrays.copyOf is a Java6 feature\r
+        // if (item == null) {\r
+        // // If the parent item is not found, make room for it in the current\r
+        // // array\r
+        // int length = 1;\r
+        // Object[] traces;\r
+        // if (_traces != null) {\r
+        // length = _traces.length + 1;\r
+        // traces = Arrays.copyOf(_traces, length);\r
+        // } else {\r
+        // traces = new Object[length];\r
+        // }\r
+        //\r
+        // // Add the new parent element to the end of the array.\r
+        // traces[length - 1] = parent;\r
+        //\r
+        // // update the filter array to accomodate a postion to the new\r
+        // // element\r
+        // traceFilter = new boolean[traces.length];\r
+        // java.util.Arrays.fill(traceFilter, true);\r
+        //\r
+        // // rebuild internal data\r
+        // _traces = traces;\r
+        // refreshData();\r
+        //\r
+        // // item must be there\r
+        // item = findTraceItem(parent);\r
+        // }\r
+\r
+        /*\r
+         * Check if this is still needed!\r
+        ITmfTimeAnalysisEntry localTraceItem = item._trace;\r
+        // Local trace found\r
+        Vector<TimeEvent> children = localTraceItem.getTraceEvents();\r
+        TimeEvent lastChildIn = children.lastElement();\r
+        long lastChildSTime = lastChildIn.getTime();\r
+        long newChildSTime = childItem.getTime();\r
+        if (newChildSTime < lastChildSTime) {\r
+            // The children are expected to arrive sorted by time\r
+            // since the new time is earlier than the last child\r
+            // The infomation is being refreshed from start, remove all\r
+            // children and start over\r
+            children.clear();\r
+        }\r
+        // Add the new item\r
+        children.add(childItem);\r
+        */\r
+\r
+    }\r
+\r
+    public void refreshData() {\r
+        clearGroups();\r
+        filteredOut.clear();\r
+        String undef = Messages.TmfTimeStatesCtrl_UNDEFINED_GROUP;\r
+        List<GroupItem> groupList = new ArrayList<GroupItem>();\r
+        for (int i = 0; i < _traces.length; i++) {\r
+            ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) _traces[i];\r
+            if (!traceFilter[i]) {\r
+                filteredOut.add(trace);\r
+                continue;\r
+            }\r
+\r
+            String groupName = trace.getGroupName();\r
+            if (null == groupName)\r
+                groupName = undef;\r
+\r
+            GroupItem group = _groupTable.get(groupName);\r
+            if (null == group) {\r
+                group = new GroupItem(NLS.bind(Messages.TmfTimeStatesCtrl_TRACE_GROUP_LABEL, groupName));\r
+                group._expanded = !groupName.equalsIgnoreCase("system") && !groupName.equalsIgnoreCase(undef); //$NON-NLS-1$\r
+                _groupTable.put(groupName, group);\r
+                groupList.add(group);\r
+            }\r
+            group.add(trace);\r
+        }\r
+\r
+        deleteEmptyGroups();\r
+        updateItems();\r
+    }\r
+\r
+    public Object[] getTraces() {\r
+        return _traces;\r
+    }\r
+\r
+    public boolean[] getTraceFilter() {\r
+        return traceFilter;\r
+    }\r
+\r
+    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
+        return filteredOut;\r
+    }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java
new file mode 100644 (file)
index 0000000..58377e0
--- /dev/null
@@ -0,0 +1,245 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Vitaly A. Provodin, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: ThreadsTipHandler.java,v 1.5 2007/06/06 19:16:16 gnagarajan Exp $\r
+ *****************************************************************************/\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.Messages;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets.Utils.Resolution;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseAdapter;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseTrackAdapter;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.swt.widgets.Widget;\r
+\r
+\r
+public class TmfTimeTipHandler {\r
+\r
+       private Shell _tipShell;\r
+       private Table _tipTable;\r
+       private Item _tipItem;\r
+       private Point _tipPosition;\r
+       private ITimeDataProvider _timeDataProvider;\r
+       TmfTimeAnalysisProvider _utilImp = null;\r
+\r
+       public TmfTimeTipHandler(Shell parent, TmfTimeAnalysisProvider rUtilImpl,\r
+                       ITimeDataProvider timeProv) {\r
+               final Display display = parent.getDisplay();\r
+\r
+               this._utilImp = rUtilImpl;\r
+               this._timeDataProvider = timeProv;\r
+               _tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL);\r
+               GridLayout gridLayout = new GridLayout();\r
+               gridLayout.numColumns = 2;\r
+               gridLayout.marginWidth = 2;\r
+               gridLayout.marginHeight = 2;\r
+               _tipShell.setLayout(gridLayout);\r
+               GridData data = new GridData(GridData.BEGINNING, GridData.BEGINNING,\r
+                               true, true);\r
+               _tipShell.setLayoutData(data);\r
+               _tipShell.setBackground(display\r
+                               .getSystemColor(SWT.COLOR_INFO_BACKGROUND));\r
+\r
+               _tipTable = new Table(_tipShell, SWT.NONE);\r
+               _tipTable.setForeground(display\r
+                               .getSystemColor(SWT.COLOR_INFO_FOREGROUND));\r
+               _tipTable.setBackground(display\r
+                               .getSystemColor(SWT.COLOR_INFO_BACKGROUND));\r
+               _tipTable.setHeaderVisible(false);\r
+               _tipTable.setLinesVisible(false);\r
+\r
+               // tipTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL\r
+               // | GridData.VERTICAL_ALIGN_CENTER));\r
+       }\r
+\r
+       public void activateHoverHelp(final Control control) {\r
+               control.addMouseListener(new MouseAdapter() {\r
+                       @Override\r
+                       public void mouseDown(MouseEvent e) {\r
+                               if (_tipShell.isVisible())\r
+                                       _tipShell.setVisible(false);\r
+                       }\r
+               });\r
+\r
+               control.addMouseTrackListener(new MouseTrackAdapter() {\r
+                       @Override\r
+                       public void mouseExit(MouseEvent e) {\r
+                               if (_tipShell.isVisible())\r
+                                       _tipShell.setVisible(false);\r
+                               _tipItem = null;\r
+\r
+                       }\r
+\r
+                       private void addItem(String name, String value) {\r
+                               TableItem line = new TableItem(_tipTable, SWT.NONE);\r
+                               line.setText(0, name);\r
+                               line.setText(1, value);\r
+                       }\r
+\r
+                       private void fillValues(Point pt, TmfTimeStatesCtrl threadStates,\r
+                                       Item item) {\r
+                               if (item instanceof TraceItem) {\r
+                                       ITmfTimeAnalysisEntry thrd = ((TraceItem) item)._trace;\r
+                                       ITimeEvent threadEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 2);\r
+                                       ITimeEvent nextEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 1);\r
+                                       // thread name\r
+                                       addItem(Messages.TmfTimeTipHandler_TRACE_NAME, thrd.getName());\r
+                                       // class name\r
+                                       String traceClass = _utilImp.getTraceClassName(thrd);\r
+                                       if (traceClass != null) {\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_CLASS_NAME, traceClass);\r
+                                       }\r
+                                       // thread state\r
+                                       String state = _utilImp.getEventName(threadEvent);\r
+                                       if (state != null) {\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_STATE, state);\r
+                                       }\r
+\r
+                                       // This block receives a\r
+                                       // list of <String, String> values to be added to the tip\r
+                                       // table\r
+                                       Map<String, String> eventAddOns = _utilImp.getEventHoverToolTipInfo(threadEvent);\r
+                                       if (eventAddOns != null) {\r
+                                               for (Iterator<String> iter = eventAddOns.keySet().iterator(); iter.hasNext();) {\r
+                                                       String message = (String) iter.next();\r
+                                                       addItem(message, eventAddOns.get(message));\r
+                                               }\r
+                                       }\r
+\r
+                                       long eventStartTime = -1;\r
+                                       long eventDuration = -1;\r
+                                       long eventEndTime = -1;\r
+                                       \r
+                                       if (threadEvent != null) {\r
+                                           eventStartTime = threadEvent.getTime();\r
+                                           eventDuration = threadEvent.getDuration();\r
+                                           if (eventDuration < 0 && nextEvent != null) {\r
+                                               eventEndTime = nextEvent.getTime();\r
+                                               eventDuration = eventEndTime - eventStartTime;\r
+                                           } else {\r
+                                               eventEndTime = eventStartTime + eventDuration;\r
+                                           }\r
+                                       }\r
+\r
+// TODO: Check if we need "format"                                     \r
+//                                     TimeFormat format = TimeFormat.RELATIVE;\r
+                                       Resolution res = Resolution.NANOSEC;\r
+                                       if (_timeDataProvider.isCalendarFormat()) {\r
+//                                             format = TimeFormat.ABSOLUTE; // Absolute format\r
+//                                                                                                             // (calendar)\r
+                                               // Add Date\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_DATE, eventStartTime > -1 ?\r
+                                                       Utils.formatDate(eventStartTime)\r
+                                                       : "?"); //$NON-NLS-1$\r
+                                               if (eventDuration > 0) {\r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, eventStartTime > -1 ?\r
+                                    Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                            \r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, eventEndTime > -1 ?\r
+                                    Utils.formatTime(eventEndTime, TimeFormat.ABSOLUTE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                                               } else {\r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, eventStartTime > -1 ?\r
+                                    Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                                               }\r
+                                       } else {\r
+                                               if (eventDuration > 0) {\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, eventStartTime > -1 ?\r
+                                                       Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
+                                                       : "?"); //$NON-NLS-1$\r
+                                           \r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, eventEndTime > -1 ?\r
+                                                       Utils.formatTime(eventEndTime, TimeFormat.RELATIVE, res)\r
+                                                       : "?"); //$NON-NLS-1$\r
+                                               } else {\r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, eventStartTime > -1 ?\r
+                                    Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                                               }\r
+                                       }\r
+\r
+                                       if (eventDuration > 0) {\r
+                                           // Duration in relative format in any case\r
+                                           addItem(Messages.TmfTimeTipHandler_DURATION, eventDuration > -1 ?\r
+                                                   Utils.formatTime(eventDuration, TimeFormat.RELATIVE, res)\r
+                                                   : "?"); //$NON-NLS-1$\r
+                                       }\r
+\r
+                               } else if (item instanceof GroupItem) {\r
+                                       addItem(Messages.TmfTimeTipHandler_TRACE_GROUP_NAME, item.toString());\r
+                                       addItem(Messages.TmfTimeTipHandler_NUMBER_OF_TRACES, "" + ((GroupItem) item)._traces.size()); //$NON-NLS-1$\r
+                               }\r
+                       }\r
+\r
+                       @Override\r
+                       public void mouseHover(MouseEvent event) {\r
+                               Point pt = new Point(event.x, event.y);\r
+                               Widget widget = event.widget;\r
+                               Item item = null;\r
+                               if (widget instanceof TmfTimeStatesCtrl) {\r
+                                       TmfTimeStatesCtrl threadStates = (TmfTimeStatesCtrl) widget;\r
+                                       item = (Item) threadStates.getItem(pt);\r
+                                       _tipTable.remove(0, _tipTable.getItemCount() - 1);\r
+                                       new TableColumn(_tipTable, SWT.NONE);\r
+                                       new TableColumn(_tipTable, SWT.NONE);\r
+                                       fillValues(pt, threadStates, item);\r
+                                       _tipTable.getColumn(0).setWidth(200);\r
+                                       _tipTable.getColumn(1).pack();\r
+                                       _tipTable.setSize(_tipTable.computeSize(SWT.DEFAULT, 200));\r
+                                       _tipShell.pack();\r
+                               } else if (widget == null) {\r
+                                       _tipShell.setVisible(false);\r
+                                       _tipItem = null;\r
+                                       return;\r
+                               }\r
+                               if (item == _tipItem)\r
+                                       return;\r
+                               _tipItem = item;\r
+                               _tipPosition = control.toDisplay(pt);\r
+                               _tipShell.pack();\r
+                               setHoverLocation(_tipShell, _tipPosition);\r
+                               _tipShell.setVisible(true);\r
+                       }\r
+               });\r
+       }\r
+\r
+       private void setHoverLocation(Shell shell, Point position) {\r
+               Rectangle displayBounds = shell.getDisplay().getBounds();\r
+               Rectangle shellBounds = shell.getBounds();\r
+               shellBounds.x = Math.max(Math.min(position.x, displayBounds.width\r
+                               - shellBounds.width), 0);\r
+               shellBounds.y = Math.max(Math.min(position.y + 16, displayBounds.height\r
+                               - shellBounds.height), 0);\r
+               shell.setBounds(shellBounds);\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TraceColorScheme.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TraceColorScheme.java
new file mode 100644 (file)
index 0000000..71b9a52
--- /dev/null
@@ -0,0 +1,381 @@
+/*****************************************************************************\r
+ * Copyright (c) 2008 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: TraceColorScheme.java,v 1.3 2008/05/09 16:11:24 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider.StateColor;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Color;\r
+\r
+\r
+public class TraceColorScheme {\r
+\r
+       // elements color indices\r
+       static public final int BLACK_STATE = 0;\r
+       static public final int GREEN_STATE = 1;\r
+       static public final int DARK_BLUE_STATE = 2;\r
+       static public final int ORANGE_STATE = 3;\r
+       static public final int GOLD_STATE = 4;\r
+       static public final int RED_STATE = 5;\r
+       static public final int GRAY_STATE = 6;\r
+       static public final int DARK_GREEN_STATE = 7;\r
+       static public final int DARK_YELLOW_STATE = 8;\r
+       static public final int MAGENTA3_STATE = 9;\r
+       static public final int PURPLE1_STATE = 10;\r
+       static public final int PINK1_STATE = 11;\r
+       static public final int AQUAMARINE_STATE = 12;\r
+       static public final int LIGHT_BLUE_STATE = 13;\r
+       static public final int CADET_BLUE_STATE = 14;\r
+       static public final int OLIVE_STATE = 15;\r
+       \r
+       static public final int STATES0 = 0;\r
+       static public final int STATES1 = 15;\r
+       \r
+       // State element index to name mapping, must keep the same order as above\r
+       public static final StateColor stateColors[] = { StateColor.BLACK,\r
+                       StateColor.GREEN, StateColor.DARK_BLUE, StateColor.ORANGE,\r
+                       StateColor.GOLD, StateColor.RED, StateColor.GRAY, StateColor.DARK_GREEN, StateColor.DARK_YELLOW, StateColor.MAGENTA3, StateColor.PURPLE1, \r
+                       StateColor.PINK1, StateColor.AQUAMARINE, StateColor.LIGHT_BLUE, StateColor.CADET_BLUE, StateColor.OLIVE\r
+                       };\r
+\r
+       // selected state elements color indices\r
+       static public final int BLACK_STATE_SEL = 16;\r
+       static public final int GREEN_STATE_SEL = 17;\r
+       static public final int DARK_BLUE_STATE_SEL = 18;\r
+       static public final int ORANGE_STATE_SEL = 19;\r
+       static public final int GOLD_STATE_SEL = 20;\r
+       static public final int RED_STATE_SEL = 21;\r
+       static public final int GRAY_STATE_SEL = 22;\r
+       static public final int DARK_GREEN_STATE_SEL = 23;\r
+       static public final int DARK_YELLOW_STATE_SEL = 24;\r
+       static public final int MAGENTA3_STATE_SEL = 25;\r
+       static public final int PURPLE1_STATE_SEL = 26;\r
+       static public final int PINK1_STATE_SEL = 27;\r
+       static public final int AQUAMARINE_STATE_SEL = 28;\r
+       static public final int LIGHT_BLUE_STATE_SEL = 29;\r
+       static public final int CADET_BLUE_STATE_SEL = 30;\r
+       static public final int OLIVE_STATE_SEL = 31;\r
+       \r
+       static public final int STATES_SEL0 = 16;\r
+       static public final int STATES_SEL1 = 31;\r
+\r
+       // colors indices for viewer controls\r
+       static public final int BACKGROUND = 32;\r
+       static public final int FOREGROUND = 33;\r
+       static public final int BACKGROUND_SEL = 34;\r
+       static public final int FOREGROUND_SEL = 35;\r
+       static public final int BACKGROUND_SEL_NOFOCUS = 36;\r
+       static public final int FOREGROUND_SEL_NOFOCUS = 37;\r
+       static public final int TOOL_BACKGROUND = 38;\r
+       static public final int TOOL_FOREGROUND = 39;\r
+\r
+       // misc colors\r
+       static public final int FIX_COLOR = 40;\r
+       static public final int WHITE = 41;\r
+       static public final int GRAY = 42;\r
+       static public final int BLACK = 43;\r
+       static public final int DARK_GRAY = 44;\r
+\r
+       // selected border color indices\r
+       static public final int BLACK_BORDER = 45;\r
+       static public final int GREEN_BORDER = 46;\r
+       static public final int DARK_BLUE_BORDER = 47;\r
+       static public final int ORANGE_BORDER = 48;\r
+       static public final int GOLD_BORDER = 49;\r
+       static public final int RED_BORDER = 50;\r
+       static public final int GRAY_BORDER = 51;\r
+       static public final int DARK_GREEN_BORDER1 = 52;\r
+       static public final int DARK_YELLOW_BORDER1 = 53;\r
+       static public final int MAGENTA3_BORDER1 = 54;\r
+       static public final int PURPLE1_BORDER1 = 55;\r
+       static public final int PINK1_BORDER1 = 56;\r
+       static public final int AQUAMARINE_BORDER1 = 57;\r
+       static public final int LIGHT_BLUE_BORDER1 = 58;\r
+       static public final int CADET_BLUE_STATE_BORDER = 59;\r
+       static public final int OLIVE_BORDER2 = 60;\r
+       \r
+       static public final int STATES_BORDER0 = 45;\r
+       static public final int STATES_BORDER1 = 60;\r
+\r
+       static public final int MID_LINE = 61;\r
+       static public final int RED = 62;\r
+       static public final int GREEN = 63;\r
+       static public final int BLUE = 64;\r
+       static public final int YELLOW = 65;\r
+       static public final int CYAN = 66;\r
+       static public final int MAGENTA = 67;\r
+\r
+       static public final int SELECTED_TIME = 68;\r
+       static public final int LEGEND_BACKGROUND = 69;\r
+       static public final int LEGEND_FOREGROUND = 70;\r
+\r
+       // group items' colors\r
+       static public final int GR_BACKGROUND = 71;\r
+       static public final int GR_FOREGROUND = 72;\r
+       static public final int GR_BACKGROUND_SEL = 73;\r
+       static public final int GR_FOREGROUND_SEL = 74;\r
+       static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;\r
+       static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;\r
+\r
+       static public final int LIGHT_LINE = 77;\r
+    static public final int BACKGROUND_NAME = 78;\r
+    static public final int BACKGROUND_NAME_SEL = 79;\r
+    static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;\r
+\r
+       // Interraction's colors\r
+       static public final int TI_START_THREAD = BLACK;\r
+       static public final int TI_HANDOFF_LOCK = BLUE;\r
+       static public final int TI_NOTIFY_ALL = GREEN;\r
+       static public final int TI_NOTIFY = GREEN;\r
+       static public final int TI_NOTIFY_JOINED = DARK_GRAY;\r
+       static public final int TI_INTERRUPT = RED;\r
+       static public final int TI_WAIT_EXCEEDED = BLUE;\r
+\r
+       static interface IColorProvider {\r
+               public Color get();\r
+       }\r
+\r
+       static class SysCol implements IColorProvider {\r
+               int syscol;\r
+\r
+               SysCol(int syscol) {\r
+                       this.syscol = syscol;\r
+               }\r
+\r
+               @Override\r
+               public Color get() {\r
+                       return Utils.getSysColor(syscol);\r
+               }\r
+       }\r
+\r
+       static class RGB implements IColorProvider {\r
+               int r;\r
+               int g;\r
+               int b;\r
+\r
+               RGB(int r, int g, int b) {\r
+                       this.r = r;\r
+                       this.g = g;\r
+                       this.b = b;\r
+               }\r
+\r
+               @Override\r
+               public Color get() {\r
+                       return new Color(null, r, g, b);\r
+               }\r
+       }\r
+\r
+       static class Mix implements IColorProvider {\r
+               IColorProvider cp1;\r
+               IColorProvider cp2;\r
+               int w1;\r
+               int w2;\r
+\r
+               Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {\r
+                       this.cp1 = cp1;\r
+                       this.cp2 = cp2;\r
+                       this.w1 = w1;\r
+                       this.w2 = w2;\r
+               }\r
+\r
+               Mix(IColorProvider cp1, IColorProvider cp2) {\r
+                       this.cp1 = cp1;\r
+                       this.cp2 = cp2;\r
+                       this.w1 = 1;\r
+                       this.w2 = 1;\r
+               }\r
+\r
+               @Override\r
+               public Color get() {\r
+                       Color col1 = cp1.get();\r
+                       Color col2 = cp2.get();\r
+                       Color col = Utils.mixColors(col1, col2, w1, w2);\r
+                       return col;\r
+               }\r
+       }\r
+\r
+       static private final IColorProvider _providersMap[] = {\r
+                       //\r
+                       new RGB(100, 100, 100), // UNKNOWN\r
+                       new RGB(174, 200, 124), // RUNNING\r
+                       new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING\r
+                       new RGB(210, 150, 60), // WAITING\r
+                       new RGB(242, 225, 168), // BLOCKED\r
+                       new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK\r
+                       new RGB(200, 200, 200), // STOPPED\r
+                       new RGB(35, 107, 42), // STEEL BLUE\r
+                       new RGB(205,205,0), // DARK YELLOW\r
+                       new RGB(205, 0, 205), // MAGENTA\r
+                       new RGB(171, 130, 255), // PURPLE\r
+                       new RGB(255, 181, 197), // PINK\r
+                       new RGB(112, 219, 147), // AQUAMARINE\r
+                       new RGB(198, 226, 255), // SLATEGRAY\r
+                       new RGB(95, 158, 160), // CADET BLUE\r
+                       new RGB(107, 142, 35), // OLIVE\r
+                       \r
+                       \r
+                       //TODO: Does not seem to be used, check during clean-up\r
+                       new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL\r
+                       new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL\r
+                       new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL\r
+                       new SysCol(SWT.COLOR_CYAN), // WAITING_SEL\r
+                       new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL\r
+                       new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL\r
+                       new SysCol(SWT.COLOR_WHITE), \r
+                       new SysCol(SWT.COLOR_GREEN), \r
+                       new SysCol(SWT.COLOR_BLUE), \r
+                       new SysCol(SWT.COLOR_CYAN), \r
+                       new SysCol(SWT.COLOR_YELLOW), \r
+                       new SysCol(SWT.COLOR_RED), \r
+                       new SysCol(SWT.COLOR_DARK_GRAY), \r
+                       new SysCol(SWT.COLOR_WHITE), \r
+                       new SysCol(SWT.COLOR_GREEN), \r
+                       \r
+\r
+                       new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND\r
+                       new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND\r
+                       new RGB(232, 242, 254), // BACKGROUND_SEL\r
+                       new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL\r
+                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS\r
+                       new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS\r
+                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND\r
+                       new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND\r
+\r
+                       new SysCol(SWT.COLOR_GRAY), // FIX_COLOR\r
+                       new SysCol(SWT.COLOR_WHITE), // WHITE\r
+                       new SysCol(SWT.COLOR_GRAY), // GRAY\r
+                       new SysCol(SWT.COLOR_BLACK), // BLACK\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY\r
+\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER\r
+                       new RGB(75, 115, 120), // GREEN_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER\r
+                       new RGB(242, 225, 168), // ORANGE_BORDER\r
+                       new RGB(210, 150, 60), // GOLD_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER\r
+                       new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER\r
+                       new RGB(75, 115, 120), // DARK_YELLOW_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER\r
+                       new RGB(242, 225, 168), // PURPLE1_BORDER\r
+                       new RGB(210, 150, 60), // PINK1_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER\r
+                       new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER\r
+                       new RGB(75, 115, 120), // OLIVE_BORDER\r
+               \r
+\r
+                       new SysCol(SWT.COLOR_GRAY), // MID_LINE\r
+                       new SysCol(SWT.COLOR_RED), // RED\r
+                       new SysCol(SWT.COLOR_GREEN), // GREEN\r
+                       new SysCol(SWT.COLOR_BLUE), // BLUE\r
+                       new SysCol(SWT.COLOR_YELLOW), // YELLOW\r
+                       new SysCol(SWT.COLOR_CYAN), // CYAN\r
+                       new SysCol(SWT.COLOR_MAGENTA), // MAGENTA\r
+\r
+                       new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME\r
+                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND\r
+                       new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND\r
+\r
+                       new Mix(new RGB(150, 200, 240), new SysCol(\r
+                                       SWT.COLOR_LIST_BACKGROUND)),// GR_BACKGROUND\r
+                       new RGB(0, 0, 50), // GR_FOREGROUND\r
+                       new Mix(new RGB(200, 200, 100),\r
+                                       new SysCol(SWT.COLOR_LIST_SELECTION)), // GR_BACKGROUND_SEL\r
+                       new Mix(new RGB(150, 200, 240), new SysCol(\r
+                                       SWT.COLOR_LIST_SELECTION_TEXT)), // GR_FOREGROUND_SEL\r
+                       new Mix(new RGB(222, 222, 155), new SysCol(\r
+                                       SWT.COLOR_WIDGET_BACKGROUND)), // GR_BACKGROUND_SEL_NOFOCUS\r
+                       new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS\r
+\r
+                       new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(\r
+                                       SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE\r
+\r
+                       new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6),   // BACKGROUND_NAME\r
+                   new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6),                  // BACKGROUND_NAME_SEL\r
+                   new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS\r
+       };\r
+\r
+       private Color _colors[];\r
+\r
+       public TraceColorScheme() {\r
+               _colors = new Color[_providersMap.length];\r
+       }\r
+\r
+       public void dispose() {\r
+               for (int i = 0; i < _colors.length; i++) {\r
+                       Utils.dispose(_colors[i]);\r
+                       _colors[i] = null;\r
+               }\r
+       }\r
+\r
+       public Color getColor(int idx) {\r
+               if (null == _colors[idx]) {\r
+                       if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {\r
+                               Color col1 = getColor(idx - STATES_SEL0);\r
+                               Color col2 = getColor(BACKGROUND_SEL);\r
+                               _colors[idx] = Utils.mixColors(col1, col2, 3, 1);\r
+                       } else {\r
+                               _colors[idx] = _providersMap[idx].get();\r
+                       }\r
+               }\r
+               return _colors[idx];\r
+       }\r
+\r
+       public Color getBkColor(boolean selected, boolean focused, boolean name) {\r
+           if (name) {\r
+               if (selected && focused)\r
+                   return getColor(BACKGROUND_NAME_SEL);\r
+               if (selected)\r
+                   return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
+               return getColor(BACKGROUND_NAME);\r
+           } else {\r
+               if (selected && focused)\r
+                   return getColor(BACKGROUND_SEL);\r
+               if (selected)\r
+                   return getColor(BACKGROUND_SEL_NOFOCUS);\r
+               return getColor(BACKGROUND);\r
+           }\r
+       }\r
+\r
+       public Color getFgColor(boolean selected, boolean focused) {\r
+               if (selected && focused)\r
+                       return getColor(FOREGROUND_SEL);\r
+               if (selected)\r
+                       return getColor(FOREGROUND_SEL_NOFOCUS);\r
+               return getColor(FOREGROUND);\r
+       }\r
+\r
+       public Color getBkColorGroup(boolean selected, boolean focused) {\r
+               if (selected && focused)\r
+                       return getColor(GR_BACKGROUND_SEL);\r
+               if (selected)\r
+                       return getColor(GR_BACKGROUND_SEL_NOFOCUS);\r
+               return getColor(GR_BACKGROUND);\r
+       }\r
+\r
+       public Color getFgColorGroup(boolean selected, boolean focused) {\r
+               if (selected && focused)\r
+                       return getColor(GR_FOREGROUND_SEL);\r
+               if (selected)\r
+                       return getColor(GR_FOREGROUND_SEL_NOFOCUS);\r
+               return getColor(GR_FOREGROUND);\r
+       }\r
+\r
+       public static StateColor[] getStateColors() {\r
+               return stateColors;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TraceCtrl.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/TraceCtrl.java
new file mode 100644 (file)
index 0000000..30b7a41
--- /dev/null
@@ -0,0 +1,68 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: TraceCtrl.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.PaintListener;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Canvas;\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+public abstract class TraceCtrl extends Canvas implements PaintListener {\r
+\r
+       static public final int MARGIN = 4;\r
+    static public final int RIGHT_MARGIN = 2; // 2 pixels less to make sure end time is visible\r
+       static public final int SMALL_ICON_SIZE = 16;\r
+\r
+       protected TraceColorScheme _colors;\r
+       protected int _fontHeight = 0;\r
+\r
+       public TraceCtrl(Composite parent, TraceColorScheme colors) {\r
+               this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);\r
+       }\r
+\r
+       public TraceCtrl(Composite parent, TraceColorScheme colors, int style) {\r
+               super(parent, style);\r
+               _colors = colors;\r
+               addPaintListener(this);\r
+       }\r
+\r
+       @Override\r
+       public void dispose() {\r
+               super.dispose();\r
+       }\r
+\r
+       @Override\r
+       public void paintControl(PaintEvent e) {\r
+               if (e.widget != this)\r
+                       return;\r
+               _fontHeight = e.gc.getFontMetrics().getHeight();\r
+               Rectangle bound = getClientArea();\r
+               if (!bound.isEmpty()) {\r
+                       Color colBackup = e.gc.getBackground();\r
+                       paint(bound, e);\r
+                       e.gc.setBackground(colBackup);\r
+               }\r
+       }\r
+\r
+       public int getFontHeight() {\r
+               return _fontHeight;\r
+       }\r
+\r
+       abstract void paint(Rectangle bound, PaintEvent e);\r
+}\r
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/Utils.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/internal/lttng/ui/viewers/timeAnalysis/widgets/Utils.java
new file mode 100644 (file)
index 0000000..c4950fb
--- /dev/null
@@ -0,0 +1,535 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008 Intel Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: Utils.java,v 1.11 2008/06/16 21:04:49 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.widgets;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Date;\r
+import java.util.Iterator;\r
+import java.util.TimeZone;\r
+\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITimeEvent;\r
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Device;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Display;\r
+\r
+public class Utils {\r
+\r
+       static public final int IMG_THREAD_RUNNING = 0;\r
+       static public final int IMG_THREAD_SUSPENDED = 1;\r
+       static public final int IMG_THREAD_STOPPED = 2;\r
+       static public final int IMG_METHOD_RUNNING = 3;\r
+       static public final int IMG_METHOD = 4;\r
+       static public final int IMG_NUM = 5;\r
+\r
+       static public final Object[] _empty = new Object[0];\r
+\r
+       static enum Resolution {\r
+               SECONDS, MILLISEC, MICROSEC, NANOSEC\r
+       };\r
+\r
+       static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$\r
+       static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$\r
+       static {\r
+        stimeformat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+        sdateformat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+       }\r
+\r
+//     static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
+//                     "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
+//                     "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
+//\r
+//     static private String _externalPath[] = {\r
+//                     "icons/full/obj16/thread_obj.gif", // running thread\r
+//                     "icons/full/obj16/threads_obj.gif", // suspended\r
+//                     "icons/full/obj16/threadt_obj.gif", // stopped\r
+//                     "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
+//                     "icons/full/obj16/stckframe_obj.gif", // stack frame\r
+//     };\r
+\r
+//     static public Image getImage(int idx) {\r
+//             if (idx < 0 || idx >= IMG_NUM)\r
+//                     SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
+//             String key = "trace.img." + idx;\r
+//             Image img = TimeAnalysisPlugin.getDefault().getImageRegistry().get(key);\r
+//             if (null == img) {\r
+//                     ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
+//                                     _externalPlugin[idx], _externalPath[idx]);\r
+//                     TimeAnalysisPlugin.getDefault().getImageRegistry().put(key, desc);\r
+//                     img = TimeAnalysisPlugin.getDefault().getImageRegistry().get(key);\r
+//             }\r
+//             return img;\r
+//     }\r
+\r
+       static public void init(Rectangle rect) {\r
+               rect.x = 0;\r
+               rect.y = 0;\r
+               rect.width = 0;\r
+               rect.height = 0;\r
+       }\r
+\r
+       static public void init(Rectangle rect, int x, int y, int width, int height) {\r
+               rect.x = x;\r
+               rect.y = y;\r
+               rect.width = width;\r
+               rect.height = height;\r
+       }\r
+\r
+       static public void init(Rectangle rect, Rectangle source) {\r
+               rect.x = source.x;\r
+               rect.y = source.y;\r
+               rect.width = source.width;\r
+               rect.height = source.height;\r
+       }\r
+\r
+       static public void deflate(Rectangle rect, int x, int y) {\r
+               rect.x += x;\r
+               rect.y += y;\r
+               rect.width -= x + x;\r
+               rect.height -= y + y;\r
+       }\r
+\r
+       static public void inflate(Rectangle rect, int x, int y) {\r
+               rect.x -= x;\r
+               rect.y -= y;\r
+               rect.width += x + x;\r
+               rect.height += y + y;\r
+       }\r
+\r
+       static void dispose(Color col) {\r
+               if (null != col)\r
+                       col.dispose();\r
+       }\r
+\r
+       static public Color mixColors(Device display, Color c1, Color c2, int w1,\r
+                       int w2) {\r
+               return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed())\r
+                               / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen())\r
+                               / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue())\r
+                               / (w1 + w2));\r
+       }\r
+\r
+       static public Color getSysColor(int id) {\r
+               Color col = Display.getCurrent().getSystemColor(id);\r
+               return new Color(col.getDevice(), col.getRGB());\r
+       }\r
+\r
+       static public Color mixColors(Color col1, Color col2, int w1, int w2) {\r
+               return mixColors(Display.getCurrent(), col1, col2, w1, w2);\r
+       }\r
+\r
+       static public int drawText(GC gc, String text, Rectangle rect,\r
+                       boolean transp) {\r
+               Point size = gc.stringExtent(text);\r
+               gc.drawText(text, rect.x, rect.y, transp);\r
+               return size.x;\r
+       }\r
+\r
+       static public int drawText(GC gc, String text, int x, int y, boolean transp) {\r
+               Point size = gc.stringExtent(text);\r
+               gc.drawText(text, x, y, transp);\r
+               return size.x;\r
+       }\r
+\r
+       /**\r
+     * Formats time in format: MM:SS:NNN\r
+     * \r
+        * @param time time\r
+        * @param format  0: MMMM:ss:nnnnnnnnn, 1: HH:MM:ss MMM.mmmm.nnn\r
+        * @param resolution the resolution\r
+        * @return the formatted time\r
+        */\r
+       static public String formatTime(long time, TimeFormat format, Resolution resolution) {\r
+               // if format is absolute (Calendar)\r
+               if (format == TimeFormat.ABSOLUTE) {\r
+                       return formatTimeAbs(time, resolution);\r
+               }\r
+\r
+               StringBuffer str = new StringBuffer();\r
+               boolean neg = time < 0;\r
+               if (neg) {\r
+                       time = -time;\r
+                       str.append('-');\r
+               }\r
+\r
+               long sec = (long) (time * 1E-9);\r
+               // TODO: Expand to make it possible to select the minute, second, nanosecond format\r
+               //printing minutes is suppressed just sec and ns\r
+               // if (sec / 60 < 10)\r
+               // str.append('0');\r
+               // str.append(sec / 60);\r
+               // str.append(':');\r
+               // sec %= 60;\r
+               // if (sec < 10)\r
+               // str.append('0');\r
+               str.append(sec);\r
+               String ns = formatNs(time, resolution);\r
+               if (!ns.equals("")) { //$NON-NLS-1$\r
+                       str.append(':');\r
+                       str.append(ns);\r
+               }\r
+\r
+               return str.toString();\r
+       }\r
+\r
+       /**\r
+        * From input time in nanoseconds, convert to Date format YYYY-MM-dd\r
+        * \r
+        * @param absTime\r
+        * @return the formatted date\r
+        */\r
+       public static String formatDate(long absTime) {\r
+               String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));\r
+               return sdate;\r
+       }\r
+\r
+       /**\r
+        * Formats time in ns to Calendar format: HH:MM:SS MMM.mmm.nnn\r
+        * \r
+        * @param time\r
+        * @return the formatted time\r
+        */\r
+       static public String formatTimeAbs(long time, Resolution res) {\r
+               StringBuffer str = new StringBuffer();\r
+\r
+               // format time from nanoseconds to calendar time HH:MM:SS\r
+               String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
+               str.append(stime + " "); //$NON-NLS-1$\r
+               // append the Milliseconds, MicroSeconds and NanoSeconds as specified in\r
+               // the Resolution\r
+               str.append(formatNs(time, res));\r
+               return str.toString();\r
+       }\r
+\r
+       /**\r
+        * Obtains the remainder fraction on unit Seconds of the entered value in\r
+        * nanoseconds. e.g. input: 1241207054171080214 ns The number of fraction\r
+        * seconds can be obtained by removing the last 9 digits: 1241207054 the\r
+        * fractional portion of seconds, expressed in ns is: 171080214\r
+        * \r
+        * @param time\r
+        * @param res\r
+        * @return the formatted nanosec\r
+        */\r
+       public static String formatNs(long time, Resolution res) {\r
+               StringBuffer temp = new StringBuffer();\r
+               boolean neg = time < 0;\r
+               if (neg) {\r
+                       time = -time;\r
+               }\r
+\r
+               // The following approach could be used although performance\r
+               // decreases in half.\r
+               // String strVal = String.format("%09d", time);\r
+               // String tmp = strVal.substring(strVal.length() - 9);\r
+\r
+               // number of segments to be included\r
+               int segments = 0;\r
+               switch (res) {\r
+               case MILLISEC:\r
+                       segments = 1;\r
+                       break;\r
+               case MICROSEC:\r
+                       segments = 2;\r
+                       break;\r
+               case NANOSEC:\r
+                       segments = 3;\r
+                       break;\r
+               default:\r
+                       break;\r
+               }\r
+\r
+               long ns = time;\r
+               ns %= 1000000000;\r
+               if (ns < 10) {\r
+                       temp.append("00000000"); //$NON-NLS-1$\r
+               } else if (ns < 100) {\r
+                       temp.append("0000000"); //$NON-NLS-1$\r
+               } else if (ns < 1000) {\r
+                       temp.append("000000"); //$NON-NLS-1$\r
+               } else if (ns < 10000) {\r
+                       temp.append("00000"); //$NON-NLS-1$\r
+               } else if (ns < 100000) {\r
+                       temp.append("0000"); //$NON-NLS-1$\r
+               } else if (ns < 1000000) {\r
+                       temp.append("000"); //$NON-NLS-1$\r
+               } else if (ns < 10000000) {\r
+                       temp.append("00"); //$NON-NLS-1$\r
+               } else if (ns < 100000000) {\r
+                       temp.append("0"); //$NON-NLS-1$\r
+               }\r
+               temp.append(ns);\r
+\r
+               StringBuffer str = new StringBuffer();\r
+               if (segments > 0) {\r
+                       // append ms\r
+                       str.append(temp.substring(0, 3));\r
+               }\r
+               if (segments > 1) {\r
+                       // append Micro secs\r
+                       str.append("."); //$NON-NLS-1$\r
+                       str.append(temp.substring(3, 6));\r
+               }\r
+               if (segments > 2) {\r
+                       // append Nano seconds\r
+                       str.append("."); //$NON-NLS-1$\r
+                       str.append(temp.substring(6));\r
+               }\r
+\r
+               return str.toString();\r
+       }\r
+\r
+       static public int loadIntOption(String opt, int def, int min, int max) {\r
+               // int val =\r
+               // TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
+               // if (0 == val)\r
+               // val = def;\r
+               // if (val < min)\r
+               // val = min;\r
+               // if (val > max)\r
+               // val = max;\r
+               return def;\r
+       }\r
+\r
+       // static public int loadIntOption(String opt) {\r
+       // int val = TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
+       // return val;\r
+       // }\r
+\r
+       static public void saveIntOption(String opt, int val) {\r
+               // TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);\r
+       }\r
+\r
+       static ITimeEvent getFirstEvent(ITmfTimeAnalysisEntry thread) {\r
+               if (null == thread)\r
+                       return null;\r
+               Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator();\r
+               if (iterator.hasNext()) {\r
+                   return iterator.next();\r
+               } else {\r
+                   return null;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * N means: <list> <li>-1: Previous Event</li> <li>0: Current Event</li> <li>\r
+        * 1: Next Event</li> <li>2: Previous Event when located in a non Event Area\r
+        * </list>\r
+        * \r
+        * @param thread\r
+        * @param time\r
+        * @param n\r
+        * @return\r
+        */\r
+    static ITimeEvent findEvent(ITmfTimeAnalysisEntry thread, long time, int n) {\r
+        if (null == thread)\r
+            return null;\r
+        Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator();\r
+        ITimeEvent nextEvent = null;\r
+        ITimeEvent currEvent = null;\r
+        ITimeEvent prevEvent = null;\r
+\r
+        while (iterator.hasNext()) {\r
+            nextEvent = (ITimeEvent) iterator.next();\r
+            long nextStartTime = nextEvent.getTime();\r
+            \r
+            if (nextStartTime > time) {\r
+                break;\r
+            }\r
+            \r
+            if (currEvent == null || currEvent.getTime() != nextStartTime) {\r
+                prevEvent = currEvent;\r
+                currEvent = nextEvent;\r
+            }\r
+        }\r
+        \r
+        if (n == -1) { //previous\r
+            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
+                return prevEvent;\r
+            } else {\r
+                return currEvent;\r
+            }\r
+        } else if (n == 0) { //current\r
+            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
+                return currEvent;\r
+            } else {\r
+                return null;\r
+            }\r
+        } else if (n == 1) { //next\r
+            return nextEvent;\r
+        } else if (n == 2) { //current or previous when in empty space\r
+            return currEvent;\r
+        }\r
+        \r
+        return null;\r
+    }\r
+\r
+       // static public TRCPackage getPackage(Object element) {\r
+       // if (element instanceof TRCPackage)\r
+       // return (TRCPackage) element;\r
+       // if (element instanceof TRCClass)\r
+       // return ((TRCClass) element).getPackage();\r
+       // return null;\r
+       // }\r
+\r
+       // static public TRCObjectAllocationAnnotation getAllocationAnnotation(\r
+       // TRCClass cls) {\r
+       // TRCObjectAllocationAnnotation aa = null;\r
+       // EList list = cls.getAnnotations();\r
+       // int len = list.size();\r
+       // for (int i = 0; i < len; i++) {\r
+       // TRCAnnotation annotation = (TRCAnnotation) list.get(i);\r
+       // if (annotation instanceof TRCObjectAllocationAnnotation)\r
+       // aa = (TRCObjectAllocationAnnotation) annotation;\r
+       // }\r
+       // return aa;\r
+       // }\r
+\r
+       static public String fixMethodSignature(String sig) {\r
+               int pos = sig.indexOf('(');\r
+               if (pos >= 0) {\r
+                       String ret = sig.substring(0, pos);\r
+                       sig = sig.substring(pos);\r
+                       sig = sig + " " + ret; //$NON-NLS-1$\r
+               }\r
+               return sig;\r
+       }\r
+\r
+       static public String restoreMethodSignature(String sig) {\r
+               String ret = ""; //$NON-NLS-1$\r
+               int pos = sig.indexOf('(');\r
+               if (pos >= 0) {\r
+                       ret = sig.substring(0, pos);\r
+                       sig = sig.substring(pos + 1);\r
+               }\r
+               pos = sig.indexOf(')');\r
+               if (pos >= 0) {\r
+                       sig = sig.substring(0, pos);\r
+               }\r
+               String args[] = sig.split(","); //$NON-NLS-1$\r
+        StringBuffer result = new StringBuffer("("); //$NON-NLS-1$\r
+               for (int i = 0; i < args.length; i++) {\r
+                       String arg = args[i].trim();\r
+                       if (arg.length() == 0 && args.length == 1)\r
+                               break;\r
+                       result.append(getTypeSignature(arg));\r
+               }\r
+               result.append(")").append(getTypeSignature(ret)); //$NON-NLS-1$\r
+               return result.toString();\r
+       }\r
+\r
+       static public String getTypeSignature(String type) {\r
+               int dim = 0;\r
+               for (int j = 0; j < type.length(); j++) {\r
+                       if (type.charAt(j) == '[')\r
+                               dim++;\r
+               }\r
+               int pos = type.indexOf('[');\r
+               if (pos >= 0)\r
+                       type = type.substring(0, pos);\r
+               StringBuffer sig = new StringBuffer(""); //$NON-NLS-1$\r
+               for (int j = 0; j < dim; j++)\r
+                       sig.append("[");                 //$NON-NLS-1$\r
+               if (type.equals("boolean"))     //$NON-NLS-1$\r
+                       sig.append("Z");                 //$NON-NLS-1$\r
+               else if (type.equals("byte"))   //$NON-NLS-1$\r
+                       sig.append("B");                 //$NON-NLS-1$\r
+               else if (type.equals("char"))   //$NON-NLS-1$\r
+                       sig.append("C");                 //$NON-NLS-1$\r
+               else if (type.equals("short"))  //$NON-NLS-1$\r
+                       sig.append("S");                 //$NON-NLS-1$\r
+               else if (type.equals("int"))    //$NON-NLS-1$\r
+                       sig.append("I");                 //$NON-NLS-1$\r
+               else if (type.equals("long"))   //$NON-NLS-1$\r
+                       sig.append("J");                 //$NON-NLS-1$\r
+               else if (type.equals("float"))  //$NON-NLS-1$\r
+                       sig.append("F");                 //$NON-NLS-1$\r
+               else if (type.equals("double")) //$NON-NLS-1$\r
+                       sig.append("D");                 //$NON-NLS-1$\r
+               else if (type.equals("void"))   //$NON-NLS-1$\r
+                       sig.append("V");                 //$NON-NLS-1$\r
+               else\r
+                       sig.append("L").append(type.replace('.', '/')).append(";"); //$NON-NLS-1$ //$NON-NLS-2$\r
+               return sig.toString();\r
+       }\r
+\r
+       // static public boolean openSource(Object element) {\r
+       // if (element instanceof String) {\r
+       // final String pattern = (String) element;\r
+       // final int javaType = IJavaSearchConstants.METHOD;\r
+       // BusyIndicator.showWhile(Display.getDefault(), new Runnable() {\r
+       // public void run() {\r
+       // if (!OpenJavaSource.openSource(pattern, javaType,\r
+       // SearchEngine.createWorkspaceScope(), true)) {\r
+       // MessageDialog.openInformation(UIPlugin.getDefault()\r
+       // .getWorkbench().getActiveWorkbenchWindow()\r
+       // .getShell(), TraceMessages.TRC_MSGT, NLS.bind(\r
+       // TraceUIMessages._68, pattern));\r
+       // }\r
+       // }\r
+       // });\r
+       // }\r
+       // OpenSource.openSource(element);\r
+       // return true;\r
+       // }\r
+\r
+       // static public int getObjAge(TRCFullTraceObject obj, EList listGC) {\r
+       // int age = 0;\r
+       // double t0 = obj.getCreateTime();\r
+       // double t1 = obj.getCollectTime();\r
+       // int len = listGC.size();\r
+       // for (int j = 0; j < len; j++) {\r
+       // TRCGCEvent gcEvent = (TRCGCEvent) listGC.get(j);\r
+       // if (gcEvent.getType().equals("finish")) {\r
+       // double time = gcEvent.getTime();\r
+       // if (time <= t0)\r
+       // continue;\r
+       // if (t1 > 0 && time >= t1)\r
+       // break;\r
+       // age++;\r
+       // }\r
+       // }\r
+       // return age;\r
+       // }\r
+\r
+       static public int compare(double d1, double d2) {\r
+               if (d1 > d2)\r
+                       return 1;\r
+               if (d1 < d2)\r
+                       return 1;\r
+               return 0;\r
+       }\r
+\r
+       static public int compare(String s1, String s2) {\r
+               if (s1 != null && s2 != null)\r
+                       return s1.compareToIgnoreCase(s2);\r
+               if (s1 != null)\r
+                       return 1;\r
+               if (s2 != null)\r
+                       return -1;\r
+               return 0;\r
+       }\r
+\r
+       // static public String formatPercent(int val, int max) {\r
+       // String s = max > 0 && max >= val ? TString\r
+       // .formatAsPercentage((double) val / (double) max) : "";\r
+       // return s;\r
+       // }\r
+}\r
index e2d963abf19efbc8212cb2ec4bce0fa265c6020f..c2854d51594685cca29634ecfe544078a8b5ace4 100644 (file)
@@ -27,6 +27,10 @@ import org.eclipse.linuxtools.internal.lttng.core.request.RequestStartedSignal;
 import org.eclipse.linuxtools.internal.lttng.core.state.evProcessor.ITransEventProcessor;
 import org.eclipse.linuxtools.internal.lttng.ui.TraceDebug;
 import org.eclipse.linuxtools.internal.lttng.ui.model.trange.ItemContainer;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
 import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
@@ -38,10 +42,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
 import org.eclipse.swt.widgets.Display;
 
index 4290ee1eae13210304236be9134ec9b7a182f0f2..f659f4b686fa7bbaa54c7432378ec0d9bad07d21 100644 (file)
@@ -13,9 +13,9 @@ package org.eclipse.linuxtools.internal.lttng.ui.views.common;
 
 import org.eclipse.linuxtools.internal.lttng.core.event.LttngTimestamp;
 import org.eclipse.linuxtools.internal.lttng.ui.TraceDebug;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
 
 /**
  * 
index 0fba3fe1c6b432dc3a883d139ea208eae9d2cf63..5a46b101f6361daac55ac95fa16b81363f5e1f21 100644 (file)
@@ -40,6 +40,14 @@ import org.eclipse.linuxtools.internal.lttng.core.state.evProcessor.ITransEventP
 import org.eclipse.linuxtools.internal.lttng.ui.TraceDebug;
 import org.eclipse.linuxtools.internal.lttng.ui.model.trange.ItemContainer;
 import org.eclipse.linuxtools.internal.lttng.ui.model.trange.TimeRangeEventProcess;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITmfTimeFilterSelectionListener;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeFilterSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfViewerFactory;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.AbsTimeUpdateView;
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.ParamsUpdater;
 import org.eclipse.linuxtools.internal.lttng.ui.views.controlflow.evProcessor.FlowEventToHandlerFactory;
@@ -55,14 +63,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
-import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeFilterSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeFilterSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.SashForm;
 import org.eclipse.swt.events.ControlAdapter;
index 2779fe4241d7165387088413f38de9d2afc77950..38100740a994e81c4662d368a22d6050b226750c 100644 (file)
@@ -23,6 +23,12 @@ import org.eclipse.linuxtools.internal.lttng.core.request.ILttngSyntEventRequest
 import org.eclipse.linuxtools.internal.lttng.core.state.evProcessor.ITransEventProcessor;
 import org.eclipse.linuxtools.internal.lttng.ui.TraceDebug;
 import org.eclipse.linuxtools.internal.lttng.ui.model.trange.ItemContainer;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.TmfViewerFactory;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.AbsTimeUpdateView;
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.ParamsUpdater;
 import org.eclipse.linuxtools.internal.lttng.ui.views.resources.evProcessor.ResourcesEventToHandlerFactory;
@@ -38,12 +44,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
-import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
index b89c08152d23d90a49ce1c57c3a3155fddb07f03..e273961a23cd27d0f87b8e3f599d6934a241466c 100644 (file)
@@ -35,6 +35,7 @@ import org.eclipse.linuxtools.internal.lttng.core.state.evProcessor.AbsEventToHa
 import org.eclipse.linuxtools.internal.lttng.core.state.experiment.StateManagerFactory;
 import org.eclipse.linuxtools.internal.lttng.ui.TraceDebug;
 import org.eclipse.linuxtools.internal.lttng.ui.model.trange.ItemContainer;
+import org.eclipse.linuxtools.internal.lttng.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.AbsTimeUpdateView;
 import org.eclipse.linuxtools.internal.lttng.ui.views.common.ParamsUpdater;
 import org.eclipse.linuxtools.internal.lttng.ui.views.statistics.evProcessor.StatsTimeCountHandlerFactory;
@@ -49,7 +50,6 @@ import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
index 9abcddf2df6008becba34c327953ac61939fa71f..0218f73d1c95466c21e8af0be1a90a6714952195 100644 (file)
@@ -14,11 +14,11 @@ package org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.adaption;
 import java.util.HashMap;\r
 import java.util.Map;\r
 \r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
 import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model.EventImpl;\r
 import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model.TraceImpl;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
 \r
 @SuppressWarnings("nls")\r
 public class TsfImplProvider extends TmfTimeAnalysisProvider {\r
index 67669cfffd51ee5f0996b4030acb0bc14dd47a89..0565adf0a7ca9ff8731ccd88b095fd0dd432f092 100644 (file)
@@ -11,8 +11,8 @@
  *******************************************************************************/\r
 package org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model;\r
 \r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
 \r
 public class EventImpl extends TimeEvent {\r
        // ========================================================================\r
index 2cf81d28b1947ad9f27f7df0a1faf0d7a24d142a..bf9496ec38d8dff918880b0e3b4ebaf9b23a80ca 100644 (file)
@@ -14,8 +14,8 @@ package org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model;
 import java.util.Iterator;\r
 import java.util.Vector;\r
 \r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
 \r
 @SuppressWarnings("nls")\r
 public class TraceImpl implements ITmfTimeAnalysisEntry {\r
index 03366cf42543b905925db94474278af042e138d4..653c13aff28641804de35cf5ce67e64cbdee78a0 100644 (file)
@@ -33,17 +33,17 @@ import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;
 import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.adaption.TsfImplProvider;
 import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model.EventImpl;
 import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model.TraceImpl;
 import org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.test.stub.model.TraceModelImplFactory;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeAnalysisViewer;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITmfTimeScaleSelectionListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITmfTimeSelectionListener;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeScaleSelectionEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeSelectionEvent;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfViewerFactory;
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.SashForm;
 import org.eclipse.swt.graphics.Image;
index ec2370dcc291476339919ec7465d239de033fcc2..ce076f1c2173453bbd249addfc8201f402fcb54e 100644 (file)
@@ -22,12 +22,7 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l
  org.eclipse.linuxtools.tmf.ui.project.model,
  org.eclipse.linuxtools.tmf.ui.project.wizards,
  org.eclipse.linuxtools.tmf.ui.signal,
- org.eclipse.linuxtools.tmf.ui.viewers,
  org.eclipse.linuxtools.tmf.ui.viewers.events,
- org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis,
- org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs,
- org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model,
- org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets,
  org.eclipse.linuxtools.tmf.ui.views,
  org.eclipse.linuxtools.tmf.ui.views.colors,
  org.eclipse.linuxtools.tmf.ui.views.distribution.model,
@@ -49,4 +44,8 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l
  org.eclipse.linuxtools.tmf.ui.views.uml2sd.loader,
  org.eclipse.linuxtools.tmf.ui.views.uml2sd.preferences,
  org.eclipse.linuxtools.tmf.ui.views.uml2sd.util,
- org.eclipse.linuxtools.tmf.ui.widgets
+ org.eclipse.linuxtools.tmf.ui.widgets,
+ org.eclipse.linuxtools.tmf.ui.widgets.timegraph,
+ org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs,
+ org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model,
+ org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/ITmfViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/ITmfViewer.java
deleted file mode 100644 (file)
index 7ce82bb..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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:
- *   Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.ui.viewers;
-
-/**
- * <b><u>ITmfWidget</u></b>
- * <p>
- *
- * TODO: Implement me. Please.
- */
-public interface ITmfViewer {
-
-}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/TmfViewerFactory.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/TmfViewerFactory.java
deleted file mode 100644 (file)
index b30f8d4..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisViewer;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-/**\r
- * <b><u>TmfWidgetFactory</u></b>\r
- * <p>\r
- *\r
- * TODO: Generalize when extension points are introduced\r
- * TODO: Today, it is specific for the TimeAnalysis widget\r
- */\r
-public class TmfViewerFactory {\r
-\r
-//    public static ITmfWidget createWidget(String id, Composite parent) {\r
-//        return null;\r
-//    }\r
-    \r
-    public static ITimeAnalysisViewer createViewer(Composite parent,\r
-            TmfTimeAnalysisProvider provider) {\r
-        return new TmfTimeAnalysisViewer(parent, provider);\r
-    }\r
-\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/GridUtil.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/GridUtil.java
deleted file mode 100644 (file)
index 95e1250..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/**********************************************************************\r
- * Copyright (c) 2005, 2006 IBM Corporation and others.\r
- * All rights reserved.   This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * $Id: GridUtil.java,v 1.3 2006/09/20 19:49:13 ewchan Exp $\r
- * \r
- * Contributors: \r
- * IBM - Initial API and implementation\r
- **********************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.layout.GridData;\r
-\r
-/**\r
- * A utility class to create convenient grid data objects.\r
- */ \r
-public class GridUtil\r
-{\r
-       /**\r
-        * Creates a grid data object that occupies vertical and horizontal\r
-        * space.\r
-        */\r
-       static public GridData createFill() \r
-       {\r
-               return new GridData(SWT.FILL, SWT.FILL, true, true);\r
-       }\r
-       /**\r
-        * Creates a grid data object that occupies horizontal space.\r
-        */\r
-       static public GridData createHorizontalFill() \r
-       {               \r
-               return new GridData(SWT.FILL, SWT.DEFAULT, true, false);                \r
-       }\r
-       /**\r
-        * Creates a grid data object that occupies vertical space.\r
-        */\r
-       static public GridData createVerticalFill() \r
-       {\r
-               return new GridData(SWT.DEFAULT, SWT.FILL, false, true);\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITimeAnalysisViewer.java
deleted file mode 100644 (file)
index c7155af..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
- package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.ITmfViewer;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.ScrollBar;\r
-\r
-/**\r
- * <b><u>ITimeAnalysisWidget</u></b>\r
- * <p>\r
- *\r
- * TODO: Implement me. Please.\r
- */\r
-public interface ITimeAnalysisViewer extends ITmfViewer {\r
-\r
-    public enum TimeFormat {\r
-               RELATIVE, ABSOLUTE\r
-       };\r
-\r
-       /**\r
-        * @param e\r
-        */\r
-       public void controlResized(ControlEvent e);\r
-\r
-       /**\r
-        * \r
-        * @param traceArr\r
-        * @param start\r
-        *            Specifies a fixed start time to the information to be\r
-        *            displayed\r
-        * @param end\r
-        *            Specifies a fixed end time to the information to be displayed\r
-        * @param updateTimeBounds\r
-        *            If True - Time Range boundaries update is required\r
-        */\r
-       public abstract void display(ITmfTimeAnalysisEntry[] traceArr, long start,\r
-                       long end, boolean updateTimeBounds);\r
-\r
-       /**\r
-        * The start and End time are taken from the limits used by the children\r
-        * events\r
-        * \r
-        * @param traceArr\r
-        */\r
-       public abstract void display(ITmfTimeAnalysisEntry[] traceArr);\r
-\r
-       public void addWidgetSelectionListner(ITmfTimeSelectionListener listener);\r
-\r
-       public void addWidgetTimeScaleSelectionListner(\r
-                       ITmfTimeScaleSelectionListener listener);\r
-\r
-       public void filterTraces();\r
-\r
-       public ITmfTimeAnalysisEntry getSelectedTrace();\r
-\r
-       public ISelection getSelection();\r
-\r
-       public void groupTraces(boolean on);\r
-\r
-       public boolean isInFocus();\r
-\r
-       public void removeWidgetSelectionListner(ITmfTimeSelectionListener listener);\r
-\r
-       public void removeWidgetTimeScaleSelectionListner(\r
-                       ITmfTimeScaleSelectionListener listener);\r
-\r
-       public void resetStartFinishTime();\r
-\r
-       public void selectNextEvent();\r
-\r
-       public void selectPrevEvent();\r
-\r
-       public void selectNextTrace();\r
-\r
-       public void selectPrevTrace();\r
-\r
-       public void showLegend();\r
-\r
-       public void zoomIn();\r
-\r
-       public void zoomOut();\r
-\r
-       public void setSelectedTime(long time, boolean ensureVisible, Object source);\r
-\r
-       public void setSelectedEvent(ITimeEvent event, Object Source);\r
-\r
-       public void setSelectedTraceTime(ITmfTimeAnalysisEntry trace, long time, Object Source);\r
-\r
-       public void setSelectVisTimeWindow(long time0, long time1, Object Source);\r
-\r
-       public void setAcceptSelectionAPIcalls(boolean acceptCalls);\r
-\r
-       public void setTimeCalendarFormat(boolean toAbsoluteCaltime);\r
-\r
-       public boolean isCalendarFormat();\r
-\r
-       public boolean isVisibleVerticalScroll();\r
-\r
-       public void setVisibleVerticalScroll(boolean visibleVerticalScroll);\r
-\r
-       public int getBorderWidth();\r
-\r
-       public void setBorderWidth(int borderWidth);\r
-\r
-       public int getHeaderHeight();\r
-\r
-       public void setHeaderHeight(int headerHeight);\r
-\r
-       public int getItemHeight();\r
-\r
-       public void setItemHeight(int rowHeight);\r
-\r
-    public void setMinimumItemWidth(int width);\r
-\r
-       public void resizeControls();\r
-\r
-       public void setSelectedTrace(ITmfTimeAnalysisEntry trace);\r
-\r
-       public ISelection getSelectionTrace();\r
-\r
-       public void setNameWidthPref(int width);\r
-\r
-       public int getNameWidthPref(int width);\r
-\r
-       public void addFilterSelectionListner(ITmfTimeFilterSelectionListener listener);\r
-\r
-       public void removeFilterSelectionListner(\r
-                       ITmfTimeFilterSelectionListener listener);\r
-\r
-       public int getTimeSpace();\r
-\r
-       public void itemUpdate(ITmfTimeAnalysisEntry parent, TimeEvent item);\r
-\r
-       public Control getControl();\r
-\r
-       public ISelectionProvider getSelectionProvider();\r
-\r
-       /**\r
-        * <p>\r
-        * Provide the possibility to control the wait cursor externally\r
-        * </p>\r
-        * <p>\r
-        * e.g. data requests in progress\r
-        * </p>\r
-        * \r
-        * @param waitInd\r
-        *            - true change to wait cursor\r
-        */\r
-       public void waitCursor(boolean waitInd);\r
-\r
-    public void setFocus();\r
-\r
-    /**\r
-     * Update the time bounds without changing the visible range\r
-     * \r
-     * @param beginTime\r
-     * @param endTime\r
-     */\r
-    public void setTimeBounds(long beginTime, long endTime);\r
-\r
-    /**\r
-     * Get the horizontal scrollbar\r
-     * @return the horizontal scrollbar\r
-     */\r
-    public ScrollBar getHorizontalBar();\r
-\r
-    /**\r
-     * Get the vertical scrollbar\r
-     * @return the vertical scrollbar\r
-     */\r
-    public ScrollBar getVerticalBar();\r
-\r
-    /**\r
-     * Set the top index\r
-     * @param index the top index\r
-     */\r
-    public void setTopIndex(int index);\r
-\r
-}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeFilterSelectionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeFilterSelectionListener.java
deleted file mode 100644 (file)
index 0b10203..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.EventListener;\r
-\r
-public interface ITmfTimeFilterSelectionListener extends EventListener {\r
-       public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event);\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeScaleSelectionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeScaleSelectionListener.java
deleted file mode 100644 (file)
index f73845b..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.EventListener;\r
-\r
-/**\r
- * Implemented by any user of TmfTime in order to be notified of available events,\r
- * upon registration\r
- * \r
- */\r
-public interface ITmfTimeScaleSelectionListener extends EventListener {\r
-       public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event);\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeSelectionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/ITmfTimeSelectionListener.java
deleted file mode 100644 (file)
index 77d7b82..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.EventListener;\r
-\r
-/**\r
- * Implemented by any user of TsfTm in order to be notified of available events,\r
- * upon registration\r
- * \r
- */\r
-public interface ITmfTimeSelectionListener extends EventListener {\r
-       public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event);\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisProvider.java
deleted file mode 100644 (file)
index 944c801..0000000
+++ /dev/null
@@ -1,328 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009, 2010 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-\r
-public abstract class TmfTimeAnalysisProvider {\r
-    \r
-       static public final int IMG_THREAD_RUNNING = 0;\r
-       static public final int IMG_THREAD_SUSPENDED = 1;\r
-       static public final int IMG_THREAD_STOPPED = 2;\r
-       static public final int IMG_METHOD_RUNNING = 3;\r
-       static public final int IMG_METHOD = 4;\r
-       static public final int IMG_NUM = 5;\r
-\r
-       public enum StateColor {\r
-               GREEN, DARK_BLUE, RED, GOLD, ORANGE, GRAY, BLACK, DARK_GREEN, DARK_YELLOW, MAGENTA3, PURPLE1, PINK1, AQUAMARINE, LIGHT_BLUE, CADET_BLUE, OLIVE;\r
-\r
-               private String stateName;\r
-\r
-               StateColor() {\r
-                       String undef = "Undefined"; //$NON-NLS-1$\r
-                       this.stateName = undef;\r
-               }\r
-\r
-               public String getStateName() {\r
-                       return stateName;\r
-               }\r
-\r
-               public void setStateName(String stateName) {\r
-                       this.stateName = stateName;\r
-               }\r
-       }\r
-\r
-       // static private String _externalPath[] = {\r
-       // "icons/full/obj16/thread_obj.gif", // running thread\r
-       // "icons/full/obj16/threads_obj.gif", // suspended\r
-       // "icons/full/obj16/threadt_obj.gif", // stopped\r
-       // "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
-       // "icons/full/obj16/stckframe_obj.gif", // stack frame\r
-       // };\r
-       //\r
-       // static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
-       // "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
-       // "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
-       //\r
-       // static private Image getImage(int idx) {\r
-       // if (idx < 0 || idx >= IMG_NUM)\r
-       // SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
-       // String key = "trace.img." + idx;\r
-       // Image img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
-       // if (null == img) {\r
-       // ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
-       // _externalPlugin[idx], _externalPath[idx]);\r
-       // TmfUiPlugin.getDefault().getImageRegistry().put(key, desc);\r
-       // img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
-       // }\r
-       // return img;\r
-       // }\r
-\r
-       public void drawState(TraceColorScheme colors, ITimeEvent event,\r
-                       Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
-                       boolean timeSelected) {\r
-               int colorIdx = getEventColorVal(event);\r
-               drawState(colors, colorIdx, rect, gc, selected, rectBound, timeSelected);\r
-\r
-       }\r
-\r
-       public void drawState(TraceColorScheme colors, int colorIdx,\r
-                       Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
-                       boolean timeSelected) {\r
-\r
-               boolean visible = rect.width == 0 ? false : true;\r
-               int colorIdx1 = colorIdx;\r
-               \r
-               timeSelected = timeSelected && selected;\r
-               if (timeSelected) {\r
-                       colorIdx1 = colorIdx + TraceColorScheme.STATES_SEL0\r
-                                       - TraceColorScheme.STATES0;\r
-               }\r
-\r
-               if (visible) {\r
-                       // fill all rect area\r
-                       if (rect.isEmpty())\r
-                               return;\r
-\r
-                       gc.setBackground(colors.getColor(colorIdx1));\r
-                       gc.fillRectangle(rect);\r
-                       colorIdx1 = colorIdx + TraceColorScheme.STATES_BORDER0\r
-                                       - TraceColorScheme.STATES0;\r
-                       gc.setForeground(colors.getColor(colorIdx1));\r
-\r
-                       // draw bounds\r
-                       if (!timeSelected) {\r
-                               if (rectBound && rect.width >= 3) {\r
-                                       gc.drawRectangle(rect.x, rect.y, rect.width - 1,\r
-                                                       rect.height - 1);\r
-                               } else {\r
-                                       // Draw the top and bottom borders i.e. no side borders\r
-                                       // top\r
-                                       gc\r
-                                                       .drawLine(rect.x, rect.y, rect.x + rect.width - 1,\r
-                                                                       rect.y);\r
-                                       // bottom\r
-                                       gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x\r
-                                                       + rect.width - 1, rect.y + rect.height - 1);\r
-                               }\r
-                       }\r
-                       // draw decoration middle line\r
-                       // int mindy = rect.y + rect.height / 2;\r
-                       // if (TraceColorScheme.GOLD_STATE == colorIdx\r
-                       // || TraceColorScheme.ORANGE_STATE == colorIdx) {\r
-                       // int s = gc.getLineStyle();\r
-                       // int w = gc.getLineWidth();\r
-                       // gc.setLineStyle(SWT.LINE_DOT);\r
-                       // gc.setLineWidth(2);\r
-                       // gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy);\r
-                       // gc.setLineStyle(s);\r
-                       // gc.setLineWidth(w);\r
-                       // } else if (TraceColorScheme.RED_STATE == colorIdx\r
-                       // || TraceColorScheme.GRAY_STATE == colorIdx) {\r
-                       // int w = gc.getLineWidth();\r
-                       // gc.setLineWidth(2);\r
-                       // gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy);\r
-                       // gc.setLineWidth(w);\r
-                       // }\r
-                       // // draw selection bounds\r
-                       // if (timeSelected) {\r
-                       // gc.setForeground(colors\r
-                       // .getColor(TraceColorScheme.SELECTED_TIME));\r
-                       // if (rect.width >= 3) {\r
-                       // gc.drawRectangle(rect.x, rect.y, rect.width - 1,\r
-                       // rect.height - 1);\r
-                       // // gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3,\r
-                       // // rect.height - 3);\r
-                       // } else {\r
-                       // gc\r
-                       // .drawLine(rect.x, rect.y, rect.x + rect.width - 1,\r
-                       // rect.y);\r
-                       // gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x\r
-                       // + rect.width - 1, rect.y + rect.height - 1);\r
-                       // }\r
-                       // gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width - 1,\r
-                       // rect.y + 1);\r
-                       // gc.drawLine(rect.x, rect.y + rect.height - 2, rect.x\r
-                       // + rect.width - 1, rect.y + rect.height - 2);\r
-                       // }\r
-               } else {\r
-                       // selected rectangle area is not visible but can be represented\r
-                       // with a broken vertical line of specified width.\r
-                       int width = 2;\r
-                       rect.width = width;\r
-                       // check if height is greater than zero.\r
-                       if (rect.isEmpty())\r
-                               return;\r
-                       // colorIdx1 = TraceColorScheme.BLACK;\r
-                       gc.setForeground(colors.getColor(colorIdx));\r
-                       int s = gc.getLineStyle();\r
-                       int w = gc.getLineWidth();\r
-                       gc.setLineStyle(SWT.LINE_DOT);\r
-                       gc.setLineWidth(width);\r
-                       // Trace.debug("Reactangle not visible, drawing vertical line with: "\r
-                       // + rect.x + "," + rect.y + "," + rect.x + "," + rect.y\r
-                       // + rect.height);\r
-                       gc.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height);\r
-                       gc.setLineStyle(s);\r
-                       gc.setLineWidth(w);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Uses the abstract method getEventcolor to obtain an enum value and\r
-        * convert it to an internal color index\r
-        * \r
-        * @param event\r
-        * @return the internal color index\r
-        */\r
-       public int getEventColorVal(ITimeEvent event) {\r
-               StateColor colors = getEventColor(event);\r
-               if (colors == StateColor.GREEN) {\r
-                       return TraceColorScheme.GREEN_STATE;\r
-               } else if (colors == StateColor.DARK_BLUE) {\r
-                       return TraceColorScheme.DARK_BLUE_STATE;\r
-               } else if (colors == StateColor.RED) {\r
-                       return TraceColorScheme.RED_STATE;\r
-               } else if (colors == StateColor.GOLD) {\r
-                       return TraceColorScheme.GOLD_STATE;\r
-               } else if (colors == StateColor.ORANGE) {\r
-                       return TraceColorScheme.ORANGE_STATE;\r
-               } else if (colors == StateColor.GRAY) {\r
-                       return TraceColorScheme.GRAY_STATE;\r
-               } else if (colors == StateColor.DARK_GREEN) {\r
-                       return TraceColorScheme.DARK_GREEN_STATE;\r
-               } else if (colors == StateColor.DARK_YELLOW) {\r
-                       return TraceColorScheme.DARK_YELLOW_STATE;\r
-               } else if (colors == StateColor.MAGENTA3) {\r
-                       return TraceColorScheme.MAGENTA3_STATE;\r
-               } else if (colors == StateColor.PURPLE1) {\r
-                       return TraceColorScheme.PURPLE1_STATE;\r
-               } else if (colors == StateColor.PINK1) {\r
-                       return TraceColorScheme.PINK1_STATE;\r
-               } else if (colors == StateColor.AQUAMARINE) {\r
-                       return TraceColorScheme.AQUAMARINE_STATE;\r
-               } else if (colors == StateColor.LIGHT_BLUE) {\r
-                       return TraceColorScheme.LIGHT_BLUE_STATE;\r
-               } else if (colors == StateColor.CADET_BLUE) {\r
-                       return TraceColorScheme.CADET_BLUE_STATE_SEL;\r
-               } else if (colors == StateColor.OLIVE) {\r
-                       return TraceColorScheme.OLIVE_STATE;\r
-               }\r
-\r
-               return TraceColorScheme.BLACK_STATE;\r
-       }\r
-\r
-       /**\r
-        * Select the color for the different internal variants of events.\r
-        * \r
-        * @param event\r
-        * @return the corresponding event color\r
-        */\r
-       public abstract StateColor getEventColor(ITimeEvent event);\r
-\r
-       /**\r
-        * This values is appended between braces to the right of Trace Name e.g.\r
-        * Trace And Error Log [Board 17] or for a Thread trace e.g. State Server\r
-        * [java.lang.Thread]\r
-        * \r
-        * @param trace\r
-        * @return the trace class name\r
-        */\r
-       public abstract String getTraceClassName(ITmfTimeAnalysisEntry trace);\r
-\r
-       public String getEventName(ITimeEvent event) {\r
-               return getEventName(event, true, false);\r
-       }\r
-\r
-       /**\r
-        * Specify a Name for the event depending on its type or state e.g. blocked,\r
-        * running, etc..\r
-        * \r
-        * @param event\r
-        * @param upper\r
-        *            True return String value in Upper case\r
-        * @param extInfo\r
-        *            Verbose, add additional information if applicable\r
-        * @return the event name\r
-        */\r
-       public abstract String getEventName(ITimeEvent event, boolean upper,\r
-                       boolean extInfo);\r
-\r
-       public String composeTraceName(ITmfTimeAnalysisEntry trace, boolean inclState) {\r
-               String name = trace.getName();\r
-               String threadClass = getTraceClassName(trace);\r
-               if (threadClass != null && threadClass.length() > 0) {\r
-                       name += " [" + threadClass + "]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-               }\r
-               /*\r
-                * Check if this is still necessary!\r
-               if (inclState) {\r
-                       List<TimeEvent> list = trace.getTraceEvents();\r
-                       if (null != list && list.size() > 0) {\r
-                               ITimeEvent event = (ITimeEvent) list.get(list.size() - 1);\r
-                               name += " (" + getEventName(event, false, true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$\r
-                       }\r
-               }\r
-               */\r
-               return name;\r
-       }\r
-\r
-       public String composeEventName(ITimeEvent event) {\r
-               String name = event.getEntry().getName();\r
-               String threadClass = getTraceClassName(event.getEntry());\r
-               if (threadClass != null && threadClass.length() > 0) {\r
-                       name += " [" + threadClass + "]"; //$NON-NLS-1$ //$NON-NLS-2$\r
-               }\r
-               name += " (" + getEventName(event, false, true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$\r
-               return name;\r
-       }\r
-\r
-       public abstract Map<String, String> getEventHoverToolTipInfo(\r
-                       ITimeEvent event);\r
-\r
-       /**\r
-        * Provides the image icon for a given Event or Trace e.g. customize to use\r
-        * different icons according to specific event /state combination\r
-        * \r
-        * @param obj\r
-        * @return the image icon\r
-        */\r
-       public Image getItemImage(Object obj) {\r
-           /*\r
-               if (obj instanceof ITmfTimeAnalysisEntry) {\r
-                       List<TimeEvent> list = ((ITmfTimeAnalysisEntry) obj).getTraceEvents();\r
-                       if (null != list && list.size() > 0)\r
-                               obj = list.get(list.size() - 1);\r
-                       else if (((ITmfTimeAnalysisEntry) obj).getStopTime() > 0)\r
-                               return getImage(IMG_THREAD_STOPPED);\r
-                       else\r
-                               return getImage(IMG_THREAD_RUNNING);\r
-               }\r
-               if (obj instanceof TimeEvent) {\r
-                       return getImage(IMG_THREAD_RUNNING);\r
-               }\r
-               */\r
-               return null;\r
-       }\r
-\r
-       public abstract String getStateName(StateColor color);\r
-\r
-}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeAnalysisViewer.java
deleted file mode 100644 (file)
index 917e999..0000000
+++ /dev/null
@@ -1,957 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, 2008, 2009, 2010 Intel Corporation, Ericsson\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alexander N. Alexeev, Intel - Add monitors statistics support\r
- *    Alvaro Sanchez-Leon - Adapted for TMF\r
- *\r
- * $Id: ThreadStatesView.java,v 1.7 2008/05/19 15:07:21 jkubasta Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.Iterator;\r
-import java.util.Vector;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs.TmfTimeFilterDialog;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs.TmfTimeLegend;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TimeScaleCtrl;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TmfTimeStatesCtrl;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TmfTimeTipHandler;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.Utils;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.ControlAdapter;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.ScrollBar;\r
-\r
-public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProvider, SelectionListener {\r
-\r
-       /** vars */\r
-       private long _minTimeInterval;\r
-       private long _selectedTime;\r
-       private long _beginTime;\r
-       private long _endTime;\r
-       private long _time0;\r
-       private long _time1;\r
-       private long _time0_;\r
-       private long _time1_;\r
-       private long _time0_extSynch = 0;\r
-       private long _time1_extSynch = 0;\r
-       private boolean _timeRangeFixed;\r
-       private int _nameWidthPref = 200;\r
-       private int _minNameWidth = 6;\r
-       private int _nameWidth;\r
-       private Composite _dataViewer;\r
-\r
-       private TmfTimeStatesCtrl _stateCtrl;\r
-       private TimeScaleCtrl _timeScaleCtrl;\r
-       private TmfTimeTipHandler _threadTip;\r
-       private TraceColorScheme _colors;\r
-       private TmfTimeAnalysisProvider _utilImplm;\r
-\r
-       private boolean _acceptSetSelAPICalls = false;\r
-       Vector<ITmfTimeSelectionListener> widgetSelectionListners = new Vector<ITmfTimeSelectionListener>();\r
-       Vector<ITmfTimeScaleSelectionListener> widgetTimeScaleSelectionListners = new Vector<ITmfTimeScaleSelectionListener>();\r
-       Vector<ITmfTimeFilterSelectionListener> widgetFilterSelectionListeners = new Vector<ITmfTimeFilterSelectionListener>();\r
-\r
-       // Calender Time format, using Epoch reference or Relative time\r
-       // format(default\r
-       private boolean calendarTimeFormat = false;\r
-       private int borderWidth = 4;\r
-       private int timeScaleHeight = 22;\r
-\r
-       /** ctor */\r
-       public TmfTimeAnalysisViewer(Composite parent, TmfTimeAnalysisProvider provider) {\r
-        createDataViewer(parent, provider);\r
-       }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.ITimeAnalysisWidget#display(org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.model.TmfTaTrace[])\r
-     */\r
-    @Override\r
-       public void display(ITmfTimeAnalysisEntry[] traceArr) {\r
-        modelUpdate(traceArr);\r
-    }\r
-\r
-       @Override\r
-       public void display(ITmfTimeAnalysisEntry[] traceArr, long start, long end,\r
-                       boolean updateTimeBounds) {\r
-               modelUpdate(traceArr, start, end, updateTimeBounds);\r
-    }\r
-\r
-    public void controlMoved(ControlEvent e) {\r
-       }\r
-\r
-       @Override\r
-       public void controlResized(ControlEvent e) {\r
-               resizeControls();\r
-       }\r
-\r
-       // called from the display order in the API\r
-       public void modelUpdate(ITmfTimeAnalysisEntry[] traces) {\r
-               if (null != _stateCtrl) {\r
-                       //loadOptions();\r
-                       updateInternalData(traces);\r
-                       _stateCtrl.redraw();\r
-                       _timeScaleCtrl.redraw();\r
-               }\r
-       }\r
-\r
-       // called from the display order in the API\r
-       public void modelUpdate(ITmfTimeAnalysisEntry[] traces, long start,\r
-                       long end, boolean updateTimeBounds) {\r
-               if (null != _stateCtrl) {\r
-                       //loadOptions();\r
-                       updateInternalData(traces, start, end);\r
-                       if (updateTimeBounds) {\r
-                               _timeRangeFixed = true;\r
-                               // set window to match limits\r
-                               setStartFinishTime(_time0_, _time1_);\r
-                       } else {\r
-                               _stateCtrl.redraw();\r
-                               _timeScaleCtrl.redraw();\r
-                       }\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void itemUpdate(ITmfTimeAnalysisEntry parent, TimeEvent item) {\r
-               if (null != parent && null != item) {\r
-                       _stateCtrl.refreshPartial(parent, item);\r
-                       _stateCtrl.redraw();\r
-                       _timeScaleCtrl.redraw();\r
-               }\r
-       }\r
-\r
-       public void selectionChanged() {\r
-       }\r
-\r
-       protected String getViewTypeStr() {\r
-               return "viewoption.threads"; //$NON-NLS-1$\r
-       }\r
-\r
-       int getMarginWidth(int idx) {\r
-               return 0;\r
-       }\r
-\r
-       int getMarginHeight(int idx) {\r
-               return 0;\r
-       }\r
-\r
-       void loadOptions() {\r
-               _minTimeInterval = 1;\r
-               _selectedTime = -1;\r
-               _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$\r
-                               _nameWidthPref, _minNameWidth, 1000);\r
-       }\r
-\r
-       void saveOptions() {\r
-               Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$\r
-       }\r
-\r
-       protected Control createDataViewer(Composite parent,\r
-                       TmfTimeAnalysisProvider utilImplm) {\r
-               loadOptions();\r
-               _utilImplm = utilImplm;\r
-               _colors = new TraceColorScheme();\r
-               _dataViewer = new Composite(parent, SWT.NULL);\r
-               _dataViewer.setLayoutData(GridUtil.createFill());\r
-               GridLayout gl = new GridLayout();\r
-               gl.marginHeight = borderWidth;\r
-               gl.marginWidth = 0;\r
-               gl.verticalSpacing = 0;\r
-               gl.horizontalSpacing = 0;\r
-               _dataViewer.setLayout(gl);\r
-\r
-               _timeScaleCtrl = new TimeScaleCtrl(_dataViewer, _colors);\r
-               _timeScaleCtrl.setTimeProvider(this);\r
-               _timeScaleCtrl.setLayoutData(GridUtil.createHorizontalFill());\r
-               _timeScaleCtrl.setHeight(timeScaleHeight);\r
-\r
-               _stateCtrl = new TmfTimeStatesCtrl(_dataViewer, _colors, _utilImplm);\r
-\r
-               _stateCtrl.setTimeProvider(this);\r
-               _stateCtrl.addSelectionListener(this);\r
-               _stateCtrl.setLayoutData(GridUtil.createFill());\r
-               _dataViewer.addControlListener(new ControlAdapter() {\r
-                       @Override\r
-                       public void controlResized(ControlEvent event) {\r
-                               resizeControls();\r
-                       }\r
-               });\r
-               resizeControls();\r
-               _dataViewer.update();\r
-               _threadTip = new TmfTimeTipHandler(parent.getShell(), _utilImplm, this);\r
-               _threadTip.activateHoverHelp(_stateCtrl);\r
-               return _dataViewer;\r
-       }\r
-\r
-       public void dispose() {\r
-               saveOptions();\r
-               _stateCtrl.dispose();\r
-               _dataViewer.dispose();\r
-               _colors.dispose();\r
-       }\r
-\r
-       @Override\r
-       public void resizeControls() {\r
-               Rectangle r = _dataViewer.getClientArea();\r
-               if (r.isEmpty())\r
-                       return;\r
-\r
-               int width = r.width;\r
-               if (_nameWidth > width - _minNameWidth)\r
-                       _nameWidth = width - _minNameWidth;\r
-               if (_nameWidth < _minNameWidth)\r
-                       _nameWidth = _minNameWidth;\r
-       }\r
-\r
-       /** Tries to set most convenient time range for display. */\r
-       void setTimeRange(Object traces[]) {\r
-               _endTime = 0;\r
-               _beginTime = -1;\r
-//             ITimeEvent event;\r
-               for (int i = 0; i < traces.length; i++) {\r
-                       ITmfTimeAnalysisEntry entry = (ITmfTimeAnalysisEntry) traces[i];\r
-                       if (entry.getStopTime() >= entry.getStartTime() && entry.getStopTime() > 0) {\r
-                           if (_beginTime < 0 || entry.getStartTime() < _beginTime) {\r
-                               _beginTime = entry.getStartTime();\r
-                           }\r
-                           if (entry.getStopTime() > _endTime) {\r
-                               _endTime = entry.getStopTime();\r
-                           }\r
-                       }\r
-                       /*\r
-                        * This is not needed if entry startTime and stopTime are properly set!\r
-                       List<TimeEvent> list = entry.getTraceEvents();\r
-                       int len = list.size();\r
-                       if (len > 0) {\r
-                event = (ITimeEvent) list.get(0);\r
-                if (_beginTime < 0 || event.getTime() < _beginTime) {\r
-                    _beginTime = event.getTime();\r
-                }\r
-                               event = (ITimeEvent) list.get(list.size() - 1);\r
-                               long eventEndTime = event.getTime() + (event.getDuration() > 0 ? event.getDuration() : 0);\r
-                               if (eventEndTime > _endTime) {\r
-                                       _endTime = eventEndTime;\r
-                               }\r
-                       }\r
-                       */\r
-               }\r
-\r
-               if (_beginTime < 0)\r
-                       _beginTime = 0;\r
-       }\r
-\r
-       void setTimeBounds() {\r
-               //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
-           _time0_ = _beginTime;\r
-               if (_time0_ < 0)\r
-                       _time0_ = 0;\r
-               // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;\r
-               _time1_ = _endTime;\r
-               // _time0_ = Math.floor(_time0_);\r
-               // _time1_ = Math.ceil(_time1_);\r
-               if (!_timeRangeFixed) {\r
-                       _time0 = _time0_;\r
-                       _time1 = _time1_;\r
-               }\r
-        if (_time1 - _time0 < _minTimeInterval) {\r
-            _time1 = _time0 + _minTimeInterval;\r
-        }\r
-       }\r
-\r
-       /**\r
-        * @param traces\r
-        */\r
-       void updateInternalData(ITmfTimeAnalysisEntry[] traces) {\r
-               if (null == traces)\r
-                       traces = new ITmfTimeAnalysisEntry[0];\r
-               setTimeRange(traces);\r
-               refreshAllData(traces);\r
-       }\r
-\r
-       /**\r
-        * @param traces\r
-        * @param start\r
-        * @param end\r
-        */\r
-       void updateInternalData(ITmfTimeAnalysisEntry[] traces, long start, long end) {\r
-               if (null == traces)\r
-                       traces = new ITmfTimeAnalysisEntry[0];\r
-               if ((start == 0 && end == 0) || start < 0 || end < 0) {\r
-                       // Start and end time are unspecified and need to be determined from\r
-                       // individual processes\r
-                       setTimeRange(traces);\r
-               } else {\r
-                       _beginTime = start;\r
-                       _endTime = end;\r
-               }\r
-\r
-               refreshAllData(traces);\r
-       }\r
-\r
-       /**\r
-        * @param traces\r
-        */\r
-       private void refreshAllData(ITmfTimeAnalysisEntry[] traces) {\r
-               setTimeBounds();\r
-               if (_selectedTime < _beginTime) {\r
-                   _selectedTime = _beginTime;\r
-               } else if (_selectedTime > _endTime) {\r
-            _selectedTime = _endTime;\r
-               }\r
-               _stateCtrl.refreshData(traces);\r
-               filterOutNotification();\r
-       }\r
-\r
-       @Override\r
-       public void setFocus() {\r
-               if (null != _stateCtrl)\r
-                       _stateCtrl.setFocus();\r
-       }\r
-\r
-       @Override\r
-       public boolean isInFocus() {\r
-               return _stateCtrl.isInFocus();\r
-       }\r
-\r
-       @Override\r
-       public ITmfTimeAnalysisEntry getSelectedTrace() {\r
-               return _stateCtrl.getSelectedTrace();\r
-       }\r
-\r
-       @Override\r
-       public ISelection getSelection() {\r
-               return _stateCtrl.getSelection();\r
-       }\r
-\r
-       @Override\r
-       public ISelection getSelectionTrace() {\r
-               return _stateCtrl.getSelectionTrace();\r
-       }\r
-\r
-       @Override\r
-       public long getTime0() {\r
-               return _time0;\r
-       }\r
-\r
-       @Override\r
-       public long getTime1() {\r
-               return _time1;\r
-       }\r
-\r
-       @Override\r
-       public long getMinTimeInterval() {\r
-               return _minTimeInterval;\r
-       }\r
-\r
-       @Override\r
-       public int getNameSpace() {\r
-               return _nameWidth;\r
-       }\r
-\r
-       @Override\r
-       public void setNameSpace(int width) {\r
-               _nameWidth = width;\r
-               width = _stateCtrl.getClientArea().width;\r
-               if (_nameWidth > width - 6)\r
-                       _nameWidth = width - 6;\r
-               if (_nameWidth < 6)\r
-                       _nameWidth = 6;\r
-               _stateCtrl.adjustScrolls();\r
-               _stateCtrl.redraw();\r
-               _timeScaleCtrl.redraw();\r
-       }\r
-\r
-       @Override\r
-       public int getTimeSpace() {\r
-               int w = _stateCtrl.getClientArea().width;\r
-               return w - _nameWidth;\r
-       }\r
-\r
-       @Override\r
-       public long getSelectedTime() {\r
-               return _selectedTime;\r
-       }\r
-\r
-       @Override\r
-       public long getBeginTime() {\r
-               return _beginTime;\r
-       }\r
-\r
-       @Override\r
-       public long getEndTime() {\r
-               return _endTime;\r
-       }\r
-\r
-       @Override\r
-       public long getMaxTime() {\r
-               return _time1_;\r
-       }\r
-\r
-       @Override\r
-       public long getMinTime() {\r
-               return _time0_;\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * \r
-        * @see\r
-        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
-        * #setStartFinishTimeNotify(long, long)\r
-        */\r
-       @Override\r
-       public void setStartFinishTimeNotify(long time0, long time1) {\r
-               setStartFinishTime(time0, time1);\r
-               notifyStartFinishTimeSelectionListeners(time0, time1);\r
-       }\r
-\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()\r
-     */\r
-    @Override\r
-       public void notifyStartFinishTime() {\r
-        notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
-    }\r
-\r
-    /*\r
-        * (non-Javadoc)\r
-        * \r
-        * @see\r
-        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
-        * #setStartFinishTime(long, long)\r
-        */\r
-       @Override\r
-       public void setStartFinishTime(long time0, long time1) {\r
-               _time0 = time0;\r
-        if (_time0 < _time0_)\r
-            _time0 = _time0_;\r
-        if (_time0 > _time1_)\r
-            _time0 = _time1_;\r
-               _time1 = time1;\r
-        if (_time1 < _time0_)\r
-            _time1 = _time0_;\r
-        if (_time1 > _time1_)\r
-            _time1 = _time1_;\r
-               if (_time1 - _time0 < _minTimeInterval)\r
-                   _time1 = _time0 + _minTimeInterval;\r
-               _timeRangeFixed = true;\r
-               _stateCtrl.adjustScrolls();\r
-               _stateCtrl.redraw();\r
-               _timeScaleCtrl.redraw();\r
-       }\r
-\r
-       @Override\r
-       public void setTimeBounds(long beginTime, long endTime) {\r
-           _beginTime = beginTime;\r
-           _endTime = endTime;\r
-           _time0_ = beginTime;\r
-           _time1_ = endTime;\r
-           _stateCtrl.adjustScrolls();\r
-       }\r
-\r
-       @Override\r
-       public void resetStartFinishTime() {\r
-               setStartFinishTimeNotify(_time0_, _time1_);\r
-               _timeRangeFixed = false;\r
-       }\r
-\r
-       @Override\r
-       public void setSelectedTimeInt(long time, boolean ensureVisible) {\r
-               // Trace.debug("currentTime:" + _selectedTime + " new time:" + time);\r
-               _selectedTime = time;\r
-               if (_selectedTime > _endTime) {\r
-                       _endTime = _selectedTime;\r
-                       _time1_ = _selectedTime;\r
-               }\r
-               if (_selectedTime < _beginTime) {\r
-                       _beginTime = _selectedTime;\r
-                       _time0_ = _selectedTime;\r
-               }\r
-               long time0 = _time0;\r
-               long time1 = _time1;\r
-               if (ensureVisible) {\r
-                       double timeSpace = (_time1 - _time0) * .02;\r
-                       double timeMid = (_time1 - _time0) * .1;\r
-                       if (_selectedTime < _time0 + timeSpace) {\r
-                               long dt = (long) (_time0 - _selectedTime + timeMid);\r
-                               _time0 -= dt;\r
-                               _time1 -= dt;\r
-                       } else if (_selectedTime > _time1 - timeSpace) {\r
-                               long dt = (long) (_selectedTime - _time1 + timeMid);\r
-                               _time0 += dt;\r
-                               _time1 += dt;\r
-                       }\r
-                       if (_time0 < _time0_) {\r
-                               _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0));\r
-                               _time0 = _time0_;\r
-                       } else if (_time1 > _time1_) {\r
-                               _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_));\r
-                               _time1 = _time1_;\r
-                       }\r
-               }\r
-               if (_time1 - _time0 < _minTimeInterval) {\r
-                       _time1 = _time0 + _minTimeInterval;\r
-               }\r
-               _stateCtrl.adjustScrolls();\r
-               _stateCtrl.redraw();\r
-               _timeScaleCtrl.redraw();\r
-               if (time0 != _time0 || time1 != _time1) {\r
-                       notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void widgetDefaultSelected(SelectionEvent e) {\r
-               // TODO: Opening call stack shall be replaced to a configurable view\r
-               // new OpenCallStackViewAction().openView(false);\r
-               // Replaced by event notification\r
-               // updateModelSelection();\r
-               notifySelectionListeners(TmfTimeSelectionEvent.Type.WIDGET_DEF_SEL);\r
-       }\r
-\r
-       @Override\r
-       public void widgetSelected(SelectionEvent e) {\r
-               // Replace by event notification\r
-               // updateModelSelection();\r
-               notifySelectionListeners(TmfTimeSelectionEvent.Type.WIDGET_SEL);\r
-       }\r
-\r
-       @Override\r
-       public void selectNextEvent() {\r
-               _stateCtrl.selectNextEvent();\r
-       }\r
-\r
-       @Override\r
-       public void selectPrevEvent() {\r
-               _stateCtrl.selectPrevEvent();\r
-       }\r
-\r
-       @Override\r
-       public void selectNextTrace() {\r
-               _stateCtrl.selectNextTrace();\r
-       }\r
-\r
-       @Override\r
-       public void selectPrevTrace() {\r
-               _stateCtrl.selectPrevTrace();\r
-       }\r
-\r
-       @Override\r
-       public void groupTraces(boolean on) {\r
-               _stateCtrl.groupTraces(on);\r
-       }\r
-\r
-       @Override\r
-       public void filterTraces() {\r
-               if (_dataViewer == null || _dataViewer.isDisposed())\r
-                       return;\r
-\r
-               if (TmfTimeFilterDialog.getTraceFilter(_dataViewer.getShell(), _stateCtrl\r
-                               .getTraces(), _stateCtrl.getTraceFilter())) {\r
-                       _stateCtrl.refreshData();\r
-                       filterOutNotification();\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void showLegend() {\r
-               if (_dataViewer == null || _dataViewer.isDisposed())\r
-                       return;\r
-\r
-               TmfTimeLegend.open(_dataViewer.getShell(), _utilImplm);\r
-       }\r
-\r
-       public void toggleThreadsInteractionDrawing() {\r
-               _stateCtrl.toggleTraceInteractionDrawing();\r
-       }\r
-\r
-       public void setThreadJoinDrawing(boolean on) {\r
-               _stateCtrl.setTraceJoinDrawing(on);\r
-       }\r
-\r
-       public void setThreadWaitDrawing(boolean on) {\r
-               _stateCtrl.setTraceWaitDrawing(on);\r
-       }\r
-\r
-       public void setThreadReleaseDrawing(boolean on) {\r
-               _stateCtrl.setTraceReleaseDrawing(on);\r
-       }\r
-\r
-       public boolean getThreadInteractionDrawing() {\r
-               return _stateCtrl.getTracesInteractionDrawing();\r
-       }\r
-\r
-       public boolean getThreadJoinDrawing() {\r
-               return _stateCtrl.getTraceJoinDrawing();\r
-       }\r
-\r
-       public boolean getThreadWaitDrawing() {\r
-               return _stateCtrl.getTraceWaitDrawing();\r
-       }\r
-\r
-       public boolean getThreadReleaseDrawing() {\r
-               return _stateCtrl.getTraceReleaseDrawing();\r
-       }\r
-\r
-       protected void select(Object obj) {\r
-               if (obj == null)\r
-                       return;\r
-               // TODO: ThreadDetails Adaption removed, might need replacement\r
-               // if (obj instanceof ThreadDetails) {\r
-               // obj = ((ThreadDetails) obj).getThread();\r
-               // }\r
-               if (obj instanceof ITmfTimeAnalysisEntry) {\r
-                       // _stateCtrl.selectThread((TsfTmTrace) obj);\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void zoomIn() {\r
-               _stateCtrl.zoomIn();\r
-       }\r
-\r
-       @Override\r
-       public void zoomOut() {\r
-               _stateCtrl.zoomOut();\r
-       }\r
-\r
-       private String getPreferenceString(String string) {\r
-               return getViewTypeStr() + "." + string; //$NON-NLS-1$\r
-       }\r
-\r
-       @Override\r
-       public void addWidgetSelectionListner(ITmfTimeSelectionListener listener) {\r
-               widgetSelectionListners.add(listener);\r
-       }\r
-\r
-       @Override\r
-       public void removeWidgetSelectionListner(ITmfTimeSelectionListener listener) {\r
-               widgetSelectionListners.removeElement(listener);\r
-       }\r
-\r
-       @Override\r
-       public void addWidgetTimeScaleSelectionListner(\r
-                       ITmfTimeScaleSelectionListener listener) {\r
-               widgetTimeScaleSelectionListners.add(listener);\r
-       }\r
-\r
-       @Override\r
-       public void removeWidgetTimeScaleSelectionListner(\r
-                       ITmfTimeScaleSelectionListener listener) {\r
-               widgetTimeScaleSelectionListners.removeElement(listener);\r
-       }\r
-\r
-       @Override\r
-       public void setSelectedTime(long time, boolean ensureVisible, Object source) {\r
-               if (_acceptSetSelAPICalls == false || this == source) {\r
-                       return;\r
-               }\r
-\r
-               setSelectedTimeInt(time, ensureVisible);\r
-       }\r
-\r
-       @Override\r
-       public void setSelectedEvent(ITimeEvent event, Object source) {\r
-               if (_acceptSetSelAPICalls == false || event == null || source == this) {\r
-                       return;\r
-               }\r
-               ITmfTimeAnalysisEntry trace = event.getEntry();\r
-               if (trace != null) {\r
-                       _stateCtrl.selectItem(trace, false);\r
-               }\r
-\r
-               setSelectedTimeInt(event.getTime(), true);\r
-       }\r
-\r
-       @Override\r
-       public void setSelectedTraceTime(ITmfTimeAnalysisEntry trace, long time, Object source) {\r
-               if (_acceptSetSelAPICalls == false || trace == null || source == this) {\r
-                       return;\r
-               }\r
-\r
-               if (trace != null) {\r
-                       _stateCtrl.selectItem(trace, false);\r
-               }\r
-\r
-               setSelectedTimeInt(time, true);\r
-       }\r
-\r
-       @Override\r
-       public void setSelectedTrace(ITmfTimeAnalysisEntry trace) {\r
-               if (trace == null) {\r
-                       return;\r
-               }\r
-\r
-               _stateCtrl.selectItem(trace, false);\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * \r
-        * @see\r
-        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
-        * #setSelectVisTimeWindow(long, long, java.lang.Object)\r
-        */\r
-       @Override\r
-       public void setSelectVisTimeWindow(long time0, long time1, Object source) {\r
-               if (_acceptSetSelAPICalls == false || source == this) {\r
-                       return;\r
-               }\r
-\r
-               setStartFinishTime(time0, time1);\r
-\r
-               // update notification time values since we are now in synch with the\r
-               // external application\r
-               updateExtSynchTimers();\r
-       }\r
-\r
-       @Override\r
-       public void setAcceptSelectionAPIcalls(boolean acceptCalls) {\r
-               _acceptSetSelAPICalls = acceptCalls;\r
-       }\r
-\r
-       private synchronized void notifySelectionListeners(\r
-                       TmfTimeSelectionEvent.Type rtype) {\r
-               // Any listeners out there ?\r
-               if (widgetSelectionListners.size() > 0) {\r
-                       // Locate the event selected\r
-                       ISelection selection = getSelection();\r
-                       Object sel = null;\r
-                       if (selection != null && !selection.isEmpty()) {\r
-                               sel = ((IStructuredSelection) selection).getFirstElement();\r
-                       }\r
-\r
-                       if (sel != null) {\r
-                               // Notify Selection Listeners\r
-                               TmfTimeSelectionEvent event = new TmfTimeSelectionEvent(this,\r
-                                               rtype, sel, getSelectedTime());\r
-\r
-                               for (Iterator<ITmfTimeSelectionListener> iter = widgetSelectionListners\r
-                                               .iterator(); iter.hasNext();) {\r
-                                       ITmfTimeSelectionListener listener = (ITmfTimeSelectionListener) iter\r
-                                                       .next();\r
-                                       listener.tsfTmProcessSelEvent(event);\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-\r
-       public void notifyStartFinishTimeSelectionListeners(long _time0, long _time1) {\r
-               if (widgetTimeScaleSelectionListners.size() > 0) {\r
-                       // Check if the time has actually changed from last notification\r
-                       if (_time0 != _time0_extSynch || _time1 != _time1_extSynch) {\r
-                               // Notify Time Scale Selection Listeners\r
-                               TmfTimeScaleSelectionEvent event = new TmfTimeScaleSelectionEvent(\r
-                                               this, _time0, _time1, getTimeSpace(), getSelectedTime());\r
-\r
-                               for (Iterator<ITmfTimeScaleSelectionListener> iter = widgetTimeScaleSelectionListners\r
-                                               .iterator(); iter.hasNext();) {\r
-                                       ITmfTimeScaleSelectionListener listener = (ITmfTimeScaleSelectionListener) iter\r
-                                                       .next();\r
-                                       listener.tsfTmProcessTimeScaleEvent(event);\r
-                               }\r
-\r
-                               // update external synch timers\r
-                               updateExtSynchTimers();\r
-                       }\r
-               }\r
-       }\r
-\r
-       /**\r
-        * update the cache timers used to identify the need to send a time window\r
-        * update to external registered listeners\r
-        */\r
-       private void updateExtSynchTimers() {\r
-               // last time notification cache\r
-               _time0_extSynch = _time0;\r
-               _time1_extSynch = _time1;\r
-       }\r
-\r
-       @Override\r
-       public void setTimeCalendarFormat(boolean toAbsoluteCaltime) {\r
-               calendarTimeFormat = toAbsoluteCaltime;\r
-       }\r
-\r
-       @Override\r
-       public boolean isCalendarFormat() {\r
-               return calendarTimeFormat;\r
-       }\r
-\r
-       @Override\r
-       public int getBorderWidth() {\r
-               return borderWidth;\r
-       }\r
-\r
-       @Override\r
-       public void setBorderWidth(int borderWidth) {\r
-               if (borderWidth > -1) {\r
-            this.borderWidth = borderWidth;\r
-            GridLayout gl = (GridLayout)_dataViewer.getLayout();\r
-            gl.marginHeight = borderWidth;\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public int getHeaderHeight() {\r
-               return timeScaleHeight;\r
-       }\r
-\r
-       @Override\r
-       public void setHeaderHeight(int headerHeight) {\r
-               if (headerHeight > -1) {\r
-                       this.timeScaleHeight = headerHeight;\r
-                       _timeScaleCtrl.setHeight(headerHeight);\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public int getItemHeight() {\r
-               if (_stateCtrl != null) {\r
-                       return _stateCtrl.getItemHeight();\r
-               }\r
-               return 0;\r
-       }\r
-\r
-       @Override\r
-       public void setItemHeight(int rowHeight) {\r
-               if (_stateCtrl != null) {\r
-                       _stateCtrl.setItemHeight(rowHeight);\r
-               }\r
-       }\r
-\r
-    @Override\r
-    public void setMinimumItemWidth(int width) {\r
-        if (_stateCtrl != null) {\r
-            _stateCtrl.setMinimumItemWidth(width);\r
-        }\r
-    }\r
-    \r
-       @Override\r
-       public boolean isVisibleVerticalScroll() {\r
-               if (_stateCtrl != null) {\r
-                       _stateCtrl.isVisibleVerticalScroll();\r
-               }\r
-               return false;\r
-       }\r
-\r
-       @Override\r
-       public void setVisibleVerticalScroll(boolean visibleVerticalScroll) {\r
-               if (_stateCtrl != null) {\r
-                       _stateCtrl.setVisibleVerticalScroll(visibleVerticalScroll);\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void setNameWidthPref(int width) {\r
-               _nameWidthPref = width;\r
-               if (width == 0) {\r
-                       _minNameWidth = 0;\r
-            _nameWidth = 0;\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public int getNameWidthPref(int width) {\r
-               return _nameWidthPref;\r
-       }\r
-\r
-       @Override\r
-       public void addFilterSelectionListner(ITmfTimeFilterSelectionListener listener) {\r
-               widgetFilterSelectionListeners.add(listener);\r
-       }\r
-\r
-       @Override\r
-       public void removeFilterSelectionListner(\r
-                       ITmfTimeFilterSelectionListener listener) {\r
-               widgetFilterSelectionListeners.remove(listener);\r
-       }\r
-\r
-       private void filterOutNotification() {\r
-               TmfTimeFilterSelectionEvent event = new TmfTimeFilterSelectionEvent(this);\r
-               event.setFilteredOut(_stateCtrl.getFilteredOut());\r
-               for (ITmfTimeFilterSelectionListener listener : widgetFilterSelectionListeners) {\r
-                       listener.tmfTaProcessFilterSelection(event);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * needed in case there's a need to associate a context menu\r
-        * \r
-        * @return the state control (selection provider)\r
-        */\r
-       @Override\r
-       public Control getControl() {\r
-               return _stateCtrl;\r
-       }\r
-\r
-       /**\r
-        * Get the selection provider\r
-        * \r
-     * @return the selection provider\r
-        */\r
-       @Override\r
-       public ISelectionProvider getSelectionProvider() {\r
-               return _stateCtrl;\r
-       }\r
-\r
-       /*\r
-        * (non-Javadoc)\r
-        * \r
-        * @see\r
-        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
-        * #waitCursor(boolean)\r
-        */\r
-       @Override\r
-       public void waitCursor(boolean waitInd) {\r
-               _stateCtrl.waitCursor(waitInd);\r
-       }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#getHorizontalBar()\r
-     */\r
-    @Override\r
-    public ScrollBar getHorizontalBar() {\r
-        return _stateCtrl.getHorizontalBar();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#getVerticalBar()\r
-     */\r
-    @Override\r
-    public ScrollBar getVerticalBar() {\r
-        return _stateCtrl.getVerticalBar();\r
-    }\r
-\r
-    /* (non-Javadoc)\r
-     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#setTopIndex(int)\r
-     */\r
-    @Override\r
-    public void setTopIndex(int index) {\r
-        _stateCtrl.setTopIndex(index);\r
-    }\r
-\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeFilterSelectionEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeFilterSelectionEvent.java
deleted file mode 100644 (file)
index 6cf92f8..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.EventObject;\r
-import java.util.Vector;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-\r
-public class TmfTimeFilterSelectionEvent extends EventObject {\r
-       /**\r
-        * \r
-        */\r
-       private static final long serialVersionUID = -150960748016449093L;\r
-\r
-       Vector<ITmfTimeAnalysisEntry> filteredOut = null;\r
-\r
-       public TmfTimeFilterSelectionEvent(Object source) {\r
-               super(source);\r
-       }\r
-\r
-       public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
-               return filteredOut;\r
-       }\r
-\r
-       public void setFilteredOut(Vector<ITmfTimeAnalysisEntry> rfilteredOut) {\r
-               this.filteredOut = rfilteredOut;\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeScaleSelectionEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeScaleSelectionEvent.java
deleted file mode 100644 (file)
index 9b9dec7..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.EventObject;\r
-\r
-public class TmfTimeScaleSelectionEvent extends EventObject {\r
-\r
-       /**\r
-        * \r
-        */\r
-       private static final long serialVersionUID = -4177428788761351379L;\r
-\r
-       \r
-       long time0 = 0;\r
-       long time1 = 0;\r
-       long selectedTime = 0;\r
-       int width = 0;\r
-\r
-       /**\r
-        * \r
-        * @param arg0\r
-        *            source of event\r
-        * @param time0\r
-        *            time0 the start time\r
-        * @param time1\r
-        * @param width\r
-        *            pixels used to draw the width of the time space\r
-        * @param selTime\r
-        *            carries the selected time if available otherwise is 0\r
-        */\r
-       public TmfTimeScaleSelectionEvent(Object arg0, long time0, long time1,\r
-                       int width, long selTime) {\r
-               super(arg0);\r
-               this.time0 = time0;\r
-               this.time1 = time1;\r
-               this.width = width;\r
-               this.selectedTime = selTime;\r
-       }\r
-       \r
-       /**\r
-        * @return the start time\r
-        */\r
-       public long getTime0() {\r
-               return time0;\r
-       }\r
-       \r
-       /**\r
-        * @return the end time\r
-        */\r
-       public long getTime1() {\r
-               return time1;\r
-       }\r
-\r
-       /**\r
-        * @return the selection width\r
-        */\r
-       public int getWidth() {\r
-               return width;\r
-       }\r
-\r
-       /**\r
-        * @return the selected time\r
-        */\r
-       public long getSelectedTime() {\r
-               return selectedTime;\r
-       }\r
-\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeSelectionEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/TmfTimeSelectionEvent.java
deleted file mode 100644 (file)
index 87d434f..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis;\r
-\r
-import java.util.EventObject;\r
-\r
-public class TmfTimeSelectionEvent extends EventObject {\r
-\r
-       /**\r
-        * \r
-        */\r
-       private static final long serialVersionUID = 1L;\r
-       \r
-       public enum Type {WIDGET_DEF_SEL, WIDGET_SEL}\r
-       Type dType;\r
-       Object selection = null;\r
-       long selTime = 0;\r
-       int index = 0;\r
-       \r
-       public TmfTimeSelectionEvent(Object arg0, Type rType, Object sel, long selectedTime) {\r
-               super(arg0);\r
-               dType = rType;\r
-               selection = sel;\r
-               selTime = selectedTime;\r
-       }\r
-       \r
-       public Type getDType() {\r
-               return dType;\r
-       }\r
-       \r
-       public Object getSelection() {\r
-               return selection;\r
-       }\r
-       \r
-       public long getSelectedTime() {\r
-               return selTime;\r
-       }\r
-\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/dialogs/TmfTimeFilterDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/dialogs/TmfTimeFilterDialog.java
deleted file mode 100644 (file)
index eb8b7c0..0000000
+++ /dev/null
@@ -1,222 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2008 Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *\r
- * $Id: ThreadFilterDialog.java,v 1.2 2008/03/05 17:31:07 ewchan Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs;\r
-\r
-import java.util.Arrays;\r
-\r
-import org.eclipse.jface.dialogs.TitleAreaDialog;\r
-import org.eclipse.jface.viewers.CheckStateChangedEvent;\r
-import org.eclipse.jface.viewers.CheckboxTableViewer;\r
-import org.eclipse.jface.viewers.ICheckStateListener;\r
-import org.eclipse.jface.viewers.IStructuredContentProvider;\r
-import org.eclipse.jface.viewers.ITableLabelProvider;\r
-import org.eclipse.jface.viewers.LabelProvider;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.jface.viewers.ViewerComparator;\r
-import org.eclipse.jface.window.Window;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Table;\r
-import org.eclipse.swt.widgets.TableColumn;\r
-\r
-public class TmfTimeFilterDialog extends TitleAreaDialog {\r
-       private CheckboxTableViewer viewer;\r
-       private Object[] threads;\r
-       private boolean[] filter;\r
-       private ViewContentProvider viewContentProvider;\r
-       private TraceComparator viewTraceComparator;\r
-       private ViewLabelProvider viewViewLabelProvider;\r
-\r
-       public TmfTimeFilterDialog(Shell parentShell, Object[] threads,\r
-                       boolean[] filter) {\r
-               super(parentShell);\r
-\r
-               this.threads = (threads != null) ? Arrays.copyOf(threads, threads.length) : null;\r
-               if (filter != null)\r
-                       this.filter = (boolean[]) filter.clone();\r
-               \r
-               viewContentProvider = new ViewContentProvider();\r
-               viewTraceComparator = new TraceComparator();\r
-               viewViewLabelProvider = new ViewLabelProvider();\r
-       }\r
-\r
-       public static boolean getTraceFilter(Shell parentShell, Object[] threads,\r
-                       boolean[] filter) {\r
-               TmfTimeFilterDialog dlg = new TmfTimeFilterDialog(parentShell, threads,\r
-                               filter);\r
-               if (dlg.open() != Window.OK)\r
-                       return false;\r
-\r
-               boolean f[] = dlg.getFilter();\r
-               if (java.util.Arrays.equals(f, filter))\r
-                       return false;\r
-               for (int i = f.length - 1; i >= 0; i--)\r
-                       filter[i] = f[i];\r
-\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       protected Control createDialogArea(Composite parent) {\r
-               Composite composite = (Composite) super.createDialogArea(parent);\r
-\r
-               viewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER\r
-                               | SWT.V_SCROLL);\r
-\r
-               Table table = viewer.getTable();\r
-               table.setLayoutData(new GridData(GridData.FILL_BOTH));\r
-               table.setBackground(parent.getBackground());\r
-               createColumns(table);\r
-\r
-               //Assign providers to the viewer.\r
-               viewer.setContentProvider(viewContentProvider);\r
-               viewer.setComparator(viewTraceComparator);\r
-               viewer.setLabelProvider(viewViewLabelProvider);\r
-               \r
-               viewer.setInput(new Object());\r
-\r
-               viewer.addCheckStateListener(new ICheckStateListener() {\r
-                       @Override\r
-                       public void checkStateChanged(CheckStateChangedEvent event) {\r
-                               Object o = event.getElement();\r
-                               for (int i = threads.length - 1; i >= 0; i--) {\r
-                                       if (threads[i].equals(o))\r
-                                               filter[i] = event.getChecked();\r
-                               }\r
-                       }\r
-               });\r
-\r
-               if (filter != null) {\r
-                       for (int i = 0; i < filter.length; i++)\r
-                               viewer.setChecked(threads[i], filter[i]);\r
-               }\r
-\r
-               setMessage(Messages.TmfTimeFilterDialog_TRACE_FILTER_DESC);\r
-               setTitle(Messages.TmfTimeFilterDialog_TRACE_FILTER);\r
-               setDialogHelpAvailable(false);\r
-               setHelpAvailable(false);\r
-\r
-//             setTitleImage(org.eclipse.hyades.trace.internal.ui.PDPluginImages.DESC_IMG_UI_WZ_EDITPROFSET\r
-//                             .createImage());\r
-\r
-               return composite;\r
-       }\r
-\r
-       private void createColumns(Table table) {\r
-               table.setHeaderVisible(true);\r
-\r
-               String headers[] = { "", Messages.TmfTimeFilterDialog_TRACE_ID, Messages.TmfTimeFilterDialog_TRACE_NAME }; //$NON-NLS-1$\r
-               int width[] = { 20, 80, 400 };\r
-\r
-               for (int i = 0; i < headers.length; i++) {\r
-                       TableColumn tc = new TableColumn(table, SWT.NONE, i);\r
-                       tc.setResizable(true);\r
-                       tc.setText(headers[i]);\r
-                       tc.setWidth(width[i]);\r
-               }\r
-       }\r
-\r
-       @Override\r
-       protected void configureShell(Shell shell) {\r
-               super.configureShell(shell);\r
-               shell.setText(Messages.TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS);\r
-       }\r
-\r
-       public boolean[] getFilter() {\r
-               return (filter != null) ? Arrays.copyOf(filter, filter.length) : null;\r
-       }\r
-\r
-       /**\r
-        * @param viewContentProvider\r
-        */\r
-       public void setViewContentProvider(ViewContentProvider viewContentProvider) {\r
-               this.viewContentProvider = viewContentProvider;\r
-       }\r
-\r
-       /**\r
-        * @param viewThreadComparator\r
-        */\r
-       public void setViewThreadComparator(TraceComparator viewThreadComparator) {\r
-               this.viewTraceComparator = viewThreadComparator;\r
-       }\r
-\r
-       /**\r
-        * @param viewViewLabelProvider\r
-        */\r
-       public void setViewViewLabelProvider(ViewLabelProvider viewViewLabelProvider) {\r
-               this.viewViewLabelProvider = viewViewLabelProvider;\r
-       }\r
-       \r
-       class ViewContentProvider implements IStructuredContentProvider {\r
-               @Override\r
-               public void dispose() {\r
-               }\r
-\r
-               @Override\r
-               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-               }\r
-\r
-               @Override\r
-               public Object[] getElements(Object input) {\r
-                       return threads;\r
-               }\r
-       }\r
-\r
-       private static class ViewLabelProvider extends LabelProvider implements\r
-                       ITableLabelProvider {\r
-               @Override\r
-               public Image getImage(Object obj) {\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public Image getColumnImage(Object element, int columnIndex) {\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String getColumnText(Object element, int columnIndex) {\r
-                       // TODO: AA: Provide Label Provider externally\r
-                       ITmfTimeAnalysisEntry t = (ITmfTimeAnalysisEntry) element;\r
-\r
-                       if (columnIndex == 1)\r
-                               return String.valueOf(t.getId());\r
-                       else if (columnIndex == 2)\r
-                               return t.getName();\r
-                       else\r
-                               return ""; //$NON-NLS-1$\r
-               }\r
-       }\r
-\r
-       private static class TraceComparator extends ViewerComparator {\r
-               @Override\r
-               public int compare(Viewer viewer, Object e1, Object e2) {\r
-                       // TODO: AA: Provide comparator externally\r
-                       int id1 = ((ITmfTimeAnalysisEntry) e1).getId();\r
-                       int id2 = ((ITmfTimeAnalysisEntry) e2).getId();\r
-\r
-                       if (id1 == id2)\r
-                               return 0;\r
-\r
-                       return (id1 < id2) ? -1 : 1;\r
-                       // return 0;\r
-               }\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/dialogs/TmfTimeLegend.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/dialogs/TmfTimeLegend.java
deleted file mode 100644 (file)
index 3db0b55..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.dialogs;\r
-\r
-import org.eclipse.jface.dialogs.IDialogConstants;\r
-import org.eclipse.jface.dialogs.TitleAreaDialog;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider.StateColor;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Group;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Listener;\r
-import org.eclipse.swt.widgets.Shell;\r
-\r
-\r
-public class TmfTimeLegend extends TitleAreaDialog {\r
-\r
-       // public static final String stateNames[] = {\r
-       // UIMessages._Unknown, // "Unknown",\r
-       // UIMessages._Running, // "Running",\r
-       // UIMessages._Sleeping, // "Sleeping",\r
-       // UIMessages._Waiting, // "Waiting",\r
-       // UIMessages._Blocked, // "Blocked",\r
-       // UIMessages._Deadlocked, // "Deadlock",\r
-       // UIMessages._Stopped, // "Stopped",\r
-       // };\r
-\r
-       // public static final String interactionNames[] = {\r
-       // UIMessages._START_THREAD,\r
-       // UIMessages._JOIN_TERMINATE,\r
-       // UIMessages._WAIT_NOTIFY,\r
-       // UIMessages._INTERRUPT,\r
-       // UIMessages._RELEASE_ACQUIRE\r
-       // };\r
-\r
-       public static final int interactionColors[] = {\r
-                       TraceColorScheme.TI_START_THREAD,\r
-                       TraceColorScheme.TI_NOTIFY_JOINED, TraceColorScheme.TI_NOTIFY,\r
-                       TraceColorScheme.TI_INTERRUPT, TraceColorScheme.TI_HANDOFF_LOCK };\r
-\r
-       protected TraceColorScheme colors;\r
-       private TmfTimeAnalysisProvider ifUtil;\r
-\r
-       public static void open(Shell parent, TmfTimeAnalysisProvider rifUtil) {\r
-               (new TmfTimeLegend(parent, rifUtil)).open();\r
-       }\r
-\r
-       public TmfTimeLegend(Shell parent, TmfTimeAnalysisProvider rifUtil) {\r
-               super(parent);\r
-               colors = new TraceColorScheme();\r
-               this.ifUtil = rifUtil;\r
-       }\r
-\r
-       @Override\r
-       protected Control createDialogArea(Composite parent) {\r
-               Composite dlgArea = (Composite) super.createDialogArea(parent);\r
-               Composite composite = new Composite(dlgArea, SWT.NONE);\r
-\r
-               GridLayout layout = new GridLayout();\r
-               layout.numColumns = 2;\r
-               composite.setLayout(layout);\r
-               GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-               composite.setLayoutData(gd);\r
-\r
-               createThreadStatesGroup(composite);\r
-               // createThreadInteractionsGroup(composite);\r
-\r
-               setMessage(Messages.TmfTimeLegend_LEGEND);\r
-               setTitle(Messages.TmfTimeLegend_TRACE_STATES_TITLE);\r
-               setDialogHelpAvailable(false);\r
-               setHelpAvailable(false);\r
-\r
-               //setTitleImage(org.eclipse.hyades.trace.internal.ui.PDPluginImages.DESC_IMG_UI_WZ_EDITPROFSET.createImage());\r
-\r
-               return composite;\r
-       }\r
-\r
-       private void createThreadStatesGroup(Composite composite) {\r
-               Group gs = new Group(composite, SWT.NONE);\r
-               gs.setText(Messages.TmfTimeLegend_TRACE_STATES);\r
-               GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
-               gs.setLayoutData(gd);\r
-\r
-               GridLayout layout = new GridLayout();\r
-               layout.numColumns = 2;\r
-               layout.marginWidth = 20;\r
-               layout.marginBottom = 10;\r
-               gs.setLayout(layout);\r
-\r
-               // Go through all the defined colors and only add the ones you need. \r
-               // This will not handle several colors assigned to a color, we have \r
-               // 16 mil colors, and should not pick two to mean the same thing. \r
-               for (int i = 0; i <  TraceColorScheme.getStateColors().length; i++) {\r
-                       //Get the color enum related to the index\r
-                       StateColor stateColor = TraceColorScheme.getStateColors()[i];\r
-                       //Get the given name, provided by the interface to the application\r
-                       String stateName = ifUtil.getStateName(stateColor);\r
-                       if( stateName != "Not mapped" ) { //$NON-NLS-1$\r
-                               Bar bar = new Bar(gs, i);\r
-                               gd = new GridData();\r
-                               gd.widthHint = 40;\r
-                               gd.heightHint = 20;\r
-                               gd.verticalIndent = 8;\r
-                               bar.setLayoutData(gd);\r
-                               Label name = new Label(gs, SWT.NONE);\r
-                               name.setText(stateName);\r
-                               gd = new GridData();\r
-                               gd.horizontalIndent = 10;\r
-                               gd.verticalIndent = 8;\r
-                               name.setLayoutData(gd);\r
-                       }\r
-               }\r
-       }\r
-\r
-       // private void createThreadInteractionsGroup(Composite composite) {\r
-       // Group g = new Group (composite, SWT.NONE);\r
-       // g.setText(UIMessages._THREAD_INTERACTIONS);\r
-       // GridData gd = new GridData (SWT.FILL, SWT.FILL, true, true);\r
-       // g.setLayoutData(gd);\r
-       //\r
-       // GridLayout layout = new GridLayout();\r
-       // layout.numColumns = 2;\r
-       // layout.marginWidth = 20;\r
-       // layout.marginBottom = 10;\r
-       // g.setLayout(layout);\r
-       //              \r
-       // for (int i=0; i<5; i++) {\r
-       // Arrow a = new Arrow(g, interactionColors[i]);\r
-       // gd = new GridData();\r
-       // gd.widthHint = 10;\r
-       // gd.heightHint = 20;\r
-       // gd.verticalIndent = 8;\r
-       // a.setLayoutData(gd);\r
-       //              \r
-       // Label name = new Label (g, SWT.NONE);\r
-       // name.setText(interactionNames[i]);\r
-       // gd = new GridData ();\r
-       // gd.horizontalIndent = 4;\r
-       // gd.verticalIndent = 8;\r
-       // name.setLayoutData(gd);\r
-       // }\r
-       //\r
-       // Mark m = new Mark(g, TraceColorScheme.TI_WAIT_EXCEEDED);\r
-       // gd = new GridData();\r
-       // gd.widthHint = 10;\r
-       // gd.heightHint = 20;\r
-       // gd.verticalIndent = 8;\r
-       // m.setLayoutData(gd);\r
-       //              \r
-       // Label name = new Label (g, SWT.NONE);\r
-       // name.setText(UIMessages._WAIT_TIMEOUT_EXCEED);\r
-       // gd = new GridData ();\r
-       // gd.horizontalIndent = 4;\r
-       // gd.verticalIndent = 8;\r
-       // name.setLayoutData(gd);\r
-       // }\r
-\r
-       @Override\r
-       protected void configureShell(Shell shell) {\r
-               super.configureShell(shell);\r
-               shell.setText(Messages.TmfTimeLegend_WINDOW_TITLE);\r
-       }\r
-\r
-       @Override\r
-       protected void createButtonsForButtonBar(Composite parent) {\r
-               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\r
-                               true);\r
-       }\r
-\r
-       class Bar extends Canvas {\r
-               private Color color;\r
-\r
-               public Bar(Composite parent, int colorIdx) {\r
-                       super(parent, SWT.NONE);\r
-\r
-                       color = colors.getColor(colorIdx);\r
-                       addListener(SWT.Paint, new Listener() {\r
-                               @Override\r
-                               public void handleEvent(Event event) {\r
-                                       draw(event.gc);\r
-                               }\r
-                       });\r
-               }\r
-\r
-               private void draw(GC gc) {\r
-                       Rectangle r = getClientArea();\r
-                       gc.setBackground(color);\r
-                       gc.fillRectangle(r);\r
-                       gc.setForeground(colors.getColor(TraceColorScheme.BLACK));\r
-                       gc.drawRectangle(0, 0, r.width - 1, r.height - 1);\r
-               }\r
-       }\r
-\r
-       class Arrow extends Canvas {\r
-               public final static int HEIGHT = 12;\r
-               public final static int DX = 3;\r
-\r
-               private Color color;\r
-\r
-               public Arrow(Composite parent, int colorIdx) {\r
-                       super(parent, SWT.NONE);\r
-\r
-                       color = colors.getColor(colorIdx);\r
-                       addListener(SWT.Paint, new Listener() {\r
-                               @Override\r
-                               public void handleEvent(Event event) {\r
-                                       draw(event.gc);\r
-                               }\r
-                       });\r
-               }\r
-\r
-               private void draw(GC gc) {\r
-                       Rectangle r = getClientArea();\r
-                       gc.setForeground(color);\r
-\r
-                       int y0, y1;\r
-                       if (r.height > HEIGHT) {\r
-                               y0 = (r.height - HEIGHT) / 2;\r
-                               y1 = y0 + HEIGHT;\r
-                       } else {\r
-                               y0 = 0;\r
-                               y1 = r.height;\r
-                       }\r
-\r
-                       gc.drawLine(DX, y0, DX, y1);\r
-\r
-                       gc.drawLine(0, y0 + 3, DX, y0);\r
-                       gc.drawLine(2 * DX, y0 + 3, DX, y0);\r
-               }\r
-       }\r
-\r
-       class Mark extends Canvas {\r
-               public final static int DX = 3;\r
-\r
-               private Color color;\r
-\r
-               public Mark(Composite parent, int colorIdx) {\r
-                       super(parent, SWT.NONE);\r
-\r
-                       color = colors.getColor(colorIdx);\r
-                       addListener(SWT.Paint, new Listener() {\r
-                               @Override\r
-                               public void handleEvent(Event event) {\r
-                                       draw(event.gc);\r
-                               }\r
-                       });\r
-               }\r
-\r
-               private void draw(GC gc) {\r
-                       Rectangle r = getClientArea();\r
-                       gc.setBackground(color);\r
-\r
-                       int y = (r.height - DX) / 2;\r
-                       int c[] = { 0, y, DX, y + DX, 2 * DX, y };\r
-                       gc.fillPolygon(c);\r
-               }\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITimeEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITimeEvent.java
deleted file mode 100644 (file)
index 9babd7a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model;\r
-\r
-public interface ITimeEvent {\r
-\r
-       public ITmfTimeAnalysisEntry getEntry();\r
-\r
-       public long getTime();\r
-\r
-       /**\r
-        * @return\r
-        * <list>\r
-        * <li>-1: Considers duration to be from current event till the next</li>\r
-        * <li>0: Duration is not relevant e.g. a Burst / no state associated</li>\r
-        * <li>>0: Valid duration value specified</li>\r
-        * </list>\r
-        * <p>\r
-        */\r
-       public long getDuration();\r
-\r
-}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/ITmfTimeAnalysisEntry.java
deleted file mode 100644 (file)
index 1afded6..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model;\r
-\r
-import java.util.Iterator;\r
-import java.util.Vector;\r
-\r
-public interface ITmfTimeAnalysisEntry {\r
-       \r
-    public String getGroupName();\r
-\r
-       public int getId();\r
-\r
-       public String getName();\r
-\r
-       public long getStartTime();\r
-\r
-       public long getStopTime();\r
-\r
-    /**\r
-     * Get a vector containing all events\r
-     * @deprecated replaced by {@link #getTraceEventsIterator()}\r
-     */\r
-    @Deprecated public <T extends ITimeEvent> Vector<T> getTraceEvents();\r
-    \r
-    /**\r
-     * Get an iterator which returns all events\r
-     */\r
-    public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator();\r
-    \r
-    /**\r
-     * Get an iterator which only returns events that fall within the start time and the stop time.\r
-     * The visible duration is the event duration below which further detail is not discernible.\r
-     * If no such iterator is implemented, provide a basic iterator which returns all events.\r
-     * \r
-     * @param startTime start time in nanoseconds\r
-     * @param stopTime stop time in nanoseconds\r
-     * @param visibleDuration duration of one pixel in nanoseconds\r
-     */\r
-    public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator(long startTime, long stopTime, long visibleDuration);\r
-    \r
-    public <T extends ITimeEvent> void addTraceEvent(T event);\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/TimeEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/model/TimeEvent.java
deleted file mode 100644 (file)
index 8083040..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2009 Ericsson\r
- * \r
- * All rights reserved. This program and the accompanying materials are\r
- * made available under the terms of the Eclipse Public License v1.0 which\r
- * accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- * \r
- * Contributors:\r
- *   Alvaro Sanchez-Leon - Initial API and implementation\r
- *******************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model;\r
-\r
-public abstract class TimeEvent implements ITimeEvent {\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTrace()\r
-        */\r
-       @Override\r
-       public abstract ITmfTimeAnalysisEntry getEntry();\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTime()\r
-        */\r
-       @Override\r
-       public abstract long getTime();\r
-       \r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getDuration()\r
-        */\r
-       @Override\r
-       public long getDuration() {\r
-               return -1;\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/ITimeDataProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/ITimeDataProvider.java
deleted file mode 100644 (file)
index 7dd7712..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, 2010 Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Updated for TMF\r
- *\r
- * $Id: ITimeDataProvider.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-public interface ITimeDataProvider {\r
-\r
-       long getSelectedTime();\r
-\r
-       long getBeginTime();\r
-\r
-       long getEndTime();\r
-\r
-       long getMinTime();\r
-\r
-       long getMaxTime();\r
-\r
-       long getTime0();\r
-\r
-       long getTime1();\r
-\r
-       long getMinTimeInterval();\r
-\r
-       /**\r
-        * Updates the time range and notify registered listeners\r
-        * \r
-        * @param time0\r
-        * @param time1\r
-        */\r
-       void setStartFinishTimeNotify(long time0, long time1);\r
-\r
-       /**\r
-        * Update the time range but do not trigger event notification\r
-        * \r
-        * @param time0\r
-        * @param time1\r
-        */\r
-       void setStartFinishTime(long time0, long time1);\r
-\r
-    /**\r
-     * Notify registered listeners without updating the time range\r
-     */\r
-    void notifyStartFinishTime();\r
-\r
-       void setSelectedTimeInt(long time, boolean ensureVisible);\r
-\r
-       void resetStartFinishTime();\r
-\r
-       int getNameSpace();\r
-\r
-       void setNameSpace(int width);\r
-\r
-       int getTimeSpace();\r
-       \r
-       boolean isCalendarFormat();\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/PlainSelection.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/PlainSelection.java
deleted file mode 100644 (file)
index 739ff77..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007 Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: PlainSelection.java,v 1.1 2007/04/20 13:06:49 ewchan Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-\r
-public class PlainSelection implements IStructuredSelection {\r
-\r
-       List<Object> list = new ArrayList<Object>();\r
-\r
-       public PlainSelection() {\r
-       }\r
-\r
-       public PlainSelection(Object sel) {\r
-               add(sel);\r
-       }\r
-\r
-       public void add(Object sel) {\r
-               if (null != sel && !list.contains(sel))\r
-                       list.add(sel);\r
-       }\r
-\r
-       @Override\r
-       public Object getFirstElement() {\r
-               if (!list.isEmpty())\r
-                       return list.get(0);\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public Iterator<Object> iterator() {\r
-               return list.iterator();\r
-       }\r
-\r
-       @Override\r
-       public int size() {\r
-               return list.size();\r
-       }\r
-\r
-       @Override\r
-       public Object[] toArray() {\r
-               return list.toArray();\r
-       }\r
-\r
-       @Override\r
-       public List<Object> toList() {\r
-               return list;\r
-       }\r
-\r
-       @Override\r
-       public boolean isEmpty() {\r
-               return list.isEmpty();\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TimeScaleCtrl.java
deleted file mode 100644 (file)
index d155e3a..0000000
+++ /dev/null
@@ -1,790 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, 2008, 2010 Intel Corporation and others.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: TimeScaleCtrl.java,v 1.5 2008/06/16 21:04:49 jkubasta Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import java.text.SimpleDateFormat;\r
-import java.util.Calendar;\r
-import java.util.Date;\r
-import java.util.GregorianCalendar;\r
-import java.util.TimeZone;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.Utils.Resolution;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseListener;\r
-import org.eclipse.swt.events.MouseMoveListener;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-public class TimeScaleCtrl extends TraceCtrl implements MouseListener,\r
-               MouseMoveListener {\r
-\r
-       public TimeScaleCtrl(Composite parent, TraceColorScheme colors) {\r
-               super(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS\r
-                               | SWT.DOUBLE_BUFFERED);\r
-               addMouseListener(this);\r
-               addMouseMoveListener(this);\r
-       }\r
-\r
-    private static final long SEC_IN_NS = 1000000000;\r
-    private static final long MIN_IN_NS = 60 * SEC_IN_NS;\r
-    private static final long HOUR_IN_NS = 60 * MIN_IN_NS;\r
-    private static final long DAY_IN_NS = 24 * HOUR_IN_NS;\r
-    private static final long MONTH_IN_NS = 31 * DAY_IN_NS; // upper limit\r
-    private static final long YEAR_IN_NS = 366 * DAY_IN_NS; // upper limit\r
-    \r
-    private static final double LOG10_1 = Math.log10(1);\r
-    private static final double LOG10_2 = Math.log10(2);\r
-    private static final double LOG10_3 = Math.log10(3);\r
-    private static final double LOG10_5 = Math.log10(5);\r
-    \r
-    private static final Calendar GREGORIAN_CALENDAR = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
-    \r
-       private ITimeDataProvider _timeProvider;\r
-       private int _dragState = 0;\r
-       private int _dragX0 = 0;\r
-       private int _dragX = 0;\r
-       private long _time0bak;\r
-       private long _time1bak;\r
-       private boolean _isInUpdate;\r
-       private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
-    private int _height;\r
-\r
-       public void setTimeProvider(ITimeDataProvider timeProvider) {\r
-               _timeProvider = timeProvider;\r
-       }\r
-\r
-       private long _timeDelta;\r
-\r
-       @Override\r
-    public Point computeSize(int wHint, int hHint, boolean changed) {\r
-        return super.computeSize(wHint, _height, changed);\r
-    }\r
-\r
-    public void setHeight(int height) {\r
-        this._height = height;\r
-    }\r
-    \r
-    private void calcTimeDelta(int width, double pixelsPerNanoSec) {\r
-        double minDelta = (double) ((pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec);\r
-        long unit = 1;\r
-        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
-            if (minDelta > 6 * MONTH_IN_NS) {\r
-                unit = YEAR_IN_NS;\r
-            } else if (minDelta > 3 * MONTH_IN_NS) {\r
-                unit = 6 * MONTH_IN_NS;\r
-            } else if (minDelta > 10 * DAY_IN_NS) {\r
-                unit = MONTH_IN_NS;\r
-            } else if (minDelta > 12 * HOUR_IN_NS) {\r
-                unit = DAY_IN_NS;\r
-            } else if (minDelta > 3 * HOUR_IN_NS) {\r
-                unit = 6 * HOUR_IN_NS;\r
-            } else if (minDelta > 30 * MIN_IN_NS) {\r
-                unit = HOUR_IN_NS;\r
-            } else if (minDelta > 10 * MIN_IN_NS) {\r
-                unit = 15 * MIN_IN_NS;\r
-            } else if (minDelta > 30 * SEC_IN_NS) {\r
-                unit = MIN_IN_NS;\r
-            } else if (minDelta > 20 * SEC_IN_NS) {\r
-                unit = 30 * SEC_IN_NS;\r
-            } else if (minDelta <= 1) {\r
-                _timeDelta = 1;\r
-                return;\r
-            }\r
-        }\r
-        double log = Math.log10((double) minDelta / unit);\r
-        long pow10 = (long) log;\r
-        double remainder = log - pow10;\r
-        if (remainder < LOG10_1) {\r
-            _timeDelta = (long) Math.pow(10, pow10) * unit;\r
-        } else if (remainder < LOG10_2) {\r
-            _timeDelta = 2 * (long) Math.pow(10, pow10) * unit;\r
-        } else if (remainder < LOG10_3 && unit >= HOUR_IN_NS && unit < YEAR_IN_NS) {\r
-            _timeDelta = 3 * (long) Math.pow(10, pow10) * unit;\r
-        } else if (remainder < LOG10_5) {\r
-            _timeDelta = 5 * (long) Math.pow(10, pow10) * unit;\r
-        } else {\r
-            _timeDelta = 10 * (long) Math.pow(10, pow10) * unit;\r
-        }\r
-    }\r
-\r
-    private static TimeDraw TIMEDRAW_NANOSEC = new TimeDrawNanosec();\r
-    private static TimeDraw TIMEDRAW_MICROSEC = new TimeDrawMicrosec();\r
-    private static TimeDraw TIMEDRAW_MILLISEC = new TimeDrawMillisec();\r
-    private static TimeDraw TIMEDRAW_SEC = new TimeDrawSec();\r
-    private static TimeDraw TIMEDRAW_ABS_NANOSEC = new TimeDrawAbsNanoSec();\r
-    private static TimeDraw TIMEDRAW_ABS_MICROSEC = new TimeDrawAbsMicroSec();\r
-    private static TimeDraw TIMEDRAW_ABS_MILLISEC = new TimeDrawAbsMillisec();\r
-    private static TimeDraw TIMEDRAW_ABS_SEC = new TimeDrawAbsSec();\r
-    private static TimeDraw TIMEDRAW_ABS_MIN = new TimeDrawAbsMin();\r
-    private static TimeDraw TIMEDRAW_ABS_HRS = new TimeDrawAbsHrs();\r
-    private static TimeDraw TIMEDRAW_ABS_DAY = new TimeDrawAbsDay();\r
-    private static TimeDraw TIMEDRAW_ABS_MONTH = new TimeDrawAbsMonth();\r
-    private static TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();\r
-\r
-       TimeDraw getTimeDraw(long timeDelta) {\r
-               TimeDraw timeDraw;\r
-               if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
-            if (timeDelta >= YEAR_IN_NS)\r
-                timeDraw = TIMEDRAW_ABS_YEAR;\r
-            else if (timeDelta >= MONTH_IN_NS)\r
-                timeDraw = TIMEDRAW_ABS_MONTH;\r
-            else if (timeDelta >= DAY_IN_NS)\r
-                timeDraw = TIMEDRAW_ABS_DAY;\r
-            else if (timeDelta >= HOUR_IN_NS)\r
-                timeDraw = TIMEDRAW_ABS_HRS;\r
-            else if (timeDelta >= MIN_IN_NS)\r
-                timeDraw = TIMEDRAW_ABS_MIN;\r
-            else if (timeDelta >= SEC_IN_NS)\r
-                timeDraw = TIMEDRAW_ABS_SEC;\r
-                       else if (timeDelta >= 1000000)\r
-                               timeDraw = TIMEDRAW_ABS_MILLISEC;\r
-                       else if (timeDelta >= 1000)\r
-                               timeDraw = TIMEDRAW_ABS_MICROSEC;\r
-                       else\r
-                               timeDraw = TIMEDRAW_ABS_NANOSEC;\r
-                       return timeDraw;\r
-               }\r
-               if (timeDelta >= 1000000000)\r
-                       timeDraw = TIMEDRAW_SEC;\r
-               else if (timeDelta >= 1000000)\r
-                       timeDraw = TIMEDRAW_MILLISEC;\r
-               else if (timeDelta >= 1000)\r
-                       timeDraw = TIMEDRAW_MICROSEC;\r
-               else\r
-                       timeDraw = TIMEDRAW_NANOSEC;\r
-               return timeDraw;\r
-       }\r
-\r
-       @Override\r
-       void paint(Rectangle rect, PaintEvent e) {\r
-\r
-               if (_isInUpdate || null == _timeProvider)\r
-                       return;\r
-\r
-               GC gc = e.gc;\r
-               gc.fillRectangle(rect);\r
-               \r
-               long time0 = _timeProvider.getTime0();\r
-               long time1 = _timeProvider.getTime1();\r
-               long selectedTime = _timeProvider.getSelectedTime();\r
-               int leftSpace = _timeProvider.getNameSpace();\r
-               int timeSpace = _timeProvider.getTimeSpace();\r
-               \r
-               gc.setBackground(_colors.getColor(TraceColorScheme.TOOL_BACKGROUND));\r
-               gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND));\r
-               Utils.init(_rect0, rect);\r
-               \r
-               // draw top left area\r
-               _rect0.width = leftSpace;\r
-               _rect0.x += 4;\r
-               _rect0.width -= 4;\r
-               if (_rect0.width > 0) {\r
-                   Utils.drawText(gc, Messages.TimeScaleCtrl_Timescale + ":", _rect0, true); //$NON-NLS-1$\r
-               }\r
-               int messageWidth = gc.stringExtent(Messages.TimeScaleCtrl_Timescale + ":").x + 4; //$NON-NLS-1$\r
-               Rectangle absHeaderRect = new Rectangle(_rect0.x + messageWidth, _rect0.y, _rect0.width - messageWidth, _rect0.height);\r
-               _rect0.x -= 4;\r
-               _rect0.width += 4;\r
-               \r
-               // prepare and draw right rect of the timescale\r
-               _rect0.x += leftSpace;\r
-               _rect0.width = rect.width - leftSpace;\r
-               \r
-               // draw bottom border and erase all other area\r
-               gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1,\r
-                       rect.y + rect.height - 1);\r
-               _rect0.height--;\r
-               gc.fillRectangle(_rect0);\r
-               \r
-               if (time1 <= time0 || timeSpace < 2) {\r
-                   return;\r
-               }\r
-               \r
-               int numDigits = calculateDigits(time0, time1);\r
-               \r
-               int labelWidth = gc.getCharWidth('0') * numDigits;\r
-               double pixelsPerNanoSec = (timeSpace <= RIGHT_MARGIN) ? 0 :\r
-                   (double) (timeSpace - RIGHT_MARGIN) / (time1 - time0);\r
-               calcTimeDelta(labelWidth, pixelsPerNanoSec);\r
-               \r
-               TimeDraw timeDraw = getTimeDraw(_timeDelta);\r
-\r
-               // draw zoom rectangle\r
-        if (3 == _dragState && null != _timeProvider) {\r
-            if (_dragX0 < _dragX) {\r
-                gc.drawRectangle(leftSpace + _dragX0, rect.y, _dragX - _dragX0 - 1, rect.height - 8);\r
-            } else if (_dragX0 > _dragX) {\r
-                gc.drawRectangle(leftSpace + _dragX, rect.y, _dragX0 - _dragX - 1, rect.height - 8);\r
-            }\r
-        }\r
-\r
-               if (_rect0.isEmpty())\r
-                       return;\r
-\r
-               // draw selected time\r
-               int x = _rect0.x + (int) ((double)(selectedTime - time0) * pixelsPerNanoSec);\r
-               if (x >= _rect0.x && x < _rect0.x + _rect0.width) {\r
-                       gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
-                       gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y\r
-                                       + _rect0.height);\r
-                       gc\r
-                                       .setForeground(_colors\r
-                                                       .getColor(TraceColorScheme.TOOL_FOREGROUND));\r
-               }\r
-\r
-               // draw time scale ticks\r
-               _rect0.y = rect.y;\r
-               _rect0.height = rect.height - 4;\r
-               _rect0.width = labelWidth;\r
-               \r
-               long time;\r
-        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
-            time = floorToCalendar(time0, _timeDelta);\r
-        } else {\r
-            time = (long) (Math.ceil((double) time0 / _timeDelta) * _timeDelta);\r
-        }\r
-               \r
-               // long t = (long) (time * 1000000000);\r
-               int y = _rect0.y + _rect0.height;\r
-\r
-        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
-            timeDraw.drawAbsHeader(gc, time, absHeaderRect);\r
-        }\r
-               \r
-               while (true) {\r
-                       x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));\r
-                       if (x >= rect.x + leftSpace + rect.width - _rect0.width) {\r
-                               break;\r
-                       }\r
-                       if (x >= rect.x + leftSpace) {\r
-                               gc.drawLine(x, y, x, y + 4);\r
-                               _rect0.x = x;\r
-                               if (x + _rect0.width <= rect.x + rect.width)\r
-                                       timeDraw.draw(gc, time, _rect0);\r
-                       }\r
-                       if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - _timeDelta || _timeDelta == 0) {\r
-                           break;\r
-                       }\r
-                       time += _timeDelta;\r
-            if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
-                if (_timeDelta >= YEAR_IN_NS) {\r
-                    GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
-                    GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
-                    GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
-                    time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
-                } else if (_timeDelta >= MONTH_IN_NS) {\r
-                    GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
-                    GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
-                    time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
-                }\r
-            }\r
-               }\r
-       }\r
-\r
-       private long floorToCalendar(long time, long timeDelta) {\r
-        if (_timeDelta >= YEAR_IN_NS) {\r
-            GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
-            int year = GREGORIAN_CALENDAR.get(Calendar.YEAR);\r
-            int yearDelta = (int) (timeDelta / YEAR_IN_NS);\r
-            year = (year / yearDelta) * yearDelta;\r
-            GREGORIAN_CALENDAR.set(Calendar.YEAR, year);\r
-            GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
-            GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
-            GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
-            GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
-            GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
-            GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
-            time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
-        } else if (_timeDelta >= MONTH_IN_NS) {\r
-            GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
-            int month = GREGORIAN_CALENDAR.get(Calendar.MONTH);\r
-            int monthDelta = (int) (timeDelta / MONTH_IN_NS);\r
-            month = (month / monthDelta) * monthDelta;\r
-            GREGORIAN_CALENDAR.set(Calendar.MONTH, month);\r
-            GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
-            GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
-            GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
-            GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
-            GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
-            time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
-        } else {\r
-            time = (time / timeDelta) * timeDelta;\r
-        }\r
-        return time;\r
-       }\r
-       \r
-       private int calculateDigits(long time0, long time1) {\r
-               int numDigits = 5;\r
-               long timeRange = time1 - time0;\r
-\r
-               if (_timeProvider.isCalendarFormat()) {\r
-                       // Calculate the number of digits to represent the minutes provided\r
-                       // 11:222\r
-                       // HH:mm:ss\r
-                       numDigits += 8;\r
-                       if (timeRange < 10000) {\r
-                               // HH:11:222:333:444__\r
-                               numDigits += 10;\r
-                       } else if (timeRange < 10000000) {\r
-                               // HH:11:222:333__\r
-                               numDigits += 6;\r
-                       }\r
-               } else {\r
-                       // Calculate the number of digits to represent the minutes provided\r
-                       long min = (long) ((time1 * 1E-9) / 60); // to sec then to minutes\r
-                       String strMinutes = String.valueOf(min);\r
-                       // 11:222\r
-                       if (strMinutes != null) {\r
-                               numDigits += strMinutes.length();\r
-                       } else {\r
-                               numDigits += 2;\r
-                       }\r
-                       if (timeRange < 10000) {\r
-                               // 11:222:333:444__\r
-                               numDigits += 8;\r
-                       } else if (timeRange < 10000000) {\r
-                               // 11:222:333__\r
-                               numDigits += 4;\r
-                       }\r
-               }\r
-\r
-//             Trace.debug("timeRange: " + timeRange + " numDigits: " + numDigits);\r
-               return numDigits;\r
-       }\r
-\r
-       @Override\r
-       public void mouseDown(MouseEvent e) {\r
-           if (_dragState == 0 && null != _timeProvider) {\r
-               if (1 == e.button) {\r
-                   setCapture(true);\r
-                   _dragState = 1;\r
-               } else if (3 == e.button) {\r
-                   _dragState = 3;\r
-               }\r
-               int x = e.x - _timeProvider.getNameSpace();\r
-               if (x < 0) {\r
-                   x = 0;\r
-               } else if (x > getSize().x - _timeProvider.getNameSpace()) {\r
-                   x = getSize().x - _timeProvider.getNameSpace();\r
-               }\r
-               _dragX = _dragX0 = x;\r
-               _time0bak = _timeProvider.getTime0();\r
-               _time1bak = _timeProvider.getTime1();\r
-           }\r
-       }\r
-\r
-       @Override\r
-       public void mouseUp(MouseEvent e) {\r
-               if (e.button == 1 && _dragState == 1) {\r
-                       setCapture(false);\r
-                       _dragState = 0;\r
-                       \r
-               // Notify time provider to check the need for listener notification\r
-                       if (_dragX != _dragX0) {\r
-                           _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
-                       }\r
-               } else if (e.button == 3 && _dragState == 3 && null != _timeProvider) {\r
-                   _dragState = 0;\r
-                       if (_dragX0 == _dragX) {\r
-                               return;\r
-                       }\r
-                       int timeSpace = _timeProvider.getTimeSpace();\r
-                       int leftSpace = _timeProvider.getNameSpace();\r
-                       int x = e.x - leftSpace;\r
-                       if (timeSpace > 0) {\r
-                               _dragX = x;\r
-                               if (_dragX0 > _dragX) { // drag right to left\r
-                                   _dragX = _dragX0;\r
-                                   _dragX0 = x;\r
-                               }\r
-                               long time0 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / timeSpace));\r
-                               long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX / timeSpace));\r
-\r
-                               _timeProvider.setStartFinishTimeNotify(time0, time1);\r
-                   _time0bak = _timeProvider.getTime0();\r
-                   _time1bak = _timeProvider.getTime1();\r
-                       }\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void mouseMove(MouseEvent e) {\r
-               if (_dragX0 < 0 || _dragState == 0 || _timeProvider == null) {\r
-                       return;\r
-               }\r
-               Point size = getSize();\r
-               int leftSpace = _timeProvider.getNameSpace();\r
-               int timeSpace = _timeProvider.getTimeSpace();\r
-               int x = e.x - leftSpace;\r
-               if (1 == _dragState) {\r
-                       if (x > 0 && size.x > leftSpace && _dragX != x) {\r
-                               _dragX = x;\r
-                               long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / _dragX));\r
-                               _timeProvider.setStartFinishTime(_time0bak, time1);\r
-                       }\r
-               } else if (3 == _dragState) {\r
-                   if (x < 0) {\r
-                       _dragX = 0;\r
-                   } else if (x > timeSpace) {\r
-                       _dragX = timeSpace;\r
-                   } else {\r
-                _dragX = x;\r
-            }\r
-                   redraw();\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public void mouseDoubleClick(MouseEvent e) {\r
-               if (null != _timeProvider) {\r
-                       _timeProvider.resetStartFinishTime();\r
-            _time0bak = _timeProvider.getTime0();\r
-            _time1bak = _timeProvider.getTime1();\r
-               }\r
-       }\r
-}\r
-\r
-abstract class TimeDraw {\r
-       static String S   = ":"  ; //$NON-NLS-1$\r
-       static String S0  = ":0" ; //$NON-NLS-1$\r
-       static String S00 = ":00"; //$NON-NLS-1$\r
-    protected static final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");          //$NON-NLS-1$\r
-    protected static final SimpleDateFormat stimeformatheader = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$\r
-    protected static final SimpleDateFormat sminformat = new SimpleDateFormat("HH:mm");              //$NON-NLS-1$\r
-    protected static final SimpleDateFormat sminformatheader = new SimpleDateFormat("yyyy MMM dd");  //$NON-NLS-1$\r
-    protected static final SimpleDateFormat shrsformat = new SimpleDateFormat("MMM dd HH:mm");              //$NON-NLS-1$\r
-    protected static final SimpleDateFormat shrsformatheader = new SimpleDateFormat("yyyy");         //$NON-NLS-1$\r
-    protected static final SimpleDateFormat sdayformat = new SimpleDateFormat("MMM dd");             //$NON-NLS-1$\r
-    protected static final SimpleDateFormat sdayformatheader = new SimpleDateFormat("yyyy");         //$NON-NLS-1$\r
-    protected static final SimpleDateFormat smonthformat = new SimpleDateFormat("yyyy MMM");         //$NON-NLS-1$\r
-    protected static final SimpleDateFormat syearformat = new SimpleDateFormat("yyyy");              //$NON-NLS-1$\r
-    static {\r
-        stimeformat.setTimeZone(TimeZone.getTimeZone("GMT"));       //$NON-NLS-1$\r
-        stimeformatheader.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
-        sminformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
-        sminformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
-        shrsformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
-        shrsformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
-        sdayformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
-        sdayformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
-        smonthformat.setTimeZone(TimeZone.getTimeZone("GMT"));      //$NON-NLS-1$\r
-        syearformat.setTimeZone(TimeZone.getTimeZone("GMT"));       //$NON-NLS-1$\r
-    }\r
-       \r
-       static String pad(long n) {\r
-               String s = S;\r
-               if (n < 10)\r
-                       s = S00;\r
-               else if (n < 100)\r
-                       s = S0;\r
-               return s + n;\r
-       }\r
-\r
-    public abstract void draw(GC gc, long time, Rectangle rect);\r
-\r
-    public void drawAbsHeader(GC gc, long time, Rectangle absHeaderRect) {\r
-        // Override to draw absolute time header\r
-        // This is for the time information not shown in the draw of each tick\r
-    }\r
-    \r
-       public abstract String hint();\r
-}\r
-\r
-class TimeDrawSec extends TimeDraw {\r
-       static String _hint = "sec"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               time /= 1000000000;\r
-               Utils.drawText(gc, time + "", rect, true); //$NON-NLS-1$\r
-       }\r
-\r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
-\r
-class TimeDrawMillisec extends TimeDraw {\r
-       static String _hint = "s:ms"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               time /= 1000000;\r
-               long ms = time % 1000;\r
-               time /= 1000;\r
-               Utils.drawText(gc, time + pad(ms), rect, true);\r
-       }\r
-\r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
-\r
-class TimeDrawMicrosec extends TimeDraw {\r
-       static String _hint = "s:ms:mcs"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               time /= 1000;\r
-               long mcs = time % 1000;\r
-               time /= 1000;\r
-               long ms = time % 1000;\r
-               time /= 1000;\r
-               Utils.drawText(gc, time + pad(ms) + pad(mcs), rect, true);\r
-       }\r
-\r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
-\r
-class TimeDrawNanosec extends TimeDraw {\r
-       static String _hint = "s:ms:mcs:ns"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               long ns = time % 1000;\r
-               time /= 1000;\r
-               long mcs = time % 1000;\r
-               time /= 1000;\r
-               long ms = time % 1000;\r
-               time /= 1000;\r
-               Utils.drawText(gc, time + pad(ms) + pad(mcs) + pad(ns), rect, true);\r
-       }\r
-\r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
-\r
-class TimeDrawAbsYear extends TimeDraw {\r
-    static String _hint = "YYYY"; //$NON-NLS-1$\r
-\r
-    @Override\r
-    public void draw(GC gc, long time, Rectangle rect) {\r
-        String stime = syearformat.format(new Date((long) (time / 1000000)));\r
-        Utils.drawText(gc, stime, rect, true);\r
-    }\r
-\r
-    @Override\r
-    public String hint() {\r
-        return _hint;\r
-    }\r
-}\r
-\r
-class TimeDrawAbsMonth extends TimeDraw {\r
-    static String _hint = "YYYY Mmm"; //$NON-NLS-1$\r
-\r
-    @Override\r
-    public void draw(GC gc, long time, Rectangle rect) {\r
-        String stime = smonthformat.format(new Date((long) (time / 1000000)));\r
-        Utils.drawText(gc, stime, rect, true);\r
-    }\r
-\r
-    @Override\r
-    public String hint() {\r
-        return _hint;\r
-    }\r
-}\r
-\r
-class TimeDrawAbsDay extends TimeDraw {\r
-    static String _hint = "Mmm dd"; //$NON-NLS-1$\r
-\r
-    @Override\r
-    public void draw(GC gc, long time, Rectangle rect) {\r
-        String stime = sdayformat.format(new Date((long) (time / 1000000)));\r
-        Utils.drawText(gc, stime, rect, true);\r
-    }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = sdayformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-    @Override\r
-    public String hint() {\r
-        return _hint;\r
-    }\r
-}\r
-\r
-class TimeDrawAbsHrs extends TimeDraw {\r
-    static String _hint = "Mmm dd HH:mm"; //$NON-NLS-1$\r
-\r
-    @Override\r
-    public void draw(GC gc, long time, Rectangle rect) {\r
-        String stime = shrsformat.format(new Date((long) (time / 1000000)));\r
-        Utils.drawText(gc, stime, rect, true);\r
-    }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = shrsformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-    @Override\r
-    public String hint() {\r
-        return _hint;\r
-    }\r
-}\r
-\r
-class TimeDrawAbsMin extends TimeDraw {\r
-    static String _hint = "HH:mm"; //$NON-NLS-1$\r
-\r
-    @Override\r
-    public void draw(GC gc, long time, Rectangle rect) {\r
-        String stime = sminformat.format(new Date((long) (time / 1000000)));\r
-        Utils.drawText(gc, stime, rect, true);\r
-    }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = sminformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-    \r
-    @Override\r
-    public String hint() {\r
-        return _hint;\r
-    }\r
-}\r
-\r
-class TimeDrawAbsSec extends TimeDraw {\r
-    static String _hint = "HH:mm:ss"; //$NON-NLS-1$\r
-\r
-    @Override\r
-    public void draw(GC gc, long time, Rectangle rect) {\r
-        String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
-        Utils.drawText(gc, stime, rect, true);\r
-    }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-    @Override\r
-    public String hint() {\r
-        return _hint;\r
-    }\r
-}\r
-\r
-class TimeDrawAbsMillisec extends TimeDraw {\r
-       static String _hint = "HH:ss:ms"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
-               String ns = Utils.formatNs(time, Resolution.MILLISEC);\r
-\r
-               Utils.drawText(gc, stime + " " + ns, rect, true); //$NON-NLS-1$\r
-       }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
-\r
-class TimeDrawAbsMicroSec extends TimeDraw {\r
-       static String _hint = "HH:ss:ms:mcs"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
-               String micr = Utils.formatNs(time, Resolution.MICROSEC);\r
-               Utils.drawText(gc, stime + " " + micr, rect, true); //$NON-NLS-1$\r
-       }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
-\r
-class TimeDrawAbsNanoSec extends TimeDraw {\r
-       static String _hint = "HH:ss:ms:mcs:ns"; //$NON-NLS-1$\r
-\r
-       @Override\r
-       public void draw(GC gc, long time, Rectangle rect) {\r
-               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
-               String ns = Utils.formatNs(time, Resolution.NANOSEC);\r
-               Utils.drawText(gc, stime + " " + ns, rect, true); //$NON-NLS-1$\r
-       }\r
-\r
-    @Override\r
-    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
-        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
-        int headerwidth = gc.stringExtent(header).x + 4;\r
-        if (headerwidth <= rect.width) {\r
-            rect.x += (rect.width - headerwidth);\r
-            Utils.drawText(gc, header, rect, true);\r
-        }\r
-    }\r
-    \r
-       @Override\r
-       public String hint() {\r
-               return _hint;\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeStatesCtrl.java
deleted file mode 100644 (file)
index 1f233af..0000000
+++ /dev/null
@@ -1,2173 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, 2008 Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: ThreadStatesCtrl.java,v 1.15 2008/07/11 13:49:01 aalexeev Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.Iterator;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Vector;\r
-\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.TimeEvent;\r
-import org.eclipse.osgi.util.NLS;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.ControlEvent;\r
-import org.eclipse.swt.events.ControlListener;\r
-import org.eclipse.swt.events.FocusEvent;\r
-import org.eclipse.swt.events.FocusListener;\r
-import org.eclipse.swt.events.KeyEvent;\r
-import org.eclipse.swt.events.KeyListener;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseListener;\r
-import org.eclipse.swt.events.MouseMoveListener;\r
-import org.eclipse.swt.events.MouseTrackListener;\r
-import org.eclipse.swt.events.MouseWheelListener;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.events.TraverseEvent;\r
-import org.eclipse.swt.events.TraverseListener;\r
-import org.eclipse.swt.graphics.Cursor;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Event;\r
-import org.eclipse.swt.widgets.Listener;\r
-import org.eclipse.swt.widgets.ScrollBar;\r
-\r
-/**\r
- * @author alvaro\r
- * \r
- */\r
-public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider {\r
-\r
-    private static final int DRAG_NONE = 0;\r
-    private static final int DRAG_TRACE_ITEM = 1;\r
-    private static final int DRAG_GROUP_ITEM = 2;\r
-    private static final int DRAG_SPLIT_LINE = 3;\r
-    public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;\r
-    public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;\r
-    public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;\r
-    public static final int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;\r
-\r
-    private static final double zoomCoeff = 1.5;\r
-\r
-    private ITimeDataProvider _timeProvider;\r
-    private boolean _isInFocus = false;\r
-    private boolean _isDragCursor3 = false;\r
-    private boolean _isWaitCursor = true;\r
-    private boolean _mouseHover = false;\r
-    private int _itemHeightDefault = 19;\r
-    private int _itemHeight = _itemHeightDefault;\r
-    private int _minimumItemWidth = 0;\r
-    private int _topItem = 0;\r
-    private int _dragState = DRAG_NONE;\r
-    private int _hitIdx = 0;\r
-    private int _dragX0 = 0;\r
-    private int _dragX = 0;\r
-    private int _idealNameWidth = 0;\r
-    // private double _timeStep = 10000000;\r
-    private long _time0bak;\r
-    private long _time1bak;\r
-    private TmfTimeAnalysisProvider utilImpl = null;\r
-    private ItemData _data = null;\r
-    private List<SelectionListener> _selectionListeners;\r
-    private List<ISelectionChangedListener> _selectionChangedListeners = new ArrayList<ISelectionChangedListener>();\r
-    private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
-    private Rectangle _rect1 = new Rectangle(0, 0, 0, 0);\r
-    private Cursor _dragCursor3;\r
-    private Cursor _WaitCursor;\r
-    private boolean drawTracesInteraction = false;\r
-    private boolean drawTraceJoins = DEFAULT_DRAW_THREAD_JOIN;\r
-    private boolean drawTraceWaits = DEFAULT_DRAW_THREAD_WAIT;\r
-    private boolean drawTraceReleases = DEFAULT_DRAW_THREAD_RELEASE;\r
-\r
-    // Vertical formatting formatting for the state control view\r
-    private boolean _visibleVerticalScroll = true;\r
-    private int _borderWidth = 0;\r
-    private int _headerHeight = 0;\r
-\r
-    private Listener mouseScrollFilterListener;\r
-\r
-    public TmfTimeStatesCtrl(Composite parent, TraceColorScheme colors, TmfTimeAnalysisProvider rutilImp) {\r
-\r
-        super(parent, colors, SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL | SWT.DOUBLE_BUFFERED);\r
-\r
-        this.utilImpl = rutilImp;\r
-        _data = new ItemData(utilImpl);\r
-\r
-        addFocusListener(this);\r
-        addMouseListener(this);\r
-        addMouseMoveListener(this);\r
-        addMouseTrackListener(this);\r
-        addMouseWheelListener(this);\r
-        addTraverseListener(this);\r
-        addKeyListener(this);\r
-        addControlListener(this);\r
-        ScrollBar scrollVer = getVerticalBar();\r
-        ScrollBar scrollHor = getHorizontalBar();\r
-        if (scrollVer != null) {\r
-            scrollVer.addSelectionListener(this);\r
-            scrollVer.setVisible(_visibleVerticalScroll);\r
-        }\r
-\r
-        if (scrollHor != null) {\r
-            scrollHor.addSelectionListener(this);\r
-        }\r
-\r
-        _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);\r
-        _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);\r
-    }\r
-\r
-    @Override\r
-    public void dispose() {\r
-        super.dispose();\r
-        _dragCursor3.dispose();\r
-        _WaitCursor.dispose();\r
-    }\r
-\r
-    public void setTimeProvider(ITimeDataProvider timeProvider) {\r
-        _timeProvider = timeProvider;\r
-        adjustScrolls();\r
-        redraw();\r
-    }\r
-\r
-    public void addSelectionListener(SelectionListener listener) {\r
-        if (listener == null)\r
-            SWT.error(SWT.ERROR_NULL_ARGUMENT);\r
-        if (null == _selectionListeners)\r
-            _selectionListeners = new ArrayList<SelectionListener>();\r
-        _selectionListeners.add(listener);\r
-    }\r
-\r
-    public void removeSelectionListener(SelectionListener listener) {\r
-        if (null != _selectionListeners)\r
-            _selectionListeners.remove(listener);\r
-    }\r
-\r
-    public void fireSelectionChanged() {\r
-        if (null != _selectionListeners) {\r
-            Iterator<SelectionListener> it = _selectionListeners.iterator();\r
-            while (it.hasNext()) {\r
-                SelectionListener listener = it.next();\r
-                listener.widgetSelected(null);\r
-            }\r
-        }\r
-    }\r
-\r
-    public void fireDefaultSelection() {\r
-        if (null != _selectionListeners) {\r
-            Iterator<SelectionListener> it = _selectionListeners.iterator();\r
-            while (it.hasNext()) {\r
-                SelectionListener listener = it.next();\r
-                listener.widgetDefaultSelected(null);\r
-            }\r
-        }\r
-    }\r
-\r
-    public Object[] getTraces() {\r
-        return _data.getTraces();\r
-    }\r
-\r
-    public boolean[] getTraceFilter() {\r
-        return _data.getTraceFilter();\r
-    }\r
-\r
-    public void refreshData() {\r
-        _data.refreshData();\r
-        adjustScrolls();\r
-        redraw();\r
-    }\r
-\r
-    public void refreshData(Object traces[]) {\r
-        _data.refreshData(traces);\r
-        adjustScrolls();\r
-        redraw();\r
-    }\r
-\r
-    public void refreshPartial(ITmfTimeAnalysisEntry parent, TimeEvent item) {\r
-        _data.refreshPartial(parent, item);\r
-        adjustScrolls();\r
-        redraw();\r
-    }\r
-\r
-    public void adjustScrolls() {\r
-        if (null == _timeProvider) {\r
-            getVerticalBar().setValues(0, 1, 1, 1, 1, 1);\r
-            getHorizontalBar().setValues(0, 1, 1, 1, 1, 1);\r
-            return;\r
-        }\r
-\r
-        // Vertical scroll bar\r
-        int page = countPerPage();\r
-        if (_topItem + page > _data._items.length)\r
-            _topItem = _data._items.length - page;\r
-        if (_topItem < 0)\r
-            _topItem = 0;\r
-        getVerticalBar().setValues(_topItem, 0, _data._items.length, page, 1, page);\r
-\r
-        // HORIZONTAL BAR\r
-        // Visible window\r
-        long time0 = _timeProvider.getTime0();\r
-        long time1 = _timeProvider.getTime1();\r
-        // Time boundaries\r
-        long timeMin = _timeProvider.getMinTime();\r
-        long timeMax = _timeProvider.getMaxTime();\r
-\r
-        long delta = timeMax - timeMin;\r
-\r
-        int timePos = 0;\r
-        int thumb = H_SCROLLBAR_MAX;\r
-\r
-        if (delta != 0) {\r
-            // Thumb size (page size)\r
-            thumb = Math.max(1, (int) (H_SCROLLBAR_MAX * ((double) (time1 - time0) / delta)));\r
-            // At the beginning of visible window\r
-            timePos = (int) (H_SCROLLBAR_MAX * ((double) (time0 - timeMin) / delta));\r
-        }\r
-\r
-        // position, minimum, maximum, thumb size, increment (half page)t, page\r
-        // increment size (full page)\r
-        getHorizontalBar().setValues(timePos, 0, H_SCROLLBAR_MAX, thumb, Math.max(1, thumb / 2), Math.max(2, thumb));\r
-    }\r
-\r
-    boolean ensureVisibleItem(int idx, boolean redraw) {\r
-        boolean changed = false;\r
-        if (idx < 0) {\r
-            for (idx = 0; idx < _data._items.length; idx++) {\r
-                if (((Item) _data._items[idx])._selected)\r
-                    break;\r
-            }\r
-        }\r
-        if (idx >= _data._items.length)\r
-            return changed;\r
-        if (idx < _topItem) {\r
-            _topItem = idx;\r
-            getVerticalBar().setSelection(_topItem);\r
-            if (redraw)\r
-                redraw();\r
-            changed = true;\r
-        } else {\r
-            int page = countPerPage();\r
-            if (idx >= _topItem + page) {\r
-                _topItem = idx - page + 1;\r
-                getVerticalBar().setSelection(_topItem);\r
-                if (redraw)\r
-                    redraw();\r
-                changed = true;\r
-            }\r
-        }\r
-        return changed;\r
-    }\r
-\r
-    public void setTopIndex(int idx) {\r
-        idx = Math.min(idx, _data._items.length - countPerPage());\r
-        idx = Math.max(0,  idx);\r
-        _topItem = idx;\r
-        getVerticalBar().setSelection(_topItem);\r
-        redraw();\r
-    }\r
-\r
-    @Override\r
-    public ISelection getSelection() {\r
-        PlainSelection sel = new PlainSelection();\r
-        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
-        if (null != trace && null != _timeProvider) {\r
-            long selectedTime = _timeProvider.getSelectedTime();\r
-            ITimeEvent event = Utils.findEvent(trace, selectedTime, 0);\r
-            if (event != null)\r
-                sel.add(event);\r
-            else\r
-                sel.add(trace);\r
-        }\r
-        return sel;\r
-    }\r
-\r
-    public ISelection getSelectionTrace() {\r
-        PlainSelection sel = new PlainSelection();\r
-        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
-        if (null != trace) {\r
-            sel.add(trace);\r
-        }\r
-        return sel;\r
-    }\r
-\r
-    public void selectTrace(int n) {\r
-        if (n != 1 && n != -1)\r
-            return;\r
-        boolean changed = false;\r
-        int lastSelection = -1;\r
-        for (int i = 0; i < _data._items.length; i++) {\r
-            Item item = (Item) _data._items[i];\r
-            if (item._selected) {\r
-                lastSelection = i;\r
-                if (1 == n && i < _data._items.length - 1) {\r
-                    item._selected = false;\r
-                    if (item._hasChildren)\r
-                        _data.expandItem(i, true);\r
-                    item = (Item) _data._items[i + 1];\r
-                    if (item._hasChildren) {\r
-                        _data.expandItem(i + 1, true);\r
-                        item = (Item) _data._items[i + 2];\r
-                    }\r
-                    item._selected = true;\r
-                    changed = true;\r
-                } else if (-1 == n && i > 0) {\r
-                    i--;\r
-                    Item prevItem = (Item) _data._items[i];\r
-                    if (prevItem._hasChildren) {\r
-                        if (prevItem._expanded) {\r
-                            if (i > 0) {\r
-                                i--;\r
-                                prevItem = (Item) _data._items[i];\r
-                            }\r
-                        }\r
-                        if (!prevItem._expanded) {\r
-                            int added = _data.expandItem(i, true);\r
-                            prevItem = (Item) _data._items[i + added];\r
-                            item._selected = false;\r
-                            prevItem._selected = true;\r
-                            changed = true;\r
-                        }\r
-                    } else {\r
-                        item._selected = false;\r
-                        prevItem._selected = true;\r
-                        changed = true;\r
-                    }\r
-                }\r
-                break;\r
-            }\r
-        }\r
-        if (lastSelection < 0 && _data._items.length > 0) {\r
-            Item item = (Item) _data._items[0];\r
-            if (item._hasChildren) {\r
-                _data.expandItem(0, true);\r
-                item = (Item) _data._items[1];\r
-                item._selected = true;\r
-                changed = true;\r
-            } else {\r
-                item._selected = true;\r
-                changed = true;\r
-            }\r
-        }\r
-        if (changed) {\r
-            ensureVisibleItem(-1, false);\r
-            redraw();\r
-            fireSelectionChanged();\r
-        }\r
-    }\r
-\r
-    public void selectEvent(int n) {\r
-        if (null == _timeProvider)\r
-            return;\r
-        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
-        if (trace == null)\r
-            return;\r
-        long selectedTime = _timeProvider.getSelectedTime();\r
-        long endTime = _timeProvider.getEndTime();\r
-        ITimeEvent nextEvent;\r
-        if (-1 == n && selectedTime > endTime)\r
-            nextEvent = Utils.findEvent(trace, selectedTime, 0);\r
-        else\r
-            nextEvent = Utils.findEvent(trace, selectedTime, n);\r
-        if (null == nextEvent && -1 == n)\r
-            nextEvent = Utils.getFirstEvent(trace);\r
-        if (null != nextEvent) {\r
-            long nextTime = nextEvent.getTime();\r
-            // If last event detected e.g. going back or not moving to a next\r
-            // event\r
-            if (nextTime <= selectedTime && n == 1) {\r
-                // Select to the end of this last event\r
-                nextTime = nextEvent.getTime() + nextEvent.getDuration();\r
-                // but not beyond the end of the trace\r
-                if (nextTime > endTime) {\r
-                    nextTime = endTime;\r
-                }\r
-            }\r
-            _timeProvider.setSelectedTimeInt(nextTime, true);\r
-            fireSelectionChanged();\r
-        } else if (1 == n) {\r
-            _timeProvider.setSelectedTimeInt(endTime, true);\r
-            fireSelectionChanged();\r
-        }\r
-    }\r
-\r
-    public void selectNextEvent() {\r
-        selectEvent(1);\r
-        // Notify if visible time window has been adjusted\r
-        _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
-    }\r
-\r
-    public void selectPrevEvent() {\r
-        selectEvent(-1);\r
-        // Notify if visible time window has been adjusted\r
-        _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
-    }\r
-\r
-    public void selectNextTrace() {\r
-        selectTrace(1);\r
-    }\r
-\r
-    public void selectPrevTrace() {\r
-        selectTrace(-1);\r
-    }\r
-\r
-    /**\r
-     * Zooming based on mouse cursor location with mouse scrolling\r
-     * \r
-     * @param zoomIn\r
-     */\r
-    public void zoom(boolean zoomIn) {\r
-        int globalX = getDisplay().getCursorLocation().x;\r
-        Point p = toControl(globalX, 0);\r
-        int nameSpace = _timeProvider.getNameSpace();\r
-        int timeSpace = _timeProvider.getTimeSpace();\r
-        int xPos = Math.max(nameSpace, Math.min(nameSpace + timeSpace, p.x));\r
-        long time0 = _timeProvider.getTime0();\r
-        long time1 = _timeProvider.getTime1();\r
-        long interval = time1 - time0;\r
-        if (interval == 0) {\r
-            interval = 1;\r
-        } // to allow getting out of single point interval\r
-        long newInterval;\r
-        if (zoomIn) {\r
-            newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());\r
-        } else {\r
-            newInterval = (long) Math.ceil((double) interval * 1.25);\r
-        }\r
-        long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));\r
-        long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);\r
-        long newTime1 = newTime0 + newInterval;\r
-        _timeProvider.setStartFinishTime(newTime0, newTime1);\r
-    }\r
-\r
-    /**\r
-     * zoom in using single click\r
-     */\r
-    public void zoomIn() {\r
-        long _time0 = _timeProvider.getTime0();\r
-        long _time1 = _timeProvider.getTime1();\r
-        long _range = _time1 - _time0;\r
-        long selTime = _timeProvider.getSelectedTime();\r
-        if (selTime <= _time0 || selTime >= _time1) {\r
-            selTime = (_time0 + _time1) / 2;\r
-        }\r
-        long time0 = selTime - (long) ((selTime - _time0) / zoomCoeff);\r
-        long time1 = selTime + (long) ((_time1 - selTime) / zoomCoeff);\r
-\r
-        long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);\r
-\r
-        // Trace.debug("selTime:" + selTime + " time0:" + time0 + " time1:"\r
-        // + time1 + " inaccuracy:" + inaccuracy);\r
-\r
-        if (inaccuracy > 0 && inaccuracy < 100) {\r
-            _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());\r
-            return;\r
-        }\r
-\r
-        long m = _timeProvider.getMinTimeInterval();\r
-        if ((time1 - time0) < m) {\r
-            time0 = selTime - (long) ((selTime - _time0) * m / _range);\r
-            time1 = time0 + m;\r
-        }\r
-\r
-        _timeProvider.setStartFinishTimeNotify(time0, time1);\r
-    }\r
-\r
-    /**\r
-     * zoom out using single click\r
-     */\r
-    public void zoomOut() {\r
-        long _time0 = _timeProvider.getTime0();\r
-        long _time1 = _timeProvider.getTime1();\r
-        long selTime = _timeProvider.getSelectedTime();\r
-        if (selTime <= _time0 || selTime >= _time1) {\r
-            selTime = (_time0 + _time1) / 2;\r
-        }\r
-        long time0 = (long) (selTime - (selTime - _time0) * zoomCoeff);\r
-        long time1 = (long) (selTime + (_time1 - selTime) * zoomCoeff);\r
-\r
-        long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);\r
-        if (inaccuracy > 0 && inaccuracy < 100) {\r
-            _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());\r
-            return;\r
-        }\r
-\r
-        _timeProvider.setStartFinishTimeNotify(time0, time1);\r
-    }\r
-\r
-    public void groupTraces(boolean on) {\r
-        _data.groupTraces(on);\r
-        adjustScrolls();\r
-        redraw();\r
-    }\r
-\r
-    public void toggleTraceInteractionDrawing() {\r
-        drawTracesInteraction = !drawTracesInteraction;\r
-        redraw();\r
-    }\r
-\r
-    public void setTraceJoinDrawing(boolean on) {\r
-        drawTraceJoins = on;\r
-        drawTracesInteraction = true;\r
-        redraw();\r
-    }\r
-\r
-    public void setTraceWaitDrawing(boolean on) {\r
-        drawTraceWaits = on;\r
-        drawTracesInteraction = true;\r
-        redraw();\r
-    }\r
-\r
-    public void setTraceReleaseDrawing(boolean on) {\r
-        drawTraceReleases = on;\r
-        drawTracesInteraction = true;\r
-        redraw();\r
-    }\r
-\r
-    public boolean getTracesInteractionDrawing() {\r
-        return drawTracesInteraction;\r
-    }\r
-\r
-    public boolean getTraceJoinDrawing() {\r
-        return drawTraceJoins;\r
-    }\r
-\r
-    public boolean getTraceWaitDrawing() {\r
-        return drawTraceWaits;\r
-    }\r
-\r
-    public boolean getTraceReleaseDrawing() {\r
-        return drawTraceReleases;\r
-    }\r
-\r
-    public ITmfTimeAnalysisEntry getSelectedTrace() {\r
-        ITmfTimeAnalysisEntry trace = null;\r
-        int idx = getSelectedIndex();\r
-        if (idx >= 0 && _data._items[idx] instanceof TraceItem)\r
-            trace = ((TraceItem) _data._items[idx])._trace;\r
-        return trace;\r
-    }\r
-\r
-    public int getSelectedIndex() {\r
-        int idx = -1;\r
-        for (int i = 0; i < _data._items.length; i++) {\r
-            Item item = (Item) _data._items[i];\r
-            if (item._selected) {\r
-                idx = i;\r
-                break;\r
-            }\r
-        }\r
-        return idx;\r
-    }\r
-\r
-    boolean toggle(int idx) {\r
-        boolean toggled = false;\r
-        if (idx >= 0 && idx < _data._items.length) {\r
-            Item item = (Item) _data._items[idx];\r
-            if (item._hasChildren) {\r
-                item._expanded = !item._expanded;\r
-                _data.updateItems();\r
-                adjustScrolls();\r
-                redraw();\r
-                toggled = true;\r
-            }\r
-        }\r
-        return toggled;\r
-    }\r
-\r
-    int hitTest(int x, int y) {\r
-        if (x < 0 || y < 0)\r
-            return -1;\r
-        int hit = -1;\r
-        int idx = y / _itemHeight;\r
-        idx += _topItem;\r
-        if (idx < _data._items.length)\r
-            hit = idx;\r
-        return hit;\r
-    }\r
-\r
-    int hitSplitTest(int x, int y) {\r
-        if (x < 0 || y < 0 || null == _timeProvider)\r
-            return -1;\r
-        int w = 4;\r
-        int hit = -1;\r
-        int nameWidth = _timeProvider.getNameSpace();\r
-        if (x > nameWidth - w && x < nameWidth + w)\r
-            hit = 1;\r
-        return hit;\r
-    }\r
-\r
-    Item getItem(Point pt) {\r
-        int idx = hitTest(pt.x, pt.y);\r
-        return idx >= 0 ? (Item) _data._items[idx] : null;\r
-    }\r
-\r
-    long hitTimeTest(int x) {\r
-        if (null == _timeProvider)\r
-            return -1;\r
-        long hitTime = -1;\r
-        Point size = getCtrlSize();\r
-        long time0 = _timeProvider.getTime0();\r
-        long time1 = _timeProvider.getTime1();\r
-        int nameWidth = _timeProvider.getNameSpace();\r
-        x -= nameWidth;\r
-        if (x >= 0 && size.x >= nameWidth) {\r
-            if (time1 - time0 > size.x - nameWidth - RIGHT_MARGIN) {\r
-                // get the last possible time represented by the pixel position\r
-                // by taking the time of the next pixel position minus 1\r
-                // nanosecond\r
-                hitTime = time0 + (long) ((time1 - time0) * ((double) (x + 1) / (size.x - nameWidth - RIGHT_MARGIN))) - 1;\r
-            } else {\r
-                hitTime = time0 + (long) ((time1 - time0) * ((double) (x) / (size.x - nameWidth - RIGHT_MARGIN)));\r
-            }\r
-        }\r
-        return hitTime;\r
-    }\r
-\r
-    void selectItem(int idx, boolean addSelection) {\r
-        boolean changed = false;\r
-        if (addSelection) {\r
-            if (idx >= 0 && idx < _data._items.length) {\r
-                Item item = (Item) _data._items[idx];\r
-                changed = (item._selected == false);\r
-                item._selected = true;\r
-            }\r
-        } else {\r
-            for (int i = 0; i < _data._items.length; i++) {\r
-                Item item = (Item) _data._items[i];\r
-                if (i == idx && item._selected == false) {\r
-                    changed = true;\r
-                }\r
-                item._selected = i == idx;\r
-            }\r
-        }\r
-        changed |= ensureVisibleItem(idx, true);\r
-        if (changed)\r
-            redraw();\r
-    }\r
-\r
-    public void selectItem(ITmfTimeAnalysisEntry trace, boolean addSelection) {\r
-        Integer idx = _data.findTraceItemIndex(trace);\r
-        if (idx != null) {\r
-            selectItem(idx, addSelection);\r
-        }\r
-    }\r
-\r
-    public int countPerPage() {\r
-        int height = getCtrlSize().y;\r
-        int count = 0;\r
-        if (height > 0)\r
-            count = height / _itemHeight;\r
-        return count;\r
-    }\r
-\r
-    public int getTopIndex() {\r
-        int idx = -1;\r
-        if (_data._items.length > 0)\r
-            idx = 0;\r
-        return idx;\r
-    }\r
-\r
-    public int getBottomIndex() {\r
-        int idx = _data._items.length - 1;\r
-        return idx;\r
-    }\r
-\r
-    Point getCtrlSize() {\r
-        Point size = getSize();\r
-        if (getVerticalBar().isVisible()) {\r
-            size.x -= getVerticalBar().getSize().x;\r
-        }\r
-        if (getHorizontalBar().isVisible()) {\r
-            size.y -= getHorizontalBar().getSize().y;\r
-        }\r
-        return size;\r
-    }\r
-\r
-    void getNameRect(Rectangle rect, Rectangle bound, int idx, int nameWidth) {\r
-        idx -= _topItem;\r
-        rect.x = bound.x;\r
-        rect.y = bound.y + idx * _itemHeight;\r
-        rect.width = nameWidth;\r
-        rect.height = _itemHeight;\r
-    }\r
-\r
-    void getStatesRect(Rectangle rect, Rectangle bound, int idx, int nameWidth) {\r
-        idx -= _topItem;\r
-        rect.x = bound.x + nameWidth;\r
-        rect.y = bound.y + idx * _itemHeight;\r
-        rect.width = bound.width - rect.x;\r
-        rect.height = _itemHeight;\r
-    }\r
-\r
-    // private int getTraceNumber(int tid) {\r
-    // int num = -1;\r
-    //\r
-    // Object[] items = _data._items;\r
-    // for (int i = _topItem; i < items.length; i++) {\r
-    // Item item = (Item) items[i];\r
-    // if ((item instanceof TraceItem)) {\r
-    // TsfTmTrace trace = ((TraceItem) item)._trace;\r
-    // if (trace != null && trace.getId() == tid) {\r
-    // num = i;\r
-    // break;\r
-    // }\r
-    // }\r
-    // }\r
-    //\r
-    // return num;\r
-    // }\r
-\r
-    // private void drawArrow(GC gc, int x0, int y0, int x1, int y1, Color c) {\r
-    // gc.setForeground(c);\r
-    // gc.drawLine(x0, y0, x1, y1);\r
-    //\r
-    // if (y1 > y0) {\r
-    // gc.drawLine(x1 - 3, y1 - 3, x1, y1);\r
-    // gc.drawLine(x1 + 3, y1 - 3, x1, y1);\r
-    // } else {\r
-    // gc.drawLine(x1 - 3, y1 + 3, x1, y1);\r
-    // gc.drawLine(x1 + 3, y1 + 3, x1, y1);\r
-    // }\r
-    // }\r
-\r
-    // TODO: CC: used in the removed functionality to draw thread interactions.\r
-    // private void drawTraceThreadEvent(Rectangle bound, TsfTmEvent e,\r
-    // TsfTmTrace trace, int nItem, int color, GC gc) {\r
-    // if (trace == null)\r
-    // return;\r
-    //\r
-    // int tid = trace.getId();\r
-    // if (tid < 0 || getTraceNumber(tid) == -1)\r
-    // return;\r
-    //\r
-    // int nameWidth = _timeProvider.getNameSpace();\r
-    //\r
-    // double time0 = _timeProvider.getTime0();\r
-    // double time1 = _timeProvider.getTime1();\r
-    // if (time0 == time1)\r
-    // return;\r
-    //\r
-    // int xr = bound.x + nameWidth;\r
-    // double K = (double) (bound.width - xr) / (time1 - time0);\r
-    //\r
-    // int x0 = xr + (int) ((e.getTime() - time0) * K);\r
-    // if (x0 < xr)\r
-    // x0 = xr;\r
-    //\r
-    // int x1 = xr + (int) ((trace.getStartTime() - time0) * K);\r
-    // if (x1 < xr)\r
-    // return;\r
-    //\r
-    // int y0 = bound.y + (nItem - _topItem) * _itemHeight + 3\r
-    // + (_itemHeight - 6) / 2;\r
-    // int y1 = bound.y + (getTraceNumber(tid) - _topItem) * _itemHeight + 3\r
-    // + (_itemHeight - 6) / 2;\r
-    //\r
-    // drawArrow(gc, x0, y0, x1, y1, _colors.getColor(color));\r
-    // }\r
-\r
-    public void drawTraceEvent(Rectangle bound, ITimeEvent e, int nItem, int color, GC gc) {\r
-        int nameWidth = _timeProvider.getNameSpace();\r
-\r
-        long time0 = _timeProvider.getTime0();\r
-        long time1 = _timeProvider.getTime1();\r
-        if (time0 == time1)\r
-            return;\r
-\r
-        int xr = bound.x + nameWidth;\r
-        double pixelsPerNanoSec = (bound.width - xr <= RIGHT_MARGIN) ? 0 : (double) (bound.width - xr - RIGHT_MARGIN) / (time1 - time0);\r
-\r
-        int x0 = xr + (int) ((e.getTime() - time0) * pixelsPerNanoSec);\r
-        if (x0 < xr)\r
-            return;\r
-\r
-        int y0 = bound.y + (nItem - _topItem) * _itemHeight + 3;\r
-\r
-        gc.setBackground(_colors.getColor(color));\r
-        int c[] = { x0 - 3, y0 - 3, x0, y0, x0 + 3, y0 - 3 };\r
-        gc.fillPolygon(c);\r
-    }\r
-\r
-    // TODO: CC:\r
-    // private void drawExecEvent(Rectangle bound, TsfTmTraceExecEventImpl e,\r
-    // int nitem, int color, GC gc) {\r
-    // List runnings = e.getRunningEvents();\r
-    // if (runnings == null)\r
-    // return;\r
-    //\r
-    // int nameWidth = _timeProvider.getNameSpace();\r
-    //\r
-    // double time0 = _timeProvider.getTime0();\r
-    // double time1 = _timeProvider.getTime1();\r
-    // if (time0 == time1)\r
-    // return;\r
-    //\r
-    // int xr = bound.x + nameWidth;\r
-    // double K = (double) (bound.width - xr) / (time1 - time0);\r
-    //\r
-    // int x0 = xr + (int) ((e.getTime() - time0) * K);\r
-    // if (x0 < xr)\r
-    // x0 = xr;\r
-    //\r
-    // Iterator it = runnings.iterator();\r
-    // while (it.hasNext()) {\r
-    // TsfTmTraceRunningEventImpl re = (TsfTmTraceRunningEventImpl) it\r
-    // .next();\r
-    // int tid = re.getThread().getId();\r
-    // if (tid < 0 || getThreadNumber(tid) == -1)\r
-    // continue;\r
-    //\r
-    // int x1 = xr + (int) ((re.getTime() - time0) * K);\r
-    // if (x1 < xr)\r
-    // continue;\r
-    //\r
-    // int y0 = bound.y + (nitem - _topItem) * _itemHeight + 3\r
-    // + (_itemHeight - 6) / 2;\r
-    // int y1 = bound.y + (getThreadNumber(tid) - _topItem) * _itemHeight\r
-    // + 3 + (_itemHeight - 6) / 2;\r
-    //\r
-    // drawArrow(gc, x0, y0, x1, y1, _colors.getColor(color));\r
-    // }\r
-    // }\r
-\r
-    public void drawTraceInteractions(Rectangle bound, GC gc) {\r
-        // int nameWidth = _timeProvider.getNameSpace();\r
-        // Object[] items = _data._items;\r
-        //\r
-        // double time0 = _timeProvider.getTime0();\r
-        // double time1 = _timeProvider.getTime1();\r
-        //\r
-        // if (time0 == time1)\r
-        // return;\r
-        //\r
-        // int xr = bound.x + nameWidth;\r
-        // double K = (double) (bound.width - xr) / (time1 - time0);\r
-\r
-        // for (int i = 0; i < items.length; i++) {\r
-        // Item item = (Item) items[i];\r
-        // if (!(item instanceof TraceItem))\r
-        // continue;\r
-        //\r
-        // TsfTmTrace trace = ((TraceItem) item)._trace;\r
-        // if (trace == null)\r
-        // continue;\r
-        //\r
-        // List<TsfTmEvent> list = trace.getTraceEvents();\r
-        // Iterator<TsfTmEvent> it = list.iterator();\r
-        // while (it.hasNext()) {\r
-        // TsfTmEvent te = (TsfTmEvent) it.next();\r
-        // TODO: CC: Thread Interactions,\r
-        // This needs to be accessed externally via a specific\r
-        // implementation.\r
-        // if (te instanceof TsfTmTraceStartThreadEventImpl) {\r
-        // TsfTmTrace child = ((TsfTmTraceStartThreadEventImpl) te)\r
-        // .getStartedThread();\r
-        // drawThreadThreadEvent(bound, te, child, i,\r
-        // TraceColorScheme.TI_START_THREAD, gc);\r
-        // } else if (te instanceof TsfTmTraceHandoffLockEventImpl) {\r
-        // if (drawThreadReleases)\r
-        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
-        // TraceColorScheme.TI_HANDOFF_LOCK, gc);\r
-        // } else if (te instanceof TsfTmTraceNotifyAllEventImpl) {\r
-        // if (drawThreadWaits)\r
-        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
-        // TraceColorScheme.TI_NOTIFY_ALL, gc);\r
-        // } else if (te instanceof TsfTmTraceNotifyEventImpl) {\r
-        // if (drawThreadWaits)\r
-        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
-        // TraceColorScheme.TI_NOTIFY, gc);\r
-        // } else if (te instanceof\r
-        // TsfTmTraceDeadAndNotifyJoinedEventImpl) {\r
-        // if (drawThreadJoins)\r
-        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
-        // TraceColorScheme.TI_NOTIFY_JOINED, gc);\r
-        // } else if (te instanceof TsfTmTraceInterruptThreadEventImpl)\r
-        // {\r
-        // if (drawThreadWaits)\r
-        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
-        // TraceColorScheme.TI_INTERRUPT, gc);\r
-        // } else if (te instanceof\r
-        // TsfTmTraceWaitTimeoutExceedEventImpl) {\r
-        // drawThreadEvent(bound, te, i,\r
-        // TraceColorScheme.TI_WAIT_EXCEEDED, gc);\r
-        // }\r
-        // }\r
-        // }\r
-    }\r
-\r
-    @Override\r
-    void paint(Rectangle bound, PaintEvent e) {\r
-        GC gc = e.gc;\r
-        gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND));\r
-        drawBackground(gc, bound.x, bound.y, bound.width, bound.height);\r
-\r
-        if (bound.width < 2 || bound.height < 2 || null == _timeProvider)\r
-            return;\r
-\r
-        _idealNameWidth = 0;\r
-        int nameWidth = _timeProvider.getNameSpace();\r
-        long time0 = _timeProvider.getTime0();\r
-        long time1 = _timeProvider.getTime1();\r
-        long endTime = _timeProvider.getEndTime();\r
-        long selectedTime = _timeProvider.getSelectedTime();\r
-        // draw trace states\r
-        Object[] items = _data._items;\r
-        for (int i = _topItem; i < items.length; i++) {\r
-            Item item = (Item) items[i];\r
-\r
-            getNameRect(_rect0, bound, i, nameWidth);\r
-            if (_rect0.y >= bound.y + bound.height)\r
-                break;\r
-\r
-            if (item instanceof GroupItem) {\r
-                getStatesRect(_rect1, bound, i, nameWidth);\r
-                _rect0.width += _rect1.width;\r
-                drawName(item, _rect0, gc);\r
-            } else {\r
-                drawName(item, _rect0, gc);\r
-            }\r
-            getStatesRect(_rect0, bound, i, nameWidth);\r
-            drawItemDataDurations(item, _rect0, time0, time1, endTime, selectedTime, gc);\r
-        }\r
-\r
-        if (drawTracesInteraction)\r
-            drawTraceInteractions(bound, e.gc);\r
-\r
-        // draw empty name space background\r
-        if (_itemHeight * items.length < bound.height) {\r
-            gc.setBackground(_colors.getBkColor(false, false, true));\r
-            drawBackground(gc, bound.x, _itemHeight * items.length, nameWidth, bound.height - _itemHeight * items.length);\r
-        }\r
-\r
-        // draw drag line, no line if name space is 0.\r
-        if (DRAG_SPLIT_LINE == _dragState) {\r
-            gc.setForeground(_colors.getColor(TraceColorScheme.BLACK));\r
-            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);\r
-        } else if (DRAG_NONE == _dragState && _mouseHover && _timeProvider.getNameSpace() > 0) {\r
-            gc.setForeground(_colors.getColor(TraceColorScheme.RED));\r
-            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);\r
-        }\r
-    }\r
-\r
-    void drawName(Item item, Rectangle rect, GC gc) {\r
-        // No name to be drawn\r
-        if (_timeProvider.getNameSpace() == 0)\r
-            return;\r
-        boolean group = item instanceof GroupItem;\r
-\r
-        int elemHeight = rect.height / 2;\r
-        int elemWidth = elemHeight;\r
-        String name = item._name;\r
-        if (group) {\r
-            gc.setBackground(_colors.getBkColorGroup(item._selected, _isInFocus));\r
-            gc.fillRectangle(rect);\r
-            if (item._selected && _isInFocus) {\r
-                gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, false));\r
-                gc.drawRectangle(rect.x, rect.y, rect.width - 2, rect.height - 2);\r
-            }\r
-            gc.setForeground(_colors.getBkColor(false, false, false));\r
-            gc.drawLine(rect.x, rect.y + rect.height - 1, rect.width - 1, rect.y + rect.height - 1);\r
-            gc.setForeground(_colors.getFgColorGroup(false, false));\r
-            gc.setBackground(_colors.getBkColor(false, false, false));\r
-            Utils.init(_rect1, rect);\r
-            _rect1.x += MARGIN;\r
-            _rect1.y += (rect.height - elemHeight) / 2;\r
-            _rect1.width = elemWidth;\r
-            _rect1.height = elemHeight;\r
-            // Get the icon rectangle in the group items\r
-            gc.fillRectangle(_rect1);\r
-            gc.drawRectangle(_rect1.x, _rect1.y, _rect1.width - 1, _rect1.height - 1);\r
-            int p = _rect1.y + _rect1.height / 2;\r
-            gc.drawLine(_rect1.x + 2, p, _rect1.x + _rect1.width - 3, p);\r
-            if (!item._expanded) {\r
-                p = _rect1.x + _rect1.width / 2;\r
-                gc.drawLine(p, _rect1.y + 2, p, _rect1.y + _rect1.height - 3);\r
-            }\r
-            gc.setForeground(_colors.getFgColorGroup(item._selected, _isInFocus));\r
-            elemWidth += MARGIN;\r
-        } else {\r
-            gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, true));\r
-            gc.setForeground(_colors.getFgColor(item._selected, _isInFocus));\r
-            gc.fillRectangle(rect);\r
-            Utils.init(_rect1, rect);\r
-            _rect1.x += MARGIN;\r
-            // draw icon\r
-            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
-            Image img = utilImpl.getItemImage(trace);\r
-            if (null != img) {\r
-                _rect1.y += (rect.height - img.getImageData().height) / 2;\r
-                gc.drawImage(img, _rect1.x, _rect1.y);\r
-            }\r
-            elemWidth = SMALL_ICON_SIZE;\r
-            // cut long string with "..."\r
-            Point size = gc.stringExtent(name);\r
-            if (_idealNameWidth < size.x)\r
-                _idealNameWidth = size.x;\r
-            int width = rect.width - MARGIN - MARGIN - elemWidth;\r
-            int cuts = 0;\r
-            while (size.x > width && name.length() > 1) {\r
-                cuts++;\r
-                name = name.substring(0, name.length() - 1);\r
-                size = gc.stringExtent(name + "..."); //$NON-NLS-1$\r
-            }\r
-            if (cuts > 0)\r
-                name += "..."; //$NON-NLS-1$\r
-            elemWidth += MARGIN;\r
-        }\r
-        Utils.init(_rect1, rect);\r
-        int leftMargin = MARGIN + elemWidth;\r
-        _rect1.x += leftMargin;\r
-        _rect1.width -= leftMargin;\r
-        int textWidth = 0;\r
-        // draw text\r
-        if (_rect1.width > 0) {\r
-            _rect1.y += 2;\r
-            textWidth = Utils.drawText(gc, name, _rect1, true) + 8;\r
-            _rect1.y -= 2;\r
-        }\r
-        // draw middle line\r
-        if (_rect1.width > 0 && !group) {\r
-            Utils.init(_rect1, rect);\r
-            _rect1.x += leftMargin + textWidth;\r
-            _rect1.width -= textWidth;\r
-            gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));\r
-            int midy = _rect1.y + _rect1.height / 2;\r
-            gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
-        }\r
-        // gc.drawLine(_rect1.x + _rect1.width - 1, _rect1.y, _rect1.x +\r
-        // _rect1.width - 1, _rect1.y + _rect1.height);\r
-    }\r
-\r
-    void drawItemData(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
-        if (rect.isEmpty())\r
-            return;\r
-        if (time1 <= time0) {\r
-            gc.setBackground(_colors.getBkColor(false, false, false));\r
-            gc.fillRectangle(rect);\r
-            return;\r
-        }\r
-\r
-        Utils.init(_rect1, rect);\r
-        boolean selected = item._selected;\r
-        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
-        boolean group = item instanceof GroupItem;\r
-\r
-        if (group) {\r
-            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
-            // gc.fillRectangle(rect);\r
-        } else if (item instanceof TraceItem) {\r
-            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
-\r
-            int x0 = rect.x;\r
-            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();\r
-            ITimeEvent lastEvent = null;\r
-            if (iterator.hasNext()) {\r
-                ITimeEvent currEvent = iterator.next();\r
-                ITimeEvent nextEvent = null;\r
-                long currEventTime = currEvent.getTime();\r
-                long nextEventTime = currEventTime;\r
-                x0 = rect.x + (int) ((currEventTime - time0) * pixelsPerNanoSec);\r
-                int xEnd = rect.x + (int) ((time1 - time0) * pixelsPerNanoSec);\r
-                int x1 = -1;\r
-\r
-                // reduce rect\r
-                _rect1.y += 3;\r
-                _rect1.height -= 6;\r
-                fillSpace(rect, gc, selected);\r
-\r
-                // draw event states\r
-                while (x0 <= xEnd && null != currEvent) {\r
-                    boolean stopped = false;// currEvent instanceof\r
-                    // TsfTmTraceDeadEvent;\r
-                    if (iterator.hasNext()) {\r
-                        nextEvent = iterator.next();\r
-                        nextEventTime = nextEvent.getTime();\r
-                    } else if (stopped) {\r
-                        nextEvent = null;\r
-                        nextEventTime = time1;\r
-                    } else {\r
-                        nextEvent = null;\r
-                        nextEventTime = endTime;\r
-                    }\r
-                    x1 = rect.x + (int) ((nextEventTime - time0) * pixelsPerNanoSec);\r
-                    if (x1 >= rect.x) {\r
-                        _rect1.x = x0 >= rect.x ? x0 : rect.x;\r
-                        _rect1.width = (x1 <= xEnd ? x1 : xEnd) - _rect1.x;\r
-                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
-                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
-                        // + _rect1.y + "," + _rect1.height + ", "\r
-                        // + _rect1.width + "-->"\r
-                        // + ((int) _rect1.x + (int) _rect1.width));\r
-                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
-                    }\r
-                    lastEvent = currEvent;\r
-                    currEvent = nextEvent;\r
-                    currEventTime = nextEventTime;\r
-                    x0 = x1;\r
-                }\r
-            }\r
-\r
-            // fill space after last event\r
-            int xEnd = rect.x + rect.width;\r
-            if (x0 < xEnd) {\r
-                _rect1.x = x0 >= rect.x ? x0 : rect.x;\r
-                _rect1.width = xEnd - _rect1.x;\r
-                gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
-                gc.fillRectangle(_rect1);\r
-                // draw middle line\r
-                gc.setForeground(_colors.getColor(utilImpl.getEventColorVal(lastEvent)));\r
-                int midy = _rect1.y + _rect1.height / 2;\r
-                int lw = gc.getLineWidth();\r
-                gc.setLineWidth(2);\r
-                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
-                gc.setLineWidth(lw);\r
-            }\r
-        }\r
-\r
-        // draw selected time\r
-        int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
-        if (x >= rect.x && x < rect.x + rect.width) {\r
-            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
-            if (group)\r
-                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
-            else\r
-                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Represent the event in series of bursts rather than sequence of states\r
-     * \r
-     * @param item\r
-     * @param rect\r
-     *            - The container rectangle to be colored to different states\r
-     * @param time0\r
-     *            - Base time of all events\r
-     * @param time1\r
-     *            - End time of all events\r
-     * @param endTime\r
-     * @param selectedTime\r
-     * @param gc\r
-     */\r
-    void drawItemDataBurst(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
-        if (rect.isEmpty())\r
-            return;\r
-        if (time1 <= time0) {\r
-            gc.setBackground(_colors.getBkColor(false, false, false));\r
-            gc.fillRectangle(rect);\r
-            return;\r
-        }\r
-\r
-        // Initialize _rect1 to same values as enclosing rectangle rect\r
-        Utils.init(_rect1, rect);\r
-        boolean selected = item._selected;\r
-        // K pixels per second\r
-        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
-        // Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
-        // + time0 + " time1:" + time1 + " endTime: " + endTime);\r
-\r
-        boolean group = item instanceof GroupItem;\r
-\r
-        if (group) {\r
-            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
-            // gc.fillRectangle(rect);\r
-            // if (Trace.isDEBUG()) {\r
-            // Trace.debug("Group");\r
-            // }\r
-        } else if (item instanceof TraceItem) {\r
-            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
-\r
-            double x0 = rect.x;\r
-            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();\r
-            ITimeEvent lastEvent = null;\r
-            // Trace.debug("count is: " + count);\r
-            if (iterator.hasNext()) {\r
-                ITimeEvent currEvent = iterator.next();\r
-                ITimeEvent nextEvent = null;\r
-                long currEventTime = currEvent.getTime();\r
-                long nextEventTime = currEventTime;\r
-                // x0 - Points to the beginning of the event being drawn\r
-                double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
-                x0 = rect.x + step;\r
-                // xEnd - Points to the end of the events rectangle\r
-                double xEnd = rect.x + (double) ((time1 - time0) * pixelsPerNanoSec);\r
-                double x1 = -1;\r
-                //double xNext = 0;\r
-\r
-                // Drawing rectangle is smaller than reserved space\r
-                _rect1.y += 3;\r
-                _rect1.height -= 6;\r
-\r
-                // Clean up to empty line to draw on top\r
-                fillSpace(rect, gc, selected);\r
-                // draw event states\r
-                while (x0 <= xEnd && null != currEvent) {\r
-                    boolean stopped = false;// currEvent instanceof\r
-                    // TsfTmTraceDeadEvent;\r
-                    if (iterator.hasNext()) {\r
-                        nextEvent = iterator.next();\r
-                        nextEventTime = nextEvent.getTime();\r
-                    } else if (stopped) {\r
-                        nextEvent = null;\r
-                        nextEventTime = time1;\r
-                    } else {\r
-                        nextEvent = null;\r
-                        nextEventTime = endTime;\r
-                        // Trace\r
-                        // .debug("nexEventTime is endTime: "\r
-                        // + nextEventTime);\r
-                    }\r
-\r
-                    // Draw it as a burst, one unit of width.\r
-                    x1 = x0 + (int) 2;\r
-                    if (x1 >= rect.x && x0 <= xEnd) {\r
-                        // Fill with space until x0\r
-                        _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
-                        _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - _rect1.x);\r
-                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
-                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
-                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
-                        // + _rect1.y + "," + _rect1.height + ", "\r
-                        // + _rect1.width + "-->"\r
-                        // + ((int) _rect1.x + (int) _rect1.width));\r
-                        // Advance rectangle to next start position and Fill\r
-                        // with space until next event\r
-                        _rect1.x += _rect1.width;\r
-                        x0 = x1;\r
-                        //xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
-                    }\r
-                    // Fill space till next event\r
-                    fillSpace(rect, gc, selected);\r
-\r
-                    lastEvent = currEvent;\r
-                    currEvent = nextEvent;\r
-                    currEventTime = nextEventTime;\r
-                    // Move x0 to the beginning of next event\r
-                    x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
-                    // Trace.debug("rect.x: " + rect.x + " + " +\r
-                    // "(nextEvenTime: "\r
-                    // + nextEventTime + "- time0: " + time0 + ") * K: "\r
-                    // + K + " = " + x0);\r
-                }\r
-            }\r
-\r
-            // fill space after last event\r
-            int xEnd = rect.x + rect.width;\r
-            if (x0 < xEnd) {\r
-                // Trace.debug("Space after last event, x0: " + x0 + ", xEnd: "\r
-                // + xEnd);\r
-                _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
-                _rect1.width = xEnd - _rect1.x;\r
-                gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
-                gc.fillRectangle(_rect1);\r
-                // draw middle line\r
-                gc.setForeground(_colors.getColor(utilImpl.getEventColorVal(lastEvent)));\r
-                int midy = _rect1.y + _rect1.height / 2;\r
-                int lw = gc.getLineWidth();\r
-                gc.setLineWidth(2);\r
-                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
-                gc.setLineWidth(lw);\r
-            }\r
-        }\r
-\r
-        // draw selected time\r
-        int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
-        if (x >= rect.x && x < rect.x + rect.width) {\r
-            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
-            if (group)\r
-                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
-            else\r
-                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Represent the series of events with specified durations\r
-     * \r
-     * @param item\r
-     * @param rect\r
-     *            - The container rectangle to be colored to different states\r
-     * @param time0\r
-     *            - Base time of all events - start of visible window\r
-     * @param time1\r
-     *            - End time of visible events - end time of visible window\r
-     * @param endTime\r
-     *            - End time of all events - may not be visible in selected\r
-     *            visible window\r
-     * @param selectedTime\r
-     * @param gc\r
-     */\r
-    void drawItemDataDurations(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
-        if (rect.isEmpty())\r
-            return;\r
-        if (time1 <= time0) {\r
-            gc.setBackground(_colors.getBkColor(false, false, false));\r
-            gc.fillRectangle(rect);\r
-            return;\r
-        }\r
-\r
-        // Initialize _rect1 to same values as enclosing rectangle rect\r
-        Utils.init(_rect1, rect);\r
-        boolean selected = item._selected;\r
-        // K pixels per second\r
-        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
-        // Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
-        // + time0 + " time1:" + time1 + " endTime: " + endTime);\r
-\r
-        boolean group = item instanceof GroupItem;\r
-\r
-        if (group) {\r
-            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
-            // gc.fillRectangle(rect);\r
-        } else if (item instanceof TraceItem) {\r
-            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
-\r
-            double x0 = rect.x;\r
-            long maxDuration = (_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace();\r
-            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(_timeProvider.getTime0(), _timeProvider.getTime1(), maxDuration);\r
-            // ITimeEvent lastEvent = null;\r
-            // if (Trace.isDEBUG()) {\r
-            // Trace.debug("\n\t\t\tTrace: " + trace.getName()\r
-            // + utilImpl.getTraceClassName(trace));\r
-            // }\r
-            // Trace.debug("count is: " + count);\r
-            // Drawing rectangle is smaller than reserved space\r
-            _rect1.y += 3;\r
-            _rect1.height -= 6;\r
-\r
-            // Clean up to empty line to draw on top\r
-            int xEnd = rect.x + rect.width;\r
-            fillSpace(rect, gc, selected);\r
-            if (iterator.hasNext()) {\r
-                ITimeEvent currEvent = iterator.next();\r
-                ITimeEvent nextEvent = null;\r
-                long currEventTime = currEvent.getTime();\r
-                long currEventDuration = currEvent.getDuration();\r
-                // initial value\r
-                long nextEventTime = currEventTime;\r
-                // x0 - Points to the beginning of the event being drawn\r
-                double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
-                x0 = rect.x + step;\r
-                // xEnd - Points to the end of the events rectangle\r
-                double x1 = -1;\r
-                double xNext = 0;\r
-\r
-                // draw event states\r
-                while (/* x0 <= xEnd && */null != currEvent) {\r
-                    boolean stopped = false;// currEvent instanceof\r
-                    // refresh current event duration as the loop moves\r
-                    currEventDuration = currEvent.getDuration();\r
-                    // TsfTmTraceDeadEvent;\r
-                    if (iterator.hasNext()) {\r
-                        nextEvent = iterator.next();\r
-                        nextEventTime = nextEvent.getTime();\r
-                    } else if (stopped) {\r
-                        nextEvent = null;\r
-                        nextEventTime = time1;\r
-                    } else {\r
-                        nextEvent = null;\r
-                        nextEventTime = endTime;\r
-                        // Trace\r
-                        // .debug("nexEventTime is endTime: "\r
-                        // + nextEventTime);\r
-                    }\r
-\r
-                    // Calculate position to next event\r
-                    xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
-\r
-                    // Calculate end position of current event\r
-                    if (currEventDuration < 0) {\r
-                        x1 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
-                    } else if (currEventDuration == 0) {\r
-                        x1 = x0;\r
-                    } else {\r
-                        x1 = x0 + (double) ((currEventDuration) * pixelsPerNanoSec);\r
-                    }\r
-\r
-                    // If event end position x1 further away than start position\r
-                    // of\r
-                    // next event, cut width till next event\r
-                    // Trace.debug("Next Event Pos: " + xNext\r
-                    // + " End Of Current at: " + x1 + " Event Duration: "\r
-                    // + currEventDuration);\r
-                    if (currEventDuration != 0) {\r
-                        x1 = x1 > xNext ? xNext : x1;\r
-                    }\r
-                    // if event end boundary is within time range\r
-                    if (x1 >= rect.x && x0 <= xEnd) {\r
-                        if (currEventDuration != 0) {\r
-                            x0 = (double) (x0 >= rect.x ? x0 : rect.x);\r
-                            _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0);\r
-                        } else {\r
-                            _rect1.width = 1;\r
-                        }\r
-                        _rect1.width = Math.max(_minimumItemWidth, _rect1.width);\r
-                        _rect1.x = (int) x0;\r
-                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
-                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
-                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
-                        // + _rect1.y + "," + _rect1.height + ", "\r
-                        // + _rect1.width + "-->"\r
-                        // + ((int) _rect1.x + (int) _rect1.width));\r
-                        // Advance rectangle to next start position and Fill\r
-                        // with space until next event\r
-                        _rect1.x += _rect1.width;\r
-                        x0 = _rect1.x;\r
-                    }\r
-\r
-                    // Fill space till next event\r
-                    // fillSpace(rect, gc, selected, x0, xNext, xEnd);\r
-\r
-                    // lastEvent = currEvent;\r
-                    currEvent = nextEvent;\r
-                    currEventTime = nextEventTime;\r
-                    // Move x0 to the beginning of next event\r
-                    x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
-                    // Trace.debug("rect.x: " + rect.x + " + " +\r
-                    // "(nextEvenTime: "\r
-                    // + nextEventTime + "- time0: " + time0 + ") * K: "\r
-                    // + K + " = " + x0);\r
-                }\r
-            }\r
-        }\r
-\r
-        // draw selected time\r
-        int x = rect.x + (int) ((double) (selectedTime - time0) * pixelsPerNanoSec);\r
-        if (x >= rect.x && x < rect.x + rect.width) {\r
-            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
-            if (group)\r
-                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
-            else\r
-                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
-        }\r
-    }\r
-\r
-    private void fillSpace(Rectangle rect, GC gc, boolean selected) {\r
-        gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
-        gc.fillRectangle(rect);\r
-        // draw middle line\r
-        gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));\r
-        int midy = rect.y + rect.height / 2;\r
-        gc.drawLine(rect.x, midy, rect.x + rect.width, midy);\r
-    }\r
-\r
-    @Override\r
-    public void keyTraversed(TraverseEvent e) {\r
-        if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))\r
-            e.doit = true;\r
-    }\r
-\r
-    @Override\r
-    public void keyPressed(KeyEvent e) {\r
-        int idx = -1;\r
-        if (SWT.HOME == e.keyCode) {\r
-            idx = getTopIndex();\r
-        } else if (SWT.END == e.keyCode) {\r
-            idx = getBottomIndex();\r
-        } else if (SWT.ARROW_DOWN == e.keyCode) {\r
-            idx = getSelectedIndex();\r
-            if (idx < 0)\r
-                idx = 0;\r
-            else if (idx < _data._items.length - 1)\r
-                idx++;\r
-        } else if (SWT.ARROW_UP == e.keyCode) {\r
-            idx = getSelectedIndex();\r
-            if (idx < 0)\r
-                idx = 0;\r
-            else if (idx > 0)\r
-                idx--;\r
-        } else if (SWT.ARROW_LEFT == e.keyCode) {\r
-            selectPrevEvent();\r
-        } else if (SWT.ARROW_RIGHT == e.keyCode) {\r
-            selectNextEvent();\r
-        } else if (SWT.PAGE_DOWN == e.keyCode) {\r
-            int page = countPerPage();\r
-            idx = getSelectedIndex();\r
-            if (idx < 0)\r
-                idx = 0;\r
-            idx += page;\r
-            if (idx >= _data._items.length)\r
-                idx = _data._items.length - 1;\r
-        } else if (SWT.PAGE_UP == e.keyCode) {\r
-            int page = countPerPage();\r
-            idx = getSelectedIndex();\r
-            if (idx < 0)\r
-                idx = 0;\r
-            idx -= page;\r
-            if (idx < 0)\r
-                idx = 0;\r
-        } else if (SWT.CR == e.keyCode) {\r
-            idx = getSelectedIndex();\r
-            if (idx >= 0) {\r
-                if (_data._items[idx] instanceof TraceItem)\r
-                    fireDefaultSelection();\r
-                else if (_data._items[idx] instanceof GroupItem)\r
-                    toggle(idx);\r
-            }\r
-            idx = -1;\r
-        }\r
-        if (idx >= 0) {\r
-            selectItem(idx, false);\r
-            fireSelectionChanged();\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void keyReleased(KeyEvent e) {\r
-    }\r
-\r
-    @Override\r
-    public void focusGained(FocusEvent e) {\r
-        _isInFocus = true;\r
-        redraw();\r
-    }\r
-\r
-    @Override\r
-    public void focusLost(FocusEvent e) {\r
-        _isInFocus = false;\r
-        if (DRAG_NONE != _dragState) {\r
-            setCapture(false);\r
-            _dragState = DRAG_NONE;\r
-        }\r
-        redraw();\r
-    }\r
-\r
-    public boolean isInFocus() {\r
-        return _isInFocus;\r
-    }\r
-\r
-    @Override\r
-    public void mouseMove(MouseEvent e) {\r
-        if (null == _timeProvider)\r
-            return;\r
-        Point size = getCtrlSize();\r
-        if (DRAG_TRACE_ITEM == _dragState) {\r
-            int nameWidth = _timeProvider.getNameSpace();\r
-            int x = e.x - nameWidth;\r
-            if (x > 0 && size.x > nameWidth && _dragX != x) {\r
-                _dragX = x;\r
-                double pixelsPerNanoSec = (size.x - nameWidth <= RIGHT_MARGIN) ? 0 : (double) (size.x - nameWidth - RIGHT_MARGIN) / (_time1bak - _time0bak);\r
-                long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((_dragX - _dragX0) / pixelsPerNanoSec));\r
-                long time1 = _time1bak - timeDelta;\r
-                long maxTime = _timeProvider.getMaxTime();\r
-                if (time1 > maxTime)\r
-                    time1 = maxTime;\r
-                long time0 = time1 - (_time1bak - _time0bak);\r
-                if (time0 < _timeProvider.getMinTime()) {\r
-                    time0 = _timeProvider.getMinTime();\r
-                    time1 = time0 + (_time1bak - _time0bak);\r
-                }\r
-                _timeProvider.setStartFinishTime(time0, time1);\r
-            }\r
-        } else if (DRAG_SPLIT_LINE == _dragState) {\r
-            _dragX = e.x;\r
-            _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0);\r
-        } else if (DRAG_NONE == _dragState) {\r
-            boolean mouseHover = hitSplitTest(e.x, e.y) > 0;\r
-            if (_mouseHover != mouseHover)\r
-                redraw();\r
-            _mouseHover = mouseHover;\r
-            // Make sure any time changes are notified to the application e.g.\r
-            // getting back from the horizontal scroll bar or zoomed using the\r
-            // mouse wheel\r
-            _timeProvider.notifyStartFinishTime();\r
-        }\r
-        updateCursor(e.x, e.y);\r
-    }\r
-\r
-    @Override\r
-    public void mouseDoubleClick(MouseEvent e) {\r
-        if (null == _timeProvider)\r
-            return;\r
-        if (1 == e.button) {\r
-            int idx = hitSplitTest(e.x, e.y);\r
-            if (idx >= 0) {\r
-                _timeProvider.setNameSpace(_idealNameWidth + 3 * MARGIN + SMALL_ICON_SIZE);\r
-                return;\r
-            }\r
-            idx = hitTest(e.x, e.y);\r
-            if (idx >= 0) {\r
-                selectItem(idx, false);\r
-                if (_data._items[idx] instanceof TraceItem) {\r
-                    fireDefaultSelection();\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * <p>\r
-     * If the x, y position is over the vertical split line (name to time\r
-     * ranges), then change the cursor to a drag cursor to indicate the user the\r
-     * possibility of resizing\r
-     * </p>\r
-     * \r
-     * @param x\r
-     * @param y\r
-     */\r
-    void updateCursor(int x, int y) {\r
-        // if Wait cursor not active, check for the need to change to a drag\r
-        // cursor\r
-        if (_isWaitCursor == false) {\r
-            int idx = hitSplitTest(x, y);\r
-            // No dragcursor is name space is fixed to zero\r
-            if (idx > 0 && !_isDragCursor3 && _timeProvider.getNameSpace() > 0) {\r
-                setCursor(_dragCursor3);\r
-                _isDragCursor3 = true;\r
-            } else if (idx <= 0 && _isDragCursor3) {\r
-                setCursor(null);\r
-                _isDragCursor3 = false;\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Provide the possibilty to control the wait cursor externally e.g. data\r
-     * requests in progress\r
-     * \r
-     * @param waitInd\r
-     */\r
-    public void waitCursor(boolean waitInd) {\r
-        // Update cursor as indicated\r
-        if (waitInd) {\r
-            setCursor(_WaitCursor);\r
-            _isWaitCursor = true;\r
-        } else {\r
-            setCursor(null);\r
-            _isWaitCursor = false;\r
-        }\r
-\r
-        // Get ready for next mouse move\r
-        _isDragCursor3 = false;\r
-    }\r
-\r
-    @Override\r
-    public void mouseDown(MouseEvent e) {\r
-        if (null == _timeProvider)\r
-            return;\r
-        int idx;\r
-        if (1 == e.button) {\r
-            int namewidth = _timeProvider.getNameSpace();\r
-            if (namewidth != 0) {\r
-                idx = hitSplitTest(e.x, e.y);\r
-                if (idx > 0) {\r
-                    _dragState = DRAG_SPLIT_LINE;\r
-                    _dragX = _dragX0 = e.x;\r
-                    _hitIdx = _timeProvider.getNameSpace();\r
-                    ;\r
-                    _time0bak = _timeProvider.getTime0();\r
-                    _time1bak = _timeProvider.getTime1();\r
-                    redraw();\r
-                    return;\r
-                }\r
-            }\r
-\r
-            idx = hitTest(e.x, e.y);\r
-            if (idx >= 0) {\r
-                if (_data._items[idx] instanceof TraceItem) {\r
-                    long hitTime = hitTimeTest(e.x);\r
-                    if (hitTime >= 0) {\r
-                        // _timeProvider.setSelectedTimeInt(hitTime, false);\r
-                        setCapture(true);\r
-                        _dragState = DRAG_TRACE_ITEM;\r
-                        _dragX = _dragX0 = e.x - _timeProvider.getNameSpace();\r
-                        _hitIdx = idx;\r
-                        _time0bak = _timeProvider.getTime0();\r
-                        _time1bak = _timeProvider.getTime1();\r
-                        return;\r
-                    }\r
-                } else if (_data._items[idx] instanceof GroupItem) {\r
-                    _dragX0 = e.x;\r
-                    _dragState = DRAG_GROUP_ITEM;\r
-                }\r
-                selectItem(idx, false);\r
-                fireSelectionChanged();\r
-            } else {\r
-                selectItem(idx, false); // clear selection\r
-                redraw();\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void mouseUp(MouseEvent e) {\r
-        if (DRAG_NONE != _dragState) {\r
-            setCapture(false);\r
-            if (DRAG_TRACE_ITEM == _dragState) {\r
-                // Notify time provider to check the need for listener\r
-                // notification\r
-                _timeProvider.notifyStartFinishTime();\r
-                if (_dragX == _dragX0) { // click without drag\r
-                    long time = hitTimeTest(e.x);\r
-                    _timeProvider.setSelectedTimeInt(time, false);\r
-                    selectItem(_hitIdx, false);\r
-                    fireSelectionChanged();\r
-                }\r
-            } else if (DRAG_GROUP_ITEM == _dragState) {\r
-                if (e.x == _dragX0) // click without drag\r
-                    toggle(_hitIdx);\r
-            } else if (DRAG_SPLIT_LINE == _dragState) {\r
-                redraw();\r
-            }\r
-            _dragState = DRAG_NONE;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void controlMoved(ControlEvent e) {\r
-    }\r
-\r
-    @Override\r
-    public void controlResized(ControlEvent e) {\r
-        adjustScrolls();\r
-    }\r
-\r
-    @Override\r
-    public void widgetDefaultSelected(SelectionEvent e) {\r
-    }\r
-\r
-    @Override\r
-    public void widgetSelected(SelectionEvent e) {\r
-        if (e.widget == getVerticalBar()) {\r
-            _topItem = getVerticalBar().getSelection();\r
-            if (_topItem < 0)\r
-                _topItem = 0;\r
-            redraw();\r
-        } else if (e.widget == getHorizontalBar() && null != _timeProvider) {\r
-            int start = getHorizontalBar().getSelection();\r
-            long time0 = _timeProvider.getTime0();\r
-            long time1 = _timeProvider.getTime1();\r
-            long timeMin = _timeProvider.getMinTime();\r
-            long timeMax = _timeProvider.getMaxTime();\r
-            long delta = timeMax - timeMin;\r
-\r
-            long range = time1 - time0;\r
-            // _timeRangeFixed = true;\r
-            time0 = timeMin + (long) (delta * ((double) start / H_SCROLLBAR_MAX));\r
-            time1 = time0 + range;\r
-\r
-            // TODO: Follow-up with Bug 310310\r
-            // In Linux SWT.DRAG is the only value received\r
-            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310310\r
-            if (e.detail == SWT.DRAG) {\r
-                _timeProvider.setStartFinishTime(time0, time1);\r
-            } else {\r
-                _timeProvider.setStartFinishTimeNotify(time0, time1);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void mouseEnter(MouseEvent e) {\r
-        if (mouseScrollFilterListener == null) {\r
-            mouseScrollFilterListener = new Listener() {\r
-                // This filter is used to prevent scrolling of the view when the\r
-                // mouse wheel is used to zoom\r
-                @Override\r
-                public void handleEvent(Event event) {\r
-                    event.doit = false;\r
-                }\r
-            };\r
-            getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void mouseExit(MouseEvent e) {\r
-        if (mouseScrollFilterListener != null) {\r
-            getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
-            mouseScrollFilterListener = null;\r
-        }\r
-        if (_mouseHover) {\r
-            _mouseHover = false;\r
-            redraw();\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void mouseHover(MouseEvent e) {\r
-    }\r
-\r
-    @Override\r
-    public void mouseScrolled(MouseEvent e) {\r
-        if ((mouseScrollFilterListener == null) || _dragState != DRAG_NONE)\r
-            return;\r
-        if (e.count > 0) {\r
-            zoom(true);\r
-        } else if (e.count < 0) {\r
-            zoom(false);\r
-        }\r
-    }\r
-\r
-    public boolean isVisibleVerticalScroll() {\r
-        return _visibleVerticalScroll;\r
-    }\r
-\r
-    public void setVisibleVerticalScroll(boolean visibleVerticalScroll) {\r
-        ScrollBar scrollVer = getVerticalBar();\r
-        if (scrollVer != null) {\r
-            scrollVer.setVisible(visibleVerticalScroll);\r
-        }\r
-        this._visibleVerticalScroll = visibleVerticalScroll;\r
-    }\r
-\r
-    @Override\r
-    public int getBorderWidth() {\r
-        return _borderWidth;\r
-    }\r
-\r
-    public void setBorderWidth(int borderWidth) {\r
-        this._borderWidth = borderWidth;\r
-    }\r
-\r
-    public int getHeaderHeight() {\r
-        return _headerHeight;\r
-    }\r
-\r
-    public void setHeaderHeight(int headerHeight) {\r
-        this._headerHeight = headerHeight;\r
-    }\r
-\r
-    public int getItemHeight() {\r
-        return _itemHeight;\r
-    }\r
-\r
-    public void setItemHeight(int rowHeight) {\r
-        this._itemHeight = rowHeight;\r
-    }\r
-\r
-    public void setMinimumItemWidth(int width) {\r
-        this._minimumItemWidth = width;\r
-    }\r
-\r
-    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
-        return _data.getFilteredOut();\r
-    }\r
-\r
-    // @Override\r
-    @Override\r
-    public void addSelectionChangedListener(ISelectionChangedListener listener) {\r
-        if (listener != null) {\r
-            if (!_selectionChangedListeners.contains(listener)) {\r
-                _selectionChangedListeners.add(listener);\r
-            }\r
-        }\r
-    }\r
-\r
-    // @Override\r
-    @Override\r
-    public void removeSelectionChangedListener(ISelectionChangedListener listener) {\r
-        if (listener != null) {\r
-            _selectionChangedListeners.remove(listener);\r
-        }\r
-    }\r
-\r
-    // @Override\r
-    @Override\r
-    public void setSelection(ISelection selection) {\r
-        if (selection instanceof PlainSelection) {\r
-            PlainSelection sel = (PlainSelection) selection;\r
-            Object ob = sel.getFirstElement();\r
-            if (ob instanceof ITmfTimeAnalysisEntry) {\r
-                ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) ob;\r
-                selectItem(trace, false);\r
-            }\r
-        }\r
-\r
-    }\r
-}\r
-\r
-class Item {\r
-    public boolean _expanded;\r
-    public boolean _selected;\r
-    public boolean _hasChildren;\r
-    public String _name;\r
-\r
-    Item(String name) {\r
-        _name = name;\r
-    }\r
-\r
-    @Override\r
-    public String toString() {\r
-        return _name;\r
-    }\r
-}\r
-\r
-class TraceItem extends Item {\r
-    public ITmfTimeAnalysisEntry _trace;\r
-\r
-    TraceItem(ITmfTimeAnalysisEntry trace, String name) {\r
-        super(name);\r
-        _trace = trace;\r
-    }\r
-}\r
-\r
-class GroupItem extends Item {\r
-    public List<ITmfTimeAnalysisEntry> _traces;\r
-\r
-    GroupItem(String name) {\r
-        super(name);\r
-        _traces = new ArrayList<ITmfTimeAnalysisEntry>();\r
-        _hasChildren = true;\r
-    }\r
-\r
-    void add(ITmfTimeAnalysisEntry trace) {\r
-        _traces.add(trace);\r
-    }\r
-}\r
-\r
-class ItemData {\r
-    public Object[] _items = new Object[0];\r
-    private Object _traces[] = new Object[0];\r
-    private boolean traceFilter[] = new boolean[0];\r
-    private Map<String, GroupItem> _groupTable = new HashMap<String, GroupItem>();\r
-    private boolean _flatList = false;\r
-    private TmfTimeAnalysisProvider utilsImp;\r
-    private Vector<ITmfTimeAnalysisEntry> filteredOut = new Vector<ITmfTimeAnalysisEntry>();\r
-\r
-    public ItemData(TmfTimeAnalysisProvider utils) {\r
-        this.utilsImp = utils;\r
-    }\r
-\r
-    protected void groupTraces(boolean on) {\r
-        if (_flatList == on) {\r
-            _flatList = !on;\r
-            updateItems();\r
-        }\r
-    }\r
-\r
-    void clearGroups() {\r
-        Iterator<GroupItem> it = _groupTable.values().iterator();\r
-        while (it.hasNext()) {\r
-            GroupItem group = it.next();\r
-            group._traces.clear();\r
-        }\r
-    }\r
-\r
-    void deleteEmptyGroups() {\r
-        Iterator<GroupItem> it = _groupTable.values().iterator();\r
-        while (it.hasNext()) {\r
-            GroupItem group = it.next();\r
-            if (group._traces.size() == 0)\r
-                it.remove();\r
-        }\r
-    }\r
-\r
-    TraceItem findTraceItem(ITmfTimeAnalysisEntry trace) {\r
-        if (trace == null)\r
-            return null;\r
-\r
-        int traceId = trace.getId();\r
-        TraceItem traceItem = null;\r
-\r
-        for (int i = 0; i < _items.length; i++) {\r
-            Object item = _items[i];\r
-            if (item instanceof TraceItem) {\r
-                TraceItem ti = (TraceItem) item;\r
-                if (ti._trace.getId() == traceId) {\r
-                    traceItem = ti;\r
-                    break;\r
-                }\r
-            }\r
-        }\r
-\r
-        return traceItem;\r
-    }\r
-\r
-    Integer findTraceItemIndex(ITmfTimeAnalysisEntry trace) {\r
-        if (trace == null)\r
-            return null;\r
-\r
-        for (int i = 0; i < _items.length; i++) {\r
-            Object item = _items[i];\r
-            if (item instanceof TraceItem) {\r
-                TraceItem ti = (TraceItem) item;\r
-                if (ti._trace == trace) {\r
-                    return i;\r
-                }\r
-            }\r
-        }\r
-\r
-        return null;\r
-    }\r
-\r
-    public void updateItems() {\r
-        List<Item> itemList = new ArrayList<Item>();\r
-        String name = ""; //$NON-NLS-1$\r
-\r
-        Iterator<GroupItem> it = _groupTable.values().iterator();\r
-        while (it.hasNext()) {\r
-            GroupItem group = it.next();\r
-            if (!_flatList)\r
-                itemList.add(group);\r
-\r
-            if (_flatList || group._expanded) {\r
-                Iterator<ITmfTimeAnalysisEntry> it2 = group._traces.iterator();\r
-                while (it2.hasNext()) {\r
-                    ITmfTimeAnalysisEntry trace = it2.next();\r
-                    TraceItem traceItem = findTraceItem(trace);\r
-                    name = utilsImp.composeTraceName(trace, false);\r
-                    traceItem = new TraceItem(trace, name);\r
-                    itemList.add(traceItem);\r
-                }\r
-            }\r
-        }\r
-        _items = itemList.toArray();\r
-    }\r
-\r
-    public int expandItem(int idx, boolean expand) {\r
-        if (idx < 0 || idx >= _items.length)\r
-            return 0;\r
-        int ret = 0;\r
-        Item item = (Item) _items[idx];\r
-        if (item._hasChildren && !item._expanded) {\r
-            item._expanded = expand;\r
-            ret = _items.length;\r
-            updateItems();\r
-            ret = _items.length - ret;\r
-        }\r
-        return ret;\r
-    }\r
-\r
-    public void refreshData(Object traces[]) {\r
-        if (traces == null || traces.length == 0) {\r
-            traceFilter = null;\r
-        } else if (traceFilter == null || traces.length != traceFilter.length) {\r
-            traceFilter = new boolean[traces.length];\r
-            java.util.Arrays.fill(traceFilter, true);\r
-        }\r
-\r
-        _traces = traces;\r
-        refreshData();\r
-    }\r
-\r
-    /**\r
-     * Allows to update the GUI from a stream of events handling addition one by\r
-     * one over known TmfTaTrace parents.\r
-     * \r
-     * @param parent\r
-     * @param childItem\r
-     */\r
-    public void refreshPartial(ITmfTimeAnalysisEntry parent, TimeEvent childItem) {\r
-        // Find the Trace item within the current list\r
-//        TraceItem item = findTraceItem(parent);\r
-\r
-        // This method is not used (yet) so this code can be commented out for\r
-        // now\r
-        // FIXME: Arrays.copyOf is a Java6 feature\r
-        // if (item == null) {\r
-        // // If the parent item is not found, make room for it in the current\r
-        // // array\r
-        // int length = 1;\r
-        // Object[] traces;\r
-        // if (_traces != null) {\r
-        // length = _traces.length + 1;\r
-        // traces = Arrays.copyOf(_traces, length);\r
-        // } else {\r
-        // traces = new Object[length];\r
-        // }\r
-        //\r
-        // // Add the new parent element to the end of the array.\r
-        // traces[length - 1] = parent;\r
-        //\r
-        // // update the filter array to accomodate a postion to the new\r
-        // // element\r
-        // traceFilter = new boolean[traces.length];\r
-        // java.util.Arrays.fill(traceFilter, true);\r
-        //\r
-        // // rebuild internal data\r
-        // _traces = traces;\r
-        // refreshData();\r
-        //\r
-        // // item must be there\r
-        // item = findTraceItem(parent);\r
-        // }\r
-\r
-        /*\r
-         * Check if this is still needed!\r
-        ITmfTimeAnalysisEntry localTraceItem = item._trace;\r
-        // Local trace found\r
-        Vector<TimeEvent> children = localTraceItem.getTraceEvents();\r
-        TimeEvent lastChildIn = children.lastElement();\r
-        long lastChildSTime = lastChildIn.getTime();\r
-        long newChildSTime = childItem.getTime();\r
-        if (newChildSTime < lastChildSTime) {\r
-            // The children are expected to arrive sorted by time\r
-            // since the new time is earlier than the last child\r
-            // The infomation is being refreshed from start, remove all\r
-            // children and start over\r
-            children.clear();\r
-        }\r
-        // Add the new item\r
-        children.add(childItem);\r
-        */\r
-\r
-    }\r
-\r
-    public void refreshData() {\r
-        clearGroups();\r
-        filteredOut.clear();\r
-        String undef = Messages.TmfTimeStatesCtrl_UNDEFINED_GROUP;\r
-        List<GroupItem> groupList = new ArrayList<GroupItem>();\r
-        for (int i = 0; i < _traces.length; i++) {\r
-            ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) _traces[i];\r
-            if (!traceFilter[i]) {\r
-                filteredOut.add(trace);\r
-                continue;\r
-            }\r
-\r
-            String groupName = trace.getGroupName();\r
-            if (null == groupName)\r
-                groupName = undef;\r
-\r
-            GroupItem group = _groupTable.get(groupName);\r
-            if (null == group) {\r
-                group = new GroupItem(NLS.bind(Messages.TmfTimeStatesCtrl_TRACE_GROUP_LABEL, groupName));\r
-                group._expanded = !groupName.equalsIgnoreCase("system") && !groupName.equalsIgnoreCase(undef); //$NON-NLS-1$\r
-                _groupTable.put(groupName, group);\r
-                groupList.add(group);\r
-            }\r
-            group.add(trace);\r
-        }\r
-\r
-        deleteEmptyGroups();\r
-        updateItems();\r
-    }\r
-\r
-    public Object[] getTraces() {\r
-        return _traces;\r
-    }\r
-\r
-    public boolean[] getTraceFilter() {\r
-        return traceFilter;\r
-    }\r
-\r
-    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
-        return filteredOut;\r
-    }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TmfTimeTipHandler.java
deleted file mode 100644 (file)
index 9ee707e..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Vitaly A. Provodin, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: ThreadsTipHandler.java,v 1.5 2007/06/06 19:16:16 gnagarajan Exp $\r
- *****************************************************************************/\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import java.util.Iterator;\r
-import java.util.Map;\r
-\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.Utils.Resolution;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.MouseAdapter;\r
-import org.eclipse.swt.events.MouseEvent;\r
-import org.eclipse.swt.events.MouseTrackAdapter;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Table;\r
-import org.eclipse.swt.widgets.TableColumn;\r
-import org.eclipse.swt.widgets.TableItem;\r
-import org.eclipse.swt.widgets.Widget;\r
-\r
-\r
-public class TmfTimeTipHandler {\r
-\r
-       private Shell _tipShell;\r
-       private Table _tipTable;\r
-       private Item _tipItem;\r
-       private Point _tipPosition;\r
-       private ITimeDataProvider _timeDataProvider;\r
-       TmfTimeAnalysisProvider _utilImp = null;\r
-\r
-       public TmfTimeTipHandler(Shell parent, TmfTimeAnalysisProvider rUtilImpl,\r
-                       ITimeDataProvider timeProv) {\r
-               final Display display = parent.getDisplay();\r
-\r
-               this._utilImp = rUtilImpl;\r
-               this._timeDataProvider = timeProv;\r
-               _tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL);\r
-               GridLayout gridLayout = new GridLayout();\r
-               gridLayout.numColumns = 2;\r
-               gridLayout.marginWidth = 2;\r
-               gridLayout.marginHeight = 2;\r
-               _tipShell.setLayout(gridLayout);\r
-               GridData data = new GridData(GridData.BEGINNING, GridData.BEGINNING,\r
-                               true, true);\r
-               _tipShell.setLayoutData(data);\r
-               _tipShell.setBackground(display\r
-                               .getSystemColor(SWT.COLOR_INFO_BACKGROUND));\r
-\r
-               _tipTable = new Table(_tipShell, SWT.NONE);\r
-               _tipTable.setForeground(display\r
-                               .getSystemColor(SWT.COLOR_INFO_FOREGROUND));\r
-               _tipTable.setBackground(display\r
-                               .getSystemColor(SWT.COLOR_INFO_BACKGROUND));\r
-               _tipTable.setHeaderVisible(false);\r
-               _tipTable.setLinesVisible(false);\r
-\r
-               // tipTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL\r
-               // | GridData.VERTICAL_ALIGN_CENTER));\r
-       }\r
-\r
-       public void activateHoverHelp(final Control control) {\r
-               control.addMouseListener(new MouseAdapter() {\r
-                       @Override\r
-                       public void mouseDown(MouseEvent e) {\r
-                               if (_tipShell.isVisible())\r
-                                       _tipShell.setVisible(false);\r
-                       }\r
-               });\r
-\r
-               control.addMouseTrackListener(new MouseTrackAdapter() {\r
-                       @Override\r
-                       public void mouseExit(MouseEvent e) {\r
-                               if (_tipShell.isVisible())\r
-                                       _tipShell.setVisible(false);\r
-                               _tipItem = null;\r
-\r
-                       }\r
-\r
-                       private void addItem(String name, String value) {\r
-                               TableItem line = new TableItem(_tipTable, SWT.NONE);\r
-                               line.setText(0, name);\r
-                               line.setText(1, value);\r
-                       }\r
-\r
-                       private void fillValues(Point pt, TmfTimeStatesCtrl threadStates,\r
-                                       Item item) {\r
-                               if (item instanceof TraceItem) {\r
-                                       ITmfTimeAnalysisEntry thrd = ((TraceItem) item)._trace;\r
-                                       ITimeEvent threadEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 2);\r
-                                       ITimeEvent nextEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 1);\r
-                                       // thread name\r
-                                       addItem(Messages.TmfTimeTipHandler_TRACE_NAME, thrd.getName());\r
-                                       // class name\r
-                                       String traceClass = _utilImp.getTraceClassName(thrd);\r
-                                       if (traceClass != null) {\r
-                                               addItem(Messages.TmfTimeTipHandler_TRACE_CLASS_NAME, traceClass);\r
-                                       }\r
-                                       // thread state\r
-                                       String state = _utilImp.getEventName(threadEvent);\r
-                                       if (state != null) {\r
-                                               addItem(Messages.TmfTimeTipHandler_TRACE_STATE, state);\r
-                                       }\r
-\r
-                                       // This block receives a\r
-                                       // list of <String, String> values to be added to the tip\r
-                                       // table\r
-                                       Map<String, String> eventAddOns = _utilImp.getEventHoverToolTipInfo(threadEvent);\r
-                                       if (eventAddOns != null) {\r
-                                               for (Iterator<String> iter = eventAddOns.keySet().iterator(); iter.hasNext();) {\r
-                                                       String message = (String) iter.next();\r
-                                                       addItem(message, eventAddOns.get(message));\r
-                                               }\r
-                                       }\r
-\r
-                                       long eventStartTime = -1;\r
-                                       long eventDuration = -1;\r
-                                       long eventEndTime = -1;\r
-                                       \r
-                                       if (threadEvent != null) {\r
-                                           eventStartTime = threadEvent.getTime();\r
-                                           eventDuration = threadEvent.getDuration();\r
-                                           if (eventDuration < 0 && nextEvent != null) {\r
-                                               eventEndTime = nextEvent.getTime();\r
-                                               eventDuration = eventEndTime - eventStartTime;\r
-                                           } else {\r
-                                               eventEndTime = eventStartTime + eventDuration;\r
-                                           }\r
-                                       }\r
-\r
-// TODO: Check if we need "format"                                     \r
-//                                     TimeFormat format = TimeFormat.RELATIVE;\r
-                                       Resolution res = Resolution.NANOSEC;\r
-                                       if (_timeDataProvider.isCalendarFormat()) {\r
-//                                             format = TimeFormat.ABSOLUTE; // Absolute format\r
-//                                                                                                             // (calendar)\r
-                                               // Add Date\r
-                                               addItem(Messages.TmfTimeTipHandler_TRACE_DATE, eventStartTime > -1 ?\r
-                                                       Utils.formatDate(eventStartTime)\r
-                                                       : "?"); //$NON-NLS-1$\r
-                                               if (eventDuration > 0) {\r
-                            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, eventStartTime > -1 ?\r
-                                    Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
-                                    : "?"); //$NON-NLS-1$\r
-                            \r
-                            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, eventEndTime > -1 ?\r
-                                    Utils.formatTime(eventEndTime, TimeFormat.ABSOLUTE, res)\r
-                                    : "?"); //$NON-NLS-1$\r
-                                               } else {\r
-                            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, eventStartTime > -1 ?\r
-                                    Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
-                                    : "?"); //$NON-NLS-1$\r
-                                               }\r
-                                       } else {\r
-                                               if (eventDuration > 0) {\r
-                                               addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, eventStartTime > -1 ?\r
-                                                       Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
-                                                       : "?"); //$NON-NLS-1$\r
-                                           \r
-                                               addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, eventEndTime > -1 ?\r
-                                                       Utils.formatTime(eventEndTime, TimeFormat.RELATIVE, res)\r
-                                                       : "?"); //$NON-NLS-1$\r
-                                               } else {\r
-                            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, eventStartTime > -1 ?\r
-                                    Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
-                                    : "?"); //$NON-NLS-1$\r
-                                               }\r
-                                       }\r
-\r
-                                       if (eventDuration > 0) {\r
-                                           // Duration in relative format in any case\r
-                                           addItem(Messages.TmfTimeTipHandler_DURATION, eventDuration > -1 ?\r
-                                                   Utils.formatTime(eventDuration, TimeFormat.RELATIVE, res)\r
-                                                   : "?"); //$NON-NLS-1$\r
-                                       }\r
-\r
-                               } else if (item instanceof GroupItem) {\r
-                                       addItem(Messages.TmfTimeTipHandler_TRACE_GROUP_NAME, item.toString());\r
-                                       addItem(Messages.TmfTimeTipHandler_NUMBER_OF_TRACES, "" + ((GroupItem) item)._traces.size()); //$NON-NLS-1$\r
-                               }\r
-                       }\r
-\r
-                       @Override\r
-                       public void mouseHover(MouseEvent event) {\r
-                               Point pt = new Point(event.x, event.y);\r
-                               Widget widget = event.widget;\r
-                               Item item = null;\r
-                               if (widget instanceof TmfTimeStatesCtrl) {\r
-                                       TmfTimeStatesCtrl threadStates = (TmfTimeStatesCtrl) widget;\r
-                                       item = (Item) threadStates.getItem(pt);\r
-                                       _tipTable.remove(0, _tipTable.getItemCount() - 1);\r
-                                       new TableColumn(_tipTable, SWT.NONE);\r
-                                       new TableColumn(_tipTable, SWT.NONE);\r
-                                       fillValues(pt, threadStates, item);\r
-                                       _tipTable.getColumn(0).setWidth(200);\r
-                                       _tipTable.getColumn(1).pack();\r
-                                       _tipTable.setSize(_tipTable.computeSize(SWT.DEFAULT, 200));\r
-                                       _tipShell.pack();\r
-                               } else if (widget == null) {\r
-                                       _tipShell.setVisible(false);\r
-                                       _tipItem = null;\r
-                                       return;\r
-                               }\r
-                               if (item == _tipItem)\r
-                                       return;\r
-                               _tipItem = item;\r
-                               _tipPosition = control.toDisplay(pt);\r
-                               _tipShell.pack();\r
-                               setHoverLocation(_tipShell, _tipPosition);\r
-                               _tipShell.setVisible(true);\r
-                       }\r
-               });\r
-       }\r
-\r
-       private void setHoverLocation(Shell shell, Point position) {\r
-               Rectangle displayBounds = shell.getDisplay().getBounds();\r
-               Rectangle shellBounds = shell.getBounds();\r
-               shellBounds.x = Math.max(Math.min(position.x, displayBounds.width\r
-                               - shellBounds.width), 0);\r
-               shellBounds.y = Math.max(Math.min(position.y + 16, displayBounds.height\r
-                               - shellBounds.height), 0);\r
-               shell.setBounds(shellBounds);\r
-       }\r
-\r
-}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TraceColorScheme.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TraceColorScheme.java
deleted file mode 100644 (file)
index fb700f7..0000000
+++ /dev/null
@@ -1,381 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2008 Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: TraceColorScheme.java,v 1.3 2008/05/09 16:11:24 jkubasta Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider.StateColor;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.graphics.Color;\r
-\r
-\r
-public class TraceColorScheme {\r
-\r
-       // elements color indices\r
-       static public final int BLACK_STATE = 0;\r
-       static public final int GREEN_STATE = 1;\r
-       static public final int DARK_BLUE_STATE = 2;\r
-       static public final int ORANGE_STATE = 3;\r
-       static public final int GOLD_STATE = 4;\r
-       static public final int RED_STATE = 5;\r
-       static public final int GRAY_STATE = 6;\r
-       static public final int DARK_GREEN_STATE = 7;\r
-       static public final int DARK_YELLOW_STATE = 8;\r
-       static public final int MAGENTA3_STATE = 9;\r
-       static public final int PURPLE1_STATE = 10;\r
-       static public final int PINK1_STATE = 11;\r
-       static public final int AQUAMARINE_STATE = 12;\r
-       static public final int LIGHT_BLUE_STATE = 13;\r
-       static public final int CADET_BLUE_STATE = 14;\r
-       static public final int OLIVE_STATE = 15;\r
-       \r
-       static public final int STATES0 = 0;\r
-       static public final int STATES1 = 15;\r
-       \r
-       // State element index to name mapping, must keep the same order as above\r
-       public static final StateColor stateColors[] = { StateColor.BLACK,\r
-                       StateColor.GREEN, StateColor.DARK_BLUE, StateColor.ORANGE,\r
-                       StateColor.GOLD, StateColor.RED, StateColor.GRAY, StateColor.DARK_GREEN, StateColor.DARK_YELLOW, StateColor.MAGENTA3, StateColor.PURPLE1, \r
-                       StateColor.PINK1, StateColor.AQUAMARINE, StateColor.LIGHT_BLUE, StateColor.CADET_BLUE, StateColor.OLIVE\r
-                       };\r
-\r
-       // selected state elements color indices\r
-       static public final int BLACK_STATE_SEL = 16;\r
-       static public final int GREEN_STATE_SEL = 17;\r
-       static public final int DARK_BLUE_STATE_SEL = 18;\r
-       static public final int ORANGE_STATE_SEL = 19;\r
-       static public final int GOLD_STATE_SEL = 20;\r
-       static public final int RED_STATE_SEL = 21;\r
-       static public final int GRAY_STATE_SEL = 22;\r
-       static public final int DARK_GREEN_STATE_SEL = 23;\r
-       static public final int DARK_YELLOW_STATE_SEL = 24;\r
-       static public final int MAGENTA3_STATE_SEL = 25;\r
-       static public final int PURPLE1_STATE_SEL = 26;\r
-       static public final int PINK1_STATE_SEL = 27;\r
-       static public final int AQUAMARINE_STATE_SEL = 28;\r
-       static public final int LIGHT_BLUE_STATE_SEL = 29;\r
-       static public final int CADET_BLUE_STATE_SEL = 30;\r
-       static public final int OLIVE_STATE_SEL = 31;\r
-       \r
-       static public final int STATES_SEL0 = 16;\r
-       static public final int STATES_SEL1 = 31;\r
-\r
-       // colors indices for viewer controls\r
-       static public final int BACKGROUND = 32;\r
-       static public final int FOREGROUND = 33;\r
-       static public final int BACKGROUND_SEL = 34;\r
-       static public final int FOREGROUND_SEL = 35;\r
-       static public final int BACKGROUND_SEL_NOFOCUS = 36;\r
-       static public final int FOREGROUND_SEL_NOFOCUS = 37;\r
-       static public final int TOOL_BACKGROUND = 38;\r
-       static public final int TOOL_FOREGROUND = 39;\r
-\r
-       // misc colors\r
-       static public final int FIX_COLOR = 40;\r
-       static public final int WHITE = 41;\r
-       static public final int GRAY = 42;\r
-       static public final int BLACK = 43;\r
-       static public final int DARK_GRAY = 44;\r
-\r
-       // selected border color indices\r
-       static public final int BLACK_BORDER = 45;\r
-       static public final int GREEN_BORDER = 46;\r
-       static public final int DARK_BLUE_BORDER = 47;\r
-       static public final int ORANGE_BORDER = 48;\r
-       static public final int GOLD_BORDER = 49;\r
-       static public final int RED_BORDER = 50;\r
-       static public final int GRAY_BORDER = 51;\r
-       static public final int DARK_GREEN_BORDER1 = 52;\r
-       static public final int DARK_YELLOW_BORDER1 = 53;\r
-       static public final int MAGENTA3_BORDER1 = 54;\r
-       static public final int PURPLE1_BORDER1 = 55;\r
-       static public final int PINK1_BORDER1 = 56;\r
-       static public final int AQUAMARINE_BORDER1 = 57;\r
-       static public final int LIGHT_BLUE_BORDER1 = 58;\r
-       static public final int CADET_BLUE_STATE_BORDER = 59;\r
-       static public final int OLIVE_BORDER2 = 60;\r
-       \r
-       static public final int STATES_BORDER0 = 45;\r
-       static public final int STATES_BORDER1 = 60;\r
-\r
-       static public final int MID_LINE = 61;\r
-       static public final int RED = 62;\r
-       static public final int GREEN = 63;\r
-       static public final int BLUE = 64;\r
-       static public final int YELLOW = 65;\r
-       static public final int CYAN = 66;\r
-       static public final int MAGENTA = 67;\r
-\r
-       static public final int SELECTED_TIME = 68;\r
-       static public final int LEGEND_BACKGROUND = 69;\r
-       static public final int LEGEND_FOREGROUND = 70;\r
-\r
-       // group items' colors\r
-       static public final int GR_BACKGROUND = 71;\r
-       static public final int GR_FOREGROUND = 72;\r
-       static public final int GR_BACKGROUND_SEL = 73;\r
-       static public final int GR_FOREGROUND_SEL = 74;\r
-       static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;\r
-       static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;\r
-\r
-       static public final int LIGHT_LINE = 77;\r
-    static public final int BACKGROUND_NAME = 78;\r
-    static public final int BACKGROUND_NAME_SEL = 79;\r
-    static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;\r
-\r
-       // Interraction's colors\r
-       static public final int TI_START_THREAD = BLACK;\r
-       static public final int TI_HANDOFF_LOCK = BLUE;\r
-       static public final int TI_NOTIFY_ALL = GREEN;\r
-       static public final int TI_NOTIFY = GREEN;\r
-       static public final int TI_NOTIFY_JOINED = DARK_GRAY;\r
-       static public final int TI_INTERRUPT = RED;\r
-       static public final int TI_WAIT_EXCEEDED = BLUE;\r
-\r
-       static interface IColorProvider {\r
-               public Color get();\r
-       }\r
-\r
-       static class SysCol implements IColorProvider {\r
-               int syscol;\r
-\r
-               SysCol(int syscol) {\r
-                       this.syscol = syscol;\r
-               }\r
-\r
-               @Override\r
-               public Color get() {\r
-                       return Utils.getSysColor(syscol);\r
-               }\r
-       }\r
-\r
-       static class RGB implements IColorProvider {\r
-               int r;\r
-               int g;\r
-               int b;\r
-\r
-               RGB(int r, int g, int b) {\r
-                       this.r = r;\r
-                       this.g = g;\r
-                       this.b = b;\r
-               }\r
-\r
-               @Override\r
-               public Color get() {\r
-                       return new Color(null, r, g, b);\r
-               }\r
-       }\r
-\r
-       static class Mix implements IColorProvider {\r
-               IColorProvider cp1;\r
-               IColorProvider cp2;\r
-               int w1;\r
-               int w2;\r
-\r
-               Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {\r
-                       this.cp1 = cp1;\r
-                       this.cp2 = cp2;\r
-                       this.w1 = w1;\r
-                       this.w2 = w2;\r
-               }\r
-\r
-               Mix(IColorProvider cp1, IColorProvider cp2) {\r
-                       this.cp1 = cp1;\r
-                       this.cp2 = cp2;\r
-                       this.w1 = 1;\r
-                       this.w2 = 1;\r
-               }\r
-\r
-               @Override\r
-               public Color get() {\r
-                       Color col1 = cp1.get();\r
-                       Color col2 = cp2.get();\r
-                       Color col = Utils.mixColors(col1, col2, w1, w2);\r
-                       return col;\r
-               }\r
-       }\r
-\r
-       static private final IColorProvider _providersMap[] = {\r
-                       //\r
-                       new RGB(100, 100, 100), // UNKNOWN\r
-                       new RGB(174, 200, 124), // RUNNING\r
-                       new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING\r
-                       new RGB(210, 150, 60), // WAITING\r
-                       new RGB(242, 225, 168), // BLOCKED\r
-                       new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK\r
-                       new RGB(200, 200, 200), // STOPPED\r
-                       new RGB(35, 107, 42), // STEEL BLUE\r
-                       new RGB(205,205,0), // DARK YELLOW\r
-                       new RGB(205, 0, 205), // MAGENTA\r
-                       new RGB(171, 130, 255), // PURPLE\r
-                       new RGB(255, 181, 197), // PINK\r
-                       new RGB(112, 219, 147), // AQUAMARINE\r
-                       new RGB(198, 226, 255), // SLATEGRAY\r
-                       new RGB(95, 158, 160), // CADET BLUE\r
-                       new RGB(107, 142, 35), // OLIVE\r
-                       \r
-                       \r
-                       //TODO: Does not seem to be used, check during clean-up\r
-                       new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL\r
-                       new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL\r
-                       new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL\r
-                       new SysCol(SWT.COLOR_CYAN), // WAITING_SEL\r
-                       new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL\r
-                       new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL\r
-                       new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL\r
-                       new SysCol(SWT.COLOR_WHITE), \r
-                       new SysCol(SWT.COLOR_GREEN), \r
-                       new SysCol(SWT.COLOR_BLUE), \r
-                       new SysCol(SWT.COLOR_CYAN), \r
-                       new SysCol(SWT.COLOR_YELLOW), \r
-                       new SysCol(SWT.COLOR_RED), \r
-                       new SysCol(SWT.COLOR_DARK_GRAY), \r
-                       new SysCol(SWT.COLOR_WHITE), \r
-                       new SysCol(SWT.COLOR_GREEN), \r
-                       \r
-\r
-                       new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND\r
-                       new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND\r
-                       new RGB(232, 242, 254), // BACKGROUND_SEL\r
-                       new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL\r
-                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS\r
-                       new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS\r
-                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND\r
-                       new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND\r
-\r
-                       new SysCol(SWT.COLOR_GRAY), // FIX_COLOR\r
-                       new SysCol(SWT.COLOR_WHITE), // WHITE\r
-                       new SysCol(SWT.COLOR_GRAY), // GRAY\r
-                       new SysCol(SWT.COLOR_BLACK), // BLACK\r
-                       new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY\r
-\r
-                       new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER\r
-                       new RGB(75, 115, 120), // GREEN_BORDER\r
-                       new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER\r
-                       new RGB(242, 225, 168), // ORANGE_BORDER\r
-                       new RGB(210, 150, 60), // GOLD_BORDER\r
-                       new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER\r
-                       new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER\r
-                       new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER\r
-                       new RGB(75, 115, 120), // DARK_YELLOW_BORDER\r
-                       new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER\r
-                       new RGB(242, 225, 168), // PURPLE1_BORDER\r
-                       new RGB(210, 150, 60), // PINK1_BORDER\r
-                       new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER\r
-                       new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER\r
-                       new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER\r
-                       new RGB(75, 115, 120), // OLIVE_BORDER\r
-               \r
-\r
-                       new SysCol(SWT.COLOR_GRAY), // MID_LINE\r
-                       new SysCol(SWT.COLOR_RED), // RED\r
-                       new SysCol(SWT.COLOR_GREEN), // GREEN\r
-                       new SysCol(SWT.COLOR_BLUE), // BLUE\r
-                       new SysCol(SWT.COLOR_YELLOW), // YELLOW\r
-                       new SysCol(SWT.COLOR_CYAN), // CYAN\r
-                       new SysCol(SWT.COLOR_MAGENTA), // MAGENTA\r
-\r
-                       new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME\r
-                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND\r
-                       new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND\r
-\r
-                       new Mix(new RGB(150, 200, 240), new SysCol(\r
-                                       SWT.COLOR_LIST_BACKGROUND)),// GR_BACKGROUND\r
-                       new RGB(0, 0, 50), // GR_FOREGROUND\r
-                       new Mix(new RGB(200, 200, 100),\r
-                                       new SysCol(SWT.COLOR_LIST_SELECTION)), // GR_BACKGROUND_SEL\r
-                       new Mix(new RGB(150, 200, 240), new SysCol(\r
-                                       SWT.COLOR_LIST_SELECTION_TEXT)), // GR_FOREGROUND_SEL\r
-                       new Mix(new RGB(222, 222, 155), new SysCol(\r
-                                       SWT.COLOR_WIDGET_BACKGROUND)), // GR_BACKGROUND_SEL_NOFOCUS\r
-                       new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS\r
-\r
-                       new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(\r
-                                       SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE\r
-\r
-                       new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6),   // BACKGROUND_NAME\r
-                   new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6),                  // BACKGROUND_NAME_SEL\r
-                   new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS\r
-       };\r
-\r
-       private Color _colors[];\r
-\r
-       public TraceColorScheme() {\r
-               _colors = new Color[_providersMap.length];\r
-       }\r
-\r
-       public void dispose() {\r
-               for (int i = 0; i < _colors.length; i++) {\r
-                       Utils.dispose(_colors[i]);\r
-                       _colors[i] = null;\r
-               }\r
-       }\r
-\r
-       public Color getColor(int idx) {\r
-               if (null == _colors[idx]) {\r
-                       if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {\r
-                               Color col1 = getColor(idx - STATES_SEL0);\r
-                               Color col2 = getColor(BACKGROUND_SEL);\r
-                               _colors[idx] = Utils.mixColors(col1, col2, 3, 1);\r
-                       } else {\r
-                               _colors[idx] = _providersMap[idx].get();\r
-                       }\r
-               }\r
-               return _colors[idx];\r
-       }\r
-\r
-       public Color getBkColor(boolean selected, boolean focused, boolean name) {\r
-           if (name) {\r
-               if (selected && focused)\r
-                   return getColor(BACKGROUND_NAME_SEL);\r
-               if (selected)\r
-                   return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
-               return getColor(BACKGROUND_NAME);\r
-           } else {\r
-               if (selected && focused)\r
-                   return getColor(BACKGROUND_SEL);\r
-               if (selected)\r
-                   return getColor(BACKGROUND_SEL_NOFOCUS);\r
-               return getColor(BACKGROUND);\r
-           }\r
-       }\r
-\r
-       public Color getFgColor(boolean selected, boolean focused) {\r
-               if (selected && focused)\r
-                       return getColor(FOREGROUND_SEL);\r
-               if (selected)\r
-                       return getColor(FOREGROUND_SEL_NOFOCUS);\r
-               return getColor(FOREGROUND);\r
-       }\r
-\r
-       public Color getBkColorGroup(boolean selected, boolean focused) {\r
-               if (selected && focused)\r
-                       return getColor(GR_BACKGROUND_SEL);\r
-               if (selected)\r
-                       return getColor(GR_BACKGROUND_SEL_NOFOCUS);\r
-               return getColor(GR_BACKGROUND);\r
-       }\r
-\r
-       public Color getFgColorGroup(boolean selected, boolean focused) {\r
-               if (selected && focused)\r
-                       return getColor(GR_FOREGROUND_SEL);\r
-               if (selected)\r
-                       return getColor(GR_FOREGROUND_SEL_NOFOCUS);\r
-               return getColor(GR_FOREGROUND);\r
-       }\r
-\r
-       public static StateColor[] getStateColors() {\r
-               return stateColors;\r
-       }\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TraceCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/TraceCtrl.java
deleted file mode 100644 (file)
index 345b481..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, Intel Corporation.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: TraceCtrl.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.PaintEvent;\r
-import org.eclipse.swt.events.PaintListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Canvas;\r
-import org.eclipse.swt.widgets.Composite;\r
-\r
-public abstract class TraceCtrl extends Canvas implements PaintListener {\r
-\r
-       static public final int MARGIN = 4;\r
-    static public final int RIGHT_MARGIN = 2; // 2 pixels less to make sure end time is visible\r
-       static public final int SMALL_ICON_SIZE = 16;\r
-\r
-       protected TraceColorScheme _colors;\r
-       protected int _fontHeight = 0;\r
-\r
-       public TraceCtrl(Composite parent, TraceColorScheme colors) {\r
-               this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);\r
-       }\r
-\r
-       public TraceCtrl(Composite parent, TraceColorScheme colors, int style) {\r
-               super(parent, style);\r
-               _colors = colors;\r
-               addPaintListener(this);\r
-       }\r
-\r
-       @Override\r
-       public void dispose() {\r
-               super.dispose();\r
-       }\r
-\r
-       @Override\r
-       public void paintControl(PaintEvent e) {\r
-               if (e.widget != this)\r
-                       return;\r
-               _fontHeight = e.gc.getFontMetrics().getHeight();\r
-               Rectangle bound = getClientArea();\r
-               if (!bound.isEmpty()) {\r
-                       Color colBackup = e.gc.getBackground();\r
-                       paint(bound, e);\r
-                       e.gc.setBackground(colBackup);\r
-               }\r
-       }\r
-\r
-       public int getFontHeight() {\r
-               return _fontHeight;\r
-       }\r
-\r
-       abstract void paint(Rectangle bound, PaintEvent e);\r
-}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/Utils.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/timeAnalysis/widgets/Utils.java
deleted file mode 100644 (file)
index 4cd5f86..0000000
+++ /dev/null
@@ -1,535 +0,0 @@
-/*****************************************************************************\r
- * Copyright (c) 2007, 2008 Intel Corporation and others.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *    Intel Corporation - Initial API and implementation\r
- *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
- *    Alvaro Sanchex-Leon - Udpated for TMF\r
- *\r
- * $Id: Utils.java,v 1.11 2008/06/16 21:04:49 jkubasta Exp $ \r
- *****************************************************************************/\r
-\r
-package org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets;\r
-\r
-import java.text.SimpleDateFormat;\r
-import java.util.Date;\r
-import java.util.Iterator;\r
-import java.util.TimeZone;\r
-\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer.TimeFormat;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Device;\r
-import org.eclipse.swt.graphics.GC;\r
-import org.eclipse.swt.graphics.Point;\r
-import org.eclipse.swt.graphics.Rectangle;\r
-import org.eclipse.swt.widgets.Display;\r
-\r
-public class Utils {\r
-\r
-       static public final int IMG_THREAD_RUNNING = 0;\r
-       static public final int IMG_THREAD_SUSPENDED = 1;\r
-       static public final int IMG_THREAD_STOPPED = 2;\r
-       static public final int IMG_METHOD_RUNNING = 3;\r
-       static public final int IMG_METHOD = 4;\r
-       static public final int IMG_NUM = 5;\r
-\r
-       static public final Object[] _empty = new Object[0];\r
-\r
-       static enum Resolution {\r
-               SECONDS, MILLISEC, MICROSEC, NANOSEC\r
-       };\r
-\r
-       static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$\r
-       static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$\r
-       static {\r
-        stimeformat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
-        sdateformat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
-       }\r
-\r
-//     static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
-//                     "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
-//                     "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
-//\r
-//     static private String _externalPath[] = {\r
-//                     "icons/full/obj16/thread_obj.gif", // running thread\r
-//                     "icons/full/obj16/threads_obj.gif", // suspended\r
-//                     "icons/full/obj16/threadt_obj.gif", // stopped\r
-//                     "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
-//                     "icons/full/obj16/stckframe_obj.gif", // stack frame\r
-//     };\r
-\r
-//     static public Image getImage(int idx) {\r
-//             if (idx < 0 || idx >= IMG_NUM)\r
-//                     SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
-//             String key = "trace.img." + idx;\r
-//             Image img = TimeAnalysisPlugin.getDefault().getImageRegistry().get(key);\r
-//             if (null == img) {\r
-//                     ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
-//                                     _externalPlugin[idx], _externalPath[idx]);\r
-//                     TimeAnalysisPlugin.getDefault().getImageRegistry().put(key, desc);\r
-//                     img = TimeAnalysisPlugin.getDefault().getImageRegistry().get(key);\r
-//             }\r
-//             return img;\r
-//     }\r
-\r
-       static public void init(Rectangle rect) {\r
-               rect.x = 0;\r
-               rect.y = 0;\r
-               rect.width = 0;\r
-               rect.height = 0;\r
-       }\r
-\r
-       static public void init(Rectangle rect, int x, int y, int width, int height) {\r
-               rect.x = x;\r
-               rect.y = y;\r
-               rect.width = width;\r
-               rect.height = height;\r
-       }\r
-\r
-       static public void init(Rectangle rect, Rectangle source) {\r
-               rect.x = source.x;\r
-               rect.y = source.y;\r
-               rect.width = source.width;\r
-               rect.height = source.height;\r
-       }\r
-\r
-       static public void deflate(Rectangle rect, int x, int y) {\r
-               rect.x += x;\r
-               rect.y += y;\r
-               rect.width -= x + x;\r
-               rect.height -= y + y;\r
-       }\r
-\r
-       static public void inflate(Rectangle rect, int x, int y) {\r
-               rect.x -= x;\r
-               rect.y -= y;\r
-               rect.width += x + x;\r
-               rect.height += y + y;\r
-       }\r
-\r
-       static void dispose(Color col) {\r
-               if (null != col)\r
-                       col.dispose();\r
-       }\r
-\r
-       static public Color mixColors(Device display, Color c1, Color c2, int w1,\r
-                       int w2) {\r
-               return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed())\r
-                               / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen())\r
-                               / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue())\r
-                               / (w1 + w2));\r
-       }\r
-\r
-       static public Color getSysColor(int id) {\r
-               Color col = Display.getCurrent().getSystemColor(id);\r
-               return new Color(col.getDevice(), col.getRGB());\r
-       }\r
-\r
-       static public Color mixColors(Color col1, Color col2, int w1, int w2) {\r
-               return mixColors(Display.getCurrent(), col1, col2, w1, w2);\r
-       }\r
-\r
-       static public int drawText(GC gc, String text, Rectangle rect,\r
-                       boolean transp) {\r
-               Point size = gc.stringExtent(text);\r
-               gc.drawText(text, rect.x, rect.y, transp);\r
-               return size.x;\r
-       }\r
-\r
-       static public int drawText(GC gc, String text, int x, int y, boolean transp) {\r
-               Point size = gc.stringExtent(text);\r
-               gc.drawText(text, x, y, transp);\r
-               return size.x;\r
-       }\r
-\r
-       /**\r
-     * Formats time in format: MM:SS:NNN\r
-     * \r
-        * @param time time\r
-        * @param format  0: MMMM:ss:nnnnnnnnn, 1: HH:MM:ss MMM.mmmm.nnn\r
-        * @param resolution the resolution\r
-        * @return the formatted time\r
-        */\r
-       static public String formatTime(long time, TimeFormat format, Resolution resolution) {\r
-               // if format is absolute (Calendar)\r
-               if (format == TimeFormat.ABSOLUTE) {\r
-                       return formatTimeAbs(time, resolution);\r
-               }\r
-\r
-               StringBuffer str = new StringBuffer();\r
-               boolean neg = time < 0;\r
-               if (neg) {\r
-                       time = -time;\r
-                       str.append('-');\r
-               }\r
-\r
-               long sec = (long) (time * 1E-9);\r
-               // TODO: Expand to make it possible to select the minute, second, nanosecond format\r
-               //printing minutes is suppressed just sec and ns\r
-               // if (sec / 60 < 10)\r
-               // str.append('0');\r
-               // str.append(sec / 60);\r
-               // str.append(':');\r
-               // sec %= 60;\r
-               // if (sec < 10)\r
-               // str.append('0');\r
-               str.append(sec);\r
-               String ns = formatNs(time, resolution);\r
-               if (!ns.equals("")) { //$NON-NLS-1$\r
-                       str.append(':');\r
-                       str.append(ns);\r
-               }\r
-\r
-               return str.toString();\r
-       }\r
-\r
-       /**\r
-        * From input time in nanoseconds, convert to Date format YYYY-MM-dd\r
-        * \r
-        * @param absTime\r
-        * @return the formatted date\r
-        */\r
-       public static String formatDate(long absTime) {\r
-               String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));\r
-               return sdate;\r
-       }\r
-\r
-       /**\r
-        * Formats time in ns to Calendar format: HH:MM:SS MMM.mmm.nnn\r
-        * \r
-        * @param time\r
-        * @return the formatted time\r
-        */\r
-       static public String formatTimeAbs(long time, Resolution res) {\r
-               StringBuffer str = new StringBuffer();\r
-\r
-               // format time from nanoseconds to calendar time HH:MM:SS\r
-               String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
-               str.append(stime + " "); //$NON-NLS-1$\r
-               // append the Milliseconds, MicroSeconds and NanoSeconds as specified in\r
-               // the Resolution\r
-               str.append(formatNs(time, res));\r
-               return str.toString();\r
-       }\r
-\r
-       /**\r
-        * Obtains the remainder fraction on unit Seconds of the entered value in\r
-        * nanoseconds. e.g. input: 1241207054171080214 ns The number of fraction\r
-        * seconds can be obtained by removing the last 9 digits: 1241207054 the\r
-        * fractional portion of seconds, expressed in ns is: 171080214\r
-        * \r
-        * @param time\r
-        * @param res\r
-        * @return the formatted nanosec\r
-        */\r
-       public static String formatNs(long time, Resolution res) {\r
-               StringBuffer temp = new StringBuffer();\r
-               boolean neg = time < 0;\r
-               if (neg) {\r
-                       time = -time;\r
-               }\r
-\r
-               // The following approach could be used although performance\r
-               // decreases in half.\r
-               // String strVal = String.format("%09d", time);\r
-               // String tmp = strVal.substring(strVal.length() - 9);\r
-\r
-               // number of segments to be included\r
-               int segments = 0;\r
-               switch (res) {\r
-               case MILLISEC:\r
-                       segments = 1;\r
-                       break;\r
-               case MICROSEC:\r
-                       segments = 2;\r
-                       break;\r
-               case NANOSEC:\r
-                       segments = 3;\r
-                       break;\r
-               default:\r
-                       break;\r
-               }\r
-\r
-               long ns = time;\r
-               ns %= 1000000000;\r
-               if (ns < 10) {\r
-                       temp.append("00000000"); //$NON-NLS-1$\r
-               } else if (ns < 100) {\r
-                       temp.append("0000000"); //$NON-NLS-1$\r
-               } else if (ns < 1000) {\r
-                       temp.append("000000"); //$NON-NLS-1$\r
-               } else if (ns < 10000) {\r
-                       temp.append("00000"); //$NON-NLS-1$\r
-               } else if (ns < 100000) {\r
-                       temp.append("0000"); //$NON-NLS-1$\r
-               } else if (ns < 1000000) {\r
-                       temp.append("000"); //$NON-NLS-1$\r
-               } else if (ns < 10000000) {\r
-                       temp.append("00"); //$NON-NLS-1$\r
-               } else if (ns < 100000000) {\r
-                       temp.append("0"); //$NON-NLS-1$\r
-               }\r
-               temp.append(ns);\r
-\r
-               StringBuffer str = new StringBuffer();\r
-               if (segments > 0) {\r
-                       // append ms\r
-                       str.append(temp.substring(0, 3));\r
-               }\r
-               if (segments > 1) {\r
-                       // append Micro secs\r
-                       str.append("."); //$NON-NLS-1$\r
-                       str.append(temp.substring(3, 6));\r
-               }\r
-               if (segments > 2) {\r
-                       // append Nano seconds\r
-                       str.append("."); //$NON-NLS-1$\r
-                       str.append(temp.substring(6));\r
-               }\r
-\r
-               return str.toString();\r
-       }\r
-\r
-       static public int loadIntOption(String opt, int def, int min, int max) {\r
-               // int val =\r
-               // TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
-               // if (0 == val)\r
-               // val = def;\r
-               // if (val < min)\r
-               // val = min;\r
-               // if (val > max)\r
-               // val = max;\r
-               return def;\r
-       }\r
-\r
-       // static public int loadIntOption(String opt) {\r
-       // int val = TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
-       // return val;\r
-       // }\r
-\r
-       static public void saveIntOption(String opt, int val) {\r
-               // TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);\r
-       }\r
-\r
-       static ITimeEvent getFirstEvent(ITmfTimeAnalysisEntry thread) {\r
-               if (null == thread)\r
-                       return null;\r
-               Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator();\r
-               if (iterator.hasNext()) {\r
-                   return iterator.next();\r
-               } else {\r
-                   return null;\r
-               }\r
-       }\r
-\r
-       /**\r
-        * N means: <list> <li>-1: Previous Event</li> <li>0: Current Event</li> <li>\r
-        * 1: Next Event</li> <li>2: Previous Event when located in a non Event Area\r
-        * </list>\r
-        * \r
-        * @param thread\r
-        * @param time\r
-        * @param n\r
-        * @return\r
-        */\r
-    static ITimeEvent findEvent(ITmfTimeAnalysisEntry thread, long time, int n) {\r
-        if (null == thread)\r
-            return null;\r
-        Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator();\r
-        ITimeEvent nextEvent = null;\r
-        ITimeEvent currEvent = null;\r
-        ITimeEvent prevEvent = null;\r
-\r
-        while (iterator.hasNext()) {\r
-            nextEvent = (ITimeEvent) iterator.next();\r
-            long nextStartTime = nextEvent.getTime();\r
-            \r
-            if (nextStartTime > time) {\r
-                break;\r
-            }\r
-            \r
-            if (currEvent == null || currEvent.getTime() != nextStartTime) {\r
-                prevEvent = currEvent;\r
-                currEvent = nextEvent;\r
-            }\r
-        }\r
-        \r
-        if (n == -1) { //previous\r
-            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
-                return prevEvent;\r
-            } else {\r
-                return currEvent;\r
-            }\r
-        } else if (n == 0) { //current\r
-            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
-                return currEvent;\r
-            } else {\r
-                return null;\r
-            }\r
-        } else if (n == 1) { //next\r
-            return nextEvent;\r
-        } else if (n == 2) { //current or previous when in empty space\r
-            return currEvent;\r
-        }\r
-        \r
-        return null;\r
-    }\r
-\r
-       // static public TRCPackage getPackage(Object element) {\r
-       // if (element instanceof TRCPackage)\r
-       // return (TRCPackage) element;\r
-       // if (element instanceof TRCClass)\r
-       // return ((TRCClass) element).getPackage();\r
-       // return null;\r
-       // }\r
-\r
-       // static public TRCObjectAllocationAnnotation getAllocationAnnotation(\r
-       // TRCClass cls) {\r
-       // TRCObjectAllocationAnnotation aa = null;\r
-       // EList list = cls.getAnnotations();\r
-       // int len = list.size();\r
-       // for (int i = 0; i < len; i++) {\r
-       // TRCAnnotation annotation = (TRCAnnotation) list.get(i);\r
-       // if (annotation instanceof TRCObjectAllocationAnnotation)\r
-       // aa = (TRCObjectAllocationAnnotation) annotation;\r
-       // }\r
-       // return aa;\r
-       // }\r
-\r
-       static public String fixMethodSignature(String sig) {\r
-               int pos = sig.indexOf('(');\r
-               if (pos >= 0) {\r
-                       String ret = sig.substring(0, pos);\r
-                       sig = sig.substring(pos);\r
-                       sig = sig + " " + ret; //$NON-NLS-1$\r
-               }\r
-               return sig;\r
-       }\r
-\r
-       static public String restoreMethodSignature(String sig) {\r
-               String ret = ""; //$NON-NLS-1$\r
-               int pos = sig.indexOf('(');\r
-               if (pos >= 0) {\r
-                       ret = sig.substring(0, pos);\r
-                       sig = sig.substring(pos + 1);\r
-               }\r
-               pos = sig.indexOf(')');\r
-               if (pos >= 0) {\r
-                       sig = sig.substring(0, pos);\r
-               }\r
-               String args[] = sig.split(","); //$NON-NLS-1$\r
-        StringBuffer result = new StringBuffer("("); //$NON-NLS-1$\r
-               for (int i = 0; i < args.length; i++) {\r
-                       String arg = args[i].trim();\r
-                       if (arg.length() == 0 && args.length == 1)\r
-                               break;\r
-                       result.append(getTypeSignature(arg));\r
-               }\r
-               result.append(")").append(getTypeSignature(ret)); //$NON-NLS-1$\r
-               return result.toString();\r
-       }\r
-\r
-       static public String getTypeSignature(String type) {\r
-               int dim = 0;\r
-               for (int j = 0; j < type.length(); j++) {\r
-                       if (type.charAt(j) == '[')\r
-                               dim++;\r
-               }\r
-               int pos = type.indexOf('[');\r
-               if (pos >= 0)\r
-                       type = type.substring(0, pos);\r
-               StringBuffer sig = new StringBuffer(""); //$NON-NLS-1$\r
-               for (int j = 0; j < dim; j++)\r
-                       sig.append("[");                 //$NON-NLS-1$\r
-               if (type.equals("boolean"))     //$NON-NLS-1$\r
-                       sig.append("Z");                 //$NON-NLS-1$\r
-               else if (type.equals("byte"))   //$NON-NLS-1$\r
-                       sig.append("B");                 //$NON-NLS-1$\r
-               else if (type.equals("char"))   //$NON-NLS-1$\r
-                       sig.append("C");                 //$NON-NLS-1$\r
-               else if (type.equals("short"))  //$NON-NLS-1$\r
-                       sig.append("S");                 //$NON-NLS-1$\r
-               else if (type.equals("int"))    //$NON-NLS-1$\r
-                       sig.append("I");                 //$NON-NLS-1$\r
-               else if (type.equals("long"))   //$NON-NLS-1$\r
-                       sig.append("J");                 //$NON-NLS-1$\r
-               else if (type.equals("float"))  //$NON-NLS-1$\r
-                       sig.append("F");                 //$NON-NLS-1$\r
-               else if (type.equals("double")) //$NON-NLS-1$\r
-                       sig.append("D");                 //$NON-NLS-1$\r
-               else if (type.equals("void"))   //$NON-NLS-1$\r
-                       sig.append("V");                 //$NON-NLS-1$\r
-               else\r
-                       sig.append("L").append(type.replace('.', '/')).append(";"); //$NON-NLS-1$ //$NON-NLS-2$\r
-               return sig.toString();\r
-       }\r
-\r
-       // static public boolean openSource(Object element) {\r
-       // if (element instanceof String) {\r
-       // final String pattern = (String) element;\r
-       // final int javaType = IJavaSearchConstants.METHOD;\r
-       // BusyIndicator.showWhile(Display.getDefault(), new Runnable() {\r
-       // public void run() {\r
-       // if (!OpenJavaSource.openSource(pattern, javaType,\r
-       // SearchEngine.createWorkspaceScope(), true)) {\r
-       // MessageDialog.openInformation(UIPlugin.getDefault()\r
-       // .getWorkbench().getActiveWorkbenchWindow()\r
-       // .getShell(), TraceMessages.TRC_MSGT, NLS.bind(\r
-       // TraceUIMessages._68, pattern));\r
-       // }\r
-       // }\r
-       // });\r
-       // }\r
-       // OpenSource.openSource(element);\r
-       // return true;\r
-       // }\r
-\r
-       // static public int getObjAge(TRCFullTraceObject obj, EList listGC) {\r
-       // int age = 0;\r
-       // double t0 = obj.getCreateTime();\r
-       // double t1 = obj.getCollectTime();\r
-       // int len = listGC.size();\r
-       // for (int j = 0; j < len; j++) {\r
-       // TRCGCEvent gcEvent = (TRCGCEvent) listGC.get(j);\r
-       // if (gcEvent.getType().equals("finish")) {\r
-       // double time = gcEvent.getTime();\r
-       // if (time <= t0)\r
-       // continue;\r
-       // if (t1 > 0 && time >= t1)\r
-       // break;\r
-       // age++;\r
-       // }\r
-       // }\r
-       // return age;\r
-       // }\r
-\r
-       static public int compare(double d1, double d2) {\r
-               if (d1 > d2)\r
-                       return 1;\r
-               if (d1 < d2)\r
-                       return 1;\r
-               return 0;\r
-       }\r
-\r
-       static public int compare(String s1, String s2) {\r
-               if (s1 != null && s2 != null)\r
-                       return s1.compareToIgnoreCase(s2);\r
-               if (s1 != null)\r
-                       return 1;\r
-               if (s2 != null)\r
-                       return -1;\r
-               return 0;\r
-       }\r
-\r
-       // static public String formatPercent(int val, int max) {\r
-       // String s = max > 0 && max >= val ? TString\r
-       // .formatAsPercentage((double) val / (double) max) : "";\r
-       // return s;\r
-       // }\r
-}\r
index f2e67aeed0972567bec8a60504c09e4ff8ad72b0..3fedf5706b70a531c5698f44b92f4f3d3bc75e79 100644 (file)
@@ -104,7 +104,7 @@ public class ColorSetting {
        \r
        /**\r
         * @return the tick color index (0-15)\r
-        * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r
+        * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme\r
         */\r
        public int getTickColorIndex() {\r
                return fTickColorIndex;\r
@@ -112,7 +112,7 @@ public class ColorSetting {
        \r
        /**\r
         * @param tickColorIndex the tick color index to set (0-15)\r
-        * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme\r
+        * @see org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme\r
         */\r
        public void setTickColorIndex(int tickColorIndex) {\r
                fTickColorIndex = tickColorIndex;\r
index 8d7dd9a0dfe79bc956f0fad0469c0855538c091c..f748f29f74000fecc0c612d3454d4645a53930aa 100644 (file)
@@ -17,7 +17,7 @@ import java.util.Arrays;
 \r
 import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;\r
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.widgets.Display;\r
 \r
index 4bad154788dae890aa91c878920168f35e43de50..81ab33ecb045d3539fe96ff2ec8ab4c0f5fc22ef 100644 (file)
@@ -25,12 +25,12 @@ import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
 import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
 import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
 import org.eclipse.linuxtools.tmf.ui.views.filter.FilterDialog;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.ScrolledComposite;\r
 import org.eclipse.swt.events.MouseAdapter;\r
index fae26f6ac1e4b3131c79bbe7a4114771eec59c83..98e39c7cf210914f4577ac9b4fe55b953e952e20 100644 (file)
@@ -16,10 +16,10 @@ import java.util.Map;
 \r
 import org.eclipse.jface.dialogs.Dialog;\r
 import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.events.MouseAdapter;\r
 import org.eclipse.swt.events.MouseEvent;\r
index 358f584ed813fd16fa769ba0717e11ed33d5b05a..c26194675379ac6340349ab03175eb0f32866460 100644 (file)
@@ -17,8 +17,8 @@ import java.util.NoSuchElementException;
 import java.util.Vector;\r
 \r
 import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
 \r
 public class TimeChartAnalysisEntry implements ITmfTimeAnalysisEntry {\r
 \r
index 3a0c31faac3f6f7ba9f8ab4393125467a9ba9c7f..692fb329f54a146c0a69ee608a9ac603875c2d80 100644 (file)
@@ -14,11 +14,11 @@ package org.eclipse.linuxtools.tmf.ui.views.timechart;
 \r
 import java.util.Map;\r
 \r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeAnalysisProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.TraceColorScheme;\r
 import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.graphics.Color;\r
 import org.eclipse.swt.graphics.GC;\r
index 2c27264ca904edd87430127f67accb471d407963..8c1c4540d32b107ecd473c2bfdf9ab5fadb1787b 100644 (file)
@@ -16,9 +16,9 @@ import java.util.ArrayList;
 import java.util.Iterator;\r
 \r
 import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
 import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
 \r
 public class TimeChartEvent implements ITimeEvent {\r
 \r
index d9077d7abc333129ee305f2a2c8e6b08e80a5a13..90666746054c2e9ee6bb40042f5a479395a31c4b 100644 (file)
@@ -36,21 +36,21 @@ import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;\r
 import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceClosedSignal;\r
 import org.eclipse.linuxtools.tmf.ui.signal.TmfTraceOpenedSignal;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.TmfViewerFactory;\r
 import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterListener;\r
 import org.eclipse.linuxtools.tmf.ui.viewers.events.ITmfEventsFilterProvider;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeScaleSelectionListener;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITmfTimeSelectionListener;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeScaleSelectionEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.TmfTimeSelectionEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITimeEvent;\r
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.model.ITmfTimeAnalysisEntry;\r
 import org.eclipse.linuxtools.tmf.ui.views.TmfView;\r
 import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSetting;\r
 import org.eclipse.linuxtools.tmf.ui.views.colors.ColorSettingsManager;\r
 import org.eclipse.linuxtools.tmf.ui.views.colors.IColorSettingsListener;\r
 import org.eclipse.linuxtools.tmf.ui.views.timechart.TimeChartEvent.RankRange;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeAnalysisViewer;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITmfTimeScaleSelectionListener;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITmfTimeSelectionListener;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeScaleSelectionEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeSelectionEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfViewerFactory;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.layout.GridLayout;\r
 import org.eclipse.swt.widgets.Composite;\r
index 055f884a0c7427c074e83f2e3b35c27661bd02a0..cca6d73fc122ae4aa4ebcfc1a9bdf44d69808ca4 100755 (executable)
@@ -18,7 +18,6 @@ import java.util.Arrays;
 
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.GridUtil;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.DiagramToolTip;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.NGC;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget;
@@ -985,7 +984,7 @@ public class SDPrintDialogUI {
 
         if (fShowPrintButton) {
             Composite printerDlg = new Composite(parent, SWT.NONE);
-            data = GridUtil.createHorizontalFill();
+            data = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
             data.horizontalSpan = 6;
             parentLayout = new GridLayout();
             parentLayout.numColumns = 2;
@@ -993,7 +992,7 @@ public class SDPrintDialogUI {
             printerDlg.setLayoutData(data);
 
             Label label = new Label(printerDlg, SWT.NONE);
-            label.setLayoutData(GridUtil.createHorizontalFill());
+            label.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
             fPrinterDialog = new Button(printerDlg, SWT.PUSH);
             fPrinterDialog.setText(SDMessages._115);
 
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/GridUtil.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/GridUtil.java
new file mode 100644 (file)
index 0000000..d15f804
--- /dev/null
@@ -0,0 +1,45 @@
+/**********************************************************************\r
+ * Copyright (c) 2005, 2006 IBM Corporation and others.\r
+ * All rights reserved.   This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * $Id: GridUtil.java,v 1.3 2006/09/20 19:49:13 ewchan Exp $\r
+ * \r
+ * Contributors: \r
+ * IBM - Initial API and implementation\r
+ **********************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.layout.GridData;\r
+\r
+/**\r
+ * A utility class to create convenient grid data objects.\r
+ */ \r
+public class GridUtil\r
+{\r
+       /**\r
+        * Creates a grid data object that occupies vertical and horizontal\r
+        * space.\r
+        */\r
+       static public GridData createFill() \r
+       {\r
+               return new GridData(SWT.FILL, SWT.FILL, true, true);\r
+       }\r
+       /**\r
+        * Creates a grid data object that occupies horizontal space.\r
+        */\r
+       static public GridData createHorizontalFill() \r
+       {               \r
+               return new GridData(SWT.FILL, SWT.DEFAULT, true, false);                \r
+       }\r
+       /**\r
+        * Creates a grid data object that occupies vertical space.\r
+        */\r
+       static public GridData createVerticalFill() \r
+       {\r
+               return new GridData(SWT.DEFAULT, SWT.FILL, false, true);\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeAnalysisViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITimeAnalysisViewer.java
new file mode 100644 (file)
index 0000000..f8ec1e7
--- /dev/null
@@ -0,0 +1,195 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009, 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+ package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
+import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.ScrollBar;\r
+\r
+/**\r
+ * <b><u>ITimeAnalysisWidget</u></b>\r
+ * <p>\r
+ *\r
+ * TODO: Implement me. Please.\r
+ */\r
+public interface ITimeAnalysisViewer extends ITmfViewer {\r
+\r
+    public enum TimeFormat {\r
+               RELATIVE, ABSOLUTE\r
+       };\r
+\r
+       /**\r
+        * @param e\r
+        */\r
+       public void controlResized(ControlEvent e);\r
+\r
+       /**\r
+        * \r
+        * @param traceArr\r
+        * @param start\r
+        *            Specifies a fixed start time to the information to be\r
+        *            displayed\r
+        * @param end\r
+        *            Specifies a fixed end time to the information to be displayed\r
+        * @param updateTimeBounds\r
+        *            If True - Time Range boundaries update is required\r
+        */\r
+       public abstract void display(ITmfTimeAnalysisEntry[] traceArr, long start,\r
+                       long end, boolean updateTimeBounds);\r
+\r
+       /**\r
+        * The start and End time are taken from the limits used by the children\r
+        * events\r
+        * \r
+        * @param traceArr\r
+        */\r
+       public abstract void display(ITmfTimeAnalysisEntry[] traceArr);\r
+\r
+       public void addWidgetSelectionListner(ITmfTimeSelectionListener listener);\r
+\r
+       public void addWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener);\r
+\r
+       public void filterTraces();\r
+\r
+       public ITmfTimeAnalysisEntry getSelectedTrace();\r
+\r
+       public ISelection getSelection();\r
+\r
+       public void groupTraces(boolean on);\r
+\r
+       public boolean isInFocus();\r
+\r
+       public void removeWidgetSelectionListner(ITmfTimeSelectionListener listener);\r
+\r
+       public void removeWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener);\r
+\r
+       public void resetStartFinishTime();\r
+\r
+       public void selectNextEvent();\r
+\r
+       public void selectPrevEvent();\r
+\r
+       public void selectNextTrace();\r
+\r
+       public void selectPrevTrace();\r
+\r
+       public void showLegend();\r
+\r
+       public void zoomIn();\r
+\r
+       public void zoomOut();\r
+\r
+       public void setSelectedTime(long time, boolean ensureVisible, Object source);\r
+\r
+       public void setSelectedEvent(ITimeEvent event, Object Source);\r
+\r
+       public void setSelectedTraceTime(ITmfTimeAnalysisEntry trace, long time, Object Source);\r
+\r
+       public void setSelectVisTimeWindow(long time0, long time1, Object Source);\r
+\r
+       public void setAcceptSelectionAPIcalls(boolean acceptCalls);\r
+\r
+       public void setTimeCalendarFormat(boolean toAbsoluteCaltime);\r
+\r
+       public boolean isCalendarFormat();\r
+\r
+       public boolean isVisibleVerticalScroll();\r
+\r
+       public void setVisibleVerticalScroll(boolean visibleVerticalScroll);\r
+\r
+       public int getBorderWidth();\r
+\r
+       public void setBorderWidth(int borderWidth);\r
+\r
+       public int getHeaderHeight();\r
+\r
+       public void setHeaderHeight(int headerHeight);\r
+\r
+       public int getItemHeight();\r
+\r
+       public void setItemHeight(int rowHeight);\r
+\r
+    public void setMinimumItemWidth(int width);\r
+\r
+       public void resizeControls();\r
+\r
+       public void setSelectedTrace(ITmfTimeAnalysisEntry trace);\r
+\r
+       public ISelection getSelectionTrace();\r
+\r
+       public void setNameWidthPref(int width);\r
+\r
+       public int getNameWidthPref(int width);\r
+\r
+       public void addFilterSelectionListner(ITmfTimeFilterSelectionListener listener);\r
+\r
+       public void removeFilterSelectionListner(\r
+                       ITmfTimeFilterSelectionListener listener);\r
+\r
+       public int getTimeSpace();\r
+\r
+       public void itemUpdate(ITmfTimeAnalysisEntry parent, TimeEvent item);\r
+\r
+       public Control getControl();\r
+\r
+       public ISelectionProvider getSelectionProvider();\r
+\r
+       /**\r
+        * <p>\r
+        * Provide the possibility to control the wait cursor externally\r
+        * </p>\r
+        * <p>\r
+        * e.g. data requests in progress\r
+        * </p>\r
+        * \r
+        * @param waitInd\r
+        *            - true change to wait cursor\r
+        */\r
+       public void waitCursor(boolean waitInd);\r
+\r
+    public void setFocus();\r
+\r
+    /**\r
+     * Update the time bounds without changing the visible range\r
+     * \r
+     * @param beginTime\r
+     * @param endTime\r
+     */\r
+    public void setTimeBounds(long beginTime, long endTime);\r
+\r
+    /**\r
+     * Get the horizontal scrollbar\r
+     * @return the horizontal scrollbar\r
+     */\r
+    public ScrollBar getHorizontalBar();\r
+\r
+    /**\r
+     * Get the vertical scrollbar\r
+     * @return the vertical scrollbar\r
+     */\r
+    public ScrollBar getVerticalBar();\r
+\r
+    /**\r
+     * Set the top index\r
+     * @param index the top index\r
+     */\r
+    public void setTopIndex(int index);\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeFilterSelectionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeFilterSelectionListener.java
new file mode 100644 (file)
index 0000000..008e52d
--- /dev/null
@@ -0,0 +1,19 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.EventListener;\r
+\r
+public interface ITmfTimeFilterSelectionListener extends EventListener {\r
+       public void tmfTaProcessFilterSelection(TmfTimeFilterSelectionEvent event);\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeScaleSelectionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeScaleSelectionListener.java
new file mode 100644 (file)
index 0000000..173862b
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.EventListener;\r
+\r
+/**\r
+ * Implemented by any user of TmfTime in order to be notified of available events,\r
+ * upon registration\r
+ * \r
+ */\r
+public interface ITmfTimeScaleSelectionListener extends EventListener {\r
+       public void tsfTmProcessTimeScaleEvent(TmfTimeScaleSelectionEvent event);\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeSelectionListener.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfTimeSelectionListener.java
new file mode 100644 (file)
index 0000000..7a6a531
--- /dev/null
@@ -0,0 +1,24 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.EventListener;\r
+\r
+/**\r
+ * Implemented by any user of TsfTm in order to be notified of available events,\r
+ * upon registration\r
+ * \r
+ */\r
+public interface ITmfTimeSelectionListener extends EventListener {\r
+       public void tsfTmProcessSelEvent(TmfTimeSelectionEvent event);\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/ITmfViewer.java
new file mode 100644 (file)
index 0000000..57b6197
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;
+
+/**
+ * <b><u>ITmfWidget</u></b>
+ * <p>
+ *
+ * TODO: Implement me. Please.
+ */
+public interface ITmfViewer {
+
+}
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeAnalysisProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeAnalysisProvider.java
new file mode 100644 (file)
index 0000000..4207f06
--- /dev/null
@@ -0,0 +1,328 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009, 2010 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+\r
+public abstract class TmfTimeAnalysisProvider {\r
+    \r
+       static public final int IMG_THREAD_RUNNING = 0;\r
+       static public final int IMG_THREAD_SUSPENDED = 1;\r
+       static public final int IMG_THREAD_STOPPED = 2;\r
+       static public final int IMG_METHOD_RUNNING = 3;\r
+       static public final int IMG_METHOD = 4;\r
+       static public final int IMG_NUM = 5;\r
+\r
+       public enum StateColor {\r
+               GREEN, DARK_BLUE, RED, GOLD, ORANGE, GRAY, BLACK, DARK_GREEN, DARK_YELLOW, MAGENTA3, PURPLE1, PINK1, AQUAMARINE, LIGHT_BLUE, CADET_BLUE, OLIVE;\r
+\r
+               private String stateName;\r
+\r
+               StateColor() {\r
+                       String undef = "Undefined"; //$NON-NLS-1$\r
+                       this.stateName = undef;\r
+               }\r
+\r
+               public String getStateName() {\r
+                       return stateName;\r
+               }\r
+\r
+               public void setStateName(String stateName) {\r
+                       this.stateName = stateName;\r
+               }\r
+       }\r
+\r
+       // static private String _externalPath[] = {\r
+       // "icons/full/obj16/thread_obj.gif", // running thread\r
+       // "icons/full/obj16/threads_obj.gif", // suspended\r
+       // "icons/full/obj16/threadt_obj.gif", // stopped\r
+       // "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
+       // "icons/full/obj16/stckframe_obj.gif", // stack frame\r
+       // };\r
+       //\r
+       // static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
+       // "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
+       // "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
+       //\r
+       // static private Image getImage(int idx) {\r
+       // if (idx < 0 || idx >= IMG_NUM)\r
+       // SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
+       // String key = "trace.img." + idx;\r
+       // Image img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
+       // if (null == img) {\r
+       // ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
+       // _externalPlugin[idx], _externalPath[idx]);\r
+       // TmfUiPlugin.getDefault().getImageRegistry().put(key, desc);\r
+       // img = TmfUiPlugin.getDefault().getImageRegistry().get(key);\r
+       // }\r
+       // return img;\r
+       // }\r
+\r
+       public void drawState(TraceColorScheme colors, ITimeEvent event,\r
+                       Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
+                       boolean timeSelected) {\r
+               int colorIdx = getEventColorVal(event);\r
+               drawState(colors, colorIdx, rect, gc, selected, rectBound, timeSelected);\r
+\r
+       }\r
+\r
+       public void drawState(TraceColorScheme colors, int colorIdx,\r
+                       Rectangle rect, GC gc, boolean selected, boolean rectBound,\r
+                       boolean timeSelected) {\r
+\r
+               boolean visible = rect.width == 0 ? false : true;\r
+               int colorIdx1 = colorIdx;\r
+               \r
+               timeSelected = timeSelected && selected;\r
+               if (timeSelected) {\r
+                       colorIdx1 = colorIdx + TraceColorScheme.STATES_SEL0\r
+                                       - TraceColorScheme.STATES0;\r
+               }\r
+\r
+               if (visible) {\r
+                       // fill all rect area\r
+                       if (rect.isEmpty())\r
+                               return;\r
+\r
+                       gc.setBackground(colors.getColor(colorIdx1));\r
+                       gc.fillRectangle(rect);\r
+                       colorIdx1 = colorIdx + TraceColorScheme.STATES_BORDER0\r
+                                       - TraceColorScheme.STATES0;\r
+                       gc.setForeground(colors.getColor(colorIdx1));\r
+\r
+                       // draw bounds\r
+                       if (!timeSelected) {\r
+                               if (rectBound && rect.width >= 3) {\r
+                                       gc.drawRectangle(rect.x, rect.y, rect.width - 1,\r
+                                                       rect.height - 1);\r
+                               } else {\r
+                                       // Draw the top and bottom borders i.e. no side borders\r
+                                       // top\r
+                                       gc\r
+                                                       .drawLine(rect.x, rect.y, rect.x + rect.width - 1,\r
+                                                                       rect.y);\r
+                                       // bottom\r
+                                       gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x\r
+                                                       + rect.width - 1, rect.y + rect.height - 1);\r
+                               }\r
+                       }\r
+                       // draw decoration middle line\r
+                       // int mindy = rect.y + rect.height / 2;\r
+                       // if (TraceColorScheme.GOLD_STATE == colorIdx\r
+                       // || TraceColorScheme.ORANGE_STATE == colorIdx) {\r
+                       // int s = gc.getLineStyle();\r
+                       // int w = gc.getLineWidth();\r
+                       // gc.setLineStyle(SWT.LINE_DOT);\r
+                       // gc.setLineWidth(2);\r
+                       // gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy);\r
+                       // gc.setLineStyle(s);\r
+                       // gc.setLineWidth(w);\r
+                       // } else if (TraceColorScheme.RED_STATE == colorIdx\r
+                       // || TraceColorScheme.GRAY_STATE == colorIdx) {\r
+                       // int w = gc.getLineWidth();\r
+                       // gc.setLineWidth(2);\r
+                       // gc.drawLine(rect.x, mindy, rect.x + rect.width, mindy);\r
+                       // gc.setLineWidth(w);\r
+                       // }\r
+                       // // draw selection bounds\r
+                       // if (timeSelected) {\r
+                       // gc.setForeground(colors\r
+                       // .getColor(TraceColorScheme.SELECTED_TIME));\r
+                       // if (rect.width >= 3) {\r
+                       // gc.drawRectangle(rect.x, rect.y, rect.width - 1,\r
+                       // rect.height - 1);\r
+                       // // gc.drawRectangle(rect.x + 1, rect.y + 1, rect.width - 3,\r
+                       // // rect.height - 3);\r
+                       // } else {\r
+                       // gc\r
+                       // .drawLine(rect.x, rect.y, rect.x + rect.width - 1,\r
+                       // rect.y);\r
+                       // gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x\r
+                       // + rect.width - 1, rect.y + rect.height - 1);\r
+                       // }\r
+                       // gc.drawLine(rect.x, rect.y + 1, rect.x + rect.width - 1,\r
+                       // rect.y + 1);\r
+                       // gc.drawLine(rect.x, rect.y + rect.height - 2, rect.x\r
+                       // + rect.width - 1, rect.y + rect.height - 2);\r
+                       // }\r
+               } else {\r
+                       // selected rectangle area is not visible but can be represented\r
+                       // with a broken vertical line of specified width.\r
+                       int width = 2;\r
+                       rect.width = width;\r
+                       // check if height is greater than zero.\r
+                       if (rect.isEmpty())\r
+                               return;\r
+                       // colorIdx1 = TraceColorScheme.BLACK;\r
+                       gc.setForeground(colors.getColor(colorIdx));\r
+                       int s = gc.getLineStyle();\r
+                       int w = gc.getLineWidth();\r
+                       gc.setLineStyle(SWT.LINE_DOT);\r
+                       gc.setLineWidth(width);\r
+                       // Trace.debug("Reactangle not visible, drawing vertical line with: "\r
+                       // + rect.x + "," + rect.y + "," + rect.x + "," + rect.y\r
+                       // + rect.height);\r
+                       gc.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height);\r
+                       gc.setLineStyle(s);\r
+                       gc.setLineWidth(w);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Uses the abstract method getEventcolor to obtain an enum value and\r
+        * convert it to an internal color index\r
+        * \r
+        * @param event\r
+        * @return the internal color index\r
+        */\r
+       public int getEventColorVal(ITimeEvent event) {\r
+               StateColor colors = getEventColor(event);\r
+               if (colors == StateColor.GREEN) {\r
+                       return TraceColorScheme.GREEN_STATE;\r
+               } else if (colors == StateColor.DARK_BLUE) {\r
+                       return TraceColorScheme.DARK_BLUE_STATE;\r
+               } else if (colors == StateColor.RED) {\r
+                       return TraceColorScheme.RED_STATE;\r
+               } else if (colors == StateColor.GOLD) {\r
+                       return TraceColorScheme.GOLD_STATE;\r
+               } else if (colors == StateColor.ORANGE) {\r
+                       return TraceColorScheme.ORANGE_STATE;\r
+               } else if (colors == StateColor.GRAY) {\r
+                       return TraceColorScheme.GRAY_STATE;\r
+               } else if (colors == StateColor.DARK_GREEN) {\r
+                       return TraceColorScheme.DARK_GREEN_STATE;\r
+               } else if (colors == StateColor.DARK_YELLOW) {\r
+                       return TraceColorScheme.DARK_YELLOW_STATE;\r
+               } else if (colors == StateColor.MAGENTA3) {\r
+                       return TraceColorScheme.MAGENTA3_STATE;\r
+               } else if (colors == StateColor.PURPLE1) {\r
+                       return TraceColorScheme.PURPLE1_STATE;\r
+               } else if (colors == StateColor.PINK1) {\r
+                       return TraceColorScheme.PINK1_STATE;\r
+               } else if (colors == StateColor.AQUAMARINE) {\r
+                       return TraceColorScheme.AQUAMARINE_STATE;\r
+               } else if (colors == StateColor.LIGHT_BLUE) {\r
+                       return TraceColorScheme.LIGHT_BLUE_STATE;\r
+               } else if (colors == StateColor.CADET_BLUE) {\r
+                       return TraceColorScheme.CADET_BLUE_STATE_SEL;\r
+               } else if (colors == StateColor.OLIVE) {\r
+                       return TraceColorScheme.OLIVE_STATE;\r
+               }\r
+\r
+               return TraceColorScheme.BLACK_STATE;\r
+       }\r
+\r
+       /**\r
+        * Select the color for the different internal variants of events.\r
+        * \r
+        * @param event\r
+        * @return the corresponding event color\r
+        */\r
+       public abstract StateColor getEventColor(ITimeEvent event);\r
+\r
+       /**\r
+        * This values is appended between braces to the right of Trace Name e.g.\r
+        * Trace And Error Log [Board 17] or for a Thread trace e.g. State Server\r
+        * [java.lang.Thread]\r
+        * \r
+        * @param trace\r
+        * @return the trace class name\r
+        */\r
+       public abstract String getTraceClassName(ITmfTimeAnalysisEntry trace);\r
+\r
+       public String getEventName(ITimeEvent event) {\r
+               return getEventName(event, true, false);\r
+       }\r
+\r
+       /**\r
+        * Specify a Name for the event depending on its type or state e.g. blocked,\r
+        * running, etc..\r
+        * \r
+        * @param event\r
+        * @param upper\r
+        *            True return String value in Upper case\r
+        * @param extInfo\r
+        *            Verbose, add additional information if applicable\r
+        * @return the event name\r
+        */\r
+       public abstract String getEventName(ITimeEvent event, boolean upper,\r
+                       boolean extInfo);\r
+\r
+       public String composeTraceName(ITmfTimeAnalysisEntry trace, boolean inclState) {\r
+               String name = trace.getName();\r
+               String threadClass = getTraceClassName(trace);\r
+               if (threadClass != null && threadClass.length() > 0) {\r
+                       name += " [" + threadClass + "]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+               }\r
+               /*\r
+                * Check if this is still necessary!\r
+               if (inclState) {\r
+                       List<TimeEvent> list = trace.getTraceEvents();\r
+                       if (null != list && list.size() > 0) {\r
+                               ITimeEvent event = (ITimeEvent) list.get(list.size() - 1);\r
+                               name += " (" + getEventName(event, false, true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$\r
+                       }\r
+               }\r
+               */\r
+               return name;\r
+       }\r
+\r
+       public String composeEventName(ITimeEvent event) {\r
+               String name = event.getEntry().getName();\r
+               String threadClass = getTraceClassName(event.getEntry());\r
+               if (threadClass != null && threadClass.length() > 0) {\r
+                       name += " [" + threadClass + "]"; //$NON-NLS-1$ //$NON-NLS-2$\r
+               }\r
+               name += " (" + getEventName(event, false, true) + ")"; //$NON-NLS-1$ //$NON-NLS-2$\r
+               return name;\r
+       }\r
+\r
+       public abstract Map<String, String> getEventHoverToolTipInfo(\r
+                       ITimeEvent event);\r
+\r
+       /**\r
+        * Provides the image icon for a given Event or Trace e.g. customize to use\r
+        * different icons according to specific event /state combination\r
+        * \r
+        * @param obj\r
+        * @return the image icon\r
+        */\r
+       public Image getItemImage(Object obj) {\r
+           /*\r
+               if (obj instanceof ITmfTimeAnalysisEntry) {\r
+                       List<TimeEvent> list = ((ITmfTimeAnalysisEntry) obj).getTraceEvents();\r
+                       if (null != list && list.size() > 0)\r
+                               obj = list.get(list.size() - 1);\r
+                       else if (((ITmfTimeAnalysisEntry) obj).getStopTime() > 0)\r
+                               return getImage(IMG_THREAD_STOPPED);\r
+                       else\r
+                               return getImage(IMG_THREAD_RUNNING);\r
+               }\r
+               if (obj instanceof TimeEvent) {\r
+                       return getImage(IMG_THREAD_RUNNING);\r
+               }\r
+               */\r
+               return null;\r
+       }\r
+\r
+       public abstract String getStateName(StateColor color);\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeAnalysisViewer.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeAnalysisViewer.java
new file mode 100644 (file)
index 0000000..39f0b95
--- /dev/null
@@ -0,0 +1,957 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008, 2009, 2010 Intel Corporation, Ericsson\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alexander N. Alexeev, Intel - Add monitors statistics support\r
+ *    Alvaro Sanchez-Leon - Adapted for TMF\r
+ *\r
+ * $Id: ThreadStatesView.java,v 1.7 2008/05/19 15:07:21 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TmfTimeFilterDialog;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs.TmfTimeLegend;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.ITimeDataProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TimeScaleCtrl;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TmfTimeStatesCtrl;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TmfTimeTipHandler;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ControlAdapter;\r
+import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.ScrollBar;\r
+\r
+public class TmfTimeAnalysisViewer implements ITimeAnalysisViewer, ITimeDataProvider, SelectionListener {\r
+\r
+       /** vars */\r
+       private long _minTimeInterval;\r
+       private long _selectedTime;\r
+       private long _beginTime;\r
+       private long _endTime;\r
+       private long _time0;\r
+       private long _time1;\r
+       private long _time0_;\r
+       private long _time1_;\r
+       private long _time0_extSynch = 0;\r
+       private long _time1_extSynch = 0;\r
+       private boolean _timeRangeFixed;\r
+       private int _nameWidthPref = 200;\r
+       private int _minNameWidth = 6;\r
+       private int _nameWidth;\r
+       private Composite _dataViewer;\r
+\r
+       private TmfTimeStatesCtrl _stateCtrl;\r
+       private TimeScaleCtrl _timeScaleCtrl;\r
+       private TmfTimeTipHandler _threadTip;\r
+       private TraceColorScheme _colors;\r
+       private TmfTimeAnalysisProvider _utilImplm;\r
+\r
+       private boolean _acceptSetSelAPICalls = false;\r
+       Vector<ITmfTimeSelectionListener> widgetSelectionListners = new Vector<ITmfTimeSelectionListener>();\r
+       Vector<ITmfTimeScaleSelectionListener> widgetTimeScaleSelectionListners = new Vector<ITmfTimeScaleSelectionListener>();\r
+       Vector<ITmfTimeFilterSelectionListener> widgetFilterSelectionListeners = new Vector<ITmfTimeFilterSelectionListener>();\r
+\r
+       // Calender Time format, using Epoch reference or Relative time\r
+       // format(default\r
+       private boolean calendarTimeFormat = false;\r
+       private int borderWidth = 4;\r
+       private int timeScaleHeight = 22;\r
+\r
+       /** ctor */\r
+       public TmfTimeAnalysisViewer(Composite parent, TmfTimeAnalysisProvider provider) {\r
+        createDataViewer(parent, provider);\r
+       }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.api.ITimeAnalysisWidget#display(org.eclipse.linuxtools.tmf.ui.widgets.timeAnalysis.model.TmfTaTrace[])\r
+     */\r
+    @Override\r
+       public void display(ITmfTimeAnalysisEntry[] traceArr) {\r
+        modelUpdate(traceArr);\r
+    }\r
+\r
+       @Override\r
+       public void display(ITmfTimeAnalysisEntry[] traceArr, long start, long end,\r
+                       boolean updateTimeBounds) {\r
+               modelUpdate(traceArr, start, end, updateTimeBounds);\r
+    }\r
+\r
+    public void controlMoved(ControlEvent e) {\r
+       }\r
+\r
+       @Override\r
+       public void controlResized(ControlEvent e) {\r
+               resizeControls();\r
+       }\r
+\r
+       // called from the display order in the API\r
+       public void modelUpdate(ITmfTimeAnalysisEntry[] traces) {\r
+               if (null != _stateCtrl) {\r
+                       //loadOptions();\r
+                       updateInternalData(traces);\r
+                       _stateCtrl.redraw();\r
+                       _timeScaleCtrl.redraw();\r
+               }\r
+       }\r
+\r
+       // called from the display order in the API\r
+       public void modelUpdate(ITmfTimeAnalysisEntry[] traces, long start,\r
+                       long end, boolean updateTimeBounds) {\r
+               if (null != _stateCtrl) {\r
+                       //loadOptions();\r
+                       updateInternalData(traces, start, end);\r
+                       if (updateTimeBounds) {\r
+                               _timeRangeFixed = true;\r
+                               // set window to match limits\r
+                               setStartFinishTime(_time0_, _time1_);\r
+                       } else {\r
+                               _stateCtrl.redraw();\r
+                               _timeScaleCtrl.redraw();\r
+                       }\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void itemUpdate(ITmfTimeAnalysisEntry parent, TimeEvent item) {\r
+               if (null != parent && null != item) {\r
+                       _stateCtrl.refreshPartial(parent, item);\r
+                       _stateCtrl.redraw();\r
+                       _timeScaleCtrl.redraw();\r
+               }\r
+       }\r
+\r
+       public void selectionChanged() {\r
+       }\r
+\r
+       protected String getViewTypeStr() {\r
+               return "viewoption.threads"; //$NON-NLS-1$\r
+       }\r
+\r
+       int getMarginWidth(int idx) {\r
+               return 0;\r
+       }\r
+\r
+       int getMarginHeight(int idx) {\r
+               return 0;\r
+       }\r
+\r
+       void loadOptions() {\r
+               _minTimeInterval = 1;\r
+               _selectedTime = -1;\r
+               _nameWidth = Utils.loadIntOption(getPreferenceString("namewidth"), //$NON-NLS-1$\r
+                               _nameWidthPref, _minNameWidth, 1000);\r
+       }\r
+\r
+       void saveOptions() {\r
+               Utils.saveIntOption(getPreferenceString("namewidth"), _nameWidth); //$NON-NLS-1$\r
+       }\r
+\r
+       protected Control createDataViewer(Composite parent,\r
+                       TmfTimeAnalysisProvider utilImplm) {\r
+               loadOptions();\r
+               _utilImplm = utilImplm;\r
+               _colors = new TraceColorScheme();\r
+               _dataViewer = new Composite(parent, SWT.NULL);\r
+               _dataViewer.setLayoutData(GridUtil.createFill());\r
+               GridLayout gl = new GridLayout();\r
+               gl.marginHeight = borderWidth;\r
+               gl.marginWidth = 0;\r
+               gl.verticalSpacing = 0;\r
+               gl.horizontalSpacing = 0;\r
+               _dataViewer.setLayout(gl);\r
+\r
+               _timeScaleCtrl = new TimeScaleCtrl(_dataViewer, _colors);\r
+               _timeScaleCtrl.setTimeProvider(this);\r
+               _timeScaleCtrl.setLayoutData(GridUtil.createHorizontalFill());\r
+               _timeScaleCtrl.setHeight(timeScaleHeight);\r
+\r
+               _stateCtrl = new TmfTimeStatesCtrl(_dataViewer, _colors, _utilImplm);\r
+\r
+               _stateCtrl.setTimeProvider(this);\r
+               _stateCtrl.addSelectionListener(this);\r
+               _stateCtrl.setLayoutData(GridUtil.createFill());\r
+               _dataViewer.addControlListener(new ControlAdapter() {\r
+                       @Override\r
+                       public void controlResized(ControlEvent event) {\r
+                               resizeControls();\r
+                       }\r
+               });\r
+               resizeControls();\r
+               _dataViewer.update();\r
+               _threadTip = new TmfTimeTipHandler(parent.getShell(), _utilImplm, this);\r
+               _threadTip.activateHoverHelp(_stateCtrl);\r
+               return _dataViewer;\r
+       }\r
+\r
+       public void dispose() {\r
+               saveOptions();\r
+               _stateCtrl.dispose();\r
+               _dataViewer.dispose();\r
+               _colors.dispose();\r
+       }\r
+\r
+       @Override\r
+       public void resizeControls() {\r
+               Rectangle r = _dataViewer.getClientArea();\r
+               if (r.isEmpty())\r
+                       return;\r
+\r
+               int width = r.width;\r
+               if (_nameWidth > width - _minNameWidth)\r
+                       _nameWidth = width - _minNameWidth;\r
+               if (_nameWidth < _minNameWidth)\r
+                       _nameWidth = _minNameWidth;\r
+       }\r
+\r
+       /** Tries to set most convenient time range for display. */\r
+       void setTimeRange(Object traces[]) {\r
+               _endTime = 0;\r
+               _beginTime = -1;\r
+//             ITimeEvent event;\r
+               for (int i = 0; i < traces.length; i++) {\r
+                       ITmfTimeAnalysisEntry entry = (ITmfTimeAnalysisEntry) traces[i];\r
+                       if (entry.getStopTime() >= entry.getStartTime() && entry.getStopTime() > 0) {\r
+                           if (_beginTime < 0 || entry.getStartTime() < _beginTime) {\r
+                               _beginTime = entry.getStartTime();\r
+                           }\r
+                           if (entry.getStopTime() > _endTime) {\r
+                               _endTime = entry.getStopTime();\r
+                           }\r
+                       }\r
+                       /*\r
+                        * This is not needed if entry startTime and stopTime are properly set!\r
+                       List<TimeEvent> list = entry.getTraceEvents();\r
+                       int len = list.size();\r
+                       if (len > 0) {\r
+                event = (ITimeEvent) list.get(0);\r
+                if (_beginTime < 0 || event.getTime() < _beginTime) {\r
+                    _beginTime = event.getTime();\r
+                }\r
+                               event = (ITimeEvent) list.get(list.size() - 1);\r
+                               long eventEndTime = event.getTime() + (event.getDuration() > 0 ? event.getDuration() : 0);\r
+                               if (eventEndTime > _endTime) {\r
+                                       _endTime = eventEndTime;\r
+                               }\r
+                       }\r
+                       */\r
+               }\r
+\r
+               if (_beginTime < 0)\r
+                       _beginTime = 0;\r
+       }\r
+\r
+       void setTimeBounds() {\r
+               //_time0_ = _beginTime - (long) ((_endTime - _beginTime) * 0.02);\r
+           _time0_ = _beginTime;\r
+               if (_time0_ < 0)\r
+                       _time0_ = 0;\r
+               // _time1_ = _time0_ + (_endTime - _time0_) * 1.05;\r
+               _time1_ = _endTime;\r
+               // _time0_ = Math.floor(_time0_);\r
+               // _time1_ = Math.ceil(_time1_);\r
+               if (!_timeRangeFixed) {\r
+                       _time0 = _time0_;\r
+                       _time1 = _time1_;\r
+               }\r
+        if (_time1 - _time0 < _minTimeInterval) {\r
+            _time1 = _time0 + _minTimeInterval;\r
+        }\r
+       }\r
+\r
+       /**\r
+        * @param traces\r
+        */\r
+       void updateInternalData(ITmfTimeAnalysisEntry[] traces) {\r
+               if (null == traces)\r
+                       traces = new ITmfTimeAnalysisEntry[0];\r
+               setTimeRange(traces);\r
+               refreshAllData(traces);\r
+       }\r
+\r
+       /**\r
+        * @param traces\r
+        * @param start\r
+        * @param end\r
+        */\r
+       void updateInternalData(ITmfTimeAnalysisEntry[] traces, long start, long end) {\r
+               if (null == traces)\r
+                       traces = new ITmfTimeAnalysisEntry[0];\r
+               if ((start == 0 && end == 0) || start < 0 || end < 0) {\r
+                       // Start and end time are unspecified and need to be determined from\r
+                       // individual processes\r
+                       setTimeRange(traces);\r
+               } else {\r
+                       _beginTime = start;\r
+                       _endTime = end;\r
+               }\r
+\r
+               refreshAllData(traces);\r
+       }\r
+\r
+       /**\r
+        * @param traces\r
+        */\r
+       private void refreshAllData(ITmfTimeAnalysisEntry[] traces) {\r
+               setTimeBounds();\r
+               if (_selectedTime < _beginTime) {\r
+                   _selectedTime = _beginTime;\r
+               } else if (_selectedTime > _endTime) {\r
+            _selectedTime = _endTime;\r
+               }\r
+               _stateCtrl.refreshData(traces);\r
+               filterOutNotification();\r
+       }\r
+\r
+       @Override\r
+       public void setFocus() {\r
+               if (null != _stateCtrl)\r
+                       _stateCtrl.setFocus();\r
+       }\r
+\r
+       @Override\r
+       public boolean isInFocus() {\r
+               return _stateCtrl.isInFocus();\r
+       }\r
+\r
+       @Override\r
+       public ITmfTimeAnalysisEntry getSelectedTrace() {\r
+               return _stateCtrl.getSelectedTrace();\r
+       }\r
+\r
+       @Override\r
+       public ISelection getSelection() {\r
+               return _stateCtrl.getSelection();\r
+       }\r
+\r
+       @Override\r
+       public ISelection getSelectionTrace() {\r
+               return _stateCtrl.getSelectionTrace();\r
+       }\r
+\r
+       @Override\r
+       public long getTime0() {\r
+               return _time0;\r
+       }\r
+\r
+       @Override\r
+       public long getTime1() {\r
+               return _time1;\r
+       }\r
+\r
+       @Override\r
+       public long getMinTimeInterval() {\r
+               return _minTimeInterval;\r
+       }\r
+\r
+       @Override\r
+       public int getNameSpace() {\r
+               return _nameWidth;\r
+       }\r
+\r
+       @Override\r
+       public void setNameSpace(int width) {\r
+               _nameWidth = width;\r
+               width = _stateCtrl.getClientArea().width;\r
+               if (_nameWidth > width - 6)\r
+                       _nameWidth = width - 6;\r
+               if (_nameWidth < 6)\r
+                       _nameWidth = 6;\r
+               _stateCtrl.adjustScrolls();\r
+               _stateCtrl.redraw();\r
+               _timeScaleCtrl.redraw();\r
+       }\r
+\r
+       @Override\r
+       public int getTimeSpace() {\r
+               int w = _stateCtrl.getClientArea().width;\r
+               return w - _nameWidth;\r
+       }\r
+\r
+       @Override\r
+       public long getSelectedTime() {\r
+               return _selectedTime;\r
+       }\r
+\r
+       @Override\r
+       public long getBeginTime() {\r
+               return _beginTime;\r
+       }\r
+\r
+       @Override\r
+       public long getEndTime() {\r
+               return _endTime;\r
+       }\r
+\r
+       @Override\r
+       public long getMaxTime() {\r
+               return _time1_;\r
+       }\r
+\r
+       @Override\r
+       public long getMinTime() {\r
+               return _time0_;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
+        * #setStartFinishTimeNotify(long, long)\r
+        */\r
+       @Override\r
+       public void setStartFinishTimeNotify(long time0, long time1) {\r
+               setStartFinishTime(time0, time1);\r
+               notifyStartFinishTimeSelectionListeners(time0, time1);\r
+       }\r
+\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider#notifyStartFinishTime()\r
+     */\r
+    @Override\r
+       public void notifyStartFinishTime() {\r
+        notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
+    }\r
+\r
+    /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.widgets.ITimeDataProvider\r
+        * #setStartFinishTime(long, long)\r
+        */\r
+       @Override\r
+       public void setStartFinishTime(long time0, long time1) {\r
+               _time0 = time0;\r
+        if (_time0 < _time0_)\r
+            _time0 = _time0_;\r
+        if (_time0 > _time1_)\r
+            _time0 = _time1_;\r
+               _time1 = time1;\r
+        if (_time1 < _time0_)\r
+            _time1 = _time0_;\r
+        if (_time1 > _time1_)\r
+            _time1 = _time1_;\r
+               if (_time1 - _time0 < _minTimeInterval)\r
+                   _time1 = _time0 + _minTimeInterval;\r
+               _timeRangeFixed = true;\r
+               _stateCtrl.adjustScrolls();\r
+               _stateCtrl.redraw();\r
+               _timeScaleCtrl.redraw();\r
+       }\r
+\r
+       @Override\r
+       public void setTimeBounds(long beginTime, long endTime) {\r
+           _beginTime = beginTime;\r
+           _endTime = endTime;\r
+           _time0_ = beginTime;\r
+           _time1_ = endTime;\r
+           _stateCtrl.adjustScrolls();\r
+       }\r
+\r
+       @Override\r
+       public void resetStartFinishTime() {\r
+               setStartFinishTimeNotify(_time0_, _time1_);\r
+               _timeRangeFixed = false;\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTimeInt(long time, boolean ensureVisible) {\r
+               // Trace.debug("currentTime:" + _selectedTime + " new time:" + time);\r
+               _selectedTime = time;\r
+               if (_selectedTime > _endTime) {\r
+                       _endTime = _selectedTime;\r
+                       _time1_ = _selectedTime;\r
+               }\r
+               if (_selectedTime < _beginTime) {\r
+                       _beginTime = _selectedTime;\r
+                       _time0_ = _selectedTime;\r
+               }\r
+               long time0 = _time0;\r
+               long time1 = _time1;\r
+               if (ensureVisible) {\r
+                       double timeSpace = (_time1 - _time0) * .02;\r
+                       double timeMid = (_time1 - _time0) * .1;\r
+                       if (_selectedTime < _time0 + timeSpace) {\r
+                               long dt = (long) (_time0 - _selectedTime + timeMid);\r
+                               _time0 -= dt;\r
+                               _time1 -= dt;\r
+                       } else if (_selectedTime > _time1 - timeSpace) {\r
+                               long dt = (long) (_selectedTime - _time1 + timeMid);\r
+                               _time0 += dt;\r
+                               _time1 += dt;\r
+                       }\r
+                       if (_time0 < _time0_) {\r
+                               _time1 = Math.min(_time1_, _time1 + (_time0_ - _time0));\r
+                               _time0 = _time0_;\r
+                       } else if (_time1 > _time1_) {\r
+                               _time0 = Math.max(_time0_, _time0 - (_time1 - _time1_));\r
+                               _time1 = _time1_;\r
+                       }\r
+               }\r
+               if (_time1 - _time0 < _minTimeInterval) {\r
+                       _time1 = _time0 + _minTimeInterval;\r
+               }\r
+               _stateCtrl.adjustScrolls();\r
+               _stateCtrl.redraw();\r
+               _timeScaleCtrl.redraw();\r
+               if (time0 != _time0 || time1 != _time1) {\r
+                       notifyStartFinishTimeSelectionListeners(_time0, _time1);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void widgetDefaultSelected(SelectionEvent e) {\r
+               // TODO: Opening call stack shall be replaced to a configurable view\r
+               // new OpenCallStackViewAction().openView(false);\r
+               // Replaced by event notification\r
+               // updateModelSelection();\r
+               notifySelectionListeners(TmfTimeSelectionEvent.Type.WIDGET_DEF_SEL);\r
+       }\r
+\r
+       @Override\r
+       public void widgetSelected(SelectionEvent e) {\r
+               // Replace by event notification\r
+               // updateModelSelection();\r
+               notifySelectionListeners(TmfTimeSelectionEvent.Type.WIDGET_SEL);\r
+       }\r
+\r
+       @Override\r
+       public void selectNextEvent() {\r
+               _stateCtrl.selectNextEvent();\r
+       }\r
+\r
+       @Override\r
+       public void selectPrevEvent() {\r
+               _stateCtrl.selectPrevEvent();\r
+       }\r
+\r
+       @Override\r
+       public void selectNextTrace() {\r
+               _stateCtrl.selectNextTrace();\r
+       }\r
+\r
+       @Override\r
+       public void selectPrevTrace() {\r
+               _stateCtrl.selectPrevTrace();\r
+       }\r
+\r
+       @Override\r
+       public void groupTraces(boolean on) {\r
+               _stateCtrl.groupTraces(on);\r
+       }\r
+\r
+       @Override\r
+       public void filterTraces() {\r
+               if (_dataViewer == null || _dataViewer.isDisposed())\r
+                       return;\r
+\r
+               if (TmfTimeFilterDialog.getTraceFilter(_dataViewer.getShell(), _stateCtrl\r
+                               .getTraces(), _stateCtrl.getTraceFilter())) {\r
+                       _stateCtrl.refreshData();\r
+                       filterOutNotification();\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void showLegend() {\r
+               if (_dataViewer == null || _dataViewer.isDisposed())\r
+                       return;\r
+\r
+               TmfTimeLegend.open(_dataViewer.getShell(), _utilImplm);\r
+       }\r
+\r
+       public void toggleThreadsInteractionDrawing() {\r
+               _stateCtrl.toggleTraceInteractionDrawing();\r
+       }\r
+\r
+       public void setThreadJoinDrawing(boolean on) {\r
+               _stateCtrl.setTraceJoinDrawing(on);\r
+       }\r
+\r
+       public void setThreadWaitDrawing(boolean on) {\r
+               _stateCtrl.setTraceWaitDrawing(on);\r
+       }\r
+\r
+       public void setThreadReleaseDrawing(boolean on) {\r
+               _stateCtrl.setTraceReleaseDrawing(on);\r
+       }\r
+\r
+       public boolean getThreadInteractionDrawing() {\r
+               return _stateCtrl.getTracesInteractionDrawing();\r
+       }\r
+\r
+       public boolean getThreadJoinDrawing() {\r
+               return _stateCtrl.getTraceJoinDrawing();\r
+       }\r
+\r
+       public boolean getThreadWaitDrawing() {\r
+               return _stateCtrl.getTraceWaitDrawing();\r
+       }\r
+\r
+       public boolean getThreadReleaseDrawing() {\r
+               return _stateCtrl.getTraceReleaseDrawing();\r
+       }\r
+\r
+       protected void select(Object obj) {\r
+               if (obj == null)\r
+                       return;\r
+               // TODO: ThreadDetails Adaption removed, might need replacement\r
+               // if (obj instanceof ThreadDetails) {\r
+               // obj = ((ThreadDetails) obj).getThread();\r
+               // }\r
+               if (obj instanceof ITmfTimeAnalysisEntry) {\r
+                       // _stateCtrl.selectThread((TsfTmTrace) obj);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void zoomIn() {\r
+               _stateCtrl.zoomIn();\r
+       }\r
+\r
+       @Override\r
+       public void zoomOut() {\r
+               _stateCtrl.zoomOut();\r
+       }\r
+\r
+       private String getPreferenceString(String string) {\r
+               return getViewTypeStr() + "." + string; //$NON-NLS-1$\r
+       }\r
+\r
+       @Override\r
+       public void addWidgetSelectionListner(ITmfTimeSelectionListener listener) {\r
+               widgetSelectionListners.add(listener);\r
+       }\r
+\r
+       @Override\r
+       public void removeWidgetSelectionListner(ITmfTimeSelectionListener listener) {\r
+               widgetSelectionListners.removeElement(listener);\r
+       }\r
+\r
+       @Override\r
+       public void addWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener) {\r
+               widgetTimeScaleSelectionListners.add(listener);\r
+       }\r
+\r
+       @Override\r
+       public void removeWidgetTimeScaleSelectionListner(\r
+                       ITmfTimeScaleSelectionListener listener) {\r
+               widgetTimeScaleSelectionListners.removeElement(listener);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTime(long time, boolean ensureVisible, Object source) {\r
+               if (_acceptSetSelAPICalls == false || this == source) {\r
+                       return;\r
+               }\r
+\r
+               setSelectedTimeInt(time, ensureVisible);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedEvent(ITimeEvent event, Object source) {\r
+               if (_acceptSetSelAPICalls == false || event == null || source == this) {\r
+                       return;\r
+               }\r
+               ITmfTimeAnalysisEntry trace = event.getEntry();\r
+               if (trace != null) {\r
+                       _stateCtrl.selectItem(trace, false);\r
+               }\r
+\r
+               setSelectedTimeInt(event.getTime(), true);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTraceTime(ITmfTimeAnalysisEntry trace, long time, Object source) {\r
+               if (_acceptSetSelAPICalls == false || trace == null || source == this) {\r
+                       return;\r
+               }\r
+\r
+               if (trace != null) {\r
+                       _stateCtrl.selectItem(trace, false);\r
+               }\r
+\r
+               setSelectedTimeInt(time, true);\r
+       }\r
+\r
+       @Override\r
+       public void setSelectedTrace(ITmfTimeAnalysisEntry trace) {\r
+               if (trace == null) {\r
+                       return;\r
+               }\r
+\r
+               _stateCtrl.selectItem(trace, false);\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
+        * #setSelectVisTimeWindow(long, long, java.lang.Object)\r
+        */\r
+       @Override\r
+       public void setSelectVisTimeWindow(long time0, long time1, Object source) {\r
+               if (_acceptSetSelAPICalls == false || source == this) {\r
+                       return;\r
+               }\r
+\r
+               setStartFinishTime(time0, time1);\r
+\r
+               // update notification time values since we are now in synch with the\r
+               // external application\r
+               updateExtSynchTimers();\r
+       }\r
+\r
+       @Override\r
+       public void setAcceptSelectionAPIcalls(boolean acceptCalls) {\r
+               _acceptSetSelAPICalls = acceptCalls;\r
+       }\r
+\r
+       private synchronized void notifySelectionListeners(\r
+                       TmfTimeSelectionEvent.Type rtype) {\r
+               // Any listeners out there ?\r
+               if (widgetSelectionListners.size() > 0) {\r
+                       // Locate the event selected\r
+                       ISelection selection = getSelection();\r
+                       Object sel = null;\r
+                       if (selection != null && !selection.isEmpty()) {\r
+                               sel = ((IStructuredSelection) selection).getFirstElement();\r
+                       }\r
+\r
+                       if (sel != null) {\r
+                               // Notify Selection Listeners\r
+                               TmfTimeSelectionEvent event = new TmfTimeSelectionEvent(this,\r
+                                               rtype, sel, getSelectedTime());\r
+\r
+                               for (Iterator<ITmfTimeSelectionListener> iter = widgetSelectionListners\r
+                                               .iterator(); iter.hasNext();) {\r
+                                       ITmfTimeSelectionListener listener = (ITmfTimeSelectionListener) iter\r
+                                                       .next();\r
+                                       listener.tsfTmProcessSelEvent(event);\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       public void notifyStartFinishTimeSelectionListeners(long _time0, long _time1) {\r
+               if (widgetTimeScaleSelectionListners.size() > 0) {\r
+                       // Check if the time has actually changed from last notification\r
+                       if (_time0 != _time0_extSynch || _time1 != _time1_extSynch) {\r
+                               // Notify Time Scale Selection Listeners\r
+                               TmfTimeScaleSelectionEvent event = new TmfTimeScaleSelectionEvent(\r
+                                               this, _time0, _time1, getTimeSpace(), getSelectedTime());\r
+\r
+                               for (Iterator<ITmfTimeScaleSelectionListener> iter = widgetTimeScaleSelectionListners\r
+                                               .iterator(); iter.hasNext();) {\r
+                                       ITmfTimeScaleSelectionListener listener = (ITmfTimeScaleSelectionListener) iter\r
+                                                       .next();\r
+                                       listener.tsfTmProcessTimeScaleEvent(event);\r
+                               }\r
+\r
+                               // update external synch timers\r
+                               updateExtSynchTimers();\r
+                       }\r
+               }\r
+       }\r
+\r
+       /**\r
+        * update the cache timers used to identify the need to send a time window\r
+        * update to external registered listeners\r
+        */\r
+       private void updateExtSynchTimers() {\r
+               // last time notification cache\r
+               _time0_extSynch = _time0;\r
+               _time1_extSynch = _time1;\r
+       }\r
+\r
+       @Override\r
+       public void setTimeCalendarFormat(boolean toAbsoluteCaltime) {\r
+               calendarTimeFormat = toAbsoluteCaltime;\r
+       }\r
+\r
+       @Override\r
+       public boolean isCalendarFormat() {\r
+               return calendarTimeFormat;\r
+       }\r
+\r
+       @Override\r
+       public int getBorderWidth() {\r
+               return borderWidth;\r
+       }\r
+\r
+       @Override\r
+       public void setBorderWidth(int borderWidth) {\r
+               if (borderWidth > -1) {\r
+            this.borderWidth = borderWidth;\r
+            GridLayout gl = (GridLayout)_dataViewer.getLayout();\r
+            gl.marginHeight = borderWidth;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public int getHeaderHeight() {\r
+               return timeScaleHeight;\r
+       }\r
+\r
+       @Override\r
+       public void setHeaderHeight(int headerHeight) {\r
+               if (headerHeight > -1) {\r
+                       this.timeScaleHeight = headerHeight;\r
+                       _timeScaleCtrl.setHeight(headerHeight);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public int getItemHeight() {\r
+               if (_stateCtrl != null) {\r
+                       return _stateCtrl.getItemHeight();\r
+               }\r
+               return 0;\r
+       }\r
+\r
+       @Override\r
+       public void setItemHeight(int rowHeight) {\r
+               if (_stateCtrl != null) {\r
+                       _stateCtrl.setItemHeight(rowHeight);\r
+               }\r
+       }\r
+\r
+    @Override\r
+    public void setMinimumItemWidth(int width) {\r
+        if (_stateCtrl != null) {\r
+            _stateCtrl.setMinimumItemWidth(width);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public boolean isVisibleVerticalScroll() {\r
+               if (_stateCtrl != null) {\r
+                       _stateCtrl.isVisibleVerticalScroll();\r
+               }\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public void setVisibleVerticalScroll(boolean visibleVerticalScroll) {\r
+               if (_stateCtrl != null) {\r
+                       _stateCtrl.setVisibleVerticalScroll(visibleVerticalScroll);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void setNameWidthPref(int width) {\r
+               _nameWidthPref = width;\r
+               if (width == 0) {\r
+                       _minNameWidth = 0;\r
+            _nameWidth = 0;\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public int getNameWidthPref(int width) {\r
+               return _nameWidthPref;\r
+       }\r
+\r
+       @Override\r
+       public void addFilterSelectionListner(ITmfTimeFilterSelectionListener listener) {\r
+               widgetFilterSelectionListeners.add(listener);\r
+       }\r
+\r
+       @Override\r
+       public void removeFilterSelectionListner(\r
+                       ITmfTimeFilterSelectionListener listener) {\r
+               widgetFilterSelectionListeners.remove(listener);\r
+       }\r
+\r
+       private void filterOutNotification() {\r
+               TmfTimeFilterSelectionEvent event = new TmfTimeFilterSelectionEvent(this);\r
+               event.setFilteredOut(_stateCtrl.getFilteredOut());\r
+               for (ITmfTimeFilterSelectionListener listener : widgetFilterSelectionListeners) {\r
+                       listener.tmfTaProcessFilterSelection(event);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * needed in case there's a need to associate a context menu\r
+        * \r
+        * @return the state control (selection provider)\r
+        */\r
+       @Override\r
+       public Control getControl() {\r
+               return _stateCtrl;\r
+       }\r
+\r
+       /**\r
+        * Get the selection provider\r
+        * \r
+     * @return the selection provider\r
+        */\r
+       @Override\r
+       public ISelectionProvider getSelectionProvider() {\r
+               return _stateCtrl;\r
+       }\r
+\r
+       /*\r
+        * (non-Javadoc)\r
+        * \r
+        * @see\r
+        * org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer\r
+        * #waitCursor(boolean)\r
+        */\r
+       @Override\r
+       public void waitCursor(boolean waitInd) {\r
+               _stateCtrl.waitCursor(waitInd);\r
+       }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#getHorizontalBar()\r
+     */\r
+    @Override\r
+    public ScrollBar getHorizontalBar() {\r
+        return _stateCtrl.getHorizontalBar();\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#getVerticalBar()\r
+     */\r
+    @Override\r
+    public ScrollBar getVerticalBar() {\r
+        return _stateCtrl.getVerticalBar();\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.eclipse.linuxtools.tmf.ui.viewers.timeAnalysis.ITimeAnalysisViewer#setTopIndex(int)\r
+     */\r
+    @Override\r
+    public void setTopIndex(int index) {\r
+        _stateCtrl.setTopIndex(index);\r
+    }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeFilterSelectionEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeFilterSelectionEvent.java
new file mode 100644 (file)
index 0000000..96757c9
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.EventObject;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+\r
+public class TmfTimeFilterSelectionEvent extends EventObject {\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = -150960748016449093L;\r
+\r
+       Vector<ITmfTimeAnalysisEntry> filteredOut = null;\r
+\r
+       public TmfTimeFilterSelectionEvent(Object source) {\r
+               super(source);\r
+       }\r
+\r
+       public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
+               return filteredOut;\r
+       }\r
+\r
+       public void setFilteredOut(Vector<ITmfTimeAnalysisEntry> rfilteredOut) {\r
+               this.filteredOut = rfilteredOut;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeScaleSelectionEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeScaleSelectionEvent.java
new file mode 100644 (file)
index 0000000..36ee71b
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.EventObject;\r
+\r
+public class TmfTimeScaleSelectionEvent extends EventObject {\r
+\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = -4177428788761351379L;\r
+\r
+       \r
+       long time0 = 0;\r
+       long time1 = 0;\r
+       long selectedTime = 0;\r
+       int width = 0;\r
+\r
+       /**\r
+        * \r
+        * @param arg0\r
+        *            source of event\r
+        * @param time0\r
+        *            time0 the start time\r
+        * @param time1\r
+        * @param width\r
+        *            pixels used to draw the width of the time space\r
+        * @param selTime\r
+        *            carries the selected time if available otherwise is 0\r
+        */\r
+       public TmfTimeScaleSelectionEvent(Object arg0, long time0, long time1,\r
+                       int width, long selTime) {\r
+               super(arg0);\r
+               this.time0 = time0;\r
+               this.time1 = time1;\r
+               this.width = width;\r
+               this.selectedTime = selTime;\r
+       }\r
+       \r
+       /**\r
+        * @return the start time\r
+        */\r
+       public long getTime0() {\r
+               return time0;\r
+       }\r
+       \r
+       /**\r
+        * @return the end time\r
+        */\r
+       public long getTime1() {\r
+               return time1;\r
+       }\r
+\r
+       /**\r
+        * @return the selection width\r
+        */\r
+       public int getWidth() {\r
+               return width;\r
+       }\r
+\r
+       /**\r
+        * @return the selected time\r
+        */\r
+       public long getSelectedTime() {\r
+               return selectedTime;\r
+       }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeSelectionEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfTimeSelectionEvent.java
new file mode 100644 (file)
index 0000000..955e1da
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import java.util.EventObject;\r
+\r
+public class TmfTimeSelectionEvent extends EventObject {\r
+\r
+       /**\r
+        * \r
+        */\r
+       private static final long serialVersionUID = 1L;\r
+       \r
+       public enum Type {WIDGET_DEF_SEL, WIDGET_SEL}\r
+       Type dType;\r
+       Object selection = null;\r
+       long selTime = 0;\r
+       int index = 0;\r
+       \r
+       public TmfTimeSelectionEvent(Object arg0, Type rType, Object sel, long selectedTime) {\r
+               super(arg0);\r
+               dType = rType;\r
+               selection = sel;\r
+               selTime = selectedTime;\r
+       }\r
+       \r
+       public Type getDType() {\r
+               return dType;\r
+       }\r
+       \r
+       public Object getSelection() {\r
+               return selection;\r
+       }\r
+       \r
+       public long getSelectedTime() {\r
+               return selTime;\r
+       }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfViewerFactory.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/TmfViewerFactory.java
new file mode 100644 (file)
index 0000000..61fcf6d
--- /dev/null
@@ -0,0 +1,35 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+/**\r
+ * <b><u>TmfWidgetFactory</u></b>\r
+ * <p>\r
+ *\r
+ * TODO: Generalize when extension points are introduced\r
+ * TODO: Today, it is specific for the TimeAnalysis widget\r
+ */\r
+public class TmfViewerFactory {\r
+\r
+//    public static ITmfWidget createWidget(String id, Composite parent) {\r
+//        return null;\r
+//    }\r
+    \r
+    public static ITimeAnalysisViewer createViewer(Composite parent,\r
+            TmfTimeAnalysisProvider provider) {\r
+        return new TmfTimeAnalysisViewer(parent, provider);\r
+    }\r
+\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TmfTimeFilterDialog.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TmfTimeFilterDialog.java
new file mode 100644 (file)
index 0000000..804f25a
--- /dev/null
@@ -0,0 +1,222 @@
+/*****************************************************************************\r
+ * Copyright (c) 2008 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *\r
+ * $Id: ThreadFilterDialog.java,v 1.2 2008/03/05 17:31:07 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs;\r
+\r
+import java.util.Arrays;\r
+\r
+import org.eclipse.jface.dialogs.TitleAreaDialog;\r
+import org.eclipse.jface.viewers.CheckStateChangedEvent;\r
+import org.eclipse.jface.viewers.CheckboxTableViewer;\r
+import org.eclipse.jface.viewers.ICheckStateListener;\r
+import org.eclipse.jface.viewers.IStructuredContentProvider;\r
+import org.eclipse.jface.viewers.ITableLabelProvider;\r
+import org.eclipse.jface.viewers.LabelProvider;\r
+import org.eclipse.jface.viewers.Viewer;\r
+import org.eclipse.jface.viewers.ViewerComparator;\r
+import org.eclipse.jface.window.Window;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+\r
+public class TmfTimeFilterDialog extends TitleAreaDialog {\r
+       private CheckboxTableViewer viewer;\r
+       private Object[] threads;\r
+       private boolean[] filter;\r
+       private ViewContentProvider viewContentProvider;\r
+       private TraceComparator viewTraceComparator;\r
+       private ViewLabelProvider viewViewLabelProvider;\r
+\r
+       public TmfTimeFilterDialog(Shell parentShell, Object[] threads,\r
+                       boolean[] filter) {\r
+               super(parentShell);\r
+\r
+               this.threads = (threads != null) ? Arrays.copyOf(threads, threads.length) : null;\r
+               if (filter != null)\r
+                       this.filter = (boolean[]) filter.clone();\r
+               \r
+               viewContentProvider = new ViewContentProvider();\r
+               viewTraceComparator = new TraceComparator();\r
+               viewViewLabelProvider = new ViewLabelProvider();\r
+       }\r
+\r
+       public static boolean getTraceFilter(Shell parentShell, Object[] threads,\r
+                       boolean[] filter) {\r
+               TmfTimeFilterDialog dlg = new TmfTimeFilterDialog(parentShell, threads,\r
+                               filter);\r
+               if (dlg.open() != Window.OK)\r
+                       return false;\r
+\r
+               boolean f[] = dlg.getFilter();\r
+               if (java.util.Arrays.equals(f, filter))\r
+                       return false;\r
+               for (int i = f.length - 1; i >= 0; i--)\r
+                       filter[i] = f[i];\r
+\r
+               return true;\r
+       }\r
+\r
+       @Override\r
+       protected Control createDialogArea(Composite parent) {\r
+               Composite composite = (Composite) super.createDialogArea(parent);\r
+\r
+               viewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER\r
+                               | SWT.V_SCROLL);\r
+\r
+               Table table = viewer.getTable();\r
+               table.setLayoutData(new GridData(GridData.FILL_BOTH));\r
+               table.setBackground(parent.getBackground());\r
+               createColumns(table);\r
+\r
+               //Assign providers to the viewer.\r
+               viewer.setContentProvider(viewContentProvider);\r
+               viewer.setComparator(viewTraceComparator);\r
+               viewer.setLabelProvider(viewViewLabelProvider);\r
+               \r
+               viewer.setInput(new Object());\r
+\r
+               viewer.addCheckStateListener(new ICheckStateListener() {\r
+                       @Override\r
+                       public void checkStateChanged(CheckStateChangedEvent event) {\r
+                               Object o = event.getElement();\r
+                               for (int i = threads.length - 1; i >= 0; i--) {\r
+                                       if (threads[i].equals(o))\r
+                                               filter[i] = event.getChecked();\r
+                               }\r
+                       }\r
+               });\r
+\r
+               if (filter != null) {\r
+                       for (int i = 0; i < filter.length; i++)\r
+                               viewer.setChecked(threads[i], filter[i]);\r
+               }\r
+\r
+               setMessage(Messages.TmfTimeFilterDialog_TRACE_FILTER_DESC);\r
+               setTitle(Messages.TmfTimeFilterDialog_TRACE_FILTER);\r
+               setDialogHelpAvailable(false);\r
+               setHelpAvailable(false);\r
+\r
+//             setTitleImage(org.eclipse.hyades.trace.internal.ui.PDPluginImages.DESC_IMG_UI_WZ_EDITPROFSET\r
+//                             .createImage());\r
+\r
+               return composite;\r
+       }\r
+\r
+       private void createColumns(Table table) {\r
+               table.setHeaderVisible(true);\r
+\r
+               String headers[] = { "", Messages.TmfTimeFilterDialog_TRACE_ID, Messages.TmfTimeFilterDialog_TRACE_NAME }; //$NON-NLS-1$\r
+               int width[] = { 20, 80, 400 };\r
+\r
+               for (int i = 0; i < headers.length; i++) {\r
+                       TableColumn tc = new TableColumn(table, SWT.NONE, i);\r
+                       tc.setResizable(true);\r
+                       tc.setText(headers[i]);\r
+                       tc.setWidth(width[i]);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       protected void configureShell(Shell shell) {\r
+               super.configureShell(shell);\r
+               shell.setText(Messages.TmfTimeFilterDialog_EDIT_PROFILING_OPTIONS);\r
+       }\r
+\r
+       public boolean[] getFilter() {\r
+               return (filter != null) ? Arrays.copyOf(filter, filter.length) : null;\r
+       }\r
+\r
+       /**\r
+        * @param viewContentProvider\r
+        */\r
+       public void setViewContentProvider(ViewContentProvider viewContentProvider) {\r
+               this.viewContentProvider = viewContentProvider;\r
+       }\r
+\r
+       /**\r
+        * @param viewThreadComparator\r
+        */\r
+       public void setViewThreadComparator(TraceComparator viewThreadComparator) {\r
+               this.viewTraceComparator = viewThreadComparator;\r
+       }\r
+\r
+       /**\r
+        * @param viewViewLabelProvider\r
+        */\r
+       public void setViewViewLabelProvider(ViewLabelProvider viewViewLabelProvider) {\r
+               this.viewViewLabelProvider = viewViewLabelProvider;\r
+       }\r
+       \r
+       class ViewContentProvider implements IStructuredContentProvider {\r
+               @Override\r
+               public void dispose() {\r
+               }\r
+\r
+               @Override\r
+               public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
+               }\r
+\r
+               @Override\r
+               public Object[] getElements(Object input) {\r
+                       return threads;\r
+               }\r
+       }\r
+\r
+       private static class ViewLabelProvider extends LabelProvider implements\r
+                       ITableLabelProvider {\r
+               @Override\r
+               public Image getImage(Object obj) {\r
+                       return null;\r
+               }\r
+\r
+               @Override\r
+               public Image getColumnImage(Object element, int columnIndex) {\r
+                       return null;\r
+               }\r
+\r
+               @Override\r
+               public String getColumnText(Object element, int columnIndex) {\r
+                       // TODO: AA: Provide Label Provider externally\r
+                       ITmfTimeAnalysisEntry t = (ITmfTimeAnalysisEntry) element;\r
+\r
+                       if (columnIndex == 1)\r
+                               return String.valueOf(t.getId());\r
+                       else if (columnIndex == 2)\r
+                               return t.getName();\r
+                       else\r
+                               return ""; //$NON-NLS-1$\r
+               }\r
+       }\r
+\r
+       private static class TraceComparator extends ViewerComparator {\r
+               @Override\r
+               public int compare(Viewer viewer, Object e1, Object e2) {\r
+                       // TODO: AA: Provide comparator externally\r
+                       int id1 = ((ITmfTimeAnalysisEntry) e1).getId();\r
+                       int id2 = ((ITmfTimeAnalysisEntry) e2).getId();\r
+\r
+                       if (id1 == id2)\r
+                               return 0;\r
+\r
+                       return (id1 < id2) ? -1 : 1;\r
+                       // return 0;\r
+               }\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TmfTimeLegend.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/dialogs/TmfTimeLegend.java
new file mode 100644 (file)
index 0000000..2878611
--- /dev/null
@@ -0,0 +1,279 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.dialogs;\r
+\r
+import org.eclipse.jface.dialogs.IDialogConstants;\r
+import org.eclipse.jface.dialogs.TitleAreaDialog;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider.StateColor;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.TraceColorScheme;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Canvas;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.Shell;\r
+\r
+\r
+public class TmfTimeLegend extends TitleAreaDialog {\r
+\r
+       // public static final String stateNames[] = {\r
+       // UIMessages._Unknown, // "Unknown",\r
+       // UIMessages._Running, // "Running",\r
+       // UIMessages._Sleeping, // "Sleeping",\r
+       // UIMessages._Waiting, // "Waiting",\r
+       // UIMessages._Blocked, // "Blocked",\r
+       // UIMessages._Deadlocked, // "Deadlock",\r
+       // UIMessages._Stopped, // "Stopped",\r
+       // };\r
+\r
+       // public static final String interactionNames[] = {\r
+       // UIMessages._START_THREAD,\r
+       // UIMessages._JOIN_TERMINATE,\r
+       // UIMessages._WAIT_NOTIFY,\r
+       // UIMessages._INTERRUPT,\r
+       // UIMessages._RELEASE_ACQUIRE\r
+       // };\r
+\r
+       public static final int interactionColors[] = {\r
+                       TraceColorScheme.TI_START_THREAD,\r
+                       TraceColorScheme.TI_NOTIFY_JOINED, TraceColorScheme.TI_NOTIFY,\r
+                       TraceColorScheme.TI_INTERRUPT, TraceColorScheme.TI_HANDOFF_LOCK };\r
+\r
+       protected TraceColorScheme colors;\r
+       private TmfTimeAnalysisProvider ifUtil;\r
+\r
+       public static void open(Shell parent, TmfTimeAnalysisProvider rifUtil) {\r
+               (new TmfTimeLegend(parent, rifUtil)).open();\r
+       }\r
+\r
+       public TmfTimeLegend(Shell parent, TmfTimeAnalysisProvider rifUtil) {\r
+               super(parent);\r
+               colors = new TraceColorScheme();\r
+               this.ifUtil = rifUtil;\r
+       }\r
+\r
+       @Override\r
+       protected Control createDialogArea(Composite parent) {\r
+               Composite dlgArea = (Composite) super.createDialogArea(parent);\r
+               Composite composite = new Composite(dlgArea, SWT.NONE);\r
+\r
+               GridLayout layout = new GridLayout();\r
+               layout.numColumns = 2;\r
+               composite.setLayout(layout);\r
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
+               composite.setLayoutData(gd);\r
+\r
+               createThreadStatesGroup(composite);\r
+               // createThreadInteractionsGroup(composite);\r
+\r
+               setMessage(Messages.TmfTimeLegend_LEGEND);\r
+               setTitle(Messages.TmfTimeLegend_TRACE_STATES_TITLE);\r
+               setDialogHelpAvailable(false);\r
+               setHelpAvailable(false);\r
+\r
+               //setTitleImage(org.eclipse.hyades.trace.internal.ui.PDPluginImages.DESC_IMG_UI_WZ_EDITPROFSET.createImage());\r
+\r
+               return composite;\r
+       }\r
+\r
+       private void createThreadStatesGroup(Composite composite) {\r
+               Group gs = new Group(composite, SWT.NONE);\r
+               gs.setText(Messages.TmfTimeLegend_TRACE_STATES);\r
+               GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);\r
+               gs.setLayoutData(gd);\r
+\r
+               GridLayout layout = new GridLayout();\r
+               layout.numColumns = 2;\r
+               layout.marginWidth = 20;\r
+               layout.marginBottom = 10;\r
+               gs.setLayout(layout);\r
+\r
+               // Go through all the defined colors and only add the ones you need. \r
+               // This will not handle several colors assigned to a color, we have \r
+               // 16 mil colors, and should not pick two to mean the same thing. \r
+               for (int i = 0; i <  TraceColorScheme.getStateColors().length; i++) {\r
+                       //Get the color enum related to the index\r
+                       StateColor stateColor = TraceColorScheme.getStateColors()[i];\r
+                       //Get the given name, provided by the interface to the application\r
+                       String stateName = ifUtil.getStateName(stateColor);\r
+                       if( stateName != "Not mapped" ) { //$NON-NLS-1$\r
+                               Bar bar = new Bar(gs, i);\r
+                               gd = new GridData();\r
+                               gd.widthHint = 40;\r
+                               gd.heightHint = 20;\r
+                               gd.verticalIndent = 8;\r
+                               bar.setLayoutData(gd);\r
+                               Label name = new Label(gs, SWT.NONE);\r
+                               name.setText(stateName);\r
+                               gd = new GridData();\r
+                               gd.horizontalIndent = 10;\r
+                               gd.verticalIndent = 8;\r
+                               name.setLayoutData(gd);\r
+                       }\r
+               }\r
+       }\r
+\r
+       // private void createThreadInteractionsGroup(Composite composite) {\r
+       // Group g = new Group (composite, SWT.NONE);\r
+       // g.setText(UIMessages._THREAD_INTERACTIONS);\r
+       // GridData gd = new GridData (SWT.FILL, SWT.FILL, true, true);\r
+       // g.setLayoutData(gd);\r
+       //\r
+       // GridLayout layout = new GridLayout();\r
+       // layout.numColumns = 2;\r
+       // layout.marginWidth = 20;\r
+       // layout.marginBottom = 10;\r
+       // g.setLayout(layout);\r
+       //              \r
+       // for (int i=0; i<5; i++) {\r
+       // Arrow a = new Arrow(g, interactionColors[i]);\r
+       // gd = new GridData();\r
+       // gd.widthHint = 10;\r
+       // gd.heightHint = 20;\r
+       // gd.verticalIndent = 8;\r
+       // a.setLayoutData(gd);\r
+       //              \r
+       // Label name = new Label (g, SWT.NONE);\r
+       // name.setText(interactionNames[i]);\r
+       // gd = new GridData ();\r
+       // gd.horizontalIndent = 4;\r
+       // gd.verticalIndent = 8;\r
+       // name.setLayoutData(gd);\r
+       // }\r
+       //\r
+       // Mark m = new Mark(g, TraceColorScheme.TI_WAIT_EXCEEDED);\r
+       // gd = new GridData();\r
+       // gd.widthHint = 10;\r
+       // gd.heightHint = 20;\r
+       // gd.verticalIndent = 8;\r
+       // m.setLayoutData(gd);\r
+       //              \r
+       // Label name = new Label (g, SWT.NONE);\r
+       // name.setText(UIMessages._WAIT_TIMEOUT_EXCEED);\r
+       // gd = new GridData ();\r
+       // gd.horizontalIndent = 4;\r
+       // gd.verticalIndent = 8;\r
+       // name.setLayoutData(gd);\r
+       // }\r
+\r
+       @Override\r
+       protected void configureShell(Shell shell) {\r
+               super.configureShell(shell);\r
+               shell.setText(Messages.TmfTimeLegend_WINDOW_TITLE);\r
+       }\r
+\r
+       @Override\r
+       protected void createButtonsForButtonBar(Composite parent) {\r
+               createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,\r
+                               true);\r
+       }\r
+\r
+       class Bar extends Canvas {\r
+               private Color color;\r
+\r
+               public Bar(Composite parent, int colorIdx) {\r
+                       super(parent, SWT.NONE);\r
+\r
+                       color = colors.getColor(colorIdx);\r
+                       addListener(SWT.Paint, new Listener() {\r
+                               @Override\r
+                               public void handleEvent(Event event) {\r
+                                       draw(event.gc);\r
+                               }\r
+                       });\r
+               }\r
+\r
+               private void draw(GC gc) {\r
+                       Rectangle r = getClientArea();\r
+                       gc.setBackground(color);\r
+                       gc.fillRectangle(r);\r
+                       gc.setForeground(colors.getColor(TraceColorScheme.BLACK));\r
+                       gc.drawRectangle(0, 0, r.width - 1, r.height - 1);\r
+               }\r
+       }\r
+\r
+       class Arrow extends Canvas {\r
+               public final static int HEIGHT = 12;\r
+               public final static int DX = 3;\r
+\r
+               private Color color;\r
+\r
+               public Arrow(Composite parent, int colorIdx) {\r
+                       super(parent, SWT.NONE);\r
+\r
+                       color = colors.getColor(colorIdx);\r
+                       addListener(SWT.Paint, new Listener() {\r
+                               @Override\r
+                               public void handleEvent(Event event) {\r
+                                       draw(event.gc);\r
+                               }\r
+                       });\r
+               }\r
+\r
+               private void draw(GC gc) {\r
+                       Rectangle r = getClientArea();\r
+                       gc.setForeground(color);\r
+\r
+                       int y0, y1;\r
+                       if (r.height > HEIGHT) {\r
+                               y0 = (r.height - HEIGHT) / 2;\r
+                               y1 = y0 + HEIGHT;\r
+                       } else {\r
+                               y0 = 0;\r
+                               y1 = r.height;\r
+                       }\r
+\r
+                       gc.drawLine(DX, y0, DX, y1);\r
+\r
+                       gc.drawLine(0, y0 + 3, DX, y0);\r
+                       gc.drawLine(2 * DX, y0 + 3, DX, y0);\r
+               }\r
+       }\r
+\r
+       class Mark extends Canvas {\r
+               public final static int DX = 3;\r
+\r
+               private Color color;\r
+\r
+               public Mark(Composite parent, int colorIdx) {\r
+                       super(parent, SWT.NONE);\r
+\r
+                       color = colors.getColor(colorIdx);\r
+                       addListener(SWT.Paint, new Listener() {\r
+                               @Override\r
+                               public void handleEvent(Event event) {\r
+                                       draw(event.gc);\r
+                               }\r
+                       });\r
+               }\r
+\r
+               private void draw(GC gc) {\r
+                       Rectangle r = getClientArea();\r
+                       gc.setBackground(color);\r
+\r
+                       int y = (r.height - DX) / 2;\r
+                       int c[] = { 0, y, DX, y + DX, 2 * DX, y };\r
+                       gc.fillPolygon(c);\r
+               }\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITimeEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITimeEvent.java
new file mode 100644 (file)
index 0000000..fbd6478
--- /dev/null
@@ -0,0 +1,33 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;\r
+\r
+\r
+public interface ITimeEvent {\r
+\r
+       public ITmfTimeAnalysisEntry getEntry();\r
+\r
+       public long getTime();\r
+\r
+       /**\r
+        * @return\r
+        * <list>\r
+        * <li>-1: Considers duration to be from current event till the next</li>\r
+        * <li>0: Duration is not relevant e.g. a Burst / no state associated</li>\r
+        * <li>>0: Valid duration value specified</li>\r
+        * </list>\r
+        * <p>\r
+        */\r
+       public long getDuration();\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITmfTimeAnalysisEntry.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/ITmfTimeAnalysisEntry.java
new file mode 100644 (file)
index 0000000..76ddfc3
--- /dev/null
@@ -0,0 +1,53 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+public interface ITmfTimeAnalysisEntry {\r
+       \r
+    public String getGroupName();\r
+\r
+       public int getId();\r
+\r
+       public String getName();\r
+\r
+       public long getStartTime();\r
+\r
+       public long getStopTime();\r
+\r
+    /**\r
+     * Get a vector containing all events\r
+     * @deprecated replaced by {@link #getTraceEventsIterator()}\r
+     */\r
+    @Deprecated public <T extends ITimeEvent> Vector<T> getTraceEvents();\r
+    \r
+    /**\r
+     * Get an iterator which returns all events\r
+     */\r
+    public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator();\r
+    \r
+    /**\r
+     * Get an iterator which only returns events that fall within the start time and the stop time.\r
+     * The visible duration is the event duration below which further detail is not discernible.\r
+     * If no such iterator is implemented, provide a basic iterator which returns all events.\r
+     * \r
+     * @param startTime start time in nanoseconds\r
+     * @param stopTime stop time in nanoseconds\r
+     * @param visibleDuration duration of one pixel in nanoseconds\r
+     */\r
+    public <T extends ITimeEvent> Iterator<T> getTraceEventsIterator(long startTime, long stopTime, long visibleDuration);\r
+    \r
+    public <T extends ITimeEvent> void addTraceEvent(T event);\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/TimeEvent.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/model/TimeEvent.java
new file mode 100644 (file)
index 0000000..ebdcdde
--- /dev/null
@@ -0,0 +1,36 @@
+/*******************************************************************************\r
+ * Copyright (c) 2009 Ericsson\r
+ * \r
+ * All rights reserved. This program and the accompanying materials are\r
+ * made available under the terms of the Eclipse Public License v1.0 which\r
+ * accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ * \r
+ * Contributors:\r
+ *   Alvaro Sanchez-Leon - Initial API and implementation\r
+ *******************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model;\r
+\r
+\r
+public abstract class TimeEvent implements ITimeEvent {\r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTrace()\r
+        */\r
+       @Override\r
+       public abstract ITmfTimeAnalysisEntry getEntry();\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getTime()\r
+        */\r
+       @Override\r
+       public abstract long getTime();\r
+       \r
+       /* (non-Javadoc)\r
+        * @see org.eclipse.linuxtools.tlf.widgets.timeAnalysis.model.TmTaEventI#getDuration()\r
+        */\r
+       @Override\r
+       public long getDuration() {\r
+               return -1;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/ITimeDataProvider.java
new file mode 100644 (file)
index 0000000..73cba5e
--- /dev/null
@@ -0,0 +1,68 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2010 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Updated for TMF\r
+ *\r
+ * $Id: ITimeDataProvider.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+public interface ITimeDataProvider {\r
+\r
+       long getSelectedTime();\r
+\r
+       long getBeginTime();\r
+\r
+       long getEndTime();\r
+\r
+       long getMinTime();\r
+\r
+       long getMaxTime();\r
+\r
+       long getTime0();\r
+\r
+       long getTime1();\r
+\r
+       long getMinTimeInterval();\r
+\r
+       /**\r
+        * Updates the time range and notify registered listeners\r
+        * \r
+        * @param time0\r
+        * @param time1\r
+        */\r
+       void setStartFinishTimeNotify(long time0, long time1);\r
+\r
+       /**\r
+        * Update the time range but do not trigger event notification\r
+        * \r
+        * @param time0\r
+        * @param time1\r
+        */\r
+       void setStartFinishTime(long time0, long time1);\r
+\r
+    /**\r
+     * Notify registered listeners without updating the time range\r
+     */\r
+    void notifyStartFinishTime();\r
+\r
+       void setSelectedTimeInt(long time, boolean ensureVisible);\r
+\r
+       void resetStartFinishTime();\r
+\r
+       int getNameSpace();\r
+\r
+       void setNameSpace(int width);\r
+\r
+       int getTimeSpace();\r
+       \r
+       boolean isCalendarFormat();\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/PlainSelection.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/PlainSelection.java
new file mode 100644 (file)
index 0000000..f163fd6
--- /dev/null
@@ -0,0 +1,71 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: PlainSelection.java,v 1.1 2007/04/20 13:06:49 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+\r
+public class PlainSelection implements IStructuredSelection {\r
+\r
+       List<Object> list = new ArrayList<Object>();\r
+\r
+       public PlainSelection() {\r
+       }\r
+\r
+       public PlainSelection(Object sel) {\r
+               add(sel);\r
+       }\r
+\r
+       public void add(Object sel) {\r
+               if (null != sel && !list.contains(sel))\r
+                       list.add(sel);\r
+       }\r
+\r
+       @Override\r
+       public Object getFirstElement() {\r
+               if (!list.isEmpty())\r
+                       return list.get(0);\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public Iterator<Object> iterator() {\r
+               return list.iterator();\r
+       }\r
+\r
+       @Override\r
+       public int size() {\r
+               return list.size();\r
+       }\r
+\r
+       @Override\r
+       public Object[] toArray() {\r
+               return list.toArray();\r
+       }\r
+\r
+       @Override\r
+       public List<Object> toList() {\r
+               return list;\r
+       }\r
+\r
+       @Override\r
+       public boolean isEmpty() {\r
+               return list.isEmpty();\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeScaleCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TimeScaleCtrl.java
new file mode 100644 (file)
index 0000000..44409b8
--- /dev/null
@@ -0,0 +1,790 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008, 2010 Intel Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: TimeScaleCtrl.java,v 1.5 2008/06/16 21:04:49 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Calendar;\r
+import java.util.Date;\r
+import java.util.GregorianCalendar;\r
+import java.util.TimeZone;\r
+\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.events.MouseMoveListener;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+public class TimeScaleCtrl extends TraceCtrl implements MouseListener,\r
+               MouseMoveListener {\r
+\r
+       public TimeScaleCtrl(Composite parent, TraceColorScheme colors) {\r
+               super(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS\r
+                               | SWT.DOUBLE_BUFFERED);\r
+               addMouseListener(this);\r
+               addMouseMoveListener(this);\r
+       }\r
+\r
+    private static final long SEC_IN_NS = 1000000000;\r
+    private static final long MIN_IN_NS = 60 * SEC_IN_NS;\r
+    private static final long HOUR_IN_NS = 60 * MIN_IN_NS;\r
+    private static final long DAY_IN_NS = 24 * HOUR_IN_NS;\r
+    private static final long MONTH_IN_NS = 31 * DAY_IN_NS; // upper limit\r
+    private static final long YEAR_IN_NS = 366 * DAY_IN_NS; // upper limit\r
+    \r
+    private static final double LOG10_1 = Math.log10(1);\r
+    private static final double LOG10_2 = Math.log10(2);\r
+    private static final double LOG10_3 = Math.log10(3);\r
+    private static final double LOG10_5 = Math.log10(5);\r
+    \r
+    private static final Calendar GREGORIAN_CALENDAR = GregorianCalendar.getInstance(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+    \r
+       private ITimeDataProvider _timeProvider;\r
+       private int _dragState = 0;\r
+       private int _dragX0 = 0;\r
+       private int _dragX = 0;\r
+       private long _time0bak;\r
+       private long _time1bak;\r
+       private boolean _isInUpdate;\r
+       private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
+    private int _height;\r
+\r
+       public void setTimeProvider(ITimeDataProvider timeProvider) {\r
+               _timeProvider = timeProvider;\r
+       }\r
+\r
+       private long _timeDelta;\r
+\r
+       @Override\r
+    public Point computeSize(int wHint, int hHint, boolean changed) {\r
+        return super.computeSize(wHint, _height, changed);\r
+    }\r
+\r
+    public void setHeight(int height) {\r
+        this._height = height;\r
+    }\r
+    \r
+    private void calcTimeDelta(int width, double pixelsPerNanoSec) {\r
+        double minDelta = (double) ((pixelsPerNanoSec == 0) ? YEAR_IN_NS : width / pixelsPerNanoSec);\r
+        long unit = 1;\r
+        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            if (minDelta > 6 * MONTH_IN_NS) {\r
+                unit = YEAR_IN_NS;\r
+            } else if (minDelta > 3 * MONTH_IN_NS) {\r
+                unit = 6 * MONTH_IN_NS;\r
+            } else if (minDelta > 10 * DAY_IN_NS) {\r
+                unit = MONTH_IN_NS;\r
+            } else if (minDelta > 12 * HOUR_IN_NS) {\r
+                unit = DAY_IN_NS;\r
+            } else if (minDelta > 3 * HOUR_IN_NS) {\r
+                unit = 6 * HOUR_IN_NS;\r
+            } else if (minDelta > 30 * MIN_IN_NS) {\r
+                unit = HOUR_IN_NS;\r
+            } else if (minDelta > 10 * MIN_IN_NS) {\r
+                unit = 15 * MIN_IN_NS;\r
+            } else if (minDelta > 30 * SEC_IN_NS) {\r
+                unit = MIN_IN_NS;\r
+            } else if (minDelta > 20 * SEC_IN_NS) {\r
+                unit = 30 * SEC_IN_NS;\r
+            } else if (minDelta <= 1) {\r
+                _timeDelta = 1;\r
+                return;\r
+            }\r
+        }\r
+        double log = Math.log10((double) minDelta / unit);\r
+        long pow10 = (long) log;\r
+        double remainder = log - pow10;\r
+        if (remainder < LOG10_1) {\r
+            _timeDelta = (long) Math.pow(10, pow10) * unit;\r
+        } else if (remainder < LOG10_2) {\r
+            _timeDelta = 2 * (long) Math.pow(10, pow10) * unit;\r
+        } else if (remainder < LOG10_3 && unit >= HOUR_IN_NS && unit < YEAR_IN_NS) {\r
+            _timeDelta = 3 * (long) Math.pow(10, pow10) * unit;\r
+        } else if (remainder < LOG10_5) {\r
+            _timeDelta = 5 * (long) Math.pow(10, pow10) * unit;\r
+        } else {\r
+            _timeDelta = 10 * (long) Math.pow(10, pow10) * unit;\r
+        }\r
+    }\r
+\r
+    private static TimeDraw TIMEDRAW_NANOSEC = new TimeDrawNanosec();\r
+    private static TimeDraw TIMEDRAW_MICROSEC = new TimeDrawMicrosec();\r
+    private static TimeDraw TIMEDRAW_MILLISEC = new TimeDrawMillisec();\r
+    private static TimeDraw TIMEDRAW_SEC = new TimeDrawSec();\r
+    private static TimeDraw TIMEDRAW_ABS_NANOSEC = new TimeDrawAbsNanoSec();\r
+    private static TimeDraw TIMEDRAW_ABS_MICROSEC = new TimeDrawAbsMicroSec();\r
+    private static TimeDraw TIMEDRAW_ABS_MILLISEC = new TimeDrawAbsMillisec();\r
+    private static TimeDraw TIMEDRAW_ABS_SEC = new TimeDrawAbsSec();\r
+    private static TimeDraw TIMEDRAW_ABS_MIN = new TimeDrawAbsMin();\r
+    private static TimeDraw TIMEDRAW_ABS_HRS = new TimeDrawAbsHrs();\r
+    private static TimeDraw TIMEDRAW_ABS_DAY = new TimeDrawAbsDay();\r
+    private static TimeDraw TIMEDRAW_ABS_MONTH = new TimeDrawAbsMonth();\r
+    private static TimeDraw TIMEDRAW_ABS_YEAR = new TimeDrawAbsYear();\r
+\r
+       TimeDraw getTimeDraw(long timeDelta) {\r
+               TimeDraw timeDraw;\r
+               if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            if (timeDelta >= YEAR_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_YEAR;\r
+            else if (timeDelta >= MONTH_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_MONTH;\r
+            else if (timeDelta >= DAY_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_DAY;\r
+            else if (timeDelta >= HOUR_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_HRS;\r
+            else if (timeDelta >= MIN_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_MIN;\r
+            else if (timeDelta >= SEC_IN_NS)\r
+                timeDraw = TIMEDRAW_ABS_SEC;\r
+                       else if (timeDelta >= 1000000)\r
+                               timeDraw = TIMEDRAW_ABS_MILLISEC;\r
+                       else if (timeDelta >= 1000)\r
+                               timeDraw = TIMEDRAW_ABS_MICROSEC;\r
+                       else\r
+                               timeDraw = TIMEDRAW_ABS_NANOSEC;\r
+                       return timeDraw;\r
+               }\r
+               if (timeDelta >= 1000000000)\r
+                       timeDraw = TIMEDRAW_SEC;\r
+               else if (timeDelta >= 1000000)\r
+                       timeDraw = TIMEDRAW_MILLISEC;\r
+               else if (timeDelta >= 1000)\r
+                       timeDraw = TIMEDRAW_MICROSEC;\r
+               else\r
+                       timeDraw = TIMEDRAW_NANOSEC;\r
+               return timeDraw;\r
+       }\r
+\r
+       @Override\r
+       void paint(Rectangle rect, PaintEvent e) {\r
+\r
+               if (_isInUpdate || null == _timeProvider)\r
+                       return;\r
+\r
+               GC gc = e.gc;\r
+               gc.fillRectangle(rect);\r
+               \r
+               long time0 = _timeProvider.getTime0();\r
+               long time1 = _timeProvider.getTime1();\r
+               long selectedTime = _timeProvider.getSelectedTime();\r
+               int leftSpace = _timeProvider.getNameSpace();\r
+               int timeSpace = _timeProvider.getTimeSpace();\r
+               \r
+               gc.setBackground(_colors.getColor(TraceColorScheme.TOOL_BACKGROUND));\r
+               gc.setForeground(_colors.getColor(TraceColorScheme.TOOL_FOREGROUND));\r
+               Utils.init(_rect0, rect);\r
+               \r
+               // draw top left area\r
+               _rect0.width = leftSpace;\r
+               _rect0.x += 4;\r
+               _rect0.width -= 4;\r
+               if (_rect0.width > 0) {\r
+                   Utils.drawText(gc, Messages.TimeScaleCtrl_Timescale + ":", _rect0, true); //$NON-NLS-1$\r
+               }\r
+               int messageWidth = gc.stringExtent(Messages.TimeScaleCtrl_Timescale + ":").x + 4; //$NON-NLS-1$\r
+               Rectangle absHeaderRect = new Rectangle(_rect0.x + messageWidth, _rect0.y, _rect0.width - messageWidth, _rect0.height);\r
+               _rect0.x -= 4;\r
+               _rect0.width += 4;\r
+               \r
+               // prepare and draw right rect of the timescale\r
+               _rect0.x += leftSpace;\r
+               _rect0.width = rect.width - leftSpace;\r
+               \r
+               // draw bottom border and erase all other area\r
+               gc.drawLine(rect.x, rect.y + rect.height - 1, rect.x + rect.width - 1,\r
+                       rect.y + rect.height - 1);\r
+               _rect0.height--;\r
+               gc.fillRectangle(_rect0);\r
+               \r
+               if (time1 <= time0 || timeSpace < 2) {\r
+                   return;\r
+               }\r
+               \r
+               int numDigits = calculateDigits(time0, time1);\r
+               \r
+               int labelWidth = gc.getCharWidth('0') * numDigits;\r
+               double pixelsPerNanoSec = (timeSpace <= RIGHT_MARGIN) ? 0 :\r
+                   (double) (timeSpace - RIGHT_MARGIN) / (time1 - time0);\r
+               calcTimeDelta(labelWidth, pixelsPerNanoSec);\r
+               \r
+               TimeDraw timeDraw = getTimeDraw(_timeDelta);\r
+\r
+               // draw zoom rectangle\r
+        if (3 == _dragState && null != _timeProvider) {\r
+            if (_dragX0 < _dragX) {\r
+                gc.drawRectangle(leftSpace + _dragX0, rect.y, _dragX - _dragX0 - 1, rect.height - 8);\r
+            } else if (_dragX0 > _dragX) {\r
+                gc.drawRectangle(leftSpace + _dragX, rect.y, _dragX0 - _dragX - 1, rect.height - 8);\r
+            }\r
+        }\r
+\r
+               if (_rect0.isEmpty())\r
+                       return;\r
+\r
+               // draw selected time\r
+               int x = _rect0.x + (int) ((double)(selectedTime - time0) * pixelsPerNanoSec);\r
+               if (x >= _rect0.x && x < _rect0.x + _rect0.width) {\r
+                       gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+                       gc.drawLine(x, _rect0.y + _rect0.height - 6, x, _rect0.y\r
+                                       + _rect0.height);\r
+                       gc\r
+                                       .setForeground(_colors\r
+                                                       .getColor(TraceColorScheme.TOOL_FOREGROUND));\r
+               }\r
+\r
+               // draw time scale ticks\r
+               _rect0.y = rect.y;\r
+               _rect0.height = rect.height - 4;\r
+               _rect0.width = labelWidth;\r
+               \r
+               long time;\r
+        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            time = floorToCalendar(time0, _timeDelta);\r
+        } else {\r
+            time = (long) (Math.ceil((double) time0 / _timeDelta) * _timeDelta);\r
+        }\r
+               \r
+               // long t = (long) (time * 1000000000);\r
+               int y = _rect0.y + _rect0.height;\r
+\r
+        if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+            timeDraw.drawAbsHeader(gc, time, absHeaderRect);\r
+        }\r
+               \r
+               while (true) {\r
+                       x = rect.x + leftSpace + (int) (Math.floor((time - time0) * pixelsPerNanoSec));\r
+                       if (x >= rect.x + leftSpace + rect.width - _rect0.width) {\r
+                               break;\r
+                       }\r
+                       if (x >= rect.x + leftSpace) {\r
+                               gc.drawLine(x, y, x, y + 4);\r
+                               _rect0.x = x;\r
+                               if (x + _rect0.width <= rect.x + rect.width)\r
+                                       timeDraw.draw(gc, time, _rect0);\r
+                       }\r
+                       if (pixelsPerNanoSec == 0 || time > Long.MAX_VALUE - _timeDelta || _timeDelta == 0) {\r
+                           break;\r
+                       }\r
+                       time += _timeDelta;\r
+            if (_timeProvider != null && _timeProvider.isCalendarFormat()) {\r
+                if (_timeDelta >= YEAR_IN_NS) {\r
+                    GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+                    GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
+                    GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
+                    time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+                } else if (_timeDelta >= MONTH_IN_NS) {\r
+                    GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+                    GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
+                    time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+                }\r
+            }\r
+               }\r
+       }\r
+\r
+       private long floorToCalendar(long time, long timeDelta) {\r
+        if (_timeDelta >= YEAR_IN_NS) {\r
+            GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+            int year = GREGORIAN_CALENDAR.get(Calendar.YEAR);\r
+            int yearDelta = (int) (timeDelta / YEAR_IN_NS);\r
+            year = (year / yearDelta) * yearDelta;\r
+            GREGORIAN_CALENDAR.set(Calendar.YEAR, year);\r
+            GREGORIAN_CALENDAR.set(Calendar.MONTH, 0); // January 1st of year\r
+            GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1);\r
+            GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
+            time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+        } else if (_timeDelta >= MONTH_IN_NS) {\r
+            GREGORIAN_CALENDAR.setTime(new Date(time / 1000000));\r
+            int month = GREGORIAN_CALENDAR.get(Calendar.MONTH);\r
+            int monthDelta = (int) (timeDelta / MONTH_IN_NS);\r
+            month = (month / monthDelta) * monthDelta;\r
+            GREGORIAN_CALENDAR.set(Calendar.MONTH, month);\r
+            GREGORIAN_CALENDAR.set(Calendar.DAY_OF_MONTH, 1); // 1st of month\r
+            GREGORIAN_CALENDAR.set(Calendar.HOUR_OF_DAY, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MINUTE, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.SECOND, 0);\r
+            GREGORIAN_CALENDAR.set(Calendar.MILLISECOND, 0);\r
+            time = GREGORIAN_CALENDAR.getTimeInMillis() * 1000000;\r
+        } else {\r
+            time = (time / timeDelta) * timeDelta;\r
+        }\r
+        return time;\r
+       }\r
+       \r
+       private int calculateDigits(long time0, long time1) {\r
+               int numDigits = 5;\r
+               long timeRange = time1 - time0;\r
+\r
+               if (_timeProvider.isCalendarFormat()) {\r
+                       // Calculate the number of digits to represent the minutes provided\r
+                       // 11:222\r
+                       // HH:mm:ss\r
+                       numDigits += 8;\r
+                       if (timeRange < 10000) {\r
+                               // HH:11:222:333:444__\r
+                               numDigits += 10;\r
+                       } else if (timeRange < 10000000) {\r
+                               // HH:11:222:333__\r
+                               numDigits += 6;\r
+                       }\r
+               } else {\r
+                       // Calculate the number of digits to represent the minutes provided\r
+                       long min = (long) ((time1 * 1E-9) / 60); // to sec then to minutes\r
+                       String strMinutes = String.valueOf(min);\r
+                       // 11:222\r
+                       if (strMinutes != null) {\r
+                               numDigits += strMinutes.length();\r
+                       } else {\r
+                               numDigits += 2;\r
+                       }\r
+                       if (timeRange < 10000) {\r
+                               // 11:222:333:444__\r
+                               numDigits += 8;\r
+                       } else if (timeRange < 10000000) {\r
+                               // 11:222:333__\r
+                               numDigits += 4;\r
+                       }\r
+               }\r
+\r
+//             Trace.debug("timeRange: " + timeRange + " numDigits: " + numDigits);\r
+               return numDigits;\r
+       }\r
+\r
+       @Override\r
+       public void mouseDown(MouseEvent e) {\r
+           if (_dragState == 0 && null != _timeProvider) {\r
+               if (1 == e.button) {\r
+                   setCapture(true);\r
+                   _dragState = 1;\r
+               } else if (3 == e.button) {\r
+                   _dragState = 3;\r
+               }\r
+               int x = e.x - _timeProvider.getNameSpace();\r
+               if (x < 0) {\r
+                   x = 0;\r
+               } else if (x > getSize().x - _timeProvider.getNameSpace()) {\r
+                   x = getSize().x - _timeProvider.getNameSpace();\r
+               }\r
+               _dragX = _dragX0 = x;\r
+               _time0bak = _timeProvider.getTime0();\r
+               _time1bak = _timeProvider.getTime1();\r
+           }\r
+       }\r
+\r
+       @Override\r
+       public void mouseUp(MouseEvent e) {\r
+               if (e.button == 1 && _dragState == 1) {\r
+                       setCapture(false);\r
+                       _dragState = 0;\r
+                       \r
+               // Notify time provider to check the need for listener notification\r
+                       if (_dragX != _dragX0) {\r
+                           _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
+                       }\r
+               } else if (e.button == 3 && _dragState == 3 && null != _timeProvider) {\r
+                   _dragState = 0;\r
+                       if (_dragX0 == _dragX) {\r
+                               return;\r
+                       }\r
+                       int timeSpace = _timeProvider.getTimeSpace();\r
+                       int leftSpace = _timeProvider.getNameSpace();\r
+                       int x = e.x - leftSpace;\r
+                       if (timeSpace > 0) {\r
+                               _dragX = x;\r
+                               if (_dragX0 > _dragX) { // drag right to left\r
+                                   _dragX = _dragX0;\r
+                                   _dragX0 = x;\r
+                               }\r
+                               long time0 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / timeSpace));\r
+                               long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX / timeSpace));\r
+\r
+                               _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+                   _time0bak = _timeProvider.getTime0();\r
+                   _time1bak = _timeProvider.getTime1();\r
+                       }\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void mouseMove(MouseEvent e) {\r
+               if (_dragX0 < 0 || _dragState == 0 || _timeProvider == null) {\r
+                       return;\r
+               }\r
+               Point size = getSize();\r
+               int leftSpace = _timeProvider.getNameSpace();\r
+               int timeSpace = _timeProvider.getTimeSpace();\r
+               int x = e.x - leftSpace;\r
+               if (1 == _dragState) {\r
+                       if (x > 0 && size.x > leftSpace && _dragX != x) {\r
+                               _dragX = x;\r
+                               long time1 = _time0bak + (long) ((_time1bak - _time0bak) * ((double) _dragX0 / _dragX));\r
+                               _timeProvider.setStartFinishTime(_time0bak, time1);\r
+                       }\r
+               } else if (3 == _dragState) {\r
+                   if (x < 0) {\r
+                       _dragX = 0;\r
+                   } else if (x > timeSpace) {\r
+                       _dragX = timeSpace;\r
+                   } else {\r
+                _dragX = x;\r
+            }\r
+                   redraw();\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public void mouseDoubleClick(MouseEvent e) {\r
+               if (null != _timeProvider) {\r
+                       _timeProvider.resetStartFinishTime();\r
+            _time0bak = _timeProvider.getTime0();\r
+            _time1bak = _timeProvider.getTime1();\r
+               }\r
+       }\r
+}\r
+\r
+abstract class TimeDraw {\r
+       static String S   = ":"  ; //$NON-NLS-1$\r
+       static String S0  = ":0" ; //$NON-NLS-1$\r
+       static String S00 = ":00"; //$NON-NLS-1$\r
+    protected static final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss");          //$NON-NLS-1$\r
+    protected static final SimpleDateFormat stimeformatheader = new SimpleDateFormat("yyyy MMM dd"); //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sminformat = new SimpleDateFormat("HH:mm");              //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sminformatheader = new SimpleDateFormat("yyyy MMM dd");  //$NON-NLS-1$\r
+    protected static final SimpleDateFormat shrsformat = new SimpleDateFormat("MMM dd HH:mm");              //$NON-NLS-1$\r
+    protected static final SimpleDateFormat shrsformatheader = new SimpleDateFormat("yyyy");         //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sdayformat = new SimpleDateFormat("MMM dd");             //$NON-NLS-1$\r
+    protected static final SimpleDateFormat sdayformatheader = new SimpleDateFormat("yyyy");         //$NON-NLS-1$\r
+    protected static final SimpleDateFormat smonthformat = new SimpleDateFormat("yyyy MMM");         //$NON-NLS-1$\r
+    protected static final SimpleDateFormat syearformat = new SimpleDateFormat("yyyy");              //$NON-NLS-1$\r
+    static {\r
+        stimeformat.setTimeZone(TimeZone.getTimeZone("GMT"));       //$NON-NLS-1$\r
+        stimeformatheader.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+        sminformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
+        sminformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
+        shrsformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
+        shrsformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
+        sdayformat.setTimeZone(TimeZone.getTimeZone("GMT"));        //$NON-NLS-1$\r
+        sdayformatheader.setTimeZone(TimeZone.getTimeZone("GMT"));  //$NON-NLS-1$\r
+        smonthformat.setTimeZone(TimeZone.getTimeZone("GMT"));      //$NON-NLS-1$\r
+        syearformat.setTimeZone(TimeZone.getTimeZone("GMT"));       //$NON-NLS-1$\r
+    }\r
+       \r
+       static String pad(long n) {\r
+               String s = S;\r
+               if (n < 10)\r
+                       s = S00;\r
+               else if (n < 100)\r
+                       s = S0;\r
+               return s + n;\r
+       }\r
+\r
+    public abstract void draw(GC gc, long time, Rectangle rect);\r
+\r
+    public void drawAbsHeader(GC gc, long time, Rectangle absHeaderRect) {\r
+        // Override to draw absolute time header\r
+        // This is for the time information not shown in the draw of each tick\r
+    }\r
+    \r
+       public abstract String hint();\r
+}\r
+\r
+class TimeDrawSec extends TimeDraw {\r
+       static String _hint = "sec"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               time /= 1000000000;\r
+               Utils.drawText(gc, time + "", rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawMillisec extends TimeDraw {\r
+       static String _hint = "s:ms"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               time /= 1000000;\r
+               long ms = time % 1000;\r
+               time /= 1000;\r
+               Utils.drawText(gc, time + pad(ms), rect, true);\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawMicrosec extends TimeDraw {\r
+       static String _hint = "s:ms:mcs"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               time /= 1000;\r
+               long mcs = time % 1000;\r
+               time /= 1000;\r
+               long ms = time % 1000;\r
+               time /= 1000;\r
+               Utils.drawText(gc, time + pad(ms) + pad(mcs), rect, true);\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawNanosec extends TimeDraw {\r
+       static String _hint = "s:ms:mcs:ns"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               long ns = time % 1000;\r
+               time /= 1000;\r
+               long mcs = time % 1000;\r
+               time /= 1000;\r
+               long ms = time % 1000;\r
+               time /= 1000;\r
+               Utils.drawText(gc, time + pad(ms) + pad(mcs) + pad(ns), rect, true);\r
+       }\r
+\r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawAbsYear extends TimeDraw {\r
+    static String _hint = "YYYY"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = syearformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsMonth extends TimeDraw {\r
+    static String _hint = "YYYY Mmm"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = smonthformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsDay extends TimeDraw {\r
+    static String _hint = "Mmm dd"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = sdayformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = sdayformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsHrs extends TimeDraw {\r
+    static String _hint = "Mmm dd HH:mm"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = shrsformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = shrsformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsMin extends TimeDraw {\r
+    static String _hint = "HH:mm"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = sminformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = sminformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsSec extends TimeDraw {\r
+    static String _hint = "HH:mm:ss"; //$NON-NLS-1$\r
+\r
+    @Override\r
+    public void draw(GC gc, long time, Rectangle rect) {\r
+        String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+        Utils.drawText(gc, stime, rect, true);\r
+    }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+    @Override\r
+    public String hint() {\r
+        return _hint;\r
+    }\r
+}\r
+\r
+class TimeDrawAbsMillisec extends TimeDraw {\r
+       static String _hint = "HH:ss:ms"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+               String ns = Utils.formatNs(time, Resolution.MILLISEC);\r
+\r
+               Utils.drawText(gc, stime + " " + ns, rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawAbsMicroSec extends TimeDraw {\r
+       static String _hint = "HH:ss:ms:mcs"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+               String micr = Utils.formatNs(time, Resolution.MICROSEC);\r
+               Utils.drawText(gc, stime + " " + micr, rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
+\r
+class TimeDrawAbsNanoSec extends TimeDraw {\r
+       static String _hint = "HH:ss:ms:mcs:ns"; //$NON-NLS-1$\r
+\r
+       @Override\r
+       public void draw(GC gc, long time, Rectangle rect) {\r
+               String stime = stimeformat.format(new Date((long) (time / 1000000)));\r
+               String ns = Utils.formatNs(time, Resolution.NANOSEC);\r
+               Utils.drawText(gc, stime + " " + ns, rect, true); //$NON-NLS-1$\r
+       }\r
+\r
+    @Override\r
+    public void drawAbsHeader(GC gc, long time, Rectangle rect) {\r
+        String header = stimeformatheader.format(new Date((long) (time / 1000000)));\r
+        int headerwidth = gc.stringExtent(header).x + 4;\r
+        if (headerwidth <= rect.width) {\r
+            rect.x += (rect.width - headerwidth);\r
+            Utils.drawText(gc, header, rect, true);\r
+        }\r
+    }\r
+    \r
+       @Override\r
+       public String hint() {\r
+               return _hint;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TmfTimeStatesCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TmfTimeStatesCtrl.java
new file mode 100644 (file)
index 0000000..6731ce0
--- /dev/null
@@ -0,0 +1,2173 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: ThreadStatesCtrl.java,v 1.15 2008/07/11 13:49:01 aalexeev Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Vector;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.ISelectionChangedListener;\r
+import org.eclipse.jface.viewers.ISelectionProvider;\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.TimeEvent;\r
+import org.eclipse.osgi.util.NLS;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.ControlEvent;\r
+import org.eclipse.swt.events.ControlListener;\r
+import org.eclipse.swt.events.FocusEvent;\r
+import org.eclipse.swt.events.FocusListener;\r
+import org.eclipse.swt.events.KeyEvent;\r
+import org.eclipse.swt.events.KeyListener;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseListener;\r
+import org.eclipse.swt.events.MouseMoveListener;\r
+import org.eclipse.swt.events.MouseTrackListener;\r
+import org.eclipse.swt.events.MouseWheelListener;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.SelectionEvent;\r
+import org.eclipse.swt.events.SelectionListener;\r
+import org.eclipse.swt.events.TraverseEvent;\r
+import org.eclipse.swt.events.TraverseListener;\r
+import org.eclipse.swt.graphics.Cursor;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Image;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
+import org.eclipse.swt.widgets.ScrollBar;\r
+\r
+/**\r
+ * @author alvaro\r
+ * \r
+ */\r
+public class TmfTimeStatesCtrl extends TraceCtrl implements FocusListener, KeyListener, MouseMoveListener, MouseListener, MouseWheelListener, ControlListener, SelectionListener, MouseTrackListener, TraverseListener, ISelectionProvider {\r
+\r
+    private static final int DRAG_NONE = 0;\r
+    private static final int DRAG_TRACE_ITEM = 1;\r
+    private static final int DRAG_GROUP_ITEM = 2;\r
+    private static final int DRAG_SPLIT_LINE = 3;\r
+    public static final boolean DEFAULT_DRAW_THREAD_JOIN = true;\r
+    public static final boolean DEFAULT_DRAW_THREAD_WAIT = true;\r
+    public static final boolean DEFAULT_DRAW_THREAD_RELEASE = true;\r
+    public static final int H_SCROLLBAR_MAX = Integer.MAX_VALUE - 1;\r
+\r
+    private static final double zoomCoeff = 1.5;\r
+\r
+    private ITimeDataProvider _timeProvider;\r
+    private boolean _isInFocus = false;\r
+    private boolean _isDragCursor3 = false;\r
+    private boolean _isWaitCursor = true;\r
+    private boolean _mouseHover = false;\r
+    private int _itemHeightDefault = 19;\r
+    private int _itemHeight = _itemHeightDefault;\r
+    private int _minimumItemWidth = 0;\r
+    private int _topItem = 0;\r
+    private int _dragState = DRAG_NONE;\r
+    private int _hitIdx = 0;\r
+    private int _dragX0 = 0;\r
+    private int _dragX = 0;\r
+    private int _idealNameWidth = 0;\r
+    // private double _timeStep = 10000000;\r
+    private long _time0bak;\r
+    private long _time1bak;\r
+    private TmfTimeAnalysisProvider utilImpl = null;\r
+    private ItemData _data = null;\r
+    private List<SelectionListener> _selectionListeners;\r
+    private List<ISelectionChangedListener> _selectionChangedListeners = new ArrayList<ISelectionChangedListener>();\r
+    private Rectangle _rect0 = new Rectangle(0, 0, 0, 0);\r
+    private Rectangle _rect1 = new Rectangle(0, 0, 0, 0);\r
+    private Cursor _dragCursor3;\r
+    private Cursor _WaitCursor;\r
+    private boolean drawTracesInteraction = false;\r
+    private boolean drawTraceJoins = DEFAULT_DRAW_THREAD_JOIN;\r
+    private boolean drawTraceWaits = DEFAULT_DRAW_THREAD_WAIT;\r
+    private boolean drawTraceReleases = DEFAULT_DRAW_THREAD_RELEASE;\r
+\r
+    // Vertical formatting formatting for the state control view\r
+    private boolean _visibleVerticalScroll = true;\r
+    private int _borderWidth = 0;\r
+    private int _headerHeight = 0;\r
+\r
+    private Listener mouseScrollFilterListener;\r
+\r
+    public TmfTimeStatesCtrl(Composite parent, TraceColorScheme colors, TmfTimeAnalysisProvider rutilImp) {\r
+\r
+        super(parent, colors, SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL | SWT.DOUBLE_BUFFERED);\r
+\r
+        this.utilImpl = rutilImp;\r
+        _data = new ItemData(utilImpl);\r
+\r
+        addFocusListener(this);\r
+        addMouseListener(this);\r
+        addMouseMoveListener(this);\r
+        addMouseTrackListener(this);\r
+        addMouseWheelListener(this);\r
+        addTraverseListener(this);\r
+        addKeyListener(this);\r
+        addControlListener(this);\r
+        ScrollBar scrollVer = getVerticalBar();\r
+        ScrollBar scrollHor = getHorizontalBar();\r
+        if (scrollVer != null) {\r
+            scrollVer.addSelectionListener(this);\r
+            scrollVer.setVisible(_visibleVerticalScroll);\r
+        }\r
+\r
+        if (scrollHor != null) {\r
+            scrollHor.addSelectionListener(this);\r
+        }\r
+\r
+        _dragCursor3 = new Cursor(super.getDisplay(), SWT.CURSOR_SIZEWE);\r
+        _WaitCursor = new Cursor(super.getDisplay(), SWT.CURSOR_WAIT);\r
+    }\r
+\r
+    @Override\r
+    public void dispose() {\r
+        super.dispose();\r
+        _dragCursor3.dispose();\r
+        _WaitCursor.dispose();\r
+    }\r
+\r
+    public void setTimeProvider(ITimeDataProvider timeProvider) {\r
+        _timeProvider = timeProvider;\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void addSelectionListener(SelectionListener listener) {\r
+        if (listener == null)\r
+            SWT.error(SWT.ERROR_NULL_ARGUMENT);\r
+        if (null == _selectionListeners)\r
+            _selectionListeners = new ArrayList<SelectionListener>();\r
+        _selectionListeners.add(listener);\r
+    }\r
+\r
+    public void removeSelectionListener(SelectionListener listener) {\r
+        if (null != _selectionListeners)\r
+            _selectionListeners.remove(listener);\r
+    }\r
+\r
+    public void fireSelectionChanged() {\r
+        if (null != _selectionListeners) {\r
+            Iterator<SelectionListener> it = _selectionListeners.iterator();\r
+            while (it.hasNext()) {\r
+                SelectionListener listener = it.next();\r
+                listener.widgetSelected(null);\r
+            }\r
+        }\r
+    }\r
+\r
+    public void fireDefaultSelection() {\r
+        if (null != _selectionListeners) {\r
+            Iterator<SelectionListener> it = _selectionListeners.iterator();\r
+            while (it.hasNext()) {\r
+                SelectionListener listener = it.next();\r
+                listener.widgetDefaultSelected(null);\r
+            }\r
+        }\r
+    }\r
+\r
+    public Object[] getTraces() {\r
+        return _data.getTraces();\r
+    }\r
+\r
+    public boolean[] getTraceFilter() {\r
+        return _data.getTraceFilter();\r
+    }\r
+\r
+    public void refreshData() {\r
+        _data.refreshData();\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void refreshData(Object traces[]) {\r
+        _data.refreshData(traces);\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void refreshPartial(ITmfTimeAnalysisEntry parent, TimeEvent item) {\r
+        _data.refreshPartial(parent, item);\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void adjustScrolls() {\r
+        if (null == _timeProvider) {\r
+            getVerticalBar().setValues(0, 1, 1, 1, 1, 1);\r
+            getHorizontalBar().setValues(0, 1, 1, 1, 1, 1);\r
+            return;\r
+        }\r
+\r
+        // Vertical scroll bar\r
+        int page = countPerPage();\r
+        if (_topItem + page > _data._items.length)\r
+            _topItem = _data._items.length - page;\r
+        if (_topItem < 0)\r
+            _topItem = 0;\r
+        getVerticalBar().setValues(_topItem, 0, _data._items.length, page, 1, page);\r
+\r
+        // HORIZONTAL BAR\r
+        // Visible window\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        // Time boundaries\r
+        long timeMin = _timeProvider.getMinTime();\r
+        long timeMax = _timeProvider.getMaxTime();\r
+\r
+        long delta = timeMax - timeMin;\r
+\r
+        int timePos = 0;\r
+        int thumb = H_SCROLLBAR_MAX;\r
+\r
+        if (delta != 0) {\r
+            // Thumb size (page size)\r
+            thumb = Math.max(1, (int) (H_SCROLLBAR_MAX * ((double) (time1 - time0) / delta)));\r
+            // At the beginning of visible window\r
+            timePos = (int) (H_SCROLLBAR_MAX * ((double) (time0 - timeMin) / delta));\r
+        }\r
+\r
+        // position, minimum, maximum, thumb size, increment (half page)t, page\r
+        // increment size (full page)\r
+        getHorizontalBar().setValues(timePos, 0, H_SCROLLBAR_MAX, thumb, Math.max(1, thumb / 2), Math.max(2, thumb));\r
+    }\r
+\r
+    boolean ensureVisibleItem(int idx, boolean redraw) {\r
+        boolean changed = false;\r
+        if (idx < 0) {\r
+            for (idx = 0; idx < _data._items.length; idx++) {\r
+                if (((Item) _data._items[idx])._selected)\r
+                    break;\r
+            }\r
+        }\r
+        if (idx >= _data._items.length)\r
+            return changed;\r
+        if (idx < _topItem) {\r
+            _topItem = idx;\r
+            getVerticalBar().setSelection(_topItem);\r
+            if (redraw)\r
+                redraw();\r
+            changed = true;\r
+        } else {\r
+            int page = countPerPage();\r
+            if (idx >= _topItem + page) {\r
+                _topItem = idx - page + 1;\r
+                getVerticalBar().setSelection(_topItem);\r
+                if (redraw)\r
+                    redraw();\r
+                changed = true;\r
+            }\r
+        }\r
+        return changed;\r
+    }\r
+\r
+    public void setTopIndex(int idx) {\r
+        idx = Math.min(idx, _data._items.length - countPerPage());\r
+        idx = Math.max(0,  idx);\r
+        _topItem = idx;\r
+        getVerticalBar().setSelection(_topItem);\r
+        redraw();\r
+    }\r
+\r
+    @Override\r
+    public ISelection getSelection() {\r
+        PlainSelection sel = new PlainSelection();\r
+        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
+        if (null != trace && null != _timeProvider) {\r
+            long selectedTime = _timeProvider.getSelectedTime();\r
+            ITimeEvent event = Utils.findEvent(trace, selectedTime, 0);\r
+            if (event != null)\r
+                sel.add(event);\r
+            else\r
+                sel.add(trace);\r
+        }\r
+        return sel;\r
+    }\r
+\r
+    public ISelection getSelectionTrace() {\r
+        PlainSelection sel = new PlainSelection();\r
+        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
+        if (null != trace) {\r
+            sel.add(trace);\r
+        }\r
+        return sel;\r
+    }\r
+\r
+    public void selectTrace(int n) {\r
+        if (n != 1 && n != -1)\r
+            return;\r
+        boolean changed = false;\r
+        int lastSelection = -1;\r
+        for (int i = 0; i < _data._items.length; i++) {\r
+            Item item = (Item) _data._items[i];\r
+            if (item._selected) {\r
+                lastSelection = i;\r
+                if (1 == n && i < _data._items.length - 1) {\r
+                    item._selected = false;\r
+                    if (item._hasChildren)\r
+                        _data.expandItem(i, true);\r
+                    item = (Item) _data._items[i + 1];\r
+                    if (item._hasChildren) {\r
+                        _data.expandItem(i + 1, true);\r
+                        item = (Item) _data._items[i + 2];\r
+                    }\r
+                    item._selected = true;\r
+                    changed = true;\r
+                } else if (-1 == n && i > 0) {\r
+                    i--;\r
+                    Item prevItem = (Item) _data._items[i];\r
+                    if (prevItem._hasChildren) {\r
+                        if (prevItem._expanded) {\r
+                            if (i > 0) {\r
+                                i--;\r
+                                prevItem = (Item) _data._items[i];\r
+                            }\r
+                        }\r
+                        if (!prevItem._expanded) {\r
+                            int added = _data.expandItem(i, true);\r
+                            prevItem = (Item) _data._items[i + added];\r
+                            item._selected = false;\r
+                            prevItem._selected = true;\r
+                            changed = true;\r
+                        }\r
+                    } else {\r
+                        item._selected = false;\r
+                        prevItem._selected = true;\r
+                        changed = true;\r
+                    }\r
+                }\r
+                break;\r
+            }\r
+        }\r
+        if (lastSelection < 0 && _data._items.length > 0) {\r
+            Item item = (Item) _data._items[0];\r
+            if (item._hasChildren) {\r
+                _data.expandItem(0, true);\r
+                item = (Item) _data._items[1];\r
+                item._selected = true;\r
+                changed = true;\r
+            } else {\r
+                item._selected = true;\r
+                changed = true;\r
+            }\r
+        }\r
+        if (changed) {\r
+            ensureVisibleItem(-1, false);\r
+            redraw();\r
+            fireSelectionChanged();\r
+        }\r
+    }\r
+\r
+    public void selectEvent(int n) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        ITmfTimeAnalysisEntry trace = getSelectedTrace();\r
+        if (trace == null)\r
+            return;\r
+        long selectedTime = _timeProvider.getSelectedTime();\r
+        long endTime = _timeProvider.getEndTime();\r
+        ITimeEvent nextEvent;\r
+        if (-1 == n && selectedTime > endTime)\r
+            nextEvent = Utils.findEvent(trace, selectedTime, 0);\r
+        else\r
+            nextEvent = Utils.findEvent(trace, selectedTime, n);\r
+        if (null == nextEvent && -1 == n)\r
+            nextEvent = Utils.getFirstEvent(trace);\r
+        if (null != nextEvent) {\r
+            long nextTime = nextEvent.getTime();\r
+            // If last event detected e.g. going back or not moving to a next\r
+            // event\r
+            if (nextTime <= selectedTime && n == 1) {\r
+                // Select to the end of this last event\r
+                nextTime = nextEvent.getTime() + nextEvent.getDuration();\r
+                // but not beyond the end of the trace\r
+                if (nextTime > endTime) {\r
+                    nextTime = endTime;\r
+                }\r
+            }\r
+            _timeProvider.setSelectedTimeInt(nextTime, true);\r
+            fireSelectionChanged();\r
+        } else if (1 == n) {\r
+            _timeProvider.setSelectedTimeInt(endTime, true);\r
+            fireSelectionChanged();\r
+        }\r
+    }\r
+\r
+    public void selectNextEvent() {\r
+        selectEvent(1);\r
+        // Notify if visible time window has been adjusted\r
+        _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
+    }\r
+\r
+    public void selectPrevEvent() {\r
+        selectEvent(-1);\r
+        // Notify if visible time window has been adjusted\r
+        _timeProvider.setStartFinishTimeNotify(_timeProvider.getTime0(), _timeProvider.getTime1());\r
+    }\r
+\r
+    public void selectNextTrace() {\r
+        selectTrace(1);\r
+    }\r
+\r
+    public void selectPrevTrace() {\r
+        selectTrace(-1);\r
+    }\r
+\r
+    /**\r
+     * Zooming based on mouse cursor location with mouse scrolling\r
+     * \r
+     * @param zoomIn\r
+     */\r
+    public void zoom(boolean zoomIn) {\r
+        int globalX = getDisplay().getCursorLocation().x;\r
+        Point p = toControl(globalX, 0);\r
+        int nameSpace = _timeProvider.getNameSpace();\r
+        int timeSpace = _timeProvider.getTimeSpace();\r
+        int xPos = Math.max(nameSpace, Math.min(nameSpace + timeSpace, p.x));\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        long interval = time1 - time0;\r
+        if (interval == 0) {\r
+            interval = 1;\r
+        } // to allow getting out of single point interval\r
+        long newInterval;\r
+        if (zoomIn) {\r
+            newInterval = Math.max(Math.round((double) interval * 0.8), _timeProvider.getMinTimeInterval());\r
+        } else {\r
+            newInterval = (long) Math.ceil((double) interval * 1.25);\r
+        }\r
+        long center = time0 + Math.round(((double) (xPos - nameSpace) / timeSpace * interval));\r
+        long newTime0 = center - Math.round((double) newInterval * (center - time0) / interval);\r
+        long newTime1 = newTime0 + newInterval;\r
+        _timeProvider.setStartFinishTime(newTime0, newTime1);\r
+    }\r
+\r
+    /**\r
+     * zoom in using single click\r
+     */\r
+    public void zoomIn() {\r
+        long _time0 = _timeProvider.getTime0();\r
+        long _time1 = _timeProvider.getTime1();\r
+        long _range = _time1 - _time0;\r
+        long selTime = _timeProvider.getSelectedTime();\r
+        if (selTime <= _time0 || selTime >= _time1) {\r
+            selTime = (_time0 + _time1) / 2;\r
+        }\r
+        long time0 = selTime - (long) ((selTime - _time0) / zoomCoeff);\r
+        long time1 = selTime + (long) ((_time1 - selTime) / zoomCoeff);\r
+\r
+        long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);\r
+\r
+        // Trace.debug("selTime:" + selTime + " time0:" + time0 + " time1:"\r
+        // + time1 + " inaccuracy:" + inaccuracy);\r
+\r
+        if (inaccuracy > 0 && inaccuracy < 100) {\r
+            _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());\r
+            return;\r
+        }\r
+\r
+        long m = _timeProvider.getMinTimeInterval();\r
+        if ((time1 - time0) < m) {\r
+            time0 = selTime - (long) ((selTime - _time0) * m / _range);\r
+            time1 = time0 + m;\r
+        }\r
+\r
+        _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+    }\r
+\r
+    /**\r
+     * zoom out using single click\r
+     */\r
+    public void zoomOut() {\r
+        long _time0 = _timeProvider.getTime0();\r
+        long _time1 = _timeProvider.getTime1();\r
+        long selTime = _timeProvider.getSelectedTime();\r
+        if (selTime <= _time0 || selTime >= _time1) {\r
+            selTime = (_time0 + _time1) / 2;\r
+        }\r
+        long time0 = (long) (selTime - (selTime - _time0) * zoomCoeff);\r
+        long time1 = (long) (selTime + (_time1 - selTime) * zoomCoeff);\r
+\r
+        long inaccuracy = (_timeProvider.getMaxTime() - _timeProvider.getMinTime()) - (time1 - time0);\r
+        if (inaccuracy > 0 && inaccuracy < 100) {\r
+            _timeProvider.setStartFinishTimeNotify(_timeProvider.getMinTime(), _timeProvider.getMaxTime());\r
+            return;\r
+        }\r
+\r
+        _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+    }\r
+\r
+    public void groupTraces(boolean on) {\r
+        _data.groupTraces(on);\r
+        adjustScrolls();\r
+        redraw();\r
+    }\r
+\r
+    public void toggleTraceInteractionDrawing() {\r
+        drawTracesInteraction = !drawTracesInteraction;\r
+        redraw();\r
+    }\r
+\r
+    public void setTraceJoinDrawing(boolean on) {\r
+        drawTraceJoins = on;\r
+        drawTracesInteraction = true;\r
+        redraw();\r
+    }\r
+\r
+    public void setTraceWaitDrawing(boolean on) {\r
+        drawTraceWaits = on;\r
+        drawTracesInteraction = true;\r
+        redraw();\r
+    }\r
+\r
+    public void setTraceReleaseDrawing(boolean on) {\r
+        drawTraceReleases = on;\r
+        drawTracesInteraction = true;\r
+        redraw();\r
+    }\r
+\r
+    public boolean getTracesInteractionDrawing() {\r
+        return drawTracesInteraction;\r
+    }\r
+\r
+    public boolean getTraceJoinDrawing() {\r
+        return drawTraceJoins;\r
+    }\r
+\r
+    public boolean getTraceWaitDrawing() {\r
+        return drawTraceWaits;\r
+    }\r
+\r
+    public boolean getTraceReleaseDrawing() {\r
+        return drawTraceReleases;\r
+    }\r
+\r
+    public ITmfTimeAnalysisEntry getSelectedTrace() {\r
+        ITmfTimeAnalysisEntry trace = null;\r
+        int idx = getSelectedIndex();\r
+        if (idx >= 0 && _data._items[idx] instanceof TraceItem)\r
+            trace = ((TraceItem) _data._items[idx])._trace;\r
+        return trace;\r
+    }\r
+\r
+    public int getSelectedIndex() {\r
+        int idx = -1;\r
+        for (int i = 0; i < _data._items.length; i++) {\r
+            Item item = (Item) _data._items[i];\r
+            if (item._selected) {\r
+                idx = i;\r
+                break;\r
+            }\r
+        }\r
+        return idx;\r
+    }\r
+\r
+    boolean toggle(int idx) {\r
+        boolean toggled = false;\r
+        if (idx >= 0 && idx < _data._items.length) {\r
+            Item item = (Item) _data._items[idx];\r
+            if (item._hasChildren) {\r
+                item._expanded = !item._expanded;\r
+                _data.updateItems();\r
+                adjustScrolls();\r
+                redraw();\r
+                toggled = true;\r
+            }\r
+        }\r
+        return toggled;\r
+    }\r
+\r
+    int hitTest(int x, int y) {\r
+        if (x < 0 || y < 0)\r
+            return -1;\r
+        int hit = -1;\r
+        int idx = y / _itemHeight;\r
+        idx += _topItem;\r
+        if (idx < _data._items.length)\r
+            hit = idx;\r
+        return hit;\r
+    }\r
+\r
+    int hitSplitTest(int x, int y) {\r
+        if (x < 0 || y < 0 || null == _timeProvider)\r
+            return -1;\r
+        int w = 4;\r
+        int hit = -1;\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+        if (x > nameWidth - w && x < nameWidth + w)\r
+            hit = 1;\r
+        return hit;\r
+    }\r
+\r
+    Item getItem(Point pt) {\r
+        int idx = hitTest(pt.x, pt.y);\r
+        return idx >= 0 ? (Item) _data._items[idx] : null;\r
+    }\r
+\r
+    long hitTimeTest(int x) {\r
+        if (null == _timeProvider)\r
+            return -1;\r
+        long hitTime = -1;\r
+        Point size = getCtrlSize();\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+        x -= nameWidth;\r
+        if (x >= 0 && size.x >= nameWidth) {\r
+            if (time1 - time0 > size.x - nameWidth - RIGHT_MARGIN) {\r
+                // get the last possible time represented by the pixel position\r
+                // by taking the time of the next pixel position minus 1\r
+                // nanosecond\r
+                hitTime = time0 + (long) ((time1 - time0) * ((double) (x + 1) / (size.x - nameWidth - RIGHT_MARGIN))) - 1;\r
+            } else {\r
+                hitTime = time0 + (long) ((time1 - time0) * ((double) (x) / (size.x - nameWidth - RIGHT_MARGIN)));\r
+            }\r
+        }\r
+        return hitTime;\r
+    }\r
+\r
+    void selectItem(int idx, boolean addSelection) {\r
+        boolean changed = false;\r
+        if (addSelection) {\r
+            if (idx >= 0 && idx < _data._items.length) {\r
+                Item item = (Item) _data._items[idx];\r
+                changed = (item._selected == false);\r
+                item._selected = true;\r
+            }\r
+        } else {\r
+            for (int i = 0; i < _data._items.length; i++) {\r
+                Item item = (Item) _data._items[i];\r
+                if (i == idx && item._selected == false) {\r
+                    changed = true;\r
+                }\r
+                item._selected = i == idx;\r
+            }\r
+        }\r
+        changed |= ensureVisibleItem(idx, true);\r
+        if (changed)\r
+            redraw();\r
+    }\r
+\r
+    public void selectItem(ITmfTimeAnalysisEntry trace, boolean addSelection) {\r
+        Integer idx = _data.findTraceItemIndex(trace);\r
+        if (idx != null) {\r
+            selectItem(idx, addSelection);\r
+        }\r
+    }\r
+\r
+    public int countPerPage() {\r
+        int height = getCtrlSize().y;\r
+        int count = 0;\r
+        if (height > 0)\r
+            count = height / _itemHeight;\r
+        return count;\r
+    }\r
+\r
+    public int getTopIndex() {\r
+        int idx = -1;\r
+        if (_data._items.length > 0)\r
+            idx = 0;\r
+        return idx;\r
+    }\r
+\r
+    public int getBottomIndex() {\r
+        int idx = _data._items.length - 1;\r
+        return idx;\r
+    }\r
+\r
+    Point getCtrlSize() {\r
+        Point size = getSize();\r
+        if (getVerticalBar().isVisible()) {\r
+            size.x -= getVerticalBar().getSize().x;\r
+        }\r
+        if (getHorizontalBar().isVisible()) {\r
+            size.y -= getHorizontalBar().getSize().y;\r
+        }\r
+        return size;\r
+    }\r
+\r
+    void getNameRect(Rectangle rect, Rectangle bound, int idx, int nameWidth) {\r
+        idx -= _topItem;\r
+        rect.x = bound.x;\r
+        rect.y = bound.y + idx * _itemHeight;\r
+        rect.width = nameWidth;\r
+        rect.height = _itemHeight;\r
+    }\r
+\r
+    void getStatesRect(Rectangle rect, Rectangle bound, int idx, int nameWidth) {\r
+        idx -= _topItem;\r
+        rect.x = bound.x + nameWidth;\r
+        rect.y = bound.y + idx * _itemHeight;\r
+        rect.width = bound.width - rect.x;\r
+        rect.height = _itemHeight;\r
+    }\r
+\r
+    // private int getTraceNumber(int tid) {\r
+    // int num = -1;\r
+    //\r
+    // Object[] items = _data._items;\r
+    // for (int i = _topItem; i < items.length; i++) {\r
+    // Item item = (Item) items[i];\r
+    // if ((item instanceof TraceItem)) {\r
+    // TsfTmTrace trace = ((TraceItem) item)._trace;\r
+    // if (trace != null && trace.getId() == tid) {\r
+    // num = i;\r
+    // break;\r
+    // }\r
+    // }\r
+    // }\r
+    //\r
+    // return num;\r
+    // }\r
+\r
+    // private void drawArrow(GC gc, int x0, int y0, int x1, int y1, Color c) {\r
+    // gc.setForeground(c);\r
+    // gc.drawLine(x0, y0, x1, y1);\r
+    //\r
+    // if (y1 > y0) {\r
+    // gc.drawLine(x1 - 3, y1 - 3, x1, y1);\r
+    // gc.drawLine(x1 + 3, y1 - 3, x1, y1);\r
+    // } else {\r
+    // gc.drawLine(x1 - 3, y1 + 3, x1, y1);\r
+    // gc.drawLine(x1 + 3, y1 + 3, x1, y1);\r
+    // }\r
+    // }\r
+\r
+    // TODO: CC: used in the removed functionality to draw thread interactions.\r
+    // private void drawTraceThreadEvent(Rectangle bound, TsfTmEvent e,\r
+    // TsfTmTrace trace, int nItem, int color, GC gc) {\r
+    // if (trace == null)\r
+    // return;\r
+    //\r
+    // int tid = trace.getId();\r
+    // if (tid < 0 || getTraceNumber(tid) == -1)\r
+    // return;\r
+    //\r
+    // int nameWidth = _timeProvider.getNameSpace();\r
+    //\r
+    // double time0 = _timeProvider.getTime0();\r
+    // double time1 = _timeProvider.getTime1();\r
+    // if (time0 == time1)\r
+    // return;\r
+    //\r
+    // int xr = bound.x + nameWidth;\r
+    // double K = (double) (bound.width - xr) / (time1 - time0);\r
+    //\r
+    // int x0 = xr + (int) ((e.getTime() - time0) * K);\r
+    // if (x0 < xr)\r
+    // x0 = xr;\r
+    //\r
+    // int x1 = xr + (int) ((trace.getStartTime() - time0) * K);\r
+    // if (x1 < xr)\r
+    // return;\r
+    //\r
+    // int y0 = bound.y + (nItem - _topItem) * _itemHeight + 3\r
+    // + (_itemHeight - 6) / 2;\r
+    // int y1 = bound.y + (getTraceNumber(tid) - _topItem) * _itemHeight + 3\r
+    // + (_itemHeight - 6) / 2;\r
+    //\r
+    // drawArrow(gc, x0, y0, x1, y1, _colors.getColor(color));\r
+    // }\r
+\r
+    public void drawTraceEvent(Rectangle bound, ITimeEvent e, int nItem, int color, GC gc) {\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        if (time0 == time1)\r
+            return;\r
+\r
+        int xr = bound.x + nameWidth;\r
+        double pixelsPerNanoSec = (bound.width - xr <= RIGHT_MARGIN) ? 0 : (double) (bound.width - xr - RIGHT_MARGIN) / (time1 - time0);\r
+\r
+        int x0 = xr + (int) ((e.getTime() - time0) * pixelsPerNanoSec);\r
+        if (x0 < xr)\r
+            return;\r
+\r
+        int y0 = bound.y + (nItem - _topItem) * _itemHeight + 3;\r
+\r
+        gc.setBackground(_colors.getColor(color));\r
+        int c[] = { x0 - 3, y0 - 3, x0, y0, x0 + 3, y0 - 3 };\r
+        gc.fillPolygon(c);\r
+    }\r
+\r
+    // TODO: CC:\r
+    // private void drawExecEvent(Rectangle bound, TsfTmTraceExecEventImpl e,\r
+    // int nitem, int color, GC gc) {\r
+    // List runnings = e.getRunningEvents();\r
+    // if (runnings == null)\r
+    // return;\r
+    //\r
+    // int nameWidth = _timeProvider.getNameSpace();\r
+    //\r
+    // double time0 = _timeProvider.getTime0();\r
+    // double time1 = _timeProvider.getTime1();\r
+    // if (time0 == time1)\r
+    // return;\r
+    //\r
+    // int xr = bound.x + nameWidth;\r
+    // double K = (double) (bound.width - xr) / (time1 - time0);\r
+    //\r
+    // int x0 = xr + (int) ((e.getTime() - time0) * K);\r
+    // if (x0 < xr)\r
+    // x0 = xr;\r
+    //\r
+    // Iterator it = runnings.iterator();\r
+    // while (it.hasNext()) {\r
+    // TsfTmTraceRunningEventImpl re = (TsfTmTraceRunningEventImpl) it\r
+    // .next();\r
+    // int tid = re.getThread().getId();\r
+    // if (tid < 0 || getThreadNumber(tid) == -1)\r
+    // continue;\r
+    //\r
+    // int x1 = xr + (int) ((re.getTime() - time0) * K);\r
+    // if (x1 < xr)\r
+    // continue;\r
+    //\r
+    // int y0 = bound.y + (nitem - _topItem) * _itemHeight + 3\r
+    // + (_itemHeight - 6) / 2;\r
+    // int y1 = bound.y + (getThreadNumber(tid) - _topItem) * _itemHeight\r
+    // + 3 + (_itemHeight - 6) / 2;\r
+    //\r
+    // drawArrow(gc, x0, y0, x1, y1, _colors.getColor(color));\r
+    // }\r
+    // }\r
+\r
+    public void drawTraceInteractions(Rectangle bound, GC gc) {\r
+        // int nameWidth = _timeProvider.getNameSpace();\r
+        // Object[] items = _data._items;\r
+        //\r
+        // double time0 = _timeProvider.getTime0();\r
+        // double time1 = _timeProvider.getTime1();\r
+        //\r
+        // if (time0 == time1)\r
+        // return;\r
+        //\r
+        // int xr = bound.x + nameWidth;\r
+        // double K = (double) (bound.width - xr) / (time1 - time0);\r
+\r
+        // for (int i = 0; i < items.length; i++) {\r
+        // Item item = (Item) items[i];\r
+        // if (!(item instanceof TraceItem))\r
+        // continue;\r
+        //\r
+        // TsfTmTrace trace = ((TraceItem) item)._trace;\r
+        // if (trace == null)\r
+        // continue;\r
+        //\r
+        // List<TsfTmEvent> list = trace.getTraceEvents();\r
+        // Iterator<TsfTmEvent> it = list.iterator();\r
+        // while (it.hasNext()) {\r
+        // TsfTmEvent te = (TsfTmEvent) it.next();\r
+        // TODO: CC: Thread Interactions,\r
+        // This needs to be accessed externally via a specific\r
+        // implementation.\r
+        // if (te instanceof TsfTmTraceStartThreadEventImpl) {\r
+        // TsfTmTrace child = ((TsfTmTraceStartThreadEventImpl) te)\r
+        // .getStartedThread();\r
+        // drawThreadThreadEvent(bound, te, child, i,\r
+        // TraceColorScheme.TI_START_THREAD, gc);\r
+        // } else if (te instanceof TsfTmTraceHandoffLockEventImpl) {\r
+        // if (drawThreadReleases)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_HANDOFF_LOCK, gc);\r
+        // } else if (te instanceof TsfTmTraceNotifyAllEventImpl) {\r
+        // if (drawThreadWaits)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_NOTIFY_ALL, gc);\r
+        // } else if (te instanceof TsfTmTraceNotifyEventImpl) {\r
+        // if (drawThreadWaits)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_NOTIFY, gc);\r
+        // } else if (te instanceof\r
+        // TsfTmTraceDeadAndNotifyJoinedEventImpl) {\r
+        // if (drawThreadJoins)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_NOTIFY_JOINED, gc);\r
+        // } else if (te instanceof TsfTmTraceInterruptThreadEventImpl)\r
+        // {\r
+        // if (drawThreadWaits)\r
+        // drawExecEvent(bound, (TsfTmTraceExecEventImpl) te, i,\r
+        // TraceColorScheme.TI_INTERRUPT, gc);\r
+        // } else if (te instanceof\r
+        // TsfTmTraceWaitTimeoutExceedEventImpl) {\r
+        // drawThreadEvent(bound, te, i,\r
+        // TraceColorScheme.TI_WAIT_EXCEEDED, gc);\r
+        // }\r
+        // }\r
+        // }\r
+    }\r
+\r
+    @Override\r
+    void paint(Rectangle bound, PaintEvent e) {\r
+        GC gc = e.gc;\r
+        gc.setBackground(_colors.getColor(TraceColorScheme.BACKGROUND));\r
+        drawBackground(gc, bound.x, bound.y, bound.width, bound.height);\r
+\r
+        if (bound.width < 2 || bound.height < 2 || null == _timeProvider)\r
+            return;\r
+\r
+        _idealNameWidth = 0;\r
+        int nameWidth = _timeProvider.getNameSpace();\r
+        long time0 = _timeProvider.getTime0();\r
+        long time1 = _timeProvider.getTime1();\r
+        long endTime = _timeProvider.getEndTime();\r
+        long selectedTime = _timeProvider.getSelectedTime();\r
+        // draw trace states\r
+        Object[] items = _data._items;\r
+        for (int i = _topItem; i < items.length; i++) {\r
+            Item item = (Item) items[i];\r
+\r
+            getNameRect(_rect0, bound, i, nameWidth);\r
+            if (_rect0.y >= bound.y + bound.height)\r
+                break;\r
+\r
+            if (item instanceof GroupItem) {\r
+                getStatesRect(_rect1, bound, i, nameWidth);\r
+                _rect0.width += _rect1.width;\r
+                drawName(item, _rect0, gc);\r
+            } else {\r
+                drawName(item, _rect0, gc);\r
+            }\r
+            getStatesRect(_rect0, bound, i, nameWidth);\r
+            drawItemDataDurations(item, _rect0, time0, time1, endTime, selectedTime, gc);\r
+        }\r
+\r
+        if (drawTracesInteraction)\r
+            drawTraceInteractions(bound, e.gc);\r
+\r
+        // draw empty name space background\r
+        if (_itemHeight * items.length < bound.height) {\r
+            gc.setBackground(_colors.getBkColor(false, false, true));\r
+            drawBackground(gc, bound.x, _itemHeight * items.length, nameWidth, bound.height - _itemHeight * items.length);\r
+        }\r
+\r
+        // draw drag line, no line if name space is 0.\r
+        if (DRAG_SPLIT_LINE == _dragState) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.BLACK));\r
+            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);\r
+        } else if (DRAG_NONE == _dragState && _mouseHover && _timeProvider.getNameSpace() > 0) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.RED));\r
+            gc.drawLine(bound.x + nameWidth, bound.y, bound.x + nameWidth, bound.y + bound.height - 1);\r
+        }\r
+    }\r
+\r
+    void drawName(Item item, Rectangle rect, GC gc) {\r
+        // No name to be drawn\r
+        if (_timeProvider.getNameSpace() == 0)\r
+            return;\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        int elemHeight = rect.height / 2;\r
+        int elemWidth = elemHeight;\r
+        String name = item._name;\r
+        if (group) {\r
+            gc.setBackground(_colors.getBkColorGroup(item._selected, _isInFocus));\r
+            gc.fillRectangle(rect);\r
+            if (item._selected && _isInFocus) {\r
+                gc.setForeground(_colors.getBkColor(item._selected, _isInFocus, false));\r
+                gc.drawRectangle(rect.x, rect.y, rect.width - 2, rect.height - 2);\r
+            }\r
+            gc.setForeground(_colors.getBkColor(false, false, false));\r
+            gc.drawLine(rect.x, rect.y + rect.height - 1, rect.width - 1, rect.y + rect.height - 1);\r
+            gc.setForeground(_colors.getFgColorGroup(false, false));\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            Utils.init(_rect1, rect);\r
+            _rect1.x += MARGIN;\r
+            _rect1.y += (rect.height - elemHeight) / 2;\r
+            _rect1.width = elemWidth;\r
+            _rect1.height = elemHeight;\r
+            // Get the icon rectangle in the group items\r
+            gc.fillRectangle(_rect1);\r
+            gc.drawRectangle(_rect1.x, _rect1.y, _rect1.width - 1, _rect1.height - 1);\r
+            int p = _rect1.y + _rect1.height / 2;\r
+            gc.drawLine(_rect1.x + 2, p, _rect1.x + _rect1.width - 3, p);\r
+            if (!item._expanded) {\r
+                p = _rect1.x + _rect1.width / 2;\r
+                gc.drawLine(p, _rect1.y + 2, p, _rect1.y + _rect1.height - 3);\r
+            }\r
+            gc.setForeground(_colors.getFgColorGroup(item._selected, _isInFocus));\r
+            elemWidth += MARGIN;\r
+        } else {\r
+            gc.setBackground(_colors.getBkColor(item._selected, _isInFocus, true));\r
+            gc.setForeground(_colors.getFgColor(item._selected, _isInFocus));\r
+            gc.fillRectangle(rect);\r
+            Utils.init(_rect1, rect);\r
+            _rect1.x += MARGIN;\r
+            // draw icon\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+            Image img = utilImpl.getItemImage(trace);\r
+            if (null != img) {\r
+                _rect1.y += (rect.height - img.getImageData().height) / 2;\r
+                gc.drawImage(img, _rect1.x, _rect1.y);\r
+            }\r
+            elemWidth = SMALL_ICON_SIZE;\r
+            // cut long string with "..."\r
+            Point size = gc.stringExtent(name);\r
+            if (_idealNameWidth < size.x)\r
+                _idealNameWidth = size.x;\r
+            int width = rect.width - MARGIN - MARGIN - elemWidth;\r
+            int cuts = 0;\r
+            while (size.x > width && name.length() > 1) {\r
+                cuts++;\r
+                name = name.substring(0, name.length() - 1);\r
+                size = gc.stringExtent(name + "..."); //$NON-NLS-1$\r
+            }\r
+            if (cuts > 0)\r
+                name += "..."; //$NON-NLS-1$\r
+            elemWidth += MARGIN;\r
+        }\r
+        Utils.init(_rect1, rect);\r
+        int leftMargin = MARGIN + elemWidth;\r
+        _rect1.x += leftMargin;\r
+        _rect1.width -= leftMargin;\r
+        int textWidth = 0;\r
+        // draw text\r
+        if (_rect1.width > 0) {\r
+            _rect1.y += 2;\r
+            textWidth = Utils.drawText(gc, name, _rect1, true) + 8;\r
+            _rect1.y -= 2;\r
+        }\r
+        // draw middle line\r
+        if (_rect1.width > 0 && !group) {\r
+            Utils.init(_rect1, rect);\r
+            _rect1.x += leftMargin + textWidth;\r
+            _rect1.width -= textWidth;\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));\r
+            int midy = _rect1.y + _rect1.height / 2;\r
+            gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
+        }\r
+        // gc.drawLine(_rect1.x + _rect1.width - 1, _rect1.y, _rect1.x +\r
+        // _rect1.width - 1, _rect1.y + _rect1.height);\r
+    }\r
+\r
+    void drawItemData(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
+        if (rect.isEmpty())\r
+            return;\r
+        if (time1 <= time0) {\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            gc.fillRectangle(rect);\r
+            return;\r
+        }\r
+\r
+        Utils.init(_rect1, rect);\r
+        boolean selected = item._selected;\r
+        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        if (group) {\r
+            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
+            // gc.fillRectangle(rect);\r
+        } else if (item instanceof TraceItem) {\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+\r
+            int x0 = rect.x;\r
+            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();\r
+            ITimeEvent lastEvent = null;\r
+            if (iterator.hasNext()) {\r
+                ITimeEvent currEvent = iterator.next();\r
+                ITimeEvent nextEvent = null;\r
+                long currEventTime = currEvent.getTime();\r
+                long nextEventTime = currEventTime;\r
+                x0 = rect.x + (int) ((currEventTime - time0) * pixelsPerNanoSec);\r
+                int xEnd = rect.x + (int) ((time1 - time0) * pixelsPerNanoSec);\r
+                int x1 = -1;\r
+\r
+                // reduce rect\r
+                _rect1.y += 3;\r
+                _rect1.height -= 6;\r
+                fillSpace(rect, gc, selected);\r
+\r
+                // draw event states\r
+                while (x0 <= xEnd && null != currEvent) {\r
+                    boolean stopped = false;// currEvent instanceof\r
+                    // TsfTmTraceDeadEvent;\r
+                    if (iterator.hasNext()) {\r
+                        nextEvent = iterator.next();\r
+                        nextEventTime = nextEvent.getTime();\r
+                    } else if (stopped) {\r
+                        nextEvent = null;\r
+                        nextEventTime = time1;\r
+                    } else {\r
+                        nextEvent = null;\r
+                        nextEventTime = endTime;\r
+                    }\r
+                    x1 = rect.x + (int) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    if (x1 >= rect.x) {\r
+                        _rect1.x = x0 >= rect.x ? x0 : rect.x;\r
+                        _rect1.width = (x1 <= xEnd ? x1 : xEnd) - _rect1.x;\r
+                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
+                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
+                        // + _rect1.y + "," + _rect1.height + ", "\r
+                        // + _rect1.width + "-->"\r
+                        // + ((int) _rect1.x + (int) _rect1.width));\r
+                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
+                    }\r
+                    lastEvent = currEvent;\r
+                    currEvent = nextEvent;\r
+                    currEventTime = nextEventTime;\r
+                    x0 = x1;\r
+                }\r
+            }\r
+\r
+            // fill space after last event\r
+            int xEnd = rect.x + rect.width;\r
+            if (x0 < xEnd) {\r
+                _rect1.x = x0 >= rect.x ? x0 : rect.x;\r
+                _rect1.width = xEnd - _rect1.x;\r
+                gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
+                gc.fillRectangle(_rect1);\r
+                // draw middle line\r
+                gc.setForeground(_colors.getColor(utilImpl.getEventColorVal(lastEvent)));\r
+                int midy = _rect1.y + _rect1.height / 2;\r
+                int lw = gc.getLineWidth();\r
+                gc.setLineWidth(2);\r
+                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
+                gc.setLineWidth(lw);\r
+            }\r
+        }\r
+\r
+        // draw selected time\r
+        int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
+        if (x >= rect.x && x < rect.x + rect.width) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+            if (group)\r
+                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
+            else\r
+                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Represent the event in series of bursts rather than sequence of states\r
+     * \r
+     * @param item\r
+     * @param rect\r
+     *            - The container rectangle to be colored to different states\r
+     * @param time0\r
+     *            - Base time of all events\r
+     * @param time1\r
+     *            - End time of all events\r
+     * @param endTime\r
+     * @param selectedTime\r
+     * @param gc\r
+     */\r
+    void drawItemDataBurst(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
+        if (rect.isEmpty())\r
+            return;\r
+        if (time1 <= time0) {\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            gc.fillRectangle(rect);\r
+            return;\r
+        }\r
+\r
+        // Initialize _rect1 to same values as enclosing rectangle rect\r
+        Utils.init(_rect1, rect);\r
+        boolean selected = item._selected;\r
+        // K pixels per second\r
+        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
+        // Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
+        // + time0 + " time1:" + time1 + " endTime: " + endTime);\r
+\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        if (group) {\r
+            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
+            // gc.fillRectangle(rect);\r
+            // if (Trace.isDEBUG()) {\r
+            // Trace.debug("Group");\r
+            // }\r
+        } else if (item instanceof TraceItem) {\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+\r
+            double x0 = rect.x;\r
+            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator();\r
+            ITimeEvent lastEvent = null;\r
+            // Trace.debug("count is: " + count);\r
+            if (iterator.hasNext()) {\r
+                ITimeEvent currEvent = iterator.next();\r
+                ITimeEvent nextEvent = null;\r
+                long currEventTime = currEvent.getTime();\r
+                long nextEventTime = currEventTime;\r
+                // x0 - Points to the beginning of the event being drawn\r
+                double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
+                x0 = rect.x + step;\r
+                // xEnd - Points to the end of the events rectangle\r
+                double xEnd = rect.x + (double) ((time1 - time0) * pixelsPerNanoSec);\r
+                double x1 = -1;\r
+                //double xNext = 0;\r
+\r
+                // Drawing rectangle is smaller than reserved space\r
+                _rect1.y += 3;\r
+                _rect1.height -= 6;\r
+\r
+                // Clean up to empty line to draw on top\r
+                fillSpace(rect, gc, selected);\r
+                // draw event states\r
+                while (x0 <= xEnd && null != currEvent) {\r
+                    boolean stopped = false;// currEvent instanceof\r
+                    // TsfTmTraceDeadEvent;\r
+                    if (iterator.hasNext()) {\r
+                        nextEvent = iterator.next();\r
+                        nextEventTime = nextEvent.getTime();\r
+                    } else if (stopped) {\r
+                        nextEvent = null;\r
+                        nextEventTime = time1;\r
+                    } else {\r
+                        nextEvent = null;\r
+                        nextEventTime = endTime;\r
+                        // Trace\r
+                        // .debug("nexEventTime is endTime: "\r
+                        // + nextEventTime);\r
+                    }\r
+\r
+                    // Draw it as a burst, one unit of width.\r
+                    x1 = x0 + (int) 2;\r
+                    if (x1 >= rect.x && x0 <= xEnd) {\r
+                        // Fill with space until x0\r
+                        _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
+                        _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - _rect1.x);\r
+                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
+                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
+                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
+                        // + _rect1.y + "," + _rect1.height + ", "\r
+                        // + _rect1.width + "-->"\r
+                        // + ((int) _rect1.x + (int) _rect1.width));\r
+                        // Advance rectangle to next start position and Fill\r
+                        // with space until next event\r
+                        _rect1.x += _rect1.width;\r
+                        x0 = x1;\r
+                        //xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    }\r
+                    // Fill space till next event\r
+                    fillSpace(rect, gc, selected);\r
+\r
+                    lastEvent = currEvent;\r
+                    currEvent = nextEvent;\r
+                    currEventTime = nextEventTime;\r
+                    // Move x0 to the beginning of next event\r
+                    x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    // Trace.debug("rect.x: " + rect.x + " + " +\r
+                    // "(nextEvenTime: "\r
+                    // + nextEventTime + "- time0: " + time0 + ") * K: "\r
+                    // + K + " = " + x0);\r
+                }\r
+            }\r
+\r
+            // fill space after last event\r
+            int xEnd = rect.x + rect.width;\r
+            if (x0 < xEnd) {\r
+                // Trace.debug("Space after last event, x0: " + x0 + ", xEnd: "\r
+                // + xEnd);\r
+                _rect1.x = (int) (x0 >= rect.x ? x0 : rect.x);\r
+                _rect1.width = xEnd - _rect1.x;\r
+                gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
+                gc.fillRectangle(_rect1);\r
+                // draw middle line\r
+                gc.setForeground(_colors.getColor(utilImpl.getEventColorVal(lastEvent)));\r
+                int midy = _rect1.y + _rect1.height / 2;\r
+                int lw = gc.getLineWidth();\r
+                gc.setLineWidth(2);\r
+                gc.drawLine(_rect1.x, midy, _rect1.x + _rect1.width, midy);\r
+                gc.setLineWidth(lw);\r
+            }\r
+        }\r
+\r
+        // draw selected time\r
+        int x = rect.x + (int) ((selectedTime - time0) * pixelsPerNanoSec);\r
+        if (x >= rect.x && x < rect.x + rect.width) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+            if (group)\r
+                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
+            else\r
+                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Represent the series of events with specified durations\r
+     * \r
+     * @param item\r
+     * @param rect\r
+     *            - The container rectangle to be colored to different states\r
+     * @param time0\r
+     *            - Base time of all events - start of visible window\r
+     * @param time1\r
+     *            - End time of visible events - end time of visible window\r
+     * @param endTime\r
+     *            - End time of all events - may not be visible in selected\r
+     *            visible window\r
+     * @param selectedTime\r
+     * @param gc\r
+     */\r
+    void drawItemDataDurations(Item item, Rectangle rect, long time0, long time1, long endTime, long selectedTime, GC gc) {\r
+        if (rect.isEmpty())\r
+            return;\r
+        if (time1 <= time0) {\r
+            gc.setBackground(_colors.getBkColor(false, false, false));\r
+            gc.fillRectangle(rect);\r
+            return;\r
+        }\r
+\r
+        // Initialize _rect1 to same values as enclosing rectangle rect\r
+        Utils.init(_rect1, rect);\r
+        boolean selected = item._selected;\r
+        // K pixels per second\r
+        double pixelsPerNanoSec = (rect.width <= RIGHT_MARGIN) ? 0 : (double) (rect.width - RIGHT_MARGIN) / (time1 - time0);\r
+        // Trace.debug("Value of K: " + K + " width:" + rect.width + " time0: "\r
+        // + time0 + " time1:" + time1 + " endTime: " + endTime);\r
+\r
+        boolean group = item instanceof GroupItem;\r
+\r
+        if (group) {\r
+            // gc.setBackground(_colors.getBkColorGroup(selected, _isInFocus));\r
+            // gc.fillRectangle(rect);\r
+        } else if (item instanceof TraceItem) {\r
+            ITmfTimeAnalysisEntry trace = ((TraceItem) item)._trace;\r
+\r
+            double x0 = rect.x;\r
+            long maxDuration = (_timeProvider.getTimeSpace() == 0) ? Long.MAX_VALUE : 1 * (_timeProvider.getTime1() - _timeProvider.getTime0()) / _timeProvider.getTimeSpace();\r
+            Iterator<ITimeEvent> iterator = trace.getTraceEventsIterator(_timeProvider.getTime0(), _timeProvider.getTime1(), maxDuration);\r
+            // ITimeEvent lastEvent = null;\r
+            // if (Trace.isDEBUG()) {\r
+            // Trace.debug("\n\t\t\tTrace: " + trace.getName()\r
+            // + utilImpl.getTraceClassName(trace));\r
+            // }\r
+            // Trace.debug("count is: " + count);\r
+            // Drawing rectangle is smaller than reserved space\r
+            _rect1.y += 3;\r
+            _rect1.height -= 6;\r
+\r
+            // Clean up to empty line to draw on top\r
+            int xEnd = rect.x + rect.width;\r
+            fillSpace(rect, gc, selected);\r
+            if (iterator.hasNext()) {\r
+                ITimeEvent currEvent = iterator.next();\r
+                ITimeEvent nextEvent = null;\r
+                long currEventTime = currEvent.getTime();\r
+                long currEventDuration = currEvent.getDuration();\r
+                // initial value\r
+                long nextEventTime = currEventTime;\r
+                // x0 - Points to the beginning of the event being drawn\r
+                double step = (double) ((currEventTime - time0) * pixelsPerNanoSec);\r
+                x0 = rect.x + step;\r
+                // xEnd - Points to the end of the events rectangle\r
+                double x1 = -1;\r
+                double xNext = 0;\r
+\r
+                // draw event states\r
+                while (/* x0 <= xEnd && */null != currEvent) {\r
+                    boolean stopped = false;// currEvent instanceof\r
+                    // refresh current event duration as the loop moves\r
+                    currEventDuration = currEvent.getDuration();\r
+                    // TsfTmTraceDeadEvent;\r
+                    if (iterator.hasNext()) {\r
+                        nextEvent = iterator.next();\r
+                        nextEventTime = nextEvent.getTime();\r
+                    } else if (stopped) {\r
+                        nextEvent = null;\r
+                        nextEventTime = time1;\r
+                    } else {\r
+                        nextEvent = null;\r
+                        nextEventTime = endTime;\r
+                        // Trace\r
+                        // .debug("nexEventTime is endTime: "\r
+                        // + nextEventTime);\r
+                    }\r
+\r
+                    // Calculate position to next event\r
+                    xNext = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+\r
+                    // Calculate end position of current event\r
+                    if (currEventDuration < 0) {\r
+                        x1 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    } else if (currEventDuration == 0) {\r
+                        x1 = x0;\r
+                    } else {\r
+                        x1 = x0 + (double) ((currEventDuration) * pixelsPerNanoSec);\r
+                    }\r
+\r
+                    // If event end position x1 further away than start position\r
+                    // of\r
+                    // next event, cut width till next event\r
+                    // Trace.debug("Next Event Pos: " + xNext\r
+                    // + " End Of Current at: " + x1 + " Event Duration: "\r
+                    // + currEventDuration);\r
+                    if (currEventDuration != 0) {\r
+                        x1 = x1 > xNext ? xNext : x1;\r
+                    }\r
+                    // if event end boundary is within time range\r
+                    if (x1 >= rect.x && x0 <= xEnd) {\r
+                        if (currEventDuration != 0) {\r
+                            x0 = (double) (x0 >= rect.x ? x0 : rect.x);\r
+                            _rect1.width = (int) ((x1 <= xEnd ? x1 : xEnd) - x0);\r
+                        } else {\r
+                            _rect1.width = 1;\r
+                        }\r
+                        _rect1.width = Math.max(_minimumItemWidth, _rect1.width);\r
+                        _rect1.x = (int) x0;\r
+                        boolean timeSelected = currEventTime <= selectedTime && selectedTime < nextEventTime;\r
+                        utilImpl.drawState(_colors, currEvent, _rect1, gc, selected, false, timeSelected);\r
+                        // Trace.debug("Drawing rectangle: " + _rect1.x + ","\r
+                        // + _rect1.y + "," + _rect1.height + ", "\r
+                        // + _rect1.width + "-->"\r
+                        // + ((int) _rect1.x + (int) _rect1.width));\r
+                        // Advance rectangle to next start position and Fill\r
+                        // with space until next event\r
+                        _rect1.x += _rect1.width;\r
+                        x0 = _rect1.x;\r
+                    }\r
+\r
+                    // Fill space till next event\r
+                    // fillSpace(rect, gc, selected, x0, xNext, xEnd);\r
+\r
+                    // lastEvent = currEvent;\r
+                    currEvent = nextEvent;\r
+                    currEventTime = nextEventTime;\r
+                    // Move x0 to the beginning of next event\r
+                    x0 = rect.x + (double) ((nextEventTime - time0) * pixelsPerNanoSec);\r
+                    // Trace.debug("rect.x: " + rect.x + " + " +\r
+                    // "(nextEvenTime: "\r
+                    // + nextEventTime + "- time0: " + time0 + ") * K: "\r
+                    // + K + " = " + x0);\r
+                }\r
+            }\r
+        }\r
+\r
+        // draw selected time\r
+        int x = rect.x + (int) ((double) (selectedTime - time0) * pixelsPerNanoSec);\r
+        if (x >= rect.x && x < rect.x + rect.width) {\r
+            gc.setForeground(_colors.getColor(TraceColorScheme.SELECTED_TIME));\r
+            if (group)\r
+                gc.drawLine(x, rect.y + rect.height - 1, x, rect.y + rect.height);\r
+            else\r
+                gc.drawLine(x, rect.y, x, rect.y + rect.height);\r
+        }\r
+    }\r
+\r
+    private void fillSpace(Rectangle rect, GC gc, boolean selected) {\r
+        gc.setBackground(_colors.getBkColor(selected, _isInFocus, false));\r
+        gc.fillRectangle(rect);\r
+        // draw middle line\r
+        gc.setForeground(_colors.getColor(TraceColorScheme.MID_LINE));\r
+        int midy = rect.y + rect.height / 2;\r
+        gc.drawLine(rect.x, midy, rect.x + rect.width, midy);\r
+    }\r
+\r
+    @Override\r
+    public void keyTraversed(TraverseEvent e) {\r
+        if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))\r
+            e.doit = true;\r
+    }\r
+\r
+    @Override\r
+    public void keyPressed(KeyEvent e) {\r
+        int idx = -1;\r
+        if (SWT.HOME == e.keyCode) {\r
+            idx = getTopIndex();\r
+        } else if (SWT.END == e.keyCode) {\r
+            idx = getBottomIndex();\r
+        } else if (SWT.ARROW_DOWN == e.keyCode) {\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            else if (idx < _data._items.length - 1)\r
+                idx++;\r
+        } else if (SWT.ARROW_UP == e.keyCode) {\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            else if (idx > 0)\r
+                idx--;\r
+        } else if (SWT.ARROW_LEFT == e.keyCode) {\r
+            selectPrevEvent();\r
+        } else if (SWT.ARROW_RIGHT == e.keyCode) {\r
+            selectNextEvent();\r
+        } else if (SWT.PAGE_DOWN == e.keyCode) {\r
+            int page = countPerPage();\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            idx += page;\r
+            if (idx >= _data._items.length)\r
+                idx = _data._items.length - 1;\r
+        } else if (SWT.PAGE_UP == e.keyCode) {\r
+            int page = countPerPage();\r
+            idx = getSelectedIndex();\r
+            if (idx < 0)\r
+                idx = 0;\r
+            idx -= page;\r
+            if (idx < 0)\r
+                idx = 0;\r
+        } else if (SWT.CR == e.keyCode) {\r
+            idx = getSelectedIndex();\r
+            if (idx >= 0) {\r
+                if (_data._items[idx] instanceof TraceItem)\r
+                    fireDefaultSelection();\r
+                else if (_data._items[idx] instanceof GroupItem)\r
+                    toggle(idx);\r
+            }\r
+            idx = -1;\r
+        }\r
+        if (idx >= 0) {\r
+            selectItem(idx, false);\r
+            fireSelectionChanged();\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void keyReleased(KeyEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void focusGained(FocusEvent e) {\r
+        _isInFocus = true;\r
+        redraw();\r
+    }\r
+\r
+    @Override\r
+    public void focusLost(FocusEvent e) {\r
+        _isInFocus = false;\r
+        if (DRAG_NONE != _dragState) {\r
+            setCapture(false);\r
+            _dragState = DRAG_NONE;\r
+        }\r
+        redraw();\r
+    }\r
+\r
+    public boolean isInFocus() {\r
+        return _isInFocus;\r
+    }\r
+\r
+    @Override\r
+    public void mouseMove(MouseEvent e) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        Point size = getCtrlSize();\r
+        if (DRAG_TRACE_ITEM == _dragState) {\r
+            int nameWidth = _timeProvider.getNameSpace();\r
+            int x = e.x - nameWidth;\r
+            if (x > 0 && size.x > nameWidth && _dragX != x) {\r
+                _dragX = x;\r
+                double pixelsPerNanoSec = (size.x - nameWidth <= RIGHT_MARGIN) ? 0 : (double) (size.x - nameWidth - RIGHT_MARGIN) / (_time1bak - _time0bak);\r
+                long timeDelta = (long) ((pixelsPerNanoSec == 0) ? 0 : ((_dragX - _dragX0) / pixelsPerNanoSec));\r
+                long time1 = _time1bak - timeDelta;\r
+                long maxTime = _timeProvider.getMaxTime();\r
+                if (time1 > maxTime)\r
+                    time1 = maxTime;\r
+                long time0 = time1 - (_time1bak - _time0bak);\r
+                if (time0 < _timeProvider.getMinTime()) {\r
+                    time0 = _timeProvider.getMinTime();\r
+                    time1 = time0 + (_time1bak - _time0bak);\r
+                }\r
+                _timeProvider.setStartFinishTime(time0, time1);\r
+            }\r
+        } else if (DRAG_SPLIT_LINE == _dragState) {\r
+            _dragX = e.x;\r
+            _timeProvider.setNameSpace(_hitIdx + _dragX - _dragX0);\r
+        } else if (DRAG_NONE == _dragState) {\r
+            boolean mouseHover = hitSplitTest(e.x, e.y) > 0;\r
+            if (_mouseHover != mouseHover)\r
+                redraw();\r
+            _mouseHover = mouseHover;\r
+            // Make sure any time changes are notified to the application e.g.\r
+            // getting back from the horizontal scroll bar or zoomed using the\r
+            // mouse wheel\r
+            _timeProvider.notifyStartFinishTime();\r
+        }\r
+        updateCursor(e.x, e.y);\r
+    }\r
+\r
+    @Override\r
+    public void mouseDoubleClick(MouseEvent e) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        if (1 == e.button) {\r
+            int idx = hitSplitTest(e.x, e.y);\r
+            if (idx >= 0) {\r
+                _timeProvider.setNameSpace(_idealNameWidth + 3 * MARGIN + SMALL_ICON_SIZE);\r
+                return;\r
+            }\r
+            idx = hitTest(e.x, e.y);\r
+            if (idx >= 0) {\r
+                selectItem(idx, false);\r
+                if (_data._items[idx] instanceof TraceItem) {\r
+                    fireDefaultSelection();\r
+                }\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * <p>\r
+     * If the x, y position is over the vertical split line (name to time\r
+     * ranges), then change the cursor to a drag cursor to indicate the user the\r
+     * possibility of resizing\r
+     * </p>\r
+     * \r
+     * @param x\r
+     * @param y\r
+     */\r
+    void updateCursor(int x, int y) {\r
+        // if Wait cursor not active, check for the need to change to a drag\r
+        // cursor\r
+        if (_isWaitCursor == false) {\r
+            int idx = hitSplitTest(x, y);\r
+            // No dragcursor is name space is fixed to zero\r
+            if (idx > 0 && !_isDragCursor3 && _timeProvider.getNameSpace() > 0) {\r
+                setCursor(_dragCursor3);\r
+                _isDragCursor3 = true;\r
+            } else if (idx <= 0 && _isDragCursor3) {\r
+                setCursor(null);\r
+                _isDragCursor3 = false;\r
+            }\r
+        }\r
+    }\r
+\r
+    /**\r
+     * Provide the possibilty to control the wait cursor externally e.g. data\r
+     * requests in progress\r
+     * \r
+     * @param waitInd\r
+     */\r
+    public void waitCursor(boolean waitInd) {\r
+        // Update cursor as indicated\r
+        if (waitInd) {\r
+            setCursor(_WaitCursor);\r
+            _isWaitCursor = true;\r
+        } else {\r
+            setCursor(null);\r
+            _isWaitCursor = false;\r
+        }\r
+\r
+        // Get ready for next mouse move\r
+        _isDragCursor3 = false;\r
+    }\r
+\r
+    @Override\r
+    public void mouseDown(MouseEvent e) {\r
+        if (null == _timeProvider)\r
+            return;\r
+        int idx;\r
+        if (1 == e.button) {\r
+            int namewidth = _timeProvider.getNameSpace();\r
+            if (namewidth != 0) {\r
+                idx = hitSplitTest(e.x, e.y);\r
+                if (idx > 0) {\r
+                    _dragState = DRAG_SPLIT_LINE;\r
+                    _dragX = _dragX0 = e.x;\r
+                    _hitIdx = _timeProvider.getNameSpace();\r
+                    ;\r
+                    _time0bak = _timeProvider.getTime0();\r
+                    _time1bak = _timeProvider.getTime1();\r
+                    redraw();\r
+                    return;\r
+                }\r
+            }\r
+\r
+            idx = hitTest(e.x, e.y);\r
+            if (idx >= 0) {\r
+                if (_data._items[idx] instanceof TraceItem) {\r
+                    long hitTime = hitTimeTest(e.x);\r
+                    if (hitTime >= 0) {\r
+                        // _timeProvider.setSelectedTimeInt(hitTime, false);\r
+                        setCapture(true);\r
+                        _dragState = DRAG_TRACE_ITEM;\r
+                        _dragX = _dragX0 = e.x - _timeProvider.getNameSpace();\r
+                        _hitIdx = idx;\r
+                        _time0bak = _timeProvider.getTime0();\r
+                        _time1bak = _timeProvider.getTime1();\r
+                        return;\r
+                    }\r
+                } else if (_data._items[idx] instanceof GroupItem) {\r
+                    _dragX0 = e.x;\r
+                    _dragState = DRAG_GROUP_ITEM;\r
+                }\r
+                selectItem(idx, false);\r
+                fireSelectionChanged();\r
+            } else {\r
+                selectItem(idx, false); // clear selection\r
+                redraw();\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseUp(MouseEvent e) {\r
+        if (DRAG_NONE != _dragState) {\r
+            setCapture(false);\r
+            if (DRAG_TRACE_ITEM == _dragState) {\r
+                // Notify time provider to check the need for listener\r
+                // notification\r
+                _timeProvider.notifyStartFinishTime();\r
+                if (_dragX == _dragX0) { // click without drag\r
+                    long time = hitTimeTest(e.x);\r
+                    _timeProvider.setSelectedTimeInt(time, false);\r
+                    selectItem(_hitIdx, false);\r
+                    fireSelectionChanged();\r
+                }\r
+            } else if (DRAG_GROUP_ITEM == _dragState) {\r
+                if (e.x == _dragX0) // click without drag\r
+                    toggle(_hitIdx);\r
+            } else if (DRAG_SPLIT_LINE == _dragState) {\r
+                redraw();\r
+            }\r
+            _dragState = DRAG_NONE;\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void controlMoved(ControlEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void controlResized(ControlEvent e) {\r
+        adjustScrolls();\r
+    }\r
+\r
+    @Override\r
+    public void widgetDefaultSelected(SelectionEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void widgetSelected(SelectionEvent e) {\r
+        if (e.widget == getVerticalBar()) {\r
+            _topItem = getVerticalBar().getSelection();\r
+            if (_topItem < 0)\r
+                _topItem = 0;\r
+            redraw();\r
+        } else if (e.widget == getHorizontalBar() && null != _timeProvider) {\r
+            int start = getHorizontalBar().getSelection();\r
+            long time0 = _timeProvider.getTime0();\r
+            long time1 = _timeProvider.getTime1();\r
+            long timeMin = _timeProvider.getMinTime();\r
+            long timeMax = _timeProvider.getMaxTime();\r
+            long delta = timeMax - timeMin;\r
+\r
+            long range = time1 - time0;\r
+            // _timeRangeFixed = true;\r
+            time0 = timeMin + (long) (delta * ((double) start / H_SCROLLBAR_MAX));\r
+            time1 = time0 + range;\r
+\r
+            // TODO: Follow-up with Bug 310310\r
+            // In Linux SWT.DRAG is the only value received\r
+            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=310310\r
+            if (e.detail == SWT.DRAG) {\r
+                _timeProvider.setStartFinishTime(time0, time1);\r
+            } else {\r
+                _timeProvider.setStartFinishTimeNotify(time0, time1);\r
+            }\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseEnter(MouseEvent e) {\r
+        if (mouseScrollFilterListener == null) {\r
+            mouseScrollFilterListener = new Listener() {\r
+                // This filter is used to prevent scrolling of the view when the\r
+                // mouse wheel is used to zoom\r
+                @Override\r
+                public void handleEvent(Event event) {\r
+                    event.doit = false;\r
+                }\r
+            };\r
+            getDisplay().addFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseExit(MouseEvent e) {\r
+        if (mouseScrollFilterListener != null) {\r
+            getDisplay().removeFilter(SWT.MouseWheel, mouseScrollFilterListener);\r
+            mouseScrollFilterListener = null;\r
+        }\r
+        if (_mouseHover) {\r
+            _mouseHover = false;\r
+            redraw();\r
+        }\r
+    }\r
+\r
+    @Override\r
+    public void mouseHover(MouseEvent e) {\r
+    }\r
+\r
+    @Override\r
+    public void mouseScrolled(MouseEvent e) {\r
+        if ((mouseScrollFilterListener == null) || _dragState != DRAG_NONE)\r
+            return;\r
+        if (e.count > 0) {\r
+            zoom(true);\r
+        } else if (e.count < 0) {\r
+            zoom(false);\r
+        }\r
+    }\r
+\r
+    public boolean isVisibleVerticalScroll() {\r
+        return _visibleVerticalScroll;\r
+    }\r
+\r
+    public void setVisibleVerticalScroll(boolean visibleVerticalScroll) {\r
+        ScrollBar scrollVer = getVerticalBar();\r
+        if (scrollVer != null) {\r
+            scrollVer.setVisible(visibleVerticalScroll);\r
+        }\r
+        this._visibleVerticalScroll = visibleVerticalScroll;\r
+    }\r
+\r
+    @Override\r
+    public int getBorderWidth() {\r
+        return _borderWidth;\r
+    }\r
+\r
+    public void setBorderWidth(int borderWidth) {\r
+        this._borderWidth = borderWidth;\r
+    }\r
+\r
+    public int getHeaderHeight() {\r
+        return _headerHeight;\r
+    }\r
+\r
+    public void setHeaderHeight(int headerHeight) {\r
+        this._headerHeight = headerHeight;\r
+    }\r
+\r
+    public int getItemHeight() {\r
+        return _itemHeight;\r
+    }\r
+\r
+    public void setItemHeight(int rowHeight) {\r
+        this._itemHeight = rowHeight;\r
+    }\r
+\r
+    public void setMinimumItemWidth(int width) {\r
+        this._minimumItemWidth = width;\r
+    }\r
+\r
+    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
+        return _data.getFilteredOut();\r
+    }\r
+\r
+    // @Override\r
+    @Override\r
+    public void addSelectionChangedListener(ISelectionChangedListener listener) {\r
+        if (listener != null) {\r
+            if (!_selectionChangedListeners.contains(listener)) {\r
+                _selectionChangedListeners.add(listener);\r
+            }\r
+        }\r
+    }\r
+\r
+    // @Override\r
+    @Override\r
+    public void removeSelectionChangedListener(ISelectionChangedListener listener) {\r
+        if (listener != null) {\r
+            _selectionChangedListeners.remove(listener);\r
+        }\r
+    }\r
+\r
+    // @Override\r
+    @Override\r
+    public void setSelection(ISelection selection) {\r
+        if (selection instanceof PlainSelection) {\r
+            PlainSelection sel = (PlainSelection) selection;\r
+            Object ob = sel.getFirstElement();\r
+            if (ob instanceof ITmfTimeAnalysisEntry) {\r
+                ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) ob;\r
+                selectItem(trace, false);\r
+            }\r
+        }\r
+\r
+    }\r
+}\r
+\r
+class Item {\r
+    public boolean _expanded;\r
+    public boolean _selected;\r
+    public boolean _hasChildren;\r
+    public String _name;\r
+\r
+    Item(String name) {\r
+        _name = name;\r
+    }\r
+\r
+    @Override\r
+    public String toString() {\r
+        return _name;\r
+    }\r
+}\r
+\r
+class TraceItem extends Item {\r
+    public ITmfTimeAnalysisEntry _trace;\r
+\r
+    TraceItem(ITmfTimeAnalysisEntry trace, String name) {\r
+        super(name);\r
+        _trace = trace;\r
+    }\r
+}\r
+\r
+class GroupItem extends Item {\r
+    public List<ITmfTimeAnalysisEntry> _traces;\r
+\r
+    GroupItem(String name) {\r
+        super(name);\r
+        _traces = new ArrayList<ITmfTimeAnalysisEntry>();\r
+        _hasChildren = true;\r
+    }\r
+\r
+    void add(ITmfTimeAnalysisEntry trace) {\r
+        _traces.add(trace);\r
+    }\r
+}\r
+\r
+class ItemData {\r
+    public Object[] _items = new Object[0];\r
+    private Object _traces[] = new Object[0];\r
+    private boolean traceFilter[] = new boolean[0];\r
+    private Map<String, GroupItem> _groupTable = new HashMap<String, GroupItem>();\r
+    private boolean _flatList = false;\r
+    private TmfTimeAnalysisProvider utilsImp;\r
+    private Vector<ITmfTimeAnalysisEntry> filteredOut = new Vector<ITmfTimeAnalysisEntry>();\r
+\r
+    public ItemData(TmfTimeAnalysisProvider utils) {\r
+        this.utilsImp = utils;\r
+    }\r
+\r
+    protected void groupTraces(boolean on) {\r
+        if (_flatList == on) {\r
+            _flatList = !on;\r
+            updateItems();\r
+        }\r
+    }\r
+\r
+    void clearGroups() {\r
+        Iterator<GroupItem> it = _groupTable.values().iterator();\r
+        while (it.hasNext()) {\r
+            GroupItem group = it.next();\r
+            group._traces.clear();\r
+        }\r
+    }\r
+\r
+    void deleteEmptyGroups() {\r
+        Iterator<GroupItem> it = _groupTable.values().iterator();\r
+        while (it.hasNext()) {\r
+            GroupItem group = it.next();\r
+            if (group._traces.size() == 0)\r
+                it.remove();\r
+        }\r
+    }\r
+\r
+    TraceItem findTraceItem(ITmfTimeAnalysisEntry trace) {\r
+        if (trace == null)\r
+            return null;\r
+\r
+        int traceId = trace.getId();\r
+        TraceItem traceItem = null;\r
+\r
+        for (int i = 0; i < _items.length; i++) {\r
+            Object item = _items[i];\r
+            if (item instanceof TraceItem) {\r
+                TraceItem ti = (TraceItem) item;\r
+                if (ti._trace.getId() == traceId) {\r
+                    traceItem = ti;\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+\r
+        return traceItem;\r
+    }\r
+\r
+    Integer findTraceItemIndex(ITmfTimeAnalysisEntry trace) {\r
+        if (trace == null)\r
+            return null;\r
+\r
+        for (int i = 0; i < _items.length; i++) {\r
+            Object item = _items[i];\r
+            if (item instanceof TraceItem) {\r
+                TraceItem ti = (TraceItem) item;\r
+                if (ti._trace == trace) {\r
+                    return i;\r
+                }\r
+            }\r
+        }\r
+\r
+        return null;\r
+    }\r
+\r
+    public void updateItems() {\r
+        List<Item> itemList = new ArrayList<Item>();\r
+        String name = ""; //$NON-NLS-1$\r
+\r
+        Iterator<GroupItem> it = _groupTable.values().iterator();\r
+        while (it.hasNext()) {\r
+            GroupItem group = it.next();\r
+            if (!_flatList)\r
+                itemList.add(group);\r
+\r
+            if (_flatList || group._expanded) {\r
+                Iterator<ITmfTimeAnalysisEntry> it2 = group._traces.iterator();\r
+                while (it2.hasNext()) {\r
+                    ITmfTimeAnalysisEntry trace = it2.next();\r
+                    TraceItem traceItem = findTraceItem(trace);\r
+                    name = utilsImp.composeTraceName(trace, false);\r
+                    traceItem = new TraceItem(trace, name);\r
+                    itemList.add(traceItem);\r
+                }\r
+            }\r
+        }\r
+        _items = itemList.toArray();\r
+    }\r
+\r
+    public int expandItem(int idx, boolean expand) {\r
+        if (idx < 0 || idx >= _items.length)\r
+            return 0;\r
+        int ret = 0;\r
+        Item item = (Item) _items[idx];\r
+        if (item._hasChildren && !item._expanded) {\r
+            item._expanded = expand;\r
+            ret = _items.length;\r
+            updateItems();\r
+            ret = _items.length - ret;\r
+        }\r
+        return ret;\r
+    }\r
+\r
+    public void refreshData(Object traces[]) {\r
+        if (traces == null || traces.length == 0) {\r
+            traceFilter = null;\r
+        } else if (traceFilter == null || traces.length != traceFilter.length) {\r
+            traceFilter = new boolean[traces.length];\r
+            java.util.Arrays.fill(traceFilter, true);\r
+        }\r
+\r
+        _traces = traces;\r
+        refreshData();\r
+    }\r
+\r
+    /**\r
+     * Allows to update the GUI from a stream of events handling addition one by\r
+     * one over known TmfTaTrace parents.\r
+     * \r
+     * @param parent\r
+     * @param childItem\r
+     */\r
+    public void refreshPartial(ITmfTimeAnalysisEntry parent, TimeEvent childItem) {\r
+        // Find the Trace item within the current list\r
+//        TraceItem item = findTraceItem(parent);\r
+\r
+        // This method is not used (yet) so this code can be commented out for\r
+        // now\r
+        // FIXME: Arrays.copyOf is a Java6 feature\r
+        // if (item == null) {\r
+        // // If the parent item is not found, make room for it in the current\r
+        // // array\r
+        // int length = 1;\r
+        // Object[] traces;\r
+        // if (_traces != null) {\r
+        // length = _traces.length + 1;\r
+        // traces = Arrays.copyOf(_traces, length);\r
+        // } else {\r
+        // traces = new Object[length];\r
+        // }\r
+        //\r
+        // // Add the new parent element to the end of the array.\r
+        // traces[length - 1] = parent;\r
+        //\r
+        // // update the filter array to accomodate a postion to the new\r
+        // // element\r
+        // traceFilter = new boolean[traces.length];\r
+        // java.util.Arrays.fill(traceFilter, true);\r
+        //\r
+        // // rebuild internal data\r
+        // _traces = traces;\r
+        // refreshData();\r
+        //\r
+        // // item must be there\r
+        // item = findTraceItem(parent);\r
+        // }\r
+\r
+        /*\r
+         * Check if this is still needed!\r
+        ITmfTimeAnalysisEntry localTraceItem = item._trace;\r
+        // Local trace found\r
+        Vector<TimeEvent> children = localTraceItem.getTraceEvents();\r
+        TimeEvent lastChildIn = children.lastElement();\r
+        long lastChildSTime = lastChildIn.getTime();\r
+        long newChildSTime = childItem.getTime();\r
+        if (newChildSTime < lastChildSTime) {\r
+            // The children are expected to arrive sorted by time\r
+            // since the new time is earlier than the last child\r
+            // The infomation is being refreshed from start, remove all\r
+            // children and start over\r
+            children.clear();\r
+        }\r
+        // Add the new item\r
+        children.add(childItem);\r
+        */\r
+\r
+    }\r
+\r
+    public void refreshData() {\r
+        clearGroups();\r
+        filteredOut.clear();\r
+        String undef = Messages.TmfTimeStatesCtrl_UNDEFINED_GROUP;\r
+        List<GroupItem> groupList = new ArrayList<GroupItem>();\r
+        for (int i = 0; i < _traces.length; i++) {\r
+            ITmfTimeAnalysisEntry trace = (ITmfTimeAnalysisEntry) _traces[i];\r
+            if (!traceFilter[i]) {\r
+                filteredOut.add(trace);\r
+                continue;\r
+            }\r
+\r
+            String groupName = trace.getGroupName();\r
+            if (null == groupName)\r
+                groupName = undef;\r
+\r
+            GroupItem group = _groupTable.get(groupName);\r
+            if (null == group) {\r
+                group = new GroupItem(NLS.bind(Messages.TmfTimeStatesCtrl_TRACE_GROUP_LABEL, groupName));\r
+                group._expanded = !groupName.equalsIgnoreCase("system") && !groupName.equalsIgnoreCase(undef); //$NON-NLS-1$\r
+                _groupTable.put(groupName, group);\r
+                groupList.add(group);\r
+            }\r
+            group.add(trace);\r
+        }\r
+\r
+        deleteEmptyGroups();\r
+        updateItems();\r
+    }\r
+\r
+    public Object[] getTraces() {\r
+        return _traces;\r
+    }\r
+\r
+    public boolean[] getTraceFilter() {\r
+        return traceFilter;\r
+    }\r
+\r
+    public Vector<ITmfTimeAnalysisEntry> getFilteredOut() {\r
+        return filteredOut;\r
+    }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TmfTimeTipHandler.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TmfTimeTipHandler.java
new file mode 100644 (file)
index 0000000..80c95c1
--- /dev/null
@@ -0,0 +1,245 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Vitaly A. Provodin, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: ThreadsTipHandler.java,v 1.5 2007/06/06 19:16:16 gnagarajan Exp $\r
+ *****************************************************************************/\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeAnalysisViewer.TimeFormat;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseAdapter;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseTrackAdapter;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.layout.GridData;\r
+import org.eclipse.swt.layout.GridLayout;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Display;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Table;\r
+import org.eclipse.swt.widgets.TableColumn;\r
+import org.eclipse.swt.widgets.TableItem;\r
+import org.eclipse.swt.widgets.Widget;\r
+\r
+\r
+public class TmfTimeTipHandler {\r
+\r
+       private Shell _tipShell;\r
+       private Table _tipTable;\r
+       private Item _tipItem;\r
+       private Point _tipPosition;\r
+       private ITimeDataProvider _timeDataProvider;\r
+       TmfTimeAnalysisProvider _utilImp = null;\r
+\r
+       public TmfTimeTipHandler(Shell parent, TmfTimeAnalysisProvider rUtilImpl,\r
+                       ITimeDataProvider timeProv) {\r
+               final Display display = parent.getDisplay();\r
+\r
+               this._utilImp = rUtilImpl;\r
+               this._timeDataProvider = timeProv;\r
+               _tipShell = new Shell(parent, SWT.ON_TOP | SWT.TOOL);\r
+               GridLayout gridLayout = new GridLayout();\r
+               gridLayout.numColumns = 2;\r
+               gridLayout.marginWidth = 2;\r
+               gridLayout.marginHeight = 2;\r
+               _tipShell.setLayout(gridLayout);\r
+               GridData data = new GridData(GridData.BEGINNING, GridData.BEGINNING,\r
+                               true, true);\r
+               _tipShell.setLayoutData(data);\r
+               _tipShell.setBackground(display\r
+                               .getSystemColor(SWT.COLOR_INFO_BACKGROUND));\r
+\r
+               _tipTable = new Table(_tipShell, SWT.NONE);\r
+               _tipTable.setForeground(display\r
+                               .getSystemColor(SWT.COLOR_INFO_FOREGROUND));\r
+               _tipTable.setBackground(display\r
+                               .getSystemColor(SWT.COLOR_INFO_BACKGROUND));\r
+               _tipTable.setHeaderVisible(false);\r
+               _tipTable.setLinesVisible(false);\r
+\r
+               // tipTable.setLayoutData(new GridData(GridData.FILL_HORIZONTAL\r
+               // | GridData.VERTICAL_ALIGN_CENTER));\r
+       }\r
+\r
+       public void activateHoverHelp(final Control control) {\r
+               control.addMouseListener(new MouseAdapter() {\r
+                       @Override\r
+                       public void mouseDown(MouseEvent e) {\r
+                               if (_tipShell.isVisible())\r
+                                       _tipShell.setVisible(false);\r
+                       }\r
+               });\r
+\r
+               control.addMouseTrackListener(new MouseTrackAdapter() {\r
+                       @Override\r
+                       public void mouseExit(MouseEvent e) {\r
+                               if (_tipShell.isVisible())\r
+                                       _tipShell.setVisible(false);\r
+                               _tipItem = null;\r
+\r
+                       }\r
+\r
+                       private void addItem(String name, String value) {\r
+                               TableItem line = new TableItem(_tipTable, SWT.NONE);\r
+                               line.setText(0, name);\r
+                               line.setText(1, value);\r
+                       }\r
+\r
+                       private void fillValues(Point pt, TmfTimeStatesCtrl threadStates,\r
+                                       Item item) {\r
+                               if (item instanceof TraceItem) {\r
+                                       ITmfTimeAnalysisEntry thrd = ((TraceItem) item)._trace;\r
+                                       ITimeEvent threadEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 2);\r
+                                       ITimeEvent nextEvent = Utils.findEvent(thrd, threadStates.hitTimeTest(pt.x), 1);\r
+                                       // thread name\r
+                                       addItem(Messages.TmfTimeTipHandler_TRACE_NAME, thrd.getName());\r
+                                       // class name\r
+                                       String traceClass = _utilImp.getTraceClassName(thrd);\r
+                                       if (traceClass != null) {\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_CLASS_NAME, traceClass);\r
+                                       }\r
+                                       // thread state\r
+                                       String state = _utilImp.getEventName(threadEvent);\r
+                                       if (state != null) {\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_STATE, state);\r
+                                       }\r
+\r
+                                       // This block receives a\r
+                                       // list of <String, String> values to be added to the tip\r
+                                       // table\r
+                                       Map<String, String> eventAddOns = _utilImp.getEventHoverToolTipInfo(threadEvent);\r
+                                       if (eventAddOns != null) {\r
+                                               for (Iterator<String> iter = eventAddOns.keySet().iterator(); iter.hasNext();) {\r
+                                                       String message = (String) iter.next();\r
+                                                       addItem(message, eventAddOns.get(message));\r
+                                               }\r
+                                       }\r
+\r
+                                       long eventStartTime = -1;\r
+                                       long eventDuration = -1;\r
+                                       long eventEndTime = -1;\r
+                                       \r
+                                       if (threadEvent != null) {\r
+                                           eventStartTime = threadEvent.getTime();\r
+                                           eventDuration = threadEvent.getDuration();\r
+                                           if (eventDuration < 0 && nextEvent != null) {\r
+                                               eventEndTime = nextEvent.getTime();\r
+                                               eventDuration = eventEndTime - eventStartTime;\r
+                                           } else {\r
+                                               eventEndTime = eventStartTime + eventDuration;\r
+                                           }\r
+                                       }\r
+\r
+// TODO: Check if we need "format"                                     \r
+//                                     TimeFormat format = TimeFormat.RELATIVE;\r
+                                       Resolution res = Resolution.NANOSEC;\r
+                                       if (_timeDataProvider.isCalendarFormat()) {\r
+//                                             format = TimeFormat.ABSOLUTE; // Absolute format\r
+//                                                                                                             // (calendar)\r
+                                               // Add Date\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_DATE, eventStartTime > -1 ?\r
+                                                       Utils.formatDate(eventStartTime)\r
+                                                       : "?"); //$NON-NLS-1$\r
+                                               if (eventDuration > 0) {\r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, eventStartTime > -1 ?\r
+                                    Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                            \r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, eventEndTime > -1 ?\r
+                                    Utils.formatTime(eventEndTime, TimeFormat.ABSOLUTE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                                               } else {\r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, eventStartTime > -1 ?\r
+                                    Utils.formatTime(eventStartTime, TimeFormat.ABSOLUTE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                                               }\r
+                                       } else {\r
+                                               if (eventDuration > 0) {\r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_START_TIME, eventStartTime > -1 ?\r
+                                                       Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
+                                                       : "?"); //$NON-NLS-1$\r
+                                           \r
+                                               addItem(Messages.TmfTimeTipHandler_TRACE_STOP_TIME, eventEndTime > -1 ?\r
+                                                       Utils.formatTime(eventEndTime, TimeFormat.RELATIVE, res)\r
+                                                       : "?"); //$NON-NLS-1$\r
+                                               } else {\r
+                            addItem(Messages.TmfTimeTipHandler_TRACE_EVENT_TIME, eventStartTime > -1 ?\r
+                                    Utils.formatTime(eventStartTime, TimeFormat.RELATIVE, res)\r
+                                    : "?"); //$NON-NLS-1$\r
+                                               }\r
+                                       }\r
+\r
+                                       if (eventDuration > 0) {\r
+                                           // Duration in relative format in any case\r
+                                           addItem(Messages.TmfTimeTipHandler_DURATION, eventDuration > -1 ?\r
+                                                   Utils.formatTime(eventDuration, TimeFormat.RELATIVE, res)\r
+                                                   : "?"); //$NON-NLS-1$\r
+                                       }\r
+\r
+                               } else if (item instanceof GroupItem) {\r
+                                       addItem(Messages.TmfTimeTipHandler_TRACE_GROUP_NAME, item.toString());\r
+                                       addItem(Messages.TmfTimeTipHandler_NUMBER_OF_TRACES, "" + ((GroupItem) item)._traces.size()); //$NON-NLS-1$\r
+                               }\r
+                       }\r
+\r
+                       @Override\r
+                       public void mouseHover(MouseEvent event) {\r
+                               Point pt = new Point(event.x, event.y);\r
+                               Widget widget = event.widget;\r
+                               Item item = null;\r
+                               if (widget instanceof TmfTimeStatesCtrl) {\r
+                                       TmfTimeStatesCtrl threadStates = (TmfTimeStatesCtrl) widget;\r
+                                       item = (Item) threadStates.getItem(pt);\r
+                                       _tipTable.remove(0, _tipTable.getItemCount() - 1);\r
+                                       new TableColumn(_tipTable, SWT.NONE);\r
+                                       new TableColumn(_tipTable, SWT.NONE);\r
+                                       fillValues(pt, threadStates, item);\r
+                                       _tipTable.getColumn(0).setWidth(200);\r
+                                       _tipTable.getColumn(1).pack();\r
+                                       _tipTable.setSize(_tipTable.computeSize(SWT.DEFAULT, 200));\r
+                                       _tipShell.pack();\r
+                               } else if (widget == null) {\r
+                                       _tipShell.setVisible(false);\r
+                                       _tipItem = null;\r
+                                       return;\r
+                               }\r
+                               if (item == _tipItem)\r
+                                       return;\r
+                               _tipItem = item;\r
+                               _tipPosition = control.toDisplay(pt);\r
+                               _tipShell.pack();\r
+                               setHoverLocation(_tipShell, _tipPosition);\r
+                               _tipShell.setVisible(true);\r
+                       }\r
+               });\r
+       }\r
+\r
+       private void setHoverLocation(Shell shell, Point position) {\r
+               Rectangle displayBounds = shell.getDisplay().getBounds();\r
+               Rectangle shellBounds = shell.getBounds();\r
+               shellBounds.x = Math.max(Math.min(position.x, displayBounds.width\r
+                               - shellBounds.width), 0);\r
+               shellBounds.y = Math.max(Math.min(position.y + 16, displayBounds.height\r
+                               - shellBounds.height), 0);\r
+               shell.setBounds(shellBounds);\r
+       }\r
+\r
+}
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TraceColorScheme.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TraceColorScheme.java
new file mode 100644 (file)
index 0000000..e4e6244
--- /dev/null
@@ -0,0 +1,381 @@
+/*****************************************************************************\r
+ * Copyright (c) 2008 Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: TraceColorScheme.java,v 1.3 2008/05/09 16:11:24 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.TmfTimeAnalysisProvider.StateColor;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.graphics.Color;\r
+\r
+\r
+public class TraceColorScheme {\r
+\r
+       // elements color indices\r
+       static public final int BLACK_STATE = 0;\r
+       static public final int GREEN_STATE = 1;\r
+       static public final int DARK_BLUE_STATE = 2;\r
+       static public final int ORANGE_STATE = 3;\r
+       static public final int GOLD_STATE = 4;\r
+       static public final int RED_STATE = 5;\r
+       static public final int GRAY_STATE = 6;\r
+       static public final int DARK_GREEN_STATE = 7;\r
+       static public final int DARK_YELLOW_STATE = 8;\r
+       static public final int MAGENTA3_STATE = 9;\r
+       static public final int PURPLE1_STATE = 10;\r
+       static public final int PINK1_STATE = 11;\r
+       static public final int AQUAMARINE_STATE = 12;\r
+       static public final int LIGHT_BLUE_STATE = 13;\r
+       static public final int CADET_BLUE_STATE = 14;\r
+       static public final int OLIVE_STATE = 15;\r
+       \r
+       static public final int STATES0 = 0;\r
+       static public final int STATES1 = 15;\r
+       \r
+       // State element index to name mapping, must keep the same order as above\r
+       public static final StateColor stateColors[] = { StateColor.BLACK,\r
+                       StateColor.GREEN, StateColor.DARK_BLUE, StateColor.ORANGE,\r
+                       StateColor.GOLD, StateColor.RED, StateColor.GRAY, StateColor.DARK_GREEN, StateColor.DARK_YELLOW, StateColor.MAGENTA3, StateColor.PURPLE1, \r
+                       StateColor.PINK1, StateColor.AQUAMARINE, StateColor.LIGHT_BLUE, StateColor.CADET_BLUE, StateColor.OLIVE\r
+                       };\r
+\r
+       // selected state elements color indices\r
+       static public final int BLACK_STATE_SEL = 16;\r
+       static public final int GREEN_STATE_SEL = 17;\r
+       static public final int DARK_BLUE_STATE_SEL = 18;\r
+       static public final int ORANGE_STATE_SEL = 19;\r
+       static public final int GOLD_STATE_SEL = 20;\r
+       static public final int RED_STATE_SEL = 21;\r
+       static public final int GRAY_STATE_SEL = 22;\r
+       static public final int DARK_GREEN_STATE_SEL = 23;\r
+       static public final int DARK_YELLOW_STATE_SEL = 24;\r
+       static public final int MAGENTA3_STATE_SEL = 25;\r
+       static public final int PURPLE1_STATE_SEL = 26;\r
+       static public final int PINK1_STATE_SEL = 27;\r
+       static public final int AQUAMARINE_STATE_SEL = 28;\r
+       static public final int LIGHT_BLUE_STATE_SEL = 29;\r
+       static public final int CADET_BLUE_STATE_SEL = 30;\r
+       static public final int OLIVE_STATE_SEL = 31;\r
+       \r
+       static public final int STATES_SEL0 = 16;\r
+       static public final int STATES_SEL1 = 31;\r
+\r
+       // colors indices for viewer controls\r
+       static public final int BACKGROUND = 32;\r
+       static public final int FOREGROUND = 33;\r
+       static public final int BACKGROUND_SEL = 34;\r
+       static public final int FOREGROUND_SEL = 35;\r
+       static public final int BACKGROUND_SEL_NOFOCUS = 36;\r
+       static public final int FOREGROUND_SEL_NOFOCUS = 37;\r
+       static public final int TOOL_BACKGROUND = 38;\r
+       static public final int TOOL_FOREGROUND = 39;\r
+\r
+       // misc colors\r
+       static public final int FIX_COLOR = 40;\r
+       static public final int WHITE = 41;\r
+       static public final int GRAY = 42;\r
+       static public final int BLACK = 43;\r
+       static public final int DARK_GRAY = 44;\r
+\r
+       // selected border color indices\r
+       static public final int BLACK_BORDER = 45;\r
+       static public final int GREEN_BORDER = 46;\r
+       static public final int DARK_BLUE_BORDER = 47;\r
+       static public final int ORANGE_BORDER = 48;\r
+       static public final int GOLD_BORDER = 49;\r
+       static public final int RED_BORDER = 50;\r
+       static public final int GRAY_BORDER = 51;\r
+       static public final int DARK_GREEN_BORDER1 = 52;\r
+       static public final int DARK_YELLOW_BORDER1 = 53;\r
+       static public final int MAGENTA3_BORDER1 = 54;\r
+       static public final int PURPLE1_BORDER1 = 55;\r
+       static public final int PINK1_BORDER1 = 56;\r
+       static public final int AQUAMARINE_BORDER1 = 57;\r
+       static public final int LIGHT_BLUE_BORDER1 = 58;\r
+       static public final int CADET_BLUE_STATE_BORDER = 59;\r
+       static public final int OLIVE_BORDER2 = 60;\r
+       \r
+       static public final int STATES_BORDER0 = 45;\r
+       static public final int STATES_BORDER1 = 60;\r
+\r
+       static public final int MID_LINE = 61;\r
+       static public final int RED = 62;\r
+       static public final int GREEN = 63;\r
+       static public final int BLUE = 64;\r
+       static public final int YELLOW = 65;\r
+       static public final int CYAN = 66;\r
+       static public final int MAGENTA = 67;\r
+\r
+       static public final int SELECTED_TIME = 68;\r
+       static public final int LEGEND_BACKGROUND = 69;\r
+       static public final int LEGEND_FOREGROUND = 70;\r
+\r
+       // group items' colors\r
+       static public final int GR_BACKGROUND = 71;\r
+       static public final int GR_FOREGROUND = 72;\r
+       static public final int GR_BACKGROUND_SEL = 73;\r
+       static public final int GR_FOREGROUND_SEL = 74;\r
+       static public final int GR_BACKGROUND_SEL_NOFOCUS = 75;\r
+       static public final int GR_FOREGROUND_SEL_NOFOCUS = 76;\r
+\r
+       static public final int LIGHT_LINE = 77;\r
+    static public final int BACKGROUND_NAME = 78;\r
+    static public final int BACKGROUND_NAME_SEL = 79;\r
+    static public final int BACKGROUND_NAME_SEL_NOFOCUS = 80;\r
+\r
+       // Interraction's colors\r
+       static public final int TI_START_THREAD = BLACK;\r
+       static public final int TI_HANDOFF_LOCK = BLUE;\r
+       static public final int TI_NOTIFY_ALL = GREEN;\r
+       static public final int TI_NOTIFY = GREEN;\r
+       static public final int TI_NOTIFY_JOINED = DARK_GRAY;\r
+       static public final int TI_INTERRUPT = RED;\r
+       static public final int TI_WAIT_EXCEEDED = BLUE;\r
+\r
+       static interface IColorProvider {\r
+               public Color get();\r
+       }\r
+\r
+       static class SysCol implements IColorProvider {\r
+               int syscol;\r
+\r
+               SysCol(int syscol) {\r
+                       this.syscol = syscol;\r
+               }\r
+\r
+               @Override\r
+               public Color get() {\r
+                       return Utils.getSysColor(syscol);\r
+               }\r
+       }\r
+\r
+       static class RGB implements IColorProvider {\r
+               int r;\r
+               int g;\r
+               int b;\r
+\r
+               RGB(int r, int g, int b) {\r
+                       this.r = r;\r
+                       this.g = g;\r
+                       this.b = b;\r
+               }\r
+\r
+               @Override\r
+               public Color get() {\r
+                       return new Color(null, r, g, b);\r
+               }\r
+       }\r
+\r
+       static class Mix implements IColorProvider {\r
+               IColorProvider cp1;\r
+               IColorProvider cp2;\r
+               int w1;\r
+               int w2;\r
+\r
+               Mix(IColorProvider cp1, IColorProvider cp2, int w1, int w2) {\r
+                       this.cp1 = cp1;\r
+                       this.cp2 = cp2;\r
+                       this.w1 = w1;\r
+                       this.w2 = w2;\r
+               }\r
+\r
+               Mix(IColorProvider cp1, IColorProvider cp2) {\r
+                       this.cp1 = cp1;\r
+                       this.cp2 = cp2;\r
+                       this.w1 = 1;\r
+                       this.w2 = 1;\r
+               }\r
+\r
+               @Override\r
+               public Color get() {\r
+                       Color col1 = cp1.get();\r
+                       Color col2 = cp2.get();\r
+                       Color col = Utils.mixColors(col1, col2, w1, w2);\r
+                       return col;\r
+               }\r
+       }\r
+\r
+       static private final IColorProvider _providersMap[] = {\r
+                       //\r
+                       new RGB(100, 100, 100), // UNKNOWN\r
+                       new RGB(174, 200, 124), // RUNNING\r
+                       new Mix(new SysCol(SWT.COLOR_BLUE), new SysCol(SWT.COLOR_GRAY), 1, 3), // SLEEPING\r
+                       new RGB(210, 150, 60), // WAITING\r
+                       new RGB(242, 225, 168), // BLOCKED\r
+                       new Mix(new SysCol(SWT.COLOR_RED), new SysCol(SWT.COLOR_GRAY), 1, 3), // DEADLOCK\r
+                       new RGB(200, 200, 200), // STOPPED\r
+                       new RGB(35, 107, 42), // STEEL BLUE\r
+                       new RGB(205,205,0), // DARK YELLOW\r
+                       new RGB(205, 0, 205), // MAGENTA\r
+                       new RGB(171, 130, 255), // PURPLE\r
+                       new RGB(255, 181, 197), // PINK\r
+                       new RGB(112, 219, 147), // AQUAMARINE\r
+                       new RGB(198, 226, 255), // SLATEGRAY\r
+                       new RGB(95, 158, 160), // CADET BLUE\r
+                       new RGB(107, 142, 35), // OLIVE\r
+                       \r
+                       \r
+                       //TODO: Does not seem to be used, check during clean-up\r
+                       new SysCol(SWT.COLOR_WHITE), // UNKNOWN_SEL\r
+                       new SysCol(SWT.COLOR_GREEN), // RUNNING_SEL\r
+                       new SysCol(SWT.COLOR_BLUE), // SLEEPING_SEL\r
+                       new SysCol(SWT.COLOR_CYAN), // WAITING_SEL\r
+                       new SysCol(SWT.COLOR_YELLOW), // BLOCKED_SEL\r
+                       new SysCol(SWT.COLOR_RED), // DEADLOCK_SEL\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // STOPPED_SEL\r
+                       new SysCol(SWT.COLOR_WHITE), \r
+                       new SysCol(SWT.COLOR_GREEN), \r
+                       new SysCol(SWT.COLOR_BLUE), \r
+                       new SysCol(SWT.COLOR_CYAN), \r
+                       new SysCol(SWT.COLOR_YELLOW), \r
+                       new SysCol(SWT.COLOR_RED), \r
+                       new SysCol(SWT.COLOR_DARK_GRAY), \r
+                       new SysCol(SWT.COLOR_WHITE), \r
+                       new SysCol(SWT.COLOR_GREEN), \r
+                       \r
+\r
+                       new SysCol(SWT.COLOR_LIST_BACKGROUND), // BACKGROUND\r
+                       new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND\r
+                       new RGB(232, 242, 254), // BACKGROUND_SEL\r
+                       new SysCol(SWT.COLOR_LIST_FOREGROUND), // FOREGROUND_SEL\r
+                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // BACKGROUND_SEL_NOFOCUS\r
+                       new SysCol(SWT.COLOR_WIDGET_FOREGROUND), // FOREGROUND_SEL_NOFOCUS\r
+                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // TOOL_BACKGROUND\r
+                       new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // TOOL_FOREGROUND\r
+\r
+                       new SysCol(SWT.COLOR_GRAY), // FIX_COLOR\r
+                       new SysCol(SWT.COLOR_WHITE), // WHITE\r
+                       new SysCol(SWT.COLOR_GRAY), // GRAY\r
+                       new SysCol(SWT.COLOR_BLACK), // BLACK\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GRAY\r
+\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // BLACK_BORDER\r
+                       new RGB(75, 115, 120), // GREEN_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_BLUE), // DARK_BLUE_BORDER\r
+                       new RGB(242, 225, 168), // ORANGE_BORDER\r
+                       new RGB(210, 150, 60), // GOLD_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_RED), // RED_BORDER\r
+                       new SysCol(SWT.COLOR_BLACK), // GRAY_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // DARK_GREEN_BORDER\r
+                       new RGB(75, 115, 120), // DARK_YELLOW_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_BLUE), // MAGENTA3_BORDER\r
+                       new RGB(242, 225, 168), // PURPLE1_BORDER\r
+                       new RGB(210, 150, 60), // PINK1_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_RED), // AQUAMARINE_BORDER\r
+                       new SysCol(SWT.COLOR_BLACK), // LIGHT_BLUE_BORDER\r
+                       new SysCol(SWT.COLOR_DARK_GRAY), // BLUE_BORDER\r
+                       new RGB(75, 115, 120), // OLIVE_BORDER\r
+               \r
+\r
+                       new SysCol(SWT.COLOR_GRAY), // MID_LINE\r
+                       new SysCol(SWT.COLOR_RED), // RED\r
+                       new SysCol(SWT.COLOR_GREEN), // GREEN\r
+                       new SysCol(SWT.COLOR_BLUE), // BLUE\r
+                       new SysCol(SWT.COLOR_YELLOW), // YELLOW\r
+                       new SysCol(SWT.COLOR_CYAN), // CYAN\r
+                       new SysCol(SWT.COLOR_MAGENTA), // MAGENTA\r
+\r
+                       new SysCol(SWT.COLOR_BLUE), // SELECTED_TIME\r
+                       new SysCol(SWT.COLOR_WIDGET_BACKGROUND), // LEGEND_BACKGROUND\r
+                       new SysCol(SWT.COLOR_WIDGET_DARK_SHADOW), // LEGEND_FOREGROUND\r
+\r
+                       new Mix(new RGB(150, 200, 240), new SysCol(\r
+                                       SWT.COLOR_LIST_BACKGROUND)),// GR_BACKGROUND\r
+                       new RGB(0, 0, 50), // GR_FOREGROUND\r
+                       new Mix(new RGB(200, 200, 100),\r
+                                       new SysCol(SWT.COLOR_LIST_SELECTION)), // GR_BACKGROUND_SEL\r
+                       new Mix(new RGB(150, 200, 240), new SysCol(\r
+                                       SWT.COLOR_LIST_SELECTION_TEXT)), // GR_FOREGROUND_SEL\r
+                       new Mix(new RGB(222, 222, 155), new SysCol(\r
+                                       SWT.COLOR_WIDGET_BACKGROUND)), // GR_BACKGROUND_SEL_NOFOCUS\r
+                       new RGB(0, 0, 50), // GR_FOREGROUND_SEL_NOFOCUS\r
+\r
+                       new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(\r
+                                       SWT.COLOR_LIST_BACKGROUND), 1, 3), // LIGHT_LINE\r
+\r
+                       new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_LIST_BACKGROUND), 1, 6),   // BACKGROUND_NAME\r
+                   new Mix(new SysCol(SWT.COLOR_GRAY), new RGB(232, 242, 254), 1, 6),                  // BACKGROUND_NAME_SEL\r
+                   new Mix(new SysCol(SWT.COLOR_GRAY), new SysCol(SWT.COLOR_WIDGET_BACKGROUND), 1, 6), // BACKGROUND_NAME_SEL_NOFOCUS\r
+       };\r
+\r
+       private Color _colors[];\r
+\r
+       public TraceColorScheme() {\r
+               _colors = new Color[_providersMap.length];\r
+       }\r
+\r
+       public void dispose() {\r
+               for (int i = 0; i < _colors.length; i++) {\r
+                       Utils.dispose(_colors[i]);\r
+                       _colors[i] = null;\r
+               }\r
+       }\r
+\r
+       public Color getColor(int idx) {\r
+               if (null == _colors[idx]) {\r
+                       if (idx >= STATES_SEL0 && idx <= STATES_SEL1) {\r
+                               Color col1 = getColor(idx - STATES_SEL0);\r
+                               Color col2 = getColor(BACKGROUND_SEL);\r
+                               _colors[idx] = Utils.mixColors(col1, col2, 3, 1);\r
+                       } else {\r
+                               _colors[idx] = _providersMap[idx].get();\r
+                       }\r
+               }\r
+               return _colors[idx];\r
+       }\r
+\r
+       public Color getBkColor(boolean selected, boolean focused, boolean name) {\r
+           if (name) {\r
+               if (selected && focused)\r
+                   return getColor(BACKGROUND_NAME_SEL);\r
+               if (selected)\r
+                   return getColor(BACKGROUND_NAME_SEL_NOFOCUS);\r
+               return getColor(BACKGROUND_NAME);\r
+           } else {\r
+               if (selected && focused)\r
+                   return getColor(BACKGROUND_SEL);\r
+               if (selected)\r
+                   return getColor(BACKGROUND_SEL_NOFOCUS);\r
+               return getColor(BACKGROUND);\r
+           }\r
+       }\r
+\r
+       public Color getFgColor(boolean selected, boolean focused) {\r
+               if (selected && focused)\r
+                       return getColor(FOREGROUND_SEL);\r
+               if (selected)\r
+                       return getColor(FOREGROUND_SEL_NOFOCUS);\r
+               return getColor(FOREGROUND);\r
+       }\r
+\r
+       public Color getBkColorGroup(boolean selected, boolean focused) {\r
+               if (selected && focused)\r
+                       return getColor(GR_BACKGROUND_SEL);\r
+               if (selected)\r
+                       return getColor(GR_BACKGROUND_SEL_NOFOCUS);\r
+               return getColor(GR_BACKGROUND);\r
+       }\r
+\r
+       public Color getFgColorGroup(boolean selected, boolean focused) {\r
+               if (selected && focused)\r
+                       return getColor(GR_FOREGROUND_SEL);\r
+               if (selected)\r
+                       return getColor(GR_FOREGROUND_SEL_NOFOCUS);\r
+               return getColor(GR_FOREGROUND);\r
+       }\r
+\r
+       public static StateColor[] getStateColors() {\r
+               return stateColors;\r
+       }\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TraceCtrl.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/TraceCtrl.java
new file mode 100644 (file)
index 0000000..85e16aa
--- /dev/null
@@ -0,0 +1,68 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, Intel Corporation.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: TraceCtrl.java,v 1.2 2007/02/27 18:37:36 ewchan Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.PaintEvent;\r
+import org.eclipse.swt.events.PaintListener;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Canvas;\r
+import org.eclipse.swt.widgets.Composite;\r
+\r
+public abstract class TraceCtrl extends Canvas implements PaintListener {\r
+\r
+       static public final int MARGIN = 4;\r
+    static public final int RIGHT_MARGIN = 2; // 2 pixels less to make sure end time is visible\r
+       static public final int SMALL_ICON_SIZE = 16;\r
+\r
+       protected TraceColorScheme _colors;\r
+       protected int _fontHeight = 0;\r
+\r
+       public TraceCtrl(Composite parent, TraceColorScheme colors) {\r
+               this(parent, colors, SWT.NO_BACKGROUND | SWT.NO_FOCUS);\r
+       }\r
+\r
+       public TraceCtrl(Composite parent, TraceColorScheme colors, int style) {\r
+               super(parent, style);\r
+               _colors = colors;\r
+               addPaintListener(this);\r
+       }\r
+\r
+       @Override\r
+       public void dispose() {\r
+               super.dispose();\r
+       }\r
+\r
+       @Override\r
+       public void paintControl(PaintEvent e) {\r
+               if (e.widget != this)\r
+                       return;\r
+               _fontHeight = e.gc.getFontMetrics().getHeight();\r
+               Rectangle bound = getClientArea();\r
+               if (!bound.isEmpty()) {\r
+                       Color colBackup = e.gc.getBackground();\r
+                       paint(bound, e);\r
+                       e.gc.setBackground(colBackup);\r
+               }\r
+       }\r
+\r
+       public int getFontHeight() {\r
+               return _fontHeight;\r
+       }\r
+\r
+       abstract void paint(Rectangle bound, PaintEvent e);\r
+}\r
diff --git a/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java b/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/widgets/timegraph/widgets/Utils.java
new file mode 100644 (file)
index 0000000..7f2b41f
--- /dev/null
@@ -0,0 +1,535 @@
+/*****************************************************************************\r
+ * Copyright (c) 2007, 2008 Intel Corporation and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *    Intel Corporation - Initial API and implementation\r
+ *    Ruslan A. Scherbakov, Intel - Initial API and implementation\r
+ *    Alvaro Sanchex-Leon - Udpated for TMF\r
+ *\r
+ * $Id: Utils.java,v 1.11 2008/06/16 21:04:49 jkubasta Exp $ \r
+ *****************************************************************************/\r
+\r
+package org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets;\r
+\r
+import java.text.SimpleDateFormat;\r
+import java.util.Date;\r
+import java.util.Iterator;\r
+import java.util.TimeZone;\r
+\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.ITimeAnalysisViewer.TimeFormat;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITimeEvent;\r
+import org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model.ITmfTimeAnalysisEntry;\r
+import org.eclipse.swt.graphics.Color;\r
+import org.eclipse.swt.graphics.Device;\r
+import org.eclipse.swt.graphics.GC;\r
+import org.eclipse.swt.graphics.Point;\r
+import org.eclipse.swt.graphics.Rectangle;\r
+import org.eclipse.swt.widgets.Display;\r
+\r
+public class Utils {\r
+\r
+       static public final int IMG_THREAD_RUNNING = 0;\r
+       static public final int IMG_THREAD_SUSPENDED = 1;\r
+       static public final int IMG_THREAD_STOPPED = 2;\r
+       static public final int IMG_METHOD_RUNNING = 3;\r
+       static public final int IMG_METHOD = 4;\r
+       static public final int IMG_NUM = 5;\r
+\r
+       static public final Object[] _empty = new Object[0];\r
+\r
+       static enum Resolution {\r
+               SECONDS, MILLISEC, MICROSEC, NANOSEC\r
+       };\r
+\r
+       static private final SimpleDateFormat stimeformat = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$\r
+       static private final SimpleDateFormat sdateformat = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$\r
+       static {\r
+        stimeformat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+        sdateformat.setTimeZone(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$\r
+       }\r
+\r
+//     static private String _externalPlugin[] = { "org.eclipse.debug.ui",\r
+//                     "org.eclipse.debug.ui", "org.eclipse.debug.ui",\r
+//                     "org.eclipse.debug.ui", "org.eclipse.debug.ui", };\r
+//\r
+//     static private String _externalPath[] = {\r
+//                     "icons/full/obj16/thread_obj.gif", // running thread\r
+//                     "icons/full/obj16/threads_obj.gif", // suspended\r
+//                     "icons/full/obj16/threadt_obj.gif", // stopped\r
+//                     "icons/full/obj16/stckframe_running_obj.gif", // running stack frame\r
+//                     "icons/full/obj16/stckframe_obj.gif", // stack frame\r
+//     };\r
+\r
+//     static public Image getImage(int idx) {\r
+//             if (idx < 0 || idx >= IMG_NUM)\r
+//                     SWT.error(SWT.ERROR_INVALID_ARGUMENT);\r
+//             String key = "trace.img." + idx;\r
+//             Image img = TimeAnalysisPlugin.getDefault().getImageRegistry().get(key);\r
+//             if (null == img) {\r
+//                     ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(\r
+//                                     _externalPlugin[idx], _externalPath[idx]);\r
+//                     TimeAnalysisPlugin.getDefault().getImageRegistry().put(key, desc);\r
+//                     img = TimeAnalysisPlugin.getDefault().getImageRegistry().get(key);\r
+//             }\r
+//             return img;\r
+//     }\r
+\r
+       static public void init(Rectangle rect) {\r
+               rect.x = 0;\r
+               rect.y = 0;\r
+               rect.width = 0;\r
+               rect.height = 0;\r
+       }\r
+\r
+       static public void init(Rectangle rect, int x, int y, int width, int height) {\r
+               rect.x = x;\r
+               rect.y = y;\r
+               rect.width = width;\r
+               rect.height = height;\r
+       }\r
+\r
+       static public void init(Rectangle rect, Rectangle source) {\r
+               rect.x = source.x;\r
+               rect.y = source.y;\r
+               rect.width = source.width;\r
+               rect.height = source.height;\r
+       }\r
+\r
+       static public void deflate(Rectangle rect, int x, int y) {\r
+               rect.x += x;\r
+               rect.y += y;\r
+               rect.width -= x + x;\r
+               rect.height -= y + y;\r
+       }\r
+\r
+       static public void inflate(Rectangle rect, int x, int y) {\r
+               rect.x -= x;\r
+               rect.y -= y;\r
+               rect.width += x + x;\r
+               rect.height += y + y;\r
+       }\r
+\r
+       static void dispose(Color col) {\r
+               if (null != col)\r
+                       col.dispose();\r
+       }\r
+\r
+       static public Color mixColors(Device display, Color c1, Color c2, int w1,\r
+                       int w2) {\r
+               return new Color(display, (w1 * c1.getRed() + w2 * c2.getRed())\r
+                               / (w1 + w2), (w1 * c1.getGreen() + w2 * c2.getGreen())\r
+                               / (w1 + w2), (w1 * c1.getBlue() + w2 * c2.getBlue())\r
+                               / (w1 + w2));\r
+       }\r
+\r
+       static public Color getSysColor(int id) {\r
+               Color col = Display.getCurrent().getSystemColor(id);\r
+               return new Color(col.getDevice(), col.getRGB());\r
+       }\r
+\r
+       static public Color mixColors(Color col1, Color col2, int w1, int w2) {\r
+               return mixColors(Display.getCurrent(), col1, col2, w1, w2);\r
+       }\r
+\r
+       static public int drawText(GC gc, String text, Rectangle rect,\r
+                       boolean transp) {\r
+               Point size = gc.stringExtent(text);\r
+               gc.drawText(text, rect.x, rect.y, transp);\r
+               return size.x;\r
+       }\r
+\r
+       static public int drawText(GC gc, String text, int x, int y, boolean transp) {\r
+               Point size = gc.stringExtent(text);\r
+               gc.drawText(text, x, y, transp);\r
+               return size.x;\r
+       }\r
+\r
+       /**\r
+     * Formats time in format: MM:SS:NNN\r
+     * \r
+        * @param time time\r
+        * @param format  0: MMMM:ss:nnnnnnnnn, 1: HH:MM:ss MMM.mmmm.nnn\r
+        * @param resolution the resolution\r
+        * @return the formatted time\r
+        */\r
+       static public String formatTime(long time, TimeFormat format, Resolution resolution) {\r
+               // if format is absolute (Calendar)\r
+               if (format == TimeFormat.ABSOLUTE) {\r
+                       return formatTimeAbs(time, resolution);\r
+               }\r
+\r
+               StringBuffer str = new StringBuffer();\r
+               boolean neg = time < 0;\r
+               if (neg) {\r
+                       time = -time;\r
+                       str.append('-');\r
+               }\r
+\r
+               long sec = (long) (time * 1E-9);\r
+               // TODO: Expand to make it possible to select the minute, second, nanosecond format\r
+               //printing minutes is suppressed just sec and ns\r
+               // if (sec / 60 < 10)\r
+               // str.append('0');\r
+               // str.append(sec / 60);\r
+               // str.append(':');\r
+               // sec %= 60;\r
+               // if (sec < 10)\r
+               // str.append('0');\r
+               str.append(sec);\r
+               String ns = formatNs(time, resolution);\r
+               if (!ns.equals("")) { //$NON-NLS-1$\r
+                       str.append(':');\r
+                       str.append(ns);\r
+               }\r
+\r
+               return str.toString();\r
+       }\r
+\r
+       /**\r
+        * From input time in nanoseconds, convert to Date format YYYY-MM-dd\r
+        * \r
+        * @param absTime\r
+        * @return the formatted date\r
+        */\r
+       public static String formatDate(long absTime) {\r
+               String sdate = sdateformat.format(new Date((long) (absTime * 1E-6)));\r
+               return sdate;\r
+       }\r
+\r
+       /**\r
+        * Formats time in ns to Calendar format: HH:MM:SS MMM.mmm.nnn\r
+        * \r
+        * @param time\r
+        * @return the formatted time\r
+        */\r
+       static public String formatTimeAbs(long time, Resolution res) {\r
+               StringBuffer str = new StringBuffer();\r
+\r
+               // format time from nanoseconds to calendar time HH:MM:SS\r
+               String stime = stimeformat.format(new Date((long) (time * 1E-6)));\r
+               str.append(stime + " "); //$NON-NLS-1$\r
+               // append the Milliseconds, MicroSeconds and NanoSeconds as specified in\r
+               // the Resolution\r
+               str.append(formatNs(time, res));\r
+               return str.toString();\r
+       }\r
+\r
+       /**\r
+        * Obtains the remainder fraction on unit Seconds of the entered value in\r
+        * nanoseconds. e.g. input: 1241207054171080214 ns The number of fraction\r
+        * seconds can be obtained by removing the last 9 digits: 1241207054 the\r
+        * fractional portion of seconds, expressed in ns is: 171080214\r
+        * \r
+        * @param time\r
+        * @param res\r
+        * @return the formatted nanosec\r
+        */\r
+       public static String formatNs(long time, Resolution res) {\r
+               StringBuffer temp = new StringBuffer();\r
+               boolean neg = time < 0;\r
+               if (neg) {\r
+                       time = -time;\r
+               }\r
+\r
+               // The following approach could be used although performance\r
+               // decreases in half.\r
+               // String strVal = String.format("%09d", time);\r
+               // String tmp = strVal.substring(strVal.length() - 9);\r
+\r
+               // number of segments to be included\r
+               int segments = 0;\r
+               switch (res) {\r
+               case MILLISEC:\r
+                       segments = 1;\r
+                       break;\r
+               case MICROSEC:\r
+                       segments = 2;\r
+                       break;\r
+               case NANOSEC:\r
+                       segments = 3;\r
+                       break;\r
+               default:\r
+                       break;\r
+               }\r
+\r
+               long ns = time;\r
+               ns %= 1000000000;\r
+               if (ns < 10) {\r
+                       temp.append("00000000"); //$NON-NLS-1$\r
+               } else if (ns < 100) {\r
+                       temp.append("0000000"); //$NON-NLS-1$\r
+               } else if (ns < 1000) {\r
+                       temp.append("000000"); //$NON-NLS-1$\r
+               } else if (ns < 10000) {\r
+                       temp.append("00000"); //$NON-NLS-1$\r
+               } else if (ns < 100000) {\r
+                       temp.append("0000"); //$NON-NLS-1$\r
+               } else if (ns < 1000000) {\r
+                       temp.append("000"); //$NON-NLS-1$\r
+               } else if (ns < 10000000) {\r
+                       temp.append("00"); //$NON-NLS-1$\r
+               } else if (ns < 100000000) {\r
+                       temp.append("0"); //$NON-NLS-1$\r
+               }\r
+               temp.append(ns);\r
+\r
+               StringBuffer str = new StringBuffer();\r
+               if (segments > 0) {\r
+                       // append ms\r
+                       str.append(temp.substring(0, 3));\r
+               }\r
+               if (segments > 1) {\r
+                       // append Micro secs\r
+                       str.append("."); //$NON-NLS-1$\r
+                       str.append(temp.substring(3, 6));\r
+               }\r
+               if (segments > 2) {\r
+                       // append Nano seconds\r
+                       str.append("."); //$NON-NLS-1$\r
+                       str.append(temp.substring(6));\r
+               }\r
+\r
+               return str.toString();\r
+       }\r
+\r
+       static public int loadIntOption(String opt, int def, int min, int max) {\r
+               // int val =\r
+               // TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
+               // if (0 == val)\r
+               // val = def;\r
+               // if (val < min)\r
+               // val = min;\r
+               // if (val > max)\r
+               // val = max;\r
+               return def;\r
+       }\r
+\r
+       // static public int loadIntOption(String opt) {\r
+       // int val = TraceUIPlugin.getDefault().getPreferenceStore().getInt(opt);\r
+       // return val;\r
+       // }\r
+\r
+       static public void saveIntOption(String opt, int val) {\r
+               // TraceUIPlugin.getDefault().getPreferenceStore().setValue(opt, val);\r
+       }\r
+\r
+       static ITimeEvent getFirstEvent(ITmfTimeAnalysisEntry thread) {\r
+               if (null == thread)\r
+                       return null;\r
+               Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator();\r
+               if (iterator.hasNext()) {\r
+                   return iterator.next();\r
+               } else {\r
+                   return null;\r
+               }\r
+       }\r
+\r
+       /**\r
+        * N means: <list> <li>-1: Previous Event</li> <li>0: Current Event</li> <li>\r
+        * 1: Next Event</li> <li>2: Previous Event when located in a non Event Area\r
+        * </list>\r
+        * \r
+        * @param thread\r
+        * @param time\r
+        * @param n\r
+        * @return\r
+        */\r
+    static ITimeEvent findEvent(ITmfTimeAnalysisEntry thread, long time, int n) {\r
+        if (null == thread)\r
+            return null;\r
+        Iterator<ITimeEvent> iterator = thread.getTraceEventsIterator();\r
+        ITimeEvent nextEvent = null;\r
+        ITimeEvent currEvent = null;\r
+        ITimeEvent prevEvent = null;\r
+\r
+        while (iterator.hasNext()) {\r
+            nextEvent = (ITimeEvent) iterator.next();\r
+            long nextStartTime = nextEvent.getTime();\r
+            \r
+            if (nextStartTime > time) {\r
+                break;\r
+            }\r
+            \r
+            if (currEvent == null || currEvent.getTime() != nextStartTime) {\r
+                prevEvent = currEvent;\r
+                currEvent = nextEvent;\r
+            }\r
+        }\r
+        \r
+        if (n == -1) { //previous\r
+            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
+                return prevEvent;\r
+            } else {\r
+                return currEvent;\r
+            }\r
+        } else if (n == 0) { //current\r
+            if (currEvent != null && currEvent.getTime() + currEvent.getDuration() >= time) {\r
+                return currEvent;\r
+            } else {\r
+                return null;\r
+            }\r
+        } else if (n == 1) { //next\r
+            return nextEvent;\r
+        } else if (n == 2) { //current or previous when in empty space\r
+            return currEvent;\r
+        }\r
+        \r
+        return null;\r
+    }\r
+\r
+       // static public TRCPackage getPackage(Object element) {\r
+       // if (element instanceof TRCPackage)\r
+       // return (TRCPackage) element;\r
+       // if (element instanceof TRCClass)\r
+       // return ((TRCClass) element).getPackage();\r
+       // return null;\r
+       // }\r
+\r
+       // static public TRCObjectAllocationAnnotation getAllocationAnnotation(\r
+       // TRCClass cls) {\r
+       // TRCObjectAllocationAnnotation aa = null;\r
+       // EList list = cls.getAnnotations();\r
+       // int len = list.size();\r
+       // for (int i = 0; i < len; i++) {\r
+       // TRCAnnotation annotation = (TRCAnnotation) list.get(i);\r
+       // if (annotation instanceof TRCObjectAllocationAnnotation)\r
+       // aa = (TRCObjectAllocationAnnotation) annotation;\r
+       // }\r
+       // return aa;\r
+       // }\r
+\r
+       static public String fixMethodSignature(String sig) {\r
+               int pos = sig.indexOf('(');\r
+               if (pos >= 0) {\r
+                       String ret = sig.substring(0, pos);\r
+                       sig = sig.substring(pos);\r
+                       sig = sig + " " + ret; //$NON-NLS-1$\r
+               }\r
+               return sig;\r
+       }\r
+\r
+       static public String restoreMethodSignature(String sig) {\r
+               String ret = ""; //$NON-NLS-1$\r
+               int pos = sig.indexOf('(');\r
+               if (pos >= 0) {\r
+                       ret = sig.substring(0, pos);\r
+                       sig = sig.substring(pos + 1);\r
+               }\r
+               pos = sig.indexOf(')');\r
+               if (pos >= 0) {\r
+                       sig = sig.substring(0, pos);\r
+               }\r
+               String args[] = sig.split(","); //$NON-NLS-1$\r
+        StringBuffer result = new StringBuffer("("); //$NON-NLS-1$\r
+               for (int i = 0; i < args.length; i++) {\r
+                       String arg = args[i].trim();\r
+                       if (arg.length() == 0 && args.length == 1)\r
+                               break;\r
+                       result.append(getTypeSignature(arg));\r
+               }\r
+               result.append(")").append(getTypeSignature(ret)); //$NON-NLS-1$\r
+               return result.toString();\r
+       }\r
+\r
+       static public String getTypeSignature(String type) {\r
+               int dim = 0;\r
+               for (int j = 0; j < type.length(); j++) {\r
+                       if (type.charAt(j) == '[')\r
+                               dim++;\r
+               }\r
+               int pos = type.indexOf('[');\r
+               if (pos >= 0)\r
+                       type = type.substring(0, pos);\r
+               StringBuffer sig = new StringBuffer(""); //$NON-NLS-1$\r
+               for (int j = 0; j < dim; j++)\r
+                       sig.append("[");                 //$NON-NLS-1$\r
+               if (type.equals("boolean"))     //$NON-NLS-1$\r
+                       sig.append("Z");                 //$NON-NLS-1$\r
+               else if (type.equals("byte"))   //$NON-NLS-1$\r
+                       sig.append("B");                 //$NON-NLS-1$\r
+               else if (type.equals("char"))   //$NON-NLS-1$\r
+                       sig.append("C");                 //$NON-NLS-1$\r
+               else if (type.equals("short"))  //$NON-NLS-1$\r
+                       sig.append("S");                 //$NON-NLS-1$\r
+               else if (type.equals("int"))    //$NON-NLS-1$\r
+                       sig.append("I");                 //$NON-NLS-1$\r
+               else if (type.equals("long"))   //$NON-NLS-1$\r
+                       sig.append("J");                 //$NON-NLS-1$\r
+               else if (type.equals("float"))  //$NON-NLS-1$\r
+                       sig.append("F");                 //$NON-NLS-1$\r
+               else if (type.equals("double")) //$NON-NLS-1$\r
+                       sig.append("D");                 //$NON-NLS-1$\r
+               else if (type.equals("void"))   //$NON-NLS-1$\r
+                       sig.append("V");                 //$NON-NLS-1$\r
+               else\r
+                       sig.append("L").append(type.replace('.', '/')).append(";"); //$NON-NLS-1$ //$NON-NLS-2$\r
+               return sig.toString();\r
+       }\r
+\r
+       // static public boolean openSource(Object element) {\r
+       // if (element instanceof String) {\r
+       // final String pattern = (String) element;\r
+       // final int javaType = IJavaSearchConstants.METHOD;\r
+       // BusyIndicator.showWhile(Display.getDefault(), new Runnable() {\r
+       // public void run() {\r
+       // if (!OpenJavaSource.openSource(pattern, javaType,\r
+       // SearchEngine.createWorkspaceScope(), true)) {\r
+       // MessageDialog.openInformation(UIPlugin.getDefault()\r
+       // .getWorkbench().getActiveWorkbenchWindow()\r
+       // .getShell(), TraceMessages.TRC_MSGT, NLS.bind(\r
+       // TraceUIMessages._68, pattern));\r
+       // }\r
+       // }\r
+       // });\r
+       // }\r
+       // OpenSource.openSource(element);\r
+       // return true;\r
+       // }\r
+\r
+       // static public int getObjAge(TRCFullTraceObject obj, EList listGC) {\r
+       // int age = 0;\r
+       // double t0 = obj.getCreateTime();\r
+       // double t1 = obj.getCollectTime();\r
+       // int len = listGC.size();\r
+       // for (int j = 0; j < len; j++) {\r
+       // TRCGCEvent gcEvent = (TRCGCEvent) listGC.get(j);\r
+       // if (gcEvent.getType().equals("finish")) {\r
+       // double time = gcEvent.getTime();\r
+       // if (time <= t0)\r
+       // continue;\r
+       // if (t1 > 0 && time >= t1)\r
+       // break;\r
+       // age++;\r
+       // }\r
+       // }\r
+       // return age;\r
+       // }\r
+\r
+       static public int compare(double d1, double d2) {\r
+               if (d1 > d2)\r
+                       return 1;\r
+               if (d1 < d2)\r
+                       return 1;\r
+               return 0;\r
+       }\r
+\r
+       static public int compare(String s1, String s2) {\r
+               if (s1 != null && s2 != null)\r
+                       return s1.compareToIgnoreCase(s2);\r
+               if (s1 != null)\r
+                       return 1;\r
+               if (s2 != null)\r
+                       return -1;\r
+               return 0;\r
+       }\r
+\r
+       // static public String formatPercent(int val, int max) {\r
+       // String s = max > 0 && max >= val ? TString\r
+       // .formatAsPercentage((double) val / (double) max) : "";\r
+       // return s;\r
+       // }\r
+}\r
This page took 0.312787 seconds and 5 git commands to generate.