tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / widgets / virtualtable / TmfVirtualTable.java
index 2c866752dea0ed894f631b92615e7b5547e415f8..a43a6b1dfd093427294c9e1c9990c4d0c1abc216 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2010 Ericsson
+ * Copyright (c) 2010, 2013 Ericsson
  *
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -698,12 +698,12 @@ public class TmfVirtualTable extends Composite {
         *
      */
     public void setItemCount(int nbItems) {
-        nbItems = Math.max(0, nbItems);
+        final int nb = Math.max(0, nbItems);
 
-        if (nbItems != fTableItemCount) {
-            fTableItemCount = nbItems;
+        if (nb != fTableItemCount) {
+            fTableItemCount = nb;
             fTable.remove(fTableItemCount, fTable.getItemCount() - 1);
-            fSlider.setMaximum(nbItems);
+            fSlider.setMaximum(nb);
             resize();
             int tableHeight = Math.max(0, fTable.getClientArea().height - fTable.getHeaderHeight());
             fFullyVisibleRows = tableHeight / getItemHeight();
@@ -764,11 +764,11 @@ public class TmfVirtualTable extends Composite {
 
     /**
      * Method setTopIndex.
-     * @param i int suggested top index for the table.
+     * @param index int suggested top index for the table.
      */
-    public void setTopIndex(int i) {
+    public void setTopIndex(int index) {
         if (fTableItemCount > 0) {
-            i = Math.min(i, fTableItemCount - 1);
+            int i = Math.min(index, fTableItemCount - 1);
             i = Math.max(i, fFrozenRowCount);
 
             fTableTopEventRank = i - fFrozenRowCount;
@@ -928,17 +928,18 @@ public class TmfVirtualTable extends Composite {
 
     /**
      * Method setSelection.
-     * @param i int the item number to select in the table.
+     * @param index int the item number to select in the table.
      */
-    public void setSelection(int i) {
+    public void setSelection(int index) {
         if (fTableItemCount > 0) {
-            i = Math.min(i, fTableItemCount - 1);
+            int i = Math.min(index, fTableItemCount - 1);
             i = Math.max(i, 0);
 
             fSelectedEventRank = i;
             if ((i < fTableTopEventRank + fFrozenRowCount && i >= fFrozenRowCount) ||
                     (i >= fTableTopEventRank + fFullyVisibleRows)) {
-                fTableTopEventRank = Math.max(0, i - fFrozenRowCount - fFullyVisibleRows / 2);
+                int lastPageTopEntryRank = Math.max(0, fTableItemCount - fFullyVisibleRows);
+                fTableTopEventRank = Math.max(0, Math.min(lastPageTopEntryRank, i - fFrozenRowCount - fFullyVisibleRows / 2));
             }
             if (fFullyVisibleRows < fTableItemCount) {
                 fSlider.setSelection(fTableTopEventRank);
This page took 0.024428 seconds and 5 git commands to generate.