Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-02-02 06:01:31 +0000
committerspingel2011-02-02 06:01:31 +0000
commit320824604158fda38435166d428b3337a068926d (patch)
tree42368bcdb48eb1dd5bc8e47822e622b2e34dd632 /org.eclipse.mylyn.tasks.ui
parent5aa38f3fd79e1ae4f69e035bbcdb9e61ee236644 (diff)
downloadorg.eclipse.mylyn.tasks-320824604158fda38435166d428b3337a068926d.tar.gz
org.eclipse.mylyn.tasks-320824604158fda38435166d428b3337a068926d.tar.xz
org.eclipse.mylyn.tasks-320824604158fda38435166d428b3337a068926d.zip
RESOLVED - bug 332734: tooltips missing in Task Editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=332734
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskHyperlinkPresenter.java153
1 files changed, 115 insertions, 38 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskHyperlinkPresenter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskHyperlinkPresenter.java
index 70b1a63f5..c9554afa0 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskHyperlinkPresenter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskHyperlinkPresenter.java
@@ -12,15 +12,22 @@
package org.eclipse.mylyn.tasks.ui;
+import java.lang.reflect.Method;
import java.util.Iterator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextPresentation;
import org.eclipse.jface.text.hyperlink.DefaultHyperlinkPresenter;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.text.hyperlink.MultipleHyperlinkPresenter;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.core.TaskList;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.editors.Messages;
@@ -28,6 +35,7 @@ import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
/**
@@ -51,11 +59,21 @@ public final class TaskHyperlinkPresenter extends MultipleHyperlinkPresenter {
private ITextViewer textViewer;
+ private String oldToolTip;
+
+ private boolean restoreToolTip;
+
+ // TODO e3.7 remove all references to delegate and replace with calls to super methods
+ private final MultipleHyperlinkPresenter delegate;
+
+ private boolean errorLogged;
+
/**
* @see DefaultHyperlinkPresenter#DefaultHyperlinkPresenter(IPreferenceStore)
*/
public TaskHyperlinkPresenter(IPreferenceStore store) {
super(store);
+ delegate = new MultipleHyperlinkPresenter(store);
}
/**
@@ -63,25 +81,26 @@ public final class TaskHyperlinkPresenter extends MultipleHyperlinkPresenter {
*/
public TaskHyperlinkPresenter(RGB color) {
super(color);
+ delegate = new MultipleHyperlinkPresenter(color);
}
@Override
public void install(ITextViewer textViewer) {
this.textViewer = textViewer;
- super.install(textViewer);
+ delegate.install(textViewer);
}
@Override
public void uninstall() {
hideHyperlinks();
this.textViewer = null;
- super.uninstall();
+ delegate.uninstall();
}
@SuppressWarnings("unchecked")
@Override
public void applyTextPresentation(TextPresentation textPresentation) {
- super.applyTextPresentation(textPresentation);
+ delegate.applyTextPresentation(textPresentation);
// decorate hyperlink as strike-through if task is completed, this is now also handled by TaskHyperlinkTextPresentationManager
if (activeRegion != null && currentTask != null && currentTask.isCompleted()) {
Iterator<StyleRange> styleRangeIterator = textPresentation.getAllStyleRangeIterator();
@@ -95,57 +114,115 @@ public final class TaskHyperlinkPresenter extends MultipleHyperlinkPresenter {
}
}
+ // TODO e3.7 remove method
@Override
public void showHyperlinks(IHyperlink[] hyperlinks) {
- if (hyperlinks.length > 1) {
- super.showHyperlinks(hyperlinks);
- } else {
- activeRegion = null;
- if (hyperlinks.length > 0 && hyperlinks[0] instanceof TaskHyperlink) {
- TaskHyperlink hyperlink = (TaskHyperlink) hyperlinks[0];
-
- TaskList taskList = TasksUiPlugin.getTaskList();
- String repositoryUrl = hyperlink.getRepository().getRepositoryUrl();
-
- ITask task = taskList.getTask(repositoryUrl, hyperlink.getTaskId());
- if (task == null) {
- task = taskList.getTaskByKey(repositoryUrl, hyperlink.getTaskId());
- }
+ showHyperlinks(hyperlinks, false);
+ }
+
+ // TODO e3.7 add @Override annotation
+ public void showHyperlinks(IHyperlink[] hyperlinks, boolean takesFocusWhenVisible) {
+ activeRegion = null;
+ // show task name in tooltip
+ if (hyperlinks.length == 1 && hyperlinks[0] instanceof TaskHyperlink) {
+ TaskHyperlink hyperlink = (TaskHyperlink) hyperlinks[0];
- if (!hyperlinks[0].equals(currentTaskHyperlink)) {
- currentTaskHyperlink = (TaskHyperlink) hyperlinks[0];
- currentTask = task;
- activeRegion = hyperlink.getHyperlinkRegion();
- if (textViewer != null && textViewer.getTextWidget() != null
- && !textViewer.getTextWidget().isDisposed()) {
- if (task == null) {
- String taskLabel = TasksUiInternal.getTaskPrefix(hyperlink.getRepository()
- .getConnectorKind());
- taskLabel += currentTaskHyperlink.getTaskId();
- textViewer.getTextWidget().setToolTipText(
- NLS.bind(Messages.TaskHyperlinkPresenter_Not_In_Task_List, taskLabel));
- } else if (task.getTaskKey() == null) {
- textViewer.getTextWidget().setToolTipText(task.getSummary());
- } else {
- textViewer.getTextWidget().setToolTipText(task.getTaskKey() + ": " + task.getSummary()); //$NON-NLS-1$
- }
+ TaskList taskList = TasksUiPlugin.getTaskList();
+ String repositoryUrl = hyperlink.getRepository().getRepositoryUrl();
+
+ ITask task = taskList.getTask(repositoryUrl, hyperlink.getTaskId());
+ if (task == null) {
+ task = taskList.getTaskByKey(repositoryUrl, hyperlink.getTaskId());
+ }
+
+ if (!hyperlinks[0].equals(currentTaskHyperlink)) {
+ currentTaskHyperlink = (TaskHyperlink) hyperlinks[0];
+ currentTask = task;
+ activeRegion = hyperlink.getHyperlinkRegion();
+ if (textViewer != null && textViewer.getTextWidget() != null
+ && !textViewer.getTextWidget().isDisposed()) {
+ oldToolTip = textViewer.getTextWidget().getToolTipText();
+ restoreToolTip = true;
+ if (task == null) {
+ String taskLabel = TasksUiInternal.getTaskPrefix(hyperlink.getRepository().getConnectorKind());
+ taskLabel += currentTaskHyperlink.getTaskId();
+ textViewer.getTextWidget().setToolTipText(
+ NLS.bind(Messages.TaskHyperlinkPresenter_Not_In_Task_List, taskLabel));
+ } else if (task.getTaskKey() == null) {
+ textViewer.getTextWidget().setToolTipText(task.getSummary());
+ } else {
+ textViewer.getTextWidget().setToolTipText(task.getTaskKey() + ": " + task.getSummary()); //$NON-NLS-1$
}
}
}
- super.showHyperlinks(hyperlinks);
+ }
+
+ // invoke super implementation
+
+ try {
+ // Eclipse 3.7
+ Method method = MultipleHyperlinkPresenter.class.getDeclaredMethod("showHyperlinks", //$NON-NLS-1$
+ IHyperlink[].class, boolean.class);
+ method.invoke(delegate, hyperlinks, takesFocusWhenVisible);
+ } catch (NoSuchMethodException e) {
+ // Eclipse 3.6 and earlier
+ delegate.showHyperlinks(hyperlinks);
+ } catch (Exception e) {
+ if (!errorLogged) {
+ errorLogged = true;
+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ "Unexpected error while displaying hyperlink", e)); //$NON-NLS-1$
+ }
}
}
@Override
public void hideHyperlinks() {
if (currentTaskHyperlink != null) {
- if (textViewer != null && textViewer.getTextWidget() != null && !textViewer.getTextWidget().isDisposed()) {
- textViewer.getTextWidget().setToolTipText(null);
+ if (restoreToolTip && textViewer != null && textViewer.getTextWidget() != null
+ && !textViewer.getTextWidget().isDisposed()) {
+ textViewer.getTextWidget().setToolTipText(oldToolTip);
+ restoreToolTip = false;
}
currentTaskHyperlink = null;
currentTask = null;
}
- super.hideHyperlinks();
+ delegate.hideHyperlinks();
+ }
+
+ @Override
+ public boolean canHideHyperlinks() {
+ return delegate.canHideHyperlinks();
+ }
+
+ @Override
+ public boolean canShowMultipleHyperlinks() {
+ return delegate.canShowMultipleHyperlinks();
+ }
+
+ @Override
+ public void documentAboutToBeChanged(DocumentEvent event) {
+ delegate.documentAboutToBeChanged(event);
+ }
+
+ @Override
+ public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
+ delegate.inputDocumentAboutToBeChanged(oldInput, newInput);
+ }
+
+ @Override
+ public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
+ delegate.inputDocumentChanged(oldInput, newInput);
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent event) {
+ delegate.propertyChange(event);
+ }
+
+ @Override
+ public void setColor(Color color) {
+ delegate.setColor(color);
}
}

Back to the top