This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 79878 - *Gdb-lite* Gdb Console does not scroll down automatically
Summary: *Gdb-lite* Gdb Console does not scroll down automatically
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P3 blocker (vote)
Assignee: Nikolay Molchanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-09 05:58 UTC by Nikolay Molchanov
Modified: 2007-09-06 18:06 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Molchanov 2006-07-09 05:58:24 UTC
Gdb Console does not scroll down automatically, so the last messages are not
visible. It makes hard to use this window - users have to scroll down it manually
after each command.
Comment 1 Nikolay Molchanov 2006-07-09 06:31:47 UTC
The suggested fix is to update scroll bar value after each message added 
to the text area. The fix is integrated in "dev" release.

Tag: cnd-nb50-dev
User: NikMolchanov
Date: 2006/07/08 22:14:46

Modified:
   cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbConsoleWindow.java

Log:
 Fixed Issue 79878: *Gdb-lite* Gdb Console does not scroll down automatically

File Changes:

Directory: /cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/
==============================================================

File [changed]: GdbConsoleWindow.java
Url:
http://cnd.netbeans.org/source/browse/cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbConsoleWindow.java?r1=1.1.2.3&r2=1.1.2.4
Delta lines:  +16 -10
---------------------
--- GdbConsoleWindow.java	27 Jun 2006 01:01:14 -0000	1.1.2.3
+++ GdbConsoleWindow.java	9 Jul 2006 05:14:43 -0000	1.1.2.4
@@ -37,6 +37,7 @@
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
+import javax.swing.JScrollBar;
 import javax.swing.JTextArea;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
@@ -70,6 +71,7 @@
     private JMenuItem menuItemHideText;
     private JPopupMenu popup;
     private JTextArea ta;
+    private JScrollBar ta_sp_sb;
     private JScrollPane ta_sp;
     private JPanel hp;
     private JPanel cp;
@@ -234,6 +236,7 @@
         if (tree == null) {
             ta = new JTextArea();
             ta_sp = new JScrollPane(ta);
+            ta_sp.setViewportView(ta);
             setLayout(new BorderLayout());
             tree = Models.createView(Models.EMPTY_MODEL);
             tree.setName(view_name);
@@ -288,15 +291,6 @@
             ta.setText(null);
             ta.setCaretPosition(0);
         }
-        /*NM
-        carpos = ta.getCaretPosition();
-        try {
-            ta.setCaretPosition(carpos);
-        } catch (java.lang.IllegalArgumentException e) {
-            // bad position carpos
-            ta.setCaretPosition(0);
-        }
-         */
         synchronized (messagesToProcess) {
             String s;
             while (messagesToProcess.size() > 0) {
@@ -305,7 +299,19 @@
             }
             hp_name.setText(program + "               " + status); //NOI18N
         }
-        invalidate();
+        // Scroll down to show last message
+        if (ta_sp_sb == null) {
+            ta_sp_sb = ta_sp.getVerticalScrollBar();
+        }
+        if (ta_sp_sb != null) {
+            try {
+                carpos = ta_sp_sb.getMaximum();
+                ta_sp_sb.setValue(carpos);
+            } catch (java.lang.Exception e) {
+                // Bad value. Ignore it.
+            }
+        }
+        ta_sp.invalidate();
     }
     
     class PopupListener extends MouseAdapter
Comment 2 Nikolay Molchanov 2006-07-19 00:21:11 UTC
The fix did not work in some cases, so an additional fix was implemented.
The idea is to update scroll bar value *only* from AWT thread.

Tag: cnd-nb50-dev
User: NikMolchanov
Date: 2006/07/18 16:01:43

Modified:
   cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbConsoleWindow.java

Log:
 IZ 79878 *Gdb-lite* Gdb Console does not scroll down automatically
 - "scroll down" must be done in AWT thread

File Changes:

Directory: /cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/
==============================================================

File [changed]: GdbConsoleWindow.java
Url:
http://cnd.netbeans.org/source/browse/cnd/gdb/src/org/netbeans/modules/cnd/debugger/gdb/GdbConsoleWindow.java?r1=1.1.2.6&r2=1.1.2.7
Delta lines:  +22 -14
---------------------
--- GdbConsoleWindow.java	14 Jul 2006 08:23:26 -0000	1.1.2.6
+++ GdbConsoleWindow.java	18 Jul 2006 23:01:40 -0000	1.1.2.7
@@ -45,6 +45,7 @@
 import javax.swing.JScrollPane;
 import javax.swing.JScrollBar;
 import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
 import javax.swing.event.PopupMenuEvent;
 import javax.swing.event.PopupMenuListener;
 import javax.accessibility.AccessibleContext;
@@ -56,6 +57,7 @@
 
 import java.util.ResourceBundle;
 import java.util.Vector;
+
 import org.openide.util.NbBundle;
 
 /**
@@ -231,7 +233,7 @@
     }
     
     private void updateWindow() {
-        int i, k, carpos;
+        int i, k;
         String dc1="help";       //NOI18N
         String dc2="info";       //NOI18N
         String dc3="break main"; //NOI18N
@@ -303,20 +305,26 @@
                 ta.append(s);
             }
             hp_name.setText(program + "               " + status); //NOI18N
-        }
         // Scroll down to show last message
         if (ta_sp_sb == null) {
             ta_sp_sb = ta_sp.getVerticalScrollBar();
         }
+            try {
+                SwingUtilities.invokeLater(new Runnable() {
+                    public void run() {
         if (ta_sp_sb != null) {
             try {
-                carpos = ta_sp_sb.getMaximum();
-                ta_sp_sb.setValue(carpos);
+                                ta_sp_sb.setValue(ta_sp_sb.getMaximum());
             } catch (java.lang.Exception e) {
                 // Bad value. Ignore it.
             }
         }
-        ta_sp.invalidate();
+                    }
+                });
+            } catch (java.lang.Exception e) {
+                // Ignore it.
+            }
+        }
     }
     
-------------------------------------------------------------------