Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-08-20 22:06:14 -0400
committerspingel2008-08-20 22:06:14 -0400
commite39da248df8a548ebc47082941d012a961036d66 (patch)
treeba1d689894972322cd49410d48651e604210648f
parent2a5370b63e5e4c8127c7c232a082ed29af1e3e39 (diff)
downloadorg.eclipse.mylyn.tasks-e39da248df8a548ebc47082941d012a961036d66.tar.gz
org.eclipse.mylyn.tasks-e39da248df8a548ebc47082941d012a961036d66.tar.xz
org.eclipse.mylyn.tasks-e39da248df8a548ebc47082941d012a961036d66.zip
NEW - bug 205861: improve tooltip presentation and content
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205861
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java7
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java19
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java3
3 files changed, 26 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
index 1ee2b481a..66ba83658 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TasksUiInternal.java
@@ -911,4 +911,11 @@ public class TasksUiInternal {
return false;
}
+ /**
+ * Returns text masking the &-character from decoration as an accelerator in SWT labels.
+ */
+ public static String escapeLabelText(String text) {
+ return (text != null) ? text.replace("&", "&&") : null; // mask & from SWT
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java
index ca141c052..0c043b292 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListToolTip.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.mylyn.commons.core.DateUtil;
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
@@ -39,6 +40,7 @@ import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskDataDiff;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotification;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListNotifier;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
@@ -52,6 +54,7 @@ import org.eclipse.mylyn.tasks.ui.TaskElementLabelProvider;
import org.eclipse.mylyn.tasks.ui.TasksUi;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
@@ -79,6 +82,8 @@ public class TaskListToolTip extends ToolTip {
private final static int MAX_TEXT_WIDTH = 300;
+ private final static int MAX_WIDTH = 600;
+
private final static int X_SHIFT;
static {
@@ -604,11 +609,21 @@ public class TaskListToolTip extends ToolTip {
imageLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
imageLabel.setImage(image);
- Label textLabel = new Label(parent, SWT.NONE);
+ Label textLabel = new Label(parent, SWT.WRAP);
textLabel.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
textLabel.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
textLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_CENTER));
- textLabel.setText(removeTrailingNewline(text));
+ textLabel.setText(TasksUiInternal.escapeLabelText(removeTrailingNewline(text)));
+
+ GC gc = new GC(textLabel);
+ try {
+ if (gc.textExtent(text).x > MAX_WIDTH) {
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).hint(MAX_WIDTH, SWT.DEFAULT).applyTo(
+ textLabel);
+ }
+ } finally {
+ gc.dispose();
+ }
}
private static class ProgressData {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java
index c5668fdbc..91bcd00c8 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractAttributeEditor.java
@@ -9,6 +9,7 @@
package org.eclipse.mylyn.tasks.ui.editors;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.data.TaskDataModel;
@@ -76,7 +77,7 @@ public abstract class AbstractAttributeEditor {
public String getLabel() {
String label = getAttributeMapper().getLabel(getTaskAttribute());
- return (label != null) ? label.replace("&", "&&") : null; // mask & from SWT
+ return TasksUiInternal.escapeLabelText(label);
}
public Label getLabelControl() {

Back to the top