lttng: Javadoc udpate for the lttng2.kernel.ui package
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.kernel.ui / src / org / eclipse / linuxtools / internal / lttng2 / kernel / ui / views / controlflow / ControlFlowView.java
index de11dcf625d3bc6c5b8f028b6495312344eb41d8..8a27bda95cb1e9865914e9540b2198c22f4e1368 100644 (file)
@@ -1,11 +1,11 @@
 /*******************************************************************************\r
  * Copyright (c) 2012 Ericsson\r
- * \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
+ *\r
  * Contributors:\r
  *   Patrick Tasse - Initial API and implementation\r
  *******************************************************************************/\r
@@ -67,6 +67,10 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.TreeColumn;\r
 import org.eclipse.ui.IActionBars;\r
 \r
+/**\r
+ * The Control Flow view main object\r
+ *\r
+ */\r
 public class ControlFlowView extends TmfView {\r
 \r
     // ------------------------------------------------------------------------\r
@@ -110,6 +114,9 @@ public class ControlFlowView extends TmfView {
     // The timegraph entry list\r
     private ArrayList<ControlFlowEntry> fEntryList;\r
 \r
+    // The time graph entry list synchronization object\r
+    final private Object fEntryListSyncObj = new Object();\r
+\r
     // The start time\r
     private long fStartTime;\r
 \r
@@ -117,7 +124,7 @@ public class ControlFlowView extends TmfView {
     private long fEndTime;\r
 \r
     // The display width\r
-    private int fDisplayWidth;\r
+    private final int fDisplayWidth;\r
 \r
     // The zoom thread\r
     private ZoomThread fZoomThread;\r
@@ -127,9 +134,9 @@ public class ControlFlowView extends TmfView {
 \r
     // The previous resource action\r
     private Action fPreviousResourceAction;\r
-    \r
+\r
     // A comparator class\r
-    private ControlFlowEntryComparator fControlFlowEntryComparator = new ControlFlowEntryComparator();\r
+    private final ControlFlowEntryComparator fControlFlowEntryComparator = new ControlFlowEntryComparator();\r
 \r
     // ------------------------------------------------------------------------\r
     // Classes\r
@@ -241,12 +248,12 @@ public class ControlFlowView extends TmfView {
         }\r
     }\r
 \r
-    \r
+\r
     private class ZoomThread extends Thread {\r
-        private long fZoomStartTime;\r
-        private long fZoomEndTime;\r
-        private long fResolution;\r
-        private IProgressMonitor fMonitor;\r
+        private final long fZoomStartTime;\r
+        private final long fZoomEndTime;\r
+        private final long fResolution;\r
+        private final IProgressMonitor fMonitor;\r
 \r
         public ZoomThread(long startTime, long endTime) {\r
             super("ControlFlowView zoom"); //$NON-NLS-1$\r
@@ -258,7 +265,10 @@ public class ControlFlowView extends TmfView {
 \r
         @Override\r
         public void run() {\r
-            ArrayList<ControlFlowEntry> entryList = fEntryList;\r
+            ArrayList<ControlFlowEntry> entryList = null;\r
+            synchronized (fEntryListSyncObj) {\r
+                entryList = fEntryList;\r
+            }\r
             if (entryList == null) {\r
                 return;\r
             }\r
@@ -297,6 +307,9 @@ public class ControlFlowView extends TmfView {
     // Constructors\r
     // ------------------------------------------------------------------------\r
 \r
+    /**\r
+     * Constructor\r
+     */\r
     public ControlFlowView() {\r
         super(ID);\r
         fDisplayWidth = Display.getDefault().getBounds().width;\r
@@ -380,6 +393,12 @@ public class ControlFlowView extends TmfView {
     // Signal handlers\r
     // ------------------------------------------------------------------------\r
 \r
+    /**\r
+     * Handler for the experiment selected signal\r
+     *\r
+     * @param signal\r
+     *            The signal that's received\r
+     */\r
     @TmfSignalHandler\r
     public void experimentSelected(final TmfExperimentSelectedSignal<? extends ITmfEvent> signal) {\r
         if (signal.getExperiment().equals(fSelectedExperiment)) {\r
@@ -395,9 +414,15 @@ public class ControlFlowView extends TmfView {
         thread.start();\r
     }\r
 \r
+    /**\r
+     * Handler for the synch signal\r
+     *\r
+     * @param signal\r
+     *            The signal that's received\r
+     */\r
     @TmfSignalHandler\r
     public void synchToTime(final TmfTimeSynchSignal signal) {\r
-        if (signal.getSource() == this) {\r
+        if (signal.getSource() == this || fSelectedExperiment == null) {\r
             return;\r
         }\r
         final long time = signal.getCurrentTime().normalize(0, -9).getValue();\r
@@ -436,7 +461,7 @@ public class ControlFlowView extends TmfView {
             }\r
         }\r
         final int selectedThread = thread;\r
\r
+\r
         Display.getDefault().asyncExec(new Runnable() {\r
             @Override\r
             public void run() {\r
@@ -461,9 +486,15 @@ public class ControlFlowView extends TmfView {
         });\r
     }\r
 \r
+    /**\r
+     * Handler for the range sync signal\r
+     *\r
+     * @param signal\r
+     *            The signal that's received\r
+     */\r
     @TmfSignalHandler\r
     public void synchToRange(final TmfRangeSynchSignal signal) {\r
-        if (signal.getSource() == this) {\r
+        if (signal.getSource() == this || fSelectedExperiment == null) {\r
             return;\r
         }\r
         final long startTime = signal.getCurrentRange().getStartTime().normalize(0, -9).getValue();\r
@@ -482,6 +513,12 @@ public class ControlFlowView extends TmfView {
         });\r
     }\r
 \r
+    /**\r
+     * Handler for the state system build completed signal\r
+     *\r
+     * @param signal\r
+     *            The signal that's received\r
+     */\r
     @TmfSignalHandler\r
     public void stateSystemBuildCompleted (final TmfStateSystemBuildCompleted signal) {\r
         final TmfExperiment<?> selectedExperiment = fSelectedExperiment;\r
@@ -574,7 +611,9 @@ public class ControlFlowView extends TmfView {
                 buildTree(entryList, rootList);\r
             }\r
             Collections.sort(rootList, fControlFlowEntryComparator);\r
-            fEntryList = rootList;\r
+            synchronized (fEntryListSyncObj) {\r
+                fEntryList = (ArrayList<ControlFlowEntry>) rootList.clone();\r
+            }\r
             refresh(INITIAL_WINDOW_OFFSET);\r
         }\r
         for (ControlFlowEntry entry : rootList) {\r
@@ -661,7 +700,10 @@ public class ControlFlowView extends TmfView {
                 if (fTimeGraphCombo.isDisposed()) {\r
                     return;\r
                 }\r
-                ITimeGraphEntry[] entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
+                ITimeGraphEntry[] entries = null;\r
+                synchronized (fEntryListSyncObj) {\r
+                    entries = fEntryList.toArray(new ITimeGraphEntry[0]);\r
+                }\r
                 Arrays.sort(entries, fControlFlowEntryComparator);\r
                 fTimeGraphCombo.setInput(entries);\r
                 fTimeGraphCombo.getTimeGraphViewer().setTimeBounds(fStartTime, fEndTime);\r
This page took 0.026023 seconds and 5 git commands to generate.