aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2011-11-02 11:44:13 -0700
committerSiva Velusamy <vsiva@google.com>2011-11-02 11:58:28 -0700
commit1770fd67d8d426c145bbca9e181fef6d6f7ada69 (patch)
tree381dad1ee93107159d0295030fac26643a210558 /ddms/libs
parent433078ca950bddbec764071346e70ead5cfc3119 (diff)
downloadsdk-1770fd67d8d426c145bbca9e181fef6d6f7ada69.zip
sdk-1770fd67d8d426c145bbca9e181fef6d6f7ada69.tar.gz
sdk-1770fd67d8d426c145bbca9e181fef6d6f7ada69.tar.bz2
logcat: update scroll behavior when buffer is full.
When the logcat buffer is full, any received message will push out an old message. As a result, the messages keep moving up the table, which is annoying if you want to view a particular message. Ideally, we'd keep the view constant, but only the scrollbar moves up to indicate that we have received new messages. But this doesn't work in an SWT table. One solution would be to refresh the table and then scroll it to remain in the same place. This causes a flicker and is annoying. This patch stops refreshing the table when the user is viewing an older item in the table, and starts auto refresh if the scroll bar is again brought to the bottom. In addition it provides a toolbar button that reflects the state of scrolling, similar to a scroll lock checkbox. The one downside to this is that since the scrollbar does not move, the user does not have clue if new messages are being received. The new messages will be noticed only if the user unselects the scroll lock button, or manually moves the scrollbar down. This is a fix for Issue #20805. Change-Id: I12108789265fec38287a466d21505db85892594d
Diffstat (limited to 'ddms/libs')
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java43
-rw-r--r--ddms/libs/ddmuilib/src/images/scroll_latest.pngbin0 -> 291 bytes
2 files changed, 37 insertions, 6 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
index 067c9c9..a342350 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
@@ -119,6 +119,7 @@ public final class LogCatPanel extends SelectionDependentPanel
private static final String IMAGE_SAVE_LOG_TO_FILE = "save.png"; //$NON-NLS-1$
private static final String IMAGE_CLEAR_LOG = "clear.png"; //$NON-NLS-1$
private static final String IMAGE_DISPLAY_FILTERS = "displayfilters.png"; //$NON-NLS-1$
+ private static final String IMAGE_SCROLL_TO_LATEST = "scroll_latest.png"; //$NON-NLS-1$
private static final int[] WEIGHTS_SHOW_FILTERS = new int[] {15, 85};
private static final int[] WEIGHTS_LOGCAT_ONLY = new int[] {0, 100};
@@ -138,7 +139,9 @@ public final class LogCatPanel extends SelectionDependentPanel
private Text mLiveFilterText;
private TableViewer mViewer;
+
private boolean mShouldScrollToLatestLog = true;
+ private ToolItem mScrollToLastCheckBox;
private String mLogFileExportFolder;
private LogCatMessageLabelProvider mLogCatMessageLabelProvider;
@@ -557,6 +560,20 @@ public final class LogCatPanel extends SelectionDependentPanel
updateFiltersColumn(showFilters);
}
});
+
+ mScrollToLastCheckBox = new ToolItem(toolBar, SWT.CHECK);
+ mScrollToLastCheckBox.setImage(
+ ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_SCROLL_TO_LATEST,
+ toolBar.getDisplay()));
+ mScrollToLastCheckBox.setSelection(true);
+ mScrollToLastCheckBox.setToolTipText("Scroll to display the latest logcat message.");
+ mScrollToLastCheckBox.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ boolean shouldScroll = mScrollToLastCheckBox.getSelection();
+ setScrollToLatestLog(shouldScroll, false);
+ }
+ });
}
private void updateFiltersColumn(boolean showFilters) {
@@ -749,8 +766,9 @@ public final class LogCatPanel extends SelectionDependentPanel
// But on Windows 7, the scrollbar never touches the bottom, and as a result
// sb.getSelection + sb.getThumb is slightly less than sb.getMaximum.
// So we assume that as long as the thumb is close to the bottom, we want to scroll.
- mShouldScrollToLatestLog =
+ boolean shouldScroll =
Math.abs(sb.getSelection() + sb.getThumb() - sb.getMaximum()) < 10;
+ setScrollToLatestLog(shouldScroll, true);
}
});
@@ -760,13 +778,27 @@ public final class LogCatPanel extends SelectionDependentPanel
Table table = (Table) event.getSource();
int[] indices = table.getSelectionIndices();
- mShouldScrollToLatestLog =
+ boolean shouldScroll =
indices.length == 1 // only 1 item selected
- && indices[0] == table.getItemCount() -1; // and it is the last entry
+ && indices[0] == table.getItemCount() - 1; // and it is the last entry
+ setScrollToLatestLog(shouldScroll, true);
}
});
}
+ private void setScrollToLatestLog(boolean scroll, boolean updateCheckbox) {
+ mShouldScrollToLatestLog = scroll;
+
+ if (updateCheckbox) {
+ mScrollToLastCheckBox.setSelection(scroll);
+ }
+
+ if (scroll) {
+ mViewer.refresh();
+ scrollToLatestLog();
+ }
+ }
+
private static class WrappingToolTipSupport extends ColumnViewerToolTipSupport {
protected WrappingToolTipSupport(ColumnViewer viewer, int style,
boolean manualActivation) {
@@ -943,7 +975,7 @@ public final class LogCatPanel extends SelectionDependentPanel
*/
private void refreshLogCatTable() {
synchronized (this) {
- if (mCurrentRefresher == null) {
+ if (mCurrentRefresher == null && mShouldScrollToLatestLog) {
mCurrentRefresher = new LogCatTableRefresherTask();
Display.getDefault().asyncExec(mCurrentRefresher);
}
@@ -959,9 +991,8 @@ public final class LogCatPanel extends SelectionDependentPanel
mCurrentRefresher = null;
}
- mViewer.refresh();
-
if (mShouldScrollToLatestLog) {
+ mViewer.refresh();
scrollToLatestLog();
}
}
diff --git a/ddms/libs/ddmuilib/src/images/scroll_latest.png b/ddms/libs/ddmuilib/src/images/scroll_latest.png
new file mode 100644
index 0000000..5d26689
--- /dev/null
+++ b/ddms/libs/ddmuilib/src/images/scroll_latest.png
Binary files differ