aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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();
}