Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / common / ParamsUpdater.java
index 5659066bd0ff6caf2f1dad672fa1a45cb04a663f..5f3b76d368096ba4e731be49d09d0b4a0503aca4 100644 (file)
  *******************************************************************************/
 package org.eclipse.linuxtools.lttng.ui.views.common;
 
-import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.core.event.LttngTimestamp;
 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+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;
 
 /**
@@ -33,15 +33,21 @@ public class ParamsUpdater {
        private long startTime = 0;
        private long endTime = Long.MAX_VALUE;
        private Long selectedTime = null;
-       private final int defaultWidth = 2000; // number of estimated pixels that
+       private final int DEFAULT_WIDTH = 2000; // number of estimated pixels
+                                                                                                       // that
        // can hold the time range space
-       private int width = defaultWidth; // width in pixels used to represent the
+       private int width = DEFAULT_WIDTH; // width in pixels used to represent the
        // time interval
        private double pixelsPerNs = 0;
        private int eventsDiscarded = 0;
+       private int eventsDiscardedOutOfView = 0;
+       private int eventsDiscardedNotVisible = 0;
        private int eventsDiscardedWrongOrder = 0;
        private TmfTimeRange trange = null;
 
+       public static final int OUT_OF_VIEWRANGE = 0;
+       public static final int NOT_VISIBLE = 1;
+
        // ========================================================================
        // Methods
        // ========================================================================
@@ -60,7 +66,14 @@ public class ParamsUpdater {
                        int dwidth = event.getWidth();
 
                        updated = update(time0, time1, dwidth);
-                       setSelectedTime(event.getSelectedTime());
+
+                       // initialization only, otherwise wait for the actual selection
+                       // event to update its value. Note that the time must be different
+                       // upon selection of a new time in order to trigger an update to all
+                       if (selectedTime == null) {
+                               setSelectedTime(event.getSelectedTime());
+                       }
+
                }
 
                return updated;
@@ -72,11 +85,9 @@ public class ParamsUpdater {
         * @param selTime
         */
        public void setSelectedTime(long selTime) {
-               if (selTime > startTime && selTime < endTime) {
-                       selectedTime = selTime;
-               } else {
-                       selectedTime = null;
-               }
+               TraceDebug.debug("Selected time changed from: \n\t" + selectedTime //$NON-NLS-1$
+                               + " to: \n\t" + selTime); //$NON-NLS-1$
+               selectedTime = selTime;
        }
 
        /**
@@ -141,16 +152,16 @@ public class ParamsUpdater {
                        // update succeeded
                        updated = true;
 
-                       TraceDebug.debug("Configuration updated to: StartTime: " /* */
+                       TraceDebug.debug("Configuration updated to: StartTime: " /* */ //$NON-NLS-1$
                                        + fTimeStart /* */
-                                       + "-" /* */
+                                       + "-" /* */ //$NON-NLS-1$
                                        + fTimeEnd /* */
-                                       + " width: " /* */
-                                       + width + " k: " + pixelsPerNs); /* */
+                                       + " width: " /* */ //$NON-NLS-1$
+                                       + width + " k: " + pixelsPerNs); /* */ //$NON-NLS-1$
                } else {
                        TraceDebug
-                                       .debug("End time is not greater than start time, start time: "
-                                                       + time0 + " end time: " + time1);
+                                       .debug("End time is not greater than start time, start time: " //$NON-NLS-1$
+                                                       + time0 + " end time: " + time1); //$NON-NLS-1$
                }
 
                return updated;
@@ -175,9 +186,9 @@ public class ParamsUpdater {
         */
        public int getWidth() {
                if (width == 0) {
-                       return defaultWidth;
-               } else {
-                       TraceDebug.debug("Unexpected width value of 0 pixels");
+                       TraceDebug
+                                       .debug("Unexpected width value of 0 pixels, returning default"); //$NON-NLS-1$
+                       return DEFAULT_WIDTH;
                }
 
                return width;
@@ -212,13 +223,23 @@ public class ParamsUpdater {
                eventsDiscarded = value;
                if (value == 0) {
                        eventsDiscardedWrongOrder = 0;
+                       eventsDiscardedNotVisible = 0;
+                       eventsDiscardedOutOfView = 0;
                }
        }
 
        /**
         * 
         */
-       public void incrementEventsDiscarded() {
+       public void incrementEventsDiscarded(int reason) {
+               if (reason == OUT_OF_VIEWRANGE) {
+                       this.eventsDiscardedOutOfView++;
+               }
+
+               if (reason == NOT_VISIBLE) {
+                       this.eventsDiscardedNotVisible++;
+               }
+
                this.eventsDiscarded++;
        }
 
@@ -246,6 +267,22 @@ public class ParamsUpdater {
 
        }
 
+       /**
+        * @return
+        */
+       public int getEventsDiscardedNotVisible() {
+               return eventsDiscardedNotVisible;
+
+       }
+
+       /**
+        * @return
+        */
+       public int getEventsDiscardedOutOfViewRange() {
+               return eventsDiscardedOutOfView;
+
+       }
+
        /**
         * @return
         */
This page took 0.026311 seconds and 5 git commands to generate.