New generation of HistogramView : first draft of what will replace TimeFrameView
authorWilliam Bourque <william.bourque@polymtl.ca>
Tue, 13 Apr 2010 05:22:08 +0000 (05:22 +0000)
committerWilliam Bourque <william.bourque@polymtl.ca>
Tue, 13 Apr 2010 05:22:08 +0000 (05:22 +0000)
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvas.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasMouseListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramCanvasPaintListener.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramConstant.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramContent.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramRequest.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramSelectedWindow.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/HistogramView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/NanosecTextGroup.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/ParentHistogramCanvas.java

index b51e4e05d365e578785c3271701bcd28f87cccbb..be8abebf2ac8d3eff7a69fa6e9faf8a459181973 100644 (file)
@@ -111,7 +111,7 @@ public class HistogramCanvas extends Canvas
                currentWindow = new HistogramSelectedWindow(histogramContent);
                
                currentWindow.setWindowTimeWidth(windowTimeDuration);
-               currentWindow.setWindowCenterXPosition(0);
+               currentWindow.setWindowXPositionCenter(0);
                
                // Warn the paint listener about the new window
                paintListener.setSelectedWindow(currentWindow);
@@ -168,14 +168,42 @@ public class HistogramCanvas extends Canvas
         * 
         */
        public void redrawAsynchronously() {
-               
                // Create a new redrawer in case it doesn't exist yet (we never know with thread!)
                if ( canvasRedrawer == null ) {
                        canvasRedrawer = new AsyncCanvasRedrawer(this);
                }
+               
                canvasRedrawer.asynchronousRedraw();
        }
        
+       /**
+        * Method to call the "Asynchronous NotifyParentSelectionWindowChanged" for this canvas<p>
+        * This allow safe update UI objects from different threads.
+        * 
+        */
+       public void notifyParentSelectionWindowChangedAsynchronously() {
+               // Create a new redrawer in case it doesn't exist yet (we never know with thread!)
+               if ( canvasRedrawer == null ) {
+                       canvasRedrawer = new AsyncCanvasRedrawer(this);
+               }
+               
+               canvasRedrawer.asynchronousNotifyParentSelectionWindowChanged();
+       }
+       
+       /**
+        * Method to call the "Asynchronous NotifyParentUpdatedInformation" for this canvas<p>
+        * This allow safe redraw from different threads.
+        * 
+        */
+       public void notifyParentUpdatedInformationAsynchronously() {
+               // Create a new redrawer in case it doesn't exist yet (we never know with thread!)
+               if ( canvasRedrawer == null ) {
+                       canvasRedrawer = new AsyncCanvasRedrawer(this);
+               }
+               
+               canvasRedrawer.asynchronousNotifyParentUpdatedInformation();
+       }
+       
        /**
         * Function that is called when the selection window is moved.<p>
         * Note: Given position should be relative to the previous (centered) absolute position.
index a812e8881b3d2451cd6fe4e10f56607e33a10800..760829325a2c3e5c8b5332c463fb460d2cd7640c 100644 (file)
@@ -72,7 +72,7 @@ public class HistogramCanvasMouseListener implements MouseMoveListener, MouseLis
        public void mouseUp(MouseEvent event) {
                if ( event.button == 1) {
                        isWindowMoving = false;
-                       parentCanvas.notifyParentSelectionWindowChanged();
+                       parentCanvas.notifyParentSelectionWindowChangedAsynchronously();
                }
        }
        
index 39a7cc6057bd05aafa99045f7f2ae9fdc9add8c9..5daff8c527964dce8210c1c9d04ae65132898f2d 100644 (file)
@@ -119,9 +119,9 @@ public class HistogramCanvasPaintListener implements PaintListener
                event.gc.setLineWidth(HistogramConstant.SELECTION_LINE_WIDTH);
            
                // Get the window position... this would fail if the window is not initialized yet
-               int positionCenter = selectedWindow.getWindowCenterXPosition();
-               int positionLeft = selectedWindow.getWindowPositionLeft();
-               int positionRight = selectedWindow.getWindowPositionRight();
+               int positionCenter = selectedWindow.getWindowXPositionCenter();
+               int positionLeft = selectedWindow.getWindowXPositionLeft();
+               int positionRight = selectedWindow.getWindowXPositionRight();
                
                // Minimal size verification.
                if ( (positionRight - positionLeft) < HistogramConstant.MINIMUM_WINDOW_WIDTH ) {
index 56d7d48057e74d1081c5f09f5b162e9f525ed09d..745bae0ad2f1967ee442029c056f344073ec761b 100644 (file)
@@ -12,6 +12,8 @@
 package org.eclipse.linuxtools.lttng.ui.views.histogram;
 
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Composite;
 
 /**
  * <b><u>HistogramConstant</u></b>
@@ -19,7 +21,7 @@ import org.eclipse.swt.SWT;
  * Empty interface class to hold the different constants needed by the histogram.
  * <p>
  */
