You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2018/03/26 16:56:07 UTC

svn commit: r1827774 - in /jmeter/trunk: src/jorphan/org/apache/jorphan/gui/MenuScroller.java xdocs/changes.xml

Author: fschumacher
Date: Mon Mar 26 16:56:06 2018
New Revision: 1827774

URL: http://svn.apache.org/viewvc?rev=1827774&view=rev
Log:
Keep the index right, when scrolling through the menu items.

Bugzilla Id: 56150

Modified:
    jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MenuScroller.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MenuScroller.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MenuScroller.java?rev=1827774&r1=1827773&r2=1827774&view=diff
==============================================================================
--- jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MenuScroller.java (original)
+++ jmeter/trunk/src/jorphan/org/apache/jorphan/gui/MenuScroller.java Mon Mar 26 16:56:06 2018
@@ -528,34 +528,34 @@ public class MenuScroller {
     }
 
     private void refreshMenu() {
-        if (menuItems != null && menuItems.length > 0) {
+        if (menuItems != null && menuItems.length > 0 && scrollCount <= menuItems.length) {
             firstIndex = Math.max(topFixedCount, firstIndex);
-            firstIndex = Math.min(menuItems.length - bottomFixedCount
-                    - scrollCount, firstIndex);
+            firstIndex = Math.max(0, Math.min(menuItems.length - bottomFixedCount
+                    - scrollCount, firstIndex));
 
             upItem.setEnabled(firstIndex > topFixedCount);
             downItem.setEnabled(firstIndex + scrollCount < menuItems.length
                     - bottomFixedCount);
 
             menu.removeAll();
-            for (int i = 0; i < topFixedCount; i++) {
-                menu.add(menuItems[i]);
-            }
             if (topFixedCount > 0) {
+                for (int i = 0; i < topFixedCount; i++) {
+                    menu.add(menuItems[i]);
+                }
                 menu.addSeparator();
             }
 
             menu.add(upItem);
-            for (int i = firstIndex; i < scrollCount + firstIndex; i++) {
+            for (int i = firstIndex; i < Math.min(menuItems.length, scrollCount + firstIndex); i++) {
                 menu.add(menuItems[i]);
             }
             menu.add(downItem);
 
             if (bottomFixedCount > 0) {
                 menu.addSeparator();
-            }
-            for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) {
-                menu.add(menuItems[i]);
+                for (int i = Math.max(0, menuItems.length - bottomFixedCount); i < menuItems.length; i++) {
+                    menu.add(menuItems[i]);
+                }
             }
 
             int preferredWidth = 0;
@@ -568,11 +568,11 @@ public class MenuScroller {
             parent.repaint();
         }
     }
-    
+
     private class MouseScrollListener implements MouseWheelListener {
         @Override
         public void mouseWheelMoved(MouseWheelEvent mwe){
-            firstIndex += mwe.getWheelRotation();
+            firstIndex = Math.max(0, Math.min(menuItems.length - 1, firstIndex + mwe.getWheelRotation()));
             refreshMenu();
             mwe.consume(); // (Comment 16, Huw)
         }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1827774&r1=1827773&r2=1827774&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Mon Mar 26 16:56:06 2018
@@ -194,6 +194,7 @@ this behaviour, set <code>httpclient.res
   <li><pr>377</pr>Small fix of the docs. Contributed by Peter Doornbosch (peter.doornbosch at luminis.eu)</li>
   <li><bug>62124</bug>Recording templates : Add more exclusions and use Transaction Name by default</li>
   <li><bug>62127</bug>Store filename as String instead of File in FileEditor. This will prevent conversion of filenames from unix style path separators to Windows style when used for example in CSV Data Set Config.</li>
+  <li><bug>56150</bug>Keep the index right, when scrolling through the menu items.</li>
 </ul>
 
  <!--  =================== Thanks =================== -->