aboutsummaryrefslogtreecommitdiffstats
path: root/ddms
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2011-08-16 09:57:18 -0700
committerSiva Velusamy <vsiva@google.com>2011-08-16 10:48:05 -0700
commit124f447774b065c1dde88c7e3e9ecc18f13cb0d8 (patch)
treebd171790db11b63b739822c66f4fe4f01fb23adc /ddms
parent2e2454a233adb82650de2b46fa00a878a8554dd4 (diff)
downloadsdk-124f447774b065c1dde88c7e3e9ecc18f13cb0d8.zip
sdk-124f447774b065c1dde88c7e3e9ecc18f13cb0d8.tar.gz
sdk-124f447774b065c1dde88c7e3e9ecc18f13cb0d8.tar.bz2
Show count of unread messages associated with each filter.
Change-Id: I871ddc550b1d63844b8501a59c079b62f0de4cca
Diffstat (limited to 'ddms')
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilter.java36
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java12
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java43
3 files changed, 80 insertions, 11 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilter.java
index 4de950a..5e2e9e9 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilter.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilter.java
@@ -40,6 +40,12 @@ public final class LogCatFilter {
private final String mPid;
private final LogLevel mLogLevel;
+ /** Indicates the number of messages that match this filter, but have not
+ * yet been read by the user. This is really metadata about this filter
+ * necessary for the UI. If we ever end up needing to store more metadata,
+ * then it is probably better to move it out into a separate class. */
+ private int mUnreadCount;
+
private boolean mCheckPID;
private boolean mCheckTag;
private boolean mCheckText;
@@ -66,6 +72,8 @@ public final class LogCatFilter {
mPid = pid.trim();
mLogLevel = logLevel;
+ mUnreadCount = 0;
+
mCheckPID = mPid.length() != 0;
if (mTag.length() != 0) {
@@ -181,4 +189,32 @@ public final class LogCatFilter {
return true;
}
+
+ /**
+ * Update the unread count based on new messages received. The unread count
+ * is incremented by the count of messages in the received list that will be
+ * accepted by this filter.
+ * @param newMessages list of new messages.
+ */
+ public void updateUnreadCount(List<LogCatMessage> newMessages) {
+ for (LogCatMessage m : newMessages) {
+ if (matches(m)) {
+ mUnreadCount++;
+ }
+ }
+ }
+
+ /**
+ * Reset count of unread messages.
+ */
+ public void resetUnreadCount() {
+ mUnreadCount = 0;
+ }
+
+ /**
+ * Get current value for the unread message counter.
+ */
+ public int getUnreadCount() {
+ return mUnreadCount;
+ }
}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java
index 3dbc050..4cc044d 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java
@@ -41,14 +41,10 @@ public final class LogCatFilterLabelProvider extends LabelProvider implements IT
LogCatFilter f = (LogCatFilter) element;
- /* FIXME: Currently, only the name of the filter is displayed.
- * A future fix will also display the "unread count" associated
- * with each filter. */
- switch (index) {
- case 0:
- return f.getName();
- default:
- return "**";
+ if (f.getUnreadCount() == 0) {
+ return f.getName();
+ } else {
+ return String.format("%s (%d)", f.getName(), f.getUnreadCount());
}
}
}
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 469cf57..9a598c0 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
@@ -92,6 +92,7 @@ public final class LogCatPanel extends SelectionDependentPanel
private IPreferenceStore mPrefStore;
private List<LogCatFilter> mLogCatFilters;
+ private int mCurrentSelectedFilterIndex;
private ToolItem mNewFilterToolItem;
private ToolItem mDeleteFilterToolItem;
@@ -569,17 +570,27 @@ public final class LogCatPanel extends SelectionDependentPanel
* Perform all necessary updates whenever a filter is selected (by user or programmatically).
*/
private void filterSelectionChanged() {
+ mCurrentSelectedFilterIndex = getSelectedSavedFilterIndex();
+
+ resetUnreadCountForSelectedFilter();
updateFiltersToolBar();
updateAppliedFilters();
}
- private int getSavedFilterIndex() {
+ private void resetUnreadCountForSelectedFilter() {
+ int index = getSelectedSavedFilterIndex();
+ mLogCatFilters.get(index).resetUnreadCount();
+
+ refreshFiltersTable();
+ }
+
+ private int getSelectedSavedFilterIndex() {
return mFiltersTableViewer.getTable().getSelectionIndex();
}
private void updateFiltersToolBar() {
/* The default filter at index 0 can neither be edited, nor removed. */
- boolean en = getSavedFilterIndex() != 0;
+ boolean en = getSelectedSavedFilterIndex() != 0;
mEditFilterToolItem.setEnabled(en);
mDeleteFilterToolItem.setEnabled(en);
}
@@ -610,7 +621,7 @@ public final class LogCatPanel extends SelectionDependentPanel
}
private LogCatViewerFilter getSelectedSavedFilter() {
- int index = getSavedFilterIndex();
+ int index = getSelectedSavedFilterIndex();
return new LogCatViewerFilter(mLogCatFilters.get(index));
}
@@ -626,6 +637,32 @@ public final class LogCatPanel extends SelectionDependentPanel
*/
public void messageReceived(List<LogCatMessage> receivedMessages) {
refreshLogCatTable();
+
+ updateUnreadCount(receivedMessages);
+ refreshFiltersTable();
+ }
+
+ /**
+ * When new messages are received, and they match a saved filter, update
+ * the unread count associated with that filter.
+ * @param receivedMessages list of new messages received
+ */
+ private void updateUnreadCount(List<LogCatMessage> receivedMessages) {
+ for (int i = 0; i < mLogCatFilters.size(); i++) {
+ if (i == mCurrentSelectedFilterIndex) {
+ /* no need to update unread count for currently selected filter */
+ continue;
+ }
+ mLogCatFilters.get(i).updateUnreadCount(receivedMessages);
+ }
+ }
+
+ private void refreshFiltersTable() {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ mFiltersTableViewer.refresh();
+ }
+ });
}
private void refreshLogCatTable() {