-public interface HistogramConstant {
+public abstract class HistogramConstant {
        // Constants relative to requests
        final static int MAX_EVENTS_PER_READ = 1;
        final static int REDRAW_EVERY_NB_EVENTS = 10000;
@@ -60,4 +62,32 @@ public interface HistogramConstant {
        final static Integer MINIMUM_WINDOW_WIDTH = 3;
        final static Integer SELECTION_LINE_WIDTH = 2;
        final static Integer SELECTION_CROSSHAIR_LENGTH = 3;
+       
+       public static String formatNanoSecondsTime(Long nanosecTime) {
+               String returnedTime = nanosecTime.toString();
+               
+               if ( returnedTime.length() > 9 ) {
+                       returnedTime = returnedTime.substring(0, returnedTime.length() - 9 ) + "." + returnedTime.substring( returnedTime.length() - 9 );
+               }
+               else {
+                       int curSize = returnedTime.length();
+                       for (int l=0; (curSize+l)< 9; l++) {
+                               returnedTime = "0" + returnedTime;
+                       }
+                       returnedTime = "0." + returnedTime;
+               }
+               
+               return returnedTime;
+       }
+       
+       public static Integer getTextSizeInControl(Composite parent, String text) {
+               GC graphicContext = new GC(parent);
+        int textSize = 0;
+        for ( int pos=0; pos<text.length(); pos++ ) {
+               textSize += graphicContext.getAdvanceWidth( text.charAt(pos) );
+        }
+        textSize += graphicContext.getAdvanceWidth( ' ' );
+        
+        return textSize;
+       }
 }
index 5dfd0caa318fa81b91d0beaed8491cf2da2ff6d9..a26c1e68df60008d2d548d81fc551978d490db0a 100644 (file)
@@ -86,7 +86,7 @@ public class HistogramContent {
        /**
         * Reset all HistogramContent attributes, but keep the elements table untouched.<p>
         */
-       public void resetContentData() {
+       public void clearContentData() {
                startTime = 0L;
                endTime = 0L;
                
@@ -99,7 +99,7 @@ public class HistogramContent {
        
        /**
         * Reset the data in the elements table.<p>
-        * NOTE : For this to be consistent and usuable, "startTime" and "intervalTime" need to be set.
+        * NOTE : For this to be consistent and usuable, "startTime", "endTime" and "intervalTime" need to be set already.
         */
        public void resetTable() {
                for ( int x=0; x<elementTable.length; x++) {
@@ -110,6 +110,39 @@ public class HistogramContent {
                }
        }
        
+       /**
+        * Reset the data in the elements table.<p>
+        * NOTE : For this to be consistent and usuable, "startTime" and "intervalTime" need to be set.
+        */
+       public void resetTable(Long newStartTime, Long newEndTime, Long newIntervalTime) {
+               
+               startTime = newStartTime;
+               endTime = newEndTime;
+               intervalTime = newIntervalTime;
+               
+               for ( int x=0; x<elementTable.length; x++) {
+                       elementTable[x].position = x;
+                       elementTable[x].firstIntervalTimestamp = startTime + (x*intervalTime);
+                       elementTable[x].intervalNbEvents = 0L;
+                       elementTable[x].intervalHeight = 0;
+               }
+       }
+       
+       
+       /**
+        * Clear (zeroed) the data in the elements table.<p>
+        * NOTE : Unlike reset, this does not recalculate the content, 
+        *                      so it should be done either by hand or by calling reset table after.
+        */
+       public void clearTable() {
+               for ( int x=0; x<elementTable.length; x++) {
+                       elementTable[x].position = x;
+                       elementTable[x].firstIntervalTimestamp = 0L;
+                       elementTable[x].intervalNbEvents = 0L;
+                       elementTable[x].intervalHeight = 0;
+               }
+       }
+       
        /**
         * Print all HistogramContent attributes, but the elements table.
         */
@@ -129,7 +162,7 @@ public class HistogramContent {
         */
        public void printTable() {
                for ( int x=0; x<elementTable.length; x++) {
-                       System.out.println("X:" + x + " -> " + elementTable[x].intervalNbEvents + ":" + elementTable[x].intervalHeight);
+                       System.out.println("X:" + x + " -> " + elementTable[x].intervalNbEvents + ":" + elementTable[x].intervalHeight + " (" + elementTable[x].firstIntervalTimestamp + ")");
                }
        }
        
@@ -178,6 +211,21 @@ public class HistogramContent {
                return elementTable[index];
        }
        
+       /**
+        * Return the closest element's timestamp to a X position on the canvas.<p>
+        * Note : canvasFullSize need to be set correctly here, otherwise unexpected timestamp might be returned.<p>
+        * <p>
+        * NOTE : This <b>ALWAYS</b> return a timestamp; 
+        *              If calculation lead outside the table, the first or the last timestamp will be returned.  
+        * 
+        * @param position  The X position we are looking at (0 < pos < canvasWidth) 
+        * 
+        * @return      The <i>closest</i> timestamp found.
+        */
+       public Long getClosestTimestampFromXPosition(int position) {
+               return getClosestElementFromXPosition(position).firstIntervalTimestamp;
+       }
+       
        /**
         * Return the X position (relative to the canvas) of a certain element.<p>
         * Note : canvasFullSize need to be set correctly here, otherwise unexpected element might be returned.<p>
@@ -218,6 +266,21 @@ public class HistogramContent {
                return elementTable[index];
        }
        
+       /**
+        * Return the closest X position to a timestamp (long) given.<p>
+        * Note : startTime and intervalTime need to be set correctly here, otherwise unexpected position might be returned.<p>
+        * <p>
+        * NOTE : This <b>ALWAYS</b> return a position; 
+        *              If calculation lead outside the table, the first or the last position will be returned.  
+        * 
+        * @param timestamp  The timestamp (in nanosecond, as long) of the element we are looking for (startTime < timestamp < endTime) 
+        * 
+        * @return      The <i>closest</i> position found.
+        */
+       public Integer getClosestXPositionFromTimestamp(long timestamp) {
+               return getXPositionFromElement(getClosestElementFromTimestamp(timestamp));
+       }
+       
        /**
         * Return the closest element to an element and a time interval to this element.<p>
         * The time interval can be negative or positive (before or after the element).
index 3c7e72771e5341219748bc52f3015ce1c2a3ae87..d0968a68442f300f22a561b7f3d624252d457b14 100644 (file)
@@ -54,18 +54,18 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
         // This does not work! The request won't be processed or the number of events returned is wrong!
         // We cannot use this !
                //super((Class<LttngEvent>)dataType, range);
-               
+        
         parentCanvas = newParentCanvas;
         histogramContent = parentCanvas.getHistogramContent();
         
         // Reset the content of the HistogramContent... the given data better be valid or this will fail.
-        histogramContent.resetContentData();
-        histogramContent.setStartTime(range.getStartTime().getValue());
-        histogramContent.setEndTime(range.getEndTime().getValue());
-        histogramContent.setIntervalTime(timeInterval);
-        histogramContent.resetTable();
+        histogramContent.clearContentData();
+        histogramContent.resetTable(range.getStartTime().getValue(), range.getEndTime().getValue(), timeInterval);
+        
+        lastRangeTime = range.getStartTime().getValue();
         
-        lastRangeTime = histogramContent.getStartTime();
+        // Notify the UI even before the request started, so we set the timestamp already.
+        parentCanvas.notifyParentUpdatedInformationAsynchronously();
     }
        
        /**
@@ -89,7 +89,9 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
                LttngEvent tmpEvent = (LttngEvent)evt[0];
                
                // This check is linked to the evil fix mentionned above
-               if ( tmpEvent.getTimestamp().getValue() <= histogramContent.getEndTime() ) {
+               if ( ( tmpEvent.getTimestamp().getValue() >= histogramContent.getStartTime() ) &&
+                        ( tmpEvent.getTimestamp().getValue() <= histogramContent.getEndTime() ) )
+               {
                        
                        // Distance (in time) between this event and the last one we read
                        long distance = ( tmpEvent.getTimestamp().getValue() - lastRangeTime );
@@ -140,17 +142,16 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
                                }
                }
                else {
+                       //System.out.println("Requested Timerange is : " + histogramContent.getStartTime() + " / " + histogramContent.getEndTime());
+                       //System.out.println("Time is : " + tmpEvent.getTimestamp().getValue());
                        // *** FIXME ***
                // *** EVIL FIX ***
                 // Because of the other evil bug (see above), we have to ignore extra useless events we will get
                        // However, we might be far away from the end so we better start a redraw now
-                       redrawAsyncronously();
-                       requestCompleted = true;
-                       
-                       // Althought it won't do anything, try to call control functions to stop the request
-                       done();
-                       cancel();
-                       fail();
+                       if (tmpEvent.getTimestamp().getValue() >= histogramContent.getEndTime()) {
+                               redrawAsyncronously();
+                               requestCompleted = true;
+                       }
                }
                }
     }
@@ -161,7 +162,7 @@ public class HistogramRequest extends TmfEventRequest<LttngEvent> {
         */
     @Override
     public void handleCompleted() {
-       parentCanvas.canvasRedrawer.asynchronousNotifyParentUpdatedInformation();
+       parentCanvas.notifyParentUpdatedInformationAsynchronously();
                redrawAsyncronously();
     }
     
index 70a4b031e799ce40f1a19dc9fa1868629750c9b4..f2025ccbb508f4cd6b41f5337e7ffe92a4f80f50 100644 (file)
@@ -27,7 +27,7 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
  */
 public class HistogramSelectedWindow {
        
-       private int windowCenterXPosition = 0;
+       private int windowCenterPosition = 0;
        private long windowTimeWidth = 0;
        
        private boolean isSelectedWindowVisible = false;
@@ -54,7 +54,7 @@ public class HistogramSelectedWindow {
         */
        public HistogramSelectedWindow(HistogramContent newTraceContent, int centralPosition, long newWindowWidth) {
                histogramContent = newTraceContent;
-               windowCenterXPosition = centralPosition;
+               windowCenterPosition = centralPosition;
                windowTimeWidth = newWindowWidth;
        }
        
@@ -124,8 +124,8 @@ public class HistogramSelectedWindow {
         * 
         * @return Center X position of this window on the canvas.
         */
-       public int getWindowCenterXPosition() {
-               return windowCenterXPosition;
+       public int getWindowXPositionCenter() {
+               return windowCenterPosition;
        }
        
        /**
@@ -134,8 +134,8 @@ public class HistogramSelectedWindow {
         * 
         * @param newPosCenter  The new central position.
         */
-       public void setWindowCenterXPosition(int newPosCenter) {
-               this.windowCenterXPosition = newPosCenter;
+       public void setWindowXPositionCenter(int newPosCenter) {
+               this.windowCenterPosition = newPosCenter;
        }
        
        
@@ -145,8 +145,8 @@ public class HistogramSelectedWindow {
         * 
         * @return The left position of the window, or 0 if it cannot compute it. 
         */
-       public int getWindowPositionLeft() {
-               return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterXPosition, -(windowTimeWidth / 2) );
+       public Integer getWindowXPositionLeft() {
+               return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, -(windowTimeWidth / 2) );
        }
        
        /**
@@ -155,8 +155,8 @@ public class HistogramSelectedWindow {
         * 
         * @return The right position of the window, or 0 if it cannot compute it. 
         */
-       public int getWindowPositionRight() {
-               return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterXPosition, +(windowTimeWidth / 2) );
+       public Integer getWindowXPositionRight() {
+               return histogramContent.getXPositionByPositionAndTimeInterval(windowCenterPosition, +(windowTimeWidth / 2) );
        }
        
        /**
@@ -165,8 +165,18 @@ public class HistogramSelectedWindow {
         * 
         * @return  The left timestamp of the window, or 0 if it cannot compute it. 
         */
-       public long getTimestampLeft() {
-               return histogramContent.getClosestElementFromXPosition( getWindowPositionLeft() ).firstIntervalTimestamp;
+       public Long getTimestampLeft() {
+               return histogramContent.getClosestElementFromXPosition( getWindowXPositionLeft() ).firstIntervalTimestamp;
+       }
+       
+       /**
+        * Getter for the timestamp of the center of the window.<p>
+        * Compute the timestamp from the HistogramContent data; may return 0 if the content data are wrong.  
+        * 
+        * @return  The center timestamp of the window, or 0 if it cannot compute it. 
+        */
+       public Long getTimestampCenter() {
+               return histogramContent.getClosestElementFromXPosition( getWindowXPositionCenter() ).firstIntervalTimestamp;
        }
        
        /**
@@ -175,7 +185,7 @@ public class HistogramSelectedWindow {
         * 
         * @return  The right timestamp of the window, or 0 if it cannot compute it. 
         */
-       public long getTimestampRight() {
-               return histogramContent.getClosestElementFromXPosition( getWindowPositionRight() ).firstIntervalTimestamp;
+       public Long getTimestampRight() {
+               return histogramContent.getClosestElementFromXPosition( getWindowXPositionRight() ).firstIntervalTimestamp;
        }
 }
index 3bd8c597365e4d6c65d974b13da396eab9c3e4b0..dfb867a4d22120cf00ce3157f8f2343da891fad2 100644 (file)
@@ -15,6 +15,7 @@ package org.eclipse.linuxtools.lttng.ui.views.histogram;
 import org.eclipse.linuxtools.lttng.event.LttngEvent;
 import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
 import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
 import org.eclipse.linuxtools.tmf.experiment.TmfExperimentSelectedSignal;
 import org.eclipse.linuxtools.tmf.experiment.TmfExperimentUpdatedSignal;
@@ -23,28 +24,43 @@ import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
 import org.eclipse.linuxtools.tmf.ui.views.TmfView;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
 
 public class HistogramView extends TmfView {
 
     public static final String ID = "org.eclipse.linuxtools.lttng.ui.views.histogram";
     
-    private static int FULL_TRACE_CANVAS_HEIGHT = 50;
-    private static int FULL_TRACE_BAR_WIDTH = 1;
-    private static double FULL_TRACE_DIFFERENCE_TO_AVERAGE = 2.0;
     
-    private static int SELECTED_WINDOW_CANVAS_WIDTH = 300;
-    private static int SELECTED_WINDOW_CANVAS_HEIGHT = 100;
-    private static int SELECTED_WINDOW_BAR_WIDTH = 1;
-    private static double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE = 10.0;
+    private static final boolean TEST_UI = true;
+    
+    
+    private static final int FULL_TRACE_CANVAS_HEIGHT = 25;
+    private static final int FULL_TRACE_BAR_WIDTH = 1;
+    private static final double FULL_TRACE_DIFFERENCE_TO_AVERAGE = 2.0;
+    
+    private static final int SELECTED_WINDOW_CANVAS_WIDTH = 600;
+    private static final int SELECTED_WINDOW_CANVAS_HEIGHT = 75;
+    private static final int SELECTED_WINDOW_BAR_WIDTH = 1;
+    private static final double SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE = 10.0;
+    
+    // For the two "events" label (Max and min number of events in the selection), we force a width
+    // This will prevent the control from moving horizontally if the number of events in the selection varies
+    private static final int NB_EVENTS_FIXED_WIDTH = 75;
+    
+    
+    // The "small font" height used to display time will be "default font" minus this constant
+    private static final int SMALL_FONT_MODIFIER = 2;
     
     // *** TODO ***
     // This need to be changed as soon the framework implement a "window"
     private static long DEFAULT_WINDOW_SIZE = (1L * 1000000000);
     
+    
     private TmfExperiment<LttngEvent> lastUsedExperiment = null;
     
     private HistogramRequest dataBackgroundFullRequest = null;
@@ -53,11 +69,24 @@ public class HistogramView extends TmfView {
        private HistogramRequest selectedWindowRequest = null;
     private ChildrenHistogramCanvas selectedWindowCanvas = null;
     
-       private Label lblStartTime = null;
-       private Label lblStopTime = null;
-       private Label lblTopEvent = null;
-       private Label lblBottomEvent = null;
     
+    
+    
+       private Text txtExperimentStartTime = null;
+       private Text txtExperimentStopTime = null;
+       
+       private Text  txtWindowStartTime = null;
+       private Text  txtWindowStopTime  = null;
+       private Label lblWindowMaxNbEvents = null;
+       private Label lblWindowMinNbEvents = null;
+    
+       private static final String WINDOW_TIMERANGE_LABEL_TEXT         = "Window Timerange   ";
+       private static final String WINDOW_CURRENT_TIME_LABEL_TEXT      = "Window Current Time";
+       private static final String EVENT_CURRENT_TIME_LABEL_TEXT       = "Event Current Time ";
+       private NanosecTextGroup  ntgTimeRangeWindow = null;
+       private NanosecTextGroup  ntgCurrentWindowTime = null;
+       private NanosecTextGroup  ntgCurrentEventTime = null;
+       
        public HistogramView() {
                super(ID);
        }
@@ -65,75 +94,188 @@ public class HistogramView extends TmfView {
        @Override
        public void createPartControl(Composite parent) {
                
+               // Default font
                Font font = parent.getFont();
-               Composite folderGroup = new Composite(parent, SWT.BORDER);
-               
-               GridLayout gridLayout = new GridLayout();
-               gridLayout.numColumns = 3;
-               gridLayout.verticalSpacing = 2;
-               gridLayout.marginHeight = 0;
-               gridLayout.marginWidth = 0;
-               folderGroup.setLayout(gridLayout);
-               folderGroup.setSize(parent.getDisplay().getBounds().width, parent.getDisplay().getBounds().height);
-               
-               GridData gridData1 = new GridData(SWT.FILL, SWT.TOP, true, false, 3, 2);
-               gridData1.heightHint = FULL_TRACE_CANVAS_HEIGHT;
-               gridData1.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
-               fullTraceCanvas = new ParentHistogramCanvas(this, folderGroup, SWT.BORDER);
-               fullTraceCanvas.setLayoutData(gridData1);
-               fullTraceCanvas.redraw();
-               
-               GridData gridData2 = new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 2);
-               gridData2.minimumWidth = 200;
-               gridData2.grabExcessHorizontalSpace = true;
-               lblStartTime = new Label(folderGroup, SWT.LEFT | SWT.TOP);
-               lblStartTime.setFont(font);
-               lblStartTime.setText("");
-               lblStartTime.setAlignment(SWT.LEFT);
-               lblStartTime.setLayoutData(gridData2);
-               
-               GridData gridData3 = new GridData(SWT.RIGHT, SWT.TOP, true, false, 1, 2);
-               gridData3.minimumWidth = 200;
-               gridData3.grabExcessHorizontalSpace = true;
-               lblStopTime = new Label(folderGroup, SWT.RIGHT | SWT.TOP);
-               lblStopTime.setFont(font);
-               lblStopTime.setAlignment(SWT.RIGHT);
-               lblStopTime.setText("");
-               lblStopTime.setLayoutData(gridData3);
-               
-               GridData gridDataSpace = new GridData(SWT.FILL, SWT.TOP, true, false, 3, 2);
-               gridDataSpace.minimumHeight = 20;
-               gridDataSpace.heightHint = 20;
-               Label lblSpace = new Label(folderGroup, SWT.TOP);
-               lblSpace.setFont(font);
-               lblSpace.setText("");
-               lblSpace.setLayoutData(gridDataSpace);
-               
-               GridData gridData4 = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 2);
-               gridData4.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
-               gridData4.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
-               gridData4.widthHint = SELECTED_WINDOW_CANVAS_WIDTH;
-               gridData4.minimumWidth = SELECTED_WINDOW_CANVAS_WIDTH;
-               selectedWindowCanvas = new ChildrenHistogramCanvas(this, folderGroup, SWT.BORDER);
-               selectedWindowCanvas.setLayoutData(gridData4);
-               selectedWindowCanvas.redraw();
-               
-               
-               GridData gridData5 = new GridData(SWT.LEFT, SWT.TOP, true, false, 2, 1);
-               gridData5.minimumWidth = 150;
-               gridData5.grabExcessHorizontalSpace = true;
-               lblTopEvent = new Label(folderGroup, SWT.LEFT | SWT.TOP);
-               lblTopEvent.setFont(font);
-               lblTopEvent.setText("");
-               lblTopEvent.setLayoutData(gridData5);
-               
-               GridData gridData6 = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 2, 1);
-               gridData6.minimumWidth = 150;
-               gridData6.grabExcessHorizontalSpace = true;
-               lblBottomEvent = new Label(folderGroup, SWT.LEFT | SWT.BOTTOM);
-               lblBottomEvent.setFont(font);
-               lblBottomEvent.setText("");
-               lblBottomEvent.setLayoutData(gridData6);
+               FontData tmpFontData = font.getFontData()[0];
+               // Slightly smaller font for time
+               Font smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight() - SMALL_FONT_MODIFIER, tmpFontData.getStyle());
+               
+               
+               // Layout for the whole view, other elements will be in a child composite of this one 
+               // Contains :
+               //              Composite layoutSelectionWindow
+               //              Composite layoutTimesSpinner
+               //              Composite layoutExperimentHistogram
+               Composite layoutFullView = new Composite(parent, SWT.NONE);
+               GridLayout gridFullView = new GridLayout();
+               gridFullView.numColumns = 2;
+               gridFullView.marginHeight = 0;
+               gridFullView.marginWidth = 0;
+               layoutFullView.setLayout(gridFullView);
+               //layoutFullView.setSize(parent.getDisplay().getBounds().width, parent.getDisplay().getBounds().height);
+               
+               
+               // Layout that contain the SelectionWindow
+               // Contains : 
+               //              Label lblWindowStartTime
+               //              Label lblWindowStopTime
+               //              Label lblWindowMaxNbEvents
+               //              Label lblWindowMinNbEvents
+               //              ChildrenHistogramCanvas selectedWindowCanvas
+               Composite layoutSelectionWindow = new Composite(layoutFullView, SWT.NONE);
+               GridLayout gridSelectionWindow = new GridLayout();
+               gridSelectionWindow.numColumns = 3;
+               gridSelectionWindow.marginHeight = 0;
+               gridSelectionWindow.marginWidth = 0;
+               layoutSelectionWindow.setLayout(gridSelectionWindow);
+               GridData gridDataSelectionWindow = new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1);
+               layoutSelectionWindow.setLayoutData(gridDataSelectionWindow);
+               
+               
+               // Layout that contain the time spinner
+               // Contains : 
+               //              NanosecTextGroup  spTimeRangeWindow
+               //              NanosecTextGroup  spCurrentWindowTime
+               //              NanosecTextGroup  spCurrentEventTime
+               Composite layoutTimesSpinner = new Composite(layoutFullView, SWT.NONE);
+               GridLayout gridTimesSpinner = new GridLayout();
+               
+               if ( TEST_UI ) {
+                       gridTimesSpinner.numColumns = 3;
+               }
+               else {
+                       gridTimesSpinner.numColumns = 2;
+               }
+               gridTimesSpinner.marginHeight = 0;
+               gridTimesSpinner.marginWidth = 0;
+               layoutTimesSpinner.setLayout(gridTimesSpinner);
+               GridData gridDataTimesSpinner = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
+               layoutTimesSpinner.setLayoutData(gridDataTimesSpinner);
+               
+               
+               // Layout that contain the complete experiment histogram and related controls.
+               // Contains : 
+               //              Label lblExperimentStartTime
+               //              Label lblExperimentStopTime
+               //              ParentHistogramCanvas fullTraceCanvas
+               Composite layoutExperimentHistogram = new Composite(layoutFullView, SWT.NONE);
+               GridLayout gridExperimentHistogram = new GridLayout();
+               gridExperimentHistogram.numColumns = 2;
+               gridExperimentHistogram.marginHeight = 0;
+               gridExperimentHistogram.marginWidth = 0;
+               layoutExperimentHistogram.setLayout(gridExperimentHistogram);
+               GridData gridDataExperimentHistogram = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
+               layoutExperimentHistogram.setLayoutData(gridDataExperimentHistogram);
+               
+               
+               
+               // *** Everything related to the selection window is below
+               GridData gridDataSelectionWindowCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 2);
+               gridDataSelectionWindowCanvas.heightHint = SELECTED_WINDOW_CANVAS_HEIGHT;
+               gridDataSelectionWindowCanvas.minimumHeight = SELECTED_WINDOW_CANVAS_HEIGHT;
+               
+               int size = 0;
+               if ( TEST_UI ) {
+                       size = SELECTED_WINDOW_CANVAS_WIDTH/2;
+               }
+               else {
+                       size = SELECTED_WINDOW_CANVAS_WIDTH;
+               }
+               
+               gridDataSelectionWindowCanvas.widthHint = size;
+               gridDataSelectionWindowCanvas.minimumWidth = size;
+               
+               
+               selectedWindowCanvas = new ChildrenHistogramCanvas(this, layoutSelectionWindow, SWT.BORDER);
+               selectedWindowCanvas.setLayoutData(gridDataSelectionWindowCanvas);
+               
+               GridData gridDataWindowMaxEvents = new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1);
+               // Force a width, to avoid the control to enlarge if the number of events change
+               gridDataWindowMaxEvents.minimumWidth = NB_EVENTS_FIXED_WIDTH;
+               gridDataWindowMaxEvents.widthHint = NB_EVENTS_FIXED_WIDTH;
+               lblWindowMaxNbEvents = new Label(layoutSelectionWindow, SWT.NONE);
+               lblWindowMaxNbEvents.setFont(smallFont);
+               lblWindowMaxNbEvents.setText("");
+               lblWindowMaxNbEvents.setLayoutData(gridDataWindowMaxEvents);
+               
+               GridData gridDataWindowMinEvents = new GridData(SWT.LEFT, SWT.BOTTOM, true, false, 1, 1);
+               // Force a width, to avoid the control to enlarge if the number of events change
+               gridDataWindowMinEvents.minimumWidth = NB_EVENTS_FIXED_WIDTH;
+               gridDataWindowMinEvents.widthHint = NB_EVENTS_FIXED_WIDTH;
+               lblWindowMinNbEvents = new Label(layoutSelectionWindow, SWT.NONE);
+               lblWindowMinNbEvents.setFont(smallFont);
+               lblWindowMinNbEvents.setText("");
+               lblWindowMinNbEvents.setLayoutData(gridDataWindowMinEvents);
+               
+               GridData gridDataWindowStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
+               txtWindowStartTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
+               txtWindowStartTime.setFont(smallFont);
+               txtWindowStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
+               txtWindowStartTime.setEditable(false);
+               txtWindowStartTime.setText("");
+               txtWindowStartTime.setLayoutData(gridDataWindowStart);
+               
+               GridData gridDataWindowStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
+               txtWindowStopTime = new Text(layoutSelectionWindow, SWT.READ_ONLY);
+               txtWindowStopTime.setFont(smallFont);
+               txtWindowStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
+               txtWindowStopTime.setEditable(false);
+               txtWindowStopTime.setText("");
+               txtWindowStopTime.setLayoutData(gridDataWindowStop);
+               
+               
+               
+               // *** Everything related to the spinner is below
+               if ( TEST_UI ) {
+                       GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
+                       ntgCurrentWindowTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
+                       ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
+                       
+                       GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
+                       ntgTimeRangeWindow = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
+                       ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
+                       
+                       GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 2);
+                       ntgCurrentEventTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
+                       ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
+               }
+               else {
+                       GridData gridDataTimeRange = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1);
+                       ntgTimeRangeWindow = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_TIMERANGE_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
+                       ntgTimeRangeWindow.setLayoutData(gridDataTimeRange);
+                       
+                       GridData gridDataCurrentEvent = new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 2);
+                       ntgCurrentEventTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, EVENT_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
+                       ntgCurrentEventTime.setLayoutData(gridDataCurrentEvent);
+                       
+                       GridData gridDataCurrentWindow = new GridData(SWT.CENTER, SWT.BOTTOM, true, false, 1, 1);
+                       ntgCurrentWindowTime = new NanosecTextGroup(layoutTimesSpinner, SWT.BORDER, SWT.BORDER, WINDOW_CURRENT_TIME_LABEL_TEXT, HistogramConstant.formatNanoSecondsTime( 0L ));
+                       ntgCurrentWindowTime.setLayoutData(gridDataCurrentWindow);
+               }
+               
+               
+               // Everything related to the experiment canvas is below
+               GridData gridDataExperimentCanvas = new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1);
+               gridDataExperimentCanvas.heightHint = FULL_TRACE_CANVAS_HEIGHT;
+               gridDataExperimentCanvas.minimumHeight = FULL_TRACE_CANVAS_HEIGHT;
+               fullTraceCanvas = new ParentHistogramCanvas(this, layoutExperimentHistogram, SWT.BORDER);
+               fullTraceCanvas.setLayoutData(gridDataExperimentCanvas);
+               
+               GridData gridDataExperimentStart = new GridData(SWT.LEFT, SWT.TOP, false, false, 1, 1);
+               txtExperimentStartTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
+               txtExperimentStartTime.setFont(smallFont);
+               txtExperimentStartTime.setText("");
+               txtExperimentStartTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
+               txtExperimentStartTime.setEditable(false);
+               txtExperimentStartTime.setLayoutData(gridDataExperimentStart);
+               
+               GridData gridDataExperimentStop = new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1);
+               txtExperimentStopTime = new Text(layoutExperimentHistogram, SWT.READ_ONLY);
+               txtExperimentStopTime.setFont(smallFont);
+               txtExperimentStopTime.setText("");
+               txtExperimentStopTime.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_TITLE_INACTIVE_BACKGROUND));
+               txtExperimentStopTime.setEditable(false);
+               txtExperimentStopTime.setLayoutData(gridDataExperimentStop);
        }
        
        
@@ -157,17 +299,40 @@ public class HistogramView extends TmfView {
        createCanvasAndRequests(tmpExperiment);
     }
     
+    @TmfSignalHandler
+    public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
+       System.out.println("experimentUpdated");
+       
+       // *** TODO ***
+       // Update the histogram if the time changed
+       //
+    }
+    
+    @TmfSignalHandler
+    public void currentTimeUpdated(TmfTimeSynchSignal signal) {
+       if (signal.getSource() != this) {
+            TmfTimestamp currentTime = signal.getCurrentTime();
+            ntgCurrentEventTime.setValue(currentTime.getValue());
+            
+            if ( (currentTime.getValue() < fullTraceCanvas.getCurrentWindow().getTimestampLeft() ) ||
+                (currentTime.getValue() > fullTraceCanvas.getCurrentWindow().getTimestampRight() ) )
+            {
+               fullTraceCanvas.centerWindow( fullTraceCanvas.getHistogramContent().getClosestXPositionFromTimestamp(currentTime.getValue()) );
+               windowChangedNotification();
+            }
+            
+       }
+    }
+    
     public void createCanvasAndRequests(TmfExperiment<LttngEvent> newExperiment) {
        lastUsedExperiment = newExperiment;
        
-       String startTime = formatNanoSecondsTime( newExperiment.getStartTime().getValue() );
-               String stopTime = formatNanoSecondsTime( newExperiment.getEndTime().getValue() );
-       lblStartTime.setText( startTime );
-               lblStopTime.setText( stopTime );
-       
                fullTraceCanvas.createNewHistogramContent( DEFAULT_WINDOW_SIZE, FULL_TRACE_BAR_WIDTH, FULL_TRACE_CANVAS_HEIGHT, FULL_TRACE_DIFFERENCE_TO_AVERAGE);
                selectedWindowCanvas.createNewHistogramContent(0, SELECTED_WINDOW_BAR_WIDTH, SELECTED_WINDOW_CANVAS_HEIGHT, SELECTED_WINDOW_DIFFERENCE_TO_AVERAGE);
                
+               // Make sure the UI object are sane
+               resetLabelContent();
+               
                // Redraw the canvas right away to have something "clean" as soon as we can
        if ( dataBackgroundFullRequest != null ) {
                fullTraceCanvas.redraw();
@@ -194,7 +359,7 @@ public class HistogramView extends TmfView {
                
         if ( ts2.getValue() > experiment.getEndTime().getValue() ) {
                ts2 = new LttngTimestamp( experiment.getEndTime().getValue() );
-        } 
+        }
         
         TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2);
         
@@ -235,7 +400,6 @@ public class HistogramView extends TmfView {
         // HOWEVER, this would cause the request to run forever (or until it reach the end of trace).
         // Seeting an EndTime does not seems to stop the request
         returnedRequest = new HistogramRequest(newRange, Integer.MAX_VALUE, targetCanvas, newInterval );
-        
         experiment.sendRequest(returnedRequest);
         
         return returnedRequest;
@@ -243,10 +407,13 @@ public class HistogramView extends TmfView {
 
     
     public void windowChangedNotification() {
+       // *** NO GUI UPDATE SHOULD BE DONE IN HERE !! ***
+       
        if ( lastUsedExperiment != null ) {
                if ( selectedWindowRequest.isCompleted() == false ) {
                        selectedWindowRequest.cancel();
                }
+               
                performSelectedWindowEventsRequest(lastUsedExperiment);
        }
     }
@@ -262,25 +429,6 @@ public class HistogramView extends TmfView {
     }
     
     
-    @TmfSignalHandler
-    public void experimentUpdated(TmfExperimentUpdatedSignal signal) {
-       System.out.println("experimentUpdated");
-       
-       // *** TODO ***
-       // Update the histogram if the time changed
-       //
-    }
-    
-    
-    @TmfSignalHandler
-    public void currentTimeUpdated(TmfTimeSynchSignal signal) {
-       System.out.println("currentTimeUpdated");
-       
-       // *** TODO ***
-       // Update the histogram if the time changed
-       //
-    }
-    
        public TmfExperiment<LttngEvent> getLastUsedExperiment() {
                return lastUsedExperiment;
        }
@@ -293,29 +441,77 @@ public class HistogramView extends TmfView {
                fullTraceCanvas.setSelectedWindowSize(newTimeWidth);
        }
        
-       public String formatNanoSecondsTime(Long nanosecTime) {
-               String returnedTime = nanosecTime.toString();
-               if ( returnedTime.length() > 9 ) {
-                       returnedTime = returnedTime.substring(0, returnedTime.length() - 9 ) + "." + returnedTime.substring( returnedTime.length() - 9 );
+       public void resetLabelContent() {
+               
+               TmfExperiment<LttngEvent> tmpExperiment = getLastUsedExperiment();
+               
+               String startTime = null;
+               String stopTime = null;
+               if ( tmpExperiment != null ) {
+                       startTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getStartTime().getValue() );
+                       stopTime = HistogramConstant.formatNanoSecondsTime( tmpExperiment.getEndTime().getValue() );
                }
+               else {
+                       startTime = HistogramConstant.formatNanoSecondsTime( 0L );
+                       stopTime = HistogramConstant.formatNanoSecondsTime( 0L );
+               }
+               
+       txtExperimentStartTime.setText( startTime );
+               txtExperimentStopTime.setText( stopTime );
+               txtExperimentStartTime.getParent().layout();
+               
+               lblWindowMaxNbEvents.setText("" + 0);
+               lblWindowMinNbEvents.setText("" + 0);
+               txtWindowStartTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
+               txtWindowStopTime.setText( HistogramConstant.formatNanoSecondsTime( 0L ) );
+               txtWindowStartTime.getParent().layout();
                
-               return returnedTime;
+               ntgCurrentWindowTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
+               ntgTimeRangeWindow.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
+               ntgCurrentEventTime.setValue( HistogramConstant.formatNanoSecondsTime( 0L ) );
        }
        
        public void updateFullTraceInformation() {
                
-               String startTime = formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getStartTime() );
-               String stopTime = formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getEndTime() );
+               String startTime = HistogramConstant.formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getStartTime() );
+               String stopTime = HistogramConstant.formatNanoSecondsTime( fullTraceCanvas.getHistogramContent().getEndTime() );
                
-               lblStartTime.setText( startTime );
-               lblStopTime.setText( stopTime );
+               txtExperimentStartTime.setText( startTime );
+               txtExperimentStopTime.setText( stopTime );
+               
+               // Take one of the parent and call its layout to update control size
+               // Since both control have the same parent, only one call is needed 
+               txtExperimentStartTime.getParent().layout();
+               
+               // Update the selected window, just in case
+               // This should give a better user experience and it is low cost 
+               updateSelectedWindowInformation();
        }
        
        public void updateSelectedWindowInformation() {
-               lblTopEvent.setText( selectedWindowCanvas.getHistogramContent().getHeighestEventCount().toString() );
-               lblBottomEvent.setText("0");
+               // Update the timestamp as well
+               updateSelectedWindowTimestamp();
+               
+               lblWindowMaxNbEvents.setText( selectedWindowCanvas.getHistogramContent().getHeighestEventCount().toString() );
+               lblWindowMinNbEvents.setText("0");
+               
+               // Refresh the layout
+               lblWindowMaxNbEvents.getParent().layout();
        }
        
-       
+       public void updateSelectedWindowTimestamp() {
+               String startTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getStartTime() );
+               String stopTime = HistogramConstant.formatNanoSecondsTime( selectedWindowCanvas.getHistogramContent().getEndTime() );
+               txtWindowStartTime.setText( startTime );
+               txtWindowStopTime.setText( stopTime );
+               
+               ntgCurrentWindowTime.setValue( fullTraceCanvas.getCurrentWindow().getTimestampCenter() );
+               ntgTimeRangeWindow.setValue(  fullTraceCanvas.getCurrentWindow().getWindowTimeWidth() );
+               
+               // Take one control in each group to call to refresh the layout
+               // Since both control have the same parent, only one call is needed 
+               txtWindowStartTime.getParent().layout();
+               ntgCurrentWindowTime.getParent().layout();
+       }
        
 }
diff --git a/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/NanosecTextGroup.java b/org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/histogram/NanosecTextGroup.java
new file mode 100644 (file)
index 0000000..c4e5354
--- /dev/null
@@ -0,0 +1,149 @@
+/*******************************************************************************
+ * 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.lttng.ui.views.histogram;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+
+public class NanosecTextGroup {
+       
+    private static final String        NANOSEC_LABEL = "sec";
+    private static final String                LONGEST_STRING_VALUE = "." + Long.MAX_VALUE;
+    private static final Integer       MAX_CHAR_IN_TEXTBOX = LONGEST_STRING_VALUE.length();
+    
+    private Group      grpName         = null;
+    private Text       txtNanosec      = null;
+    private Label      lblNanosec      = null;
+    
+    private Long timeValue = 0L; 
+    
+    public NanosecTextGroup(Composite parent, int textStyle, int groupStyle) {
+       this(parent, textStyle, groupStyle, "", HistogramConstant.formatNanoSecondsTime(0L));
+    }
+    
+    public NanosecTextGroup(Composite parent, int textStyle, int groupStyle, String groupValue, String textValue) {
+       Font font = parent.getFont();
+               FontData tmpFontData = font.getFontData()[0];
+               //Font smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight()-1, tmpFontData.getStyle());
+               Font smallFont = new Font(font.getDevice(), tmpFontData.getName(), tmpFontData.getHeight(), tmpFontData.getStyle());
+       
+               
+        grpName = new Group(parent, groupStyle);
+        grpName.setText(groupValue);
+        grpName.setFont(smallFont);
+        grpName.setLayout(new GridLayout(2, false));
+        
+        txtNanosec = new Text(grpName, textStyle);
+        txtNanosec.setTextLimit( MAX_CHAR_IN_TEXTBOX );
+        
+        int textBoxSize = HistogramConstant.getTextSizeInControl(parent, LONGEST_STRING_VALUE);
+        
+        txtNanosec.setText( textValue );
+        txtNanosec.setOrientation(SWT.RIGHT_TO_LEFT);
+        GridData gridDataTextBox = new GridData(SWT.FILL, SWT.CENTER, true, false);
+        gridDataTextBox.widthHint = textBoxSize;
+        gridDataTextBox.minimumWidth = textBoxSize;
+        txtNanosec.setFont(smallFont);
+        txtNanosec.setLayoutData(gridDataTextBox);
+        
+        lblNanosec = new Label(grpName, SWT.LEFT);
+        lblNanosec.setText(NANOSEC_LABEL);
+        lblNanosec.setFont(smallFont);
+        lblNanosec.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
+    }
+    
+    public void setLayoutData(Object layoutData) {
+       grpName.setLayoutData(layoutData);
+    } 
+    
+    public Composite getParent() {
+       return grpName.getParent();
+    }
+    
+    public void setParent(Composite newParent) {
+       grpName.setParent(newParent);
+       txtNanosec.setParent(newParent);
+       lblNanosec.setParent(newParent);
+    }
+    
+    public Long getValue() {
+       return timeValue;
+    }
+    
+    
+    public void setValue(String newTimeAsString) {
+       
+       Long timeAsLong = convertStringToLong(newTimeAsString);
+       setValue( timeAsLong );
+    }
+    
+    public void setValue(Long newTime) {
+       timeValue = newTime;
+       txtNanosec.setText( HistogramConstant.formatNanoSecondsTime(newTime) );
+    }
+       
+    public Long convertStringToLong( String timeString ) {
+               
+       Long returnedNumber = 0L;
+               
+           try {
+               // Avoid simple commat/dot mistake
+               timeString = timeString.replace(",", ".");
+       
+               // If we have a dot, we have a decimal number to convert
+               int dotPosition = timeString.indexOf(".");
+               System.out.println("Dot pos : " + dotPosition);
+       
+               // If the user begun the line with a dot, we add a zero
+               if ( dotPosition == 0 ) {
+                timeString = "0" + timeString;
+                dotPosition = 1;
+               }
+       
+               if ( dotPosition != -1 ) {
+                int decimalNumber = (timeString.length() - dotPosition -1);
+
+                System.out.println("Decimal nb : " + decimalNumber);
+
+                if ( decimalNumber < 9 ) {
+                    for ( int nbDec=decimalNumber; nbDec<9; nbDec++) {
+                        timeString += "0";
+                    }
+                }
+               }
+       
+               System.out.println("Final string number : " + timeString);
+       
+               // Conversion into decimal seconds
+               Double dblMaxTimerange = Double.parseDouble(timeString);
+               // Conversion into nanoseconds
+               returnedNumber = (long)(dblMaxTimerange * 1000000000.0);
+       
+               System.out.println("Final long number : " + returnedNumber);
+           }
+           catch (NumberFormatException e) {
+               System.out.println("Warning : Could not convert string into nanoseconds (convertStringToLong)");
+           }
+           
+           return returnedNumber;
+    }
+    
+}
\ No newline at end of file
index b8acddaa08344a4a867c62e51341844f01a26467..9e99a0b74e1e87646684c98e9b9e4f58ce69ed98 100644 (file)
@@ -48,10 +48,10 @@ public class ParentHistogramCanvas extends HistogramCanvas {
         */
        @Override
        public void moveWindow(int newRelativeXPosition) {
-               int absolutePosition = currentWindow.getWindowCenterXPosition() + newRelativeXPosition;
+               int absolutePosition = currentWindow.getWindowXPositionCenter() + newRelativeXPosition;
                
                centerWindow(absolutePosition);
-               notifyParentSelectionWindowChanged();
+               notifyParentSelectionWindowChangedAsynchronously();
        }
        
        /**
@@ -72,8 +72,8 @@ public class ParentHistogramCanvas extends HistogramCanvas {
                        newAbsoluteXPosition = getParent().getSize().x;
                }
                
-               if ( newAbsoluteXPosition != currentWindow.getWindowCenterXPosition() ) {
-                       currentWindow.setWindowCenterXPosition(newAbsoluteXPosition);
+               if ( newAbsoluteXPosition != currentWindow.getWindowXPositionCenter() ) {
+                       currentWindow.setWindowXPositionCenter(newAbsoluteXPosition);
                        redrawAsynchronously();
                }
        }
@@ -91,7 +91,7 @@ public class ParentHistogramCanvas extends HistogramCanvas {
                if ( ajustedTime != getSelectedWindowSize() ) {
                        setSelectedWindowSize(ajustedTime);
                        
-                       notifyParentSelectionWindowChanged();
+                       notifyParentSelectionWindowChangedAsynchronously();
                        redrawAsynchronously();
                }
        }
This page took 0.049209 seconds and 5 git commands to generate.