aboutsummaryrefslogtreecommitdiffstats
path: root/ddms/libs
diff options
context:
space:
mode:
authorSiva Velusamy <vsiva@google.com>2011-09-29 12:26:48 -0700
committerSiva Velusamy <vsiva@google.com>2011-09-29 12:31:57 -0700
commit25f755d0f0f8a1c65d961a1d4a2ad508aacf8af8 (patch)
tree836bfd2888cf09d54e7093da25da9bd0686ddeb4 /ddms/libs
parent792193deab3db1efd196566cfedd477337ca679c (diff)
downloadsdk-25f755d0f0f8a1c65d961a1d4a2ad508aacf8af8.zip
sdk-25f755d0f0f8a1c65d961a1d4a2ad508aacf8af8.tar.gz
sdk-25f755d0f0f8a1c65d961a1d4a2ad508aacf8af8.tar.bz2
Display tooltips only for long messages.
Currently, the tooltips are displayed for all logcat messages. This patch makes them show up only if the logcat messages are longer than the width of the column in which they are displayed, i.e., tooltips will be displayed only for those messages that could be clipped. Change-Id: Ib5bbce7d055656d2cc8063efdf5fed5910b24ad0
Diffstat (limited to 'ddms/libs')
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageLabelProvider.java18
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java20
2 files changed, 36 insertions, 2 deletions
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageLabelProvider.java
index 7bbc471..28af776 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageLabelProvider.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageLabelProvider.java
@@ -22,7 +22,6 @@ import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
/**
* A JFace Column label provider for the LogCat log messages. It expects elements of type
@@ -44,6 +43,7 @@ public final class LogCatMessageLabelProvider extends ColumnLabelProvider {
private static final Color VERBOSE_MSG_COLOR = new Color(null, 0, 0, 0);
private Font mLogFont;
+ private int mWrapWidth = 100;
/**
* Construct a column label provider for the logcat table.
@@ -112,8 +112,22 @@ public final class LogCatMessageLabelProvider extends ColumnLabelProvider {
mLogFont = preferredFont;
}
+ public void setMinimumLengthForToolTips(int widthInChars) {
+ mWrapWidth = widthInChars;
+ }
+
+ /**
+ * Obtain the tool tip to show for a particular logcat message.
+ * We display a tool tip only for messages longer than the width set by
+ * {@link #setMinimumLengthForToolTips(int)}.
+ */
@Override
public String getToolTipText(Object element) {
- return element.toString();
+ String text = element.toString();
+ if (text.length() > mWrapWidth) {
+ return text;
+ } else {
+ return null;
+ }
}
}
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 4c883eb..aac9124 100644
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
+++ b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
@@ -42,6 +42,8 @@ import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.events.ControlAdapter;
+import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.ModifyEvent;
@@ -50,6 +52,7 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
@@ -665,6 +668,23 @@ public final class LogCatPanel extends SelectionDependentPanel
}
});
+ // Update the label provider whenever the text column's width changes
+ TableColumn textColumn = mViewer.getTable().getColumn(properties.length - 1);
+ textColumn.addControlListener(new ControlAdapter() {
+ @Override
+ public void controlResized(ControlEvent event) {
+ TableColumn tc = (TableColumn) event.getSource();
+ int width = tc.getWidth();
+ GC gc = new GC(tc.getParent());
+ int avgCharWidth = gc.getFontMetrics().getAverageCharWidth();
+ gc.dispose();
+
+ if (mLogCatMessageLabelProvider != null) {
+ mLogCatMessageLabelProvider.setMinimumLengthForToolTips(width/avgCharWidth);
+ }
+ }
+ });
+
initDoubleClickListener();
}