Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2010-05-25 20:50:21 +0000
committersminto2010-05-25 20:50:21 +0000
commitfb465fd26be2b505c2c2ffda3fe12af4d8f323be (patch)
treee2deea2071dbd729f5a0a6f7a962cb7a96d252f9 /org.eclipse.mylyn.tasks.ui/src
parent55faf8ea5c5dd6fe3ff6a17118f71c6c0a557e99 (diff)
downloadorg.eclipse.mylyn.tasks-fb465fd26be2b505c2c2ffda3fe12af4d8f323be.tar.gz
org.eclipse.mylyn.tasks-fb465fd26be2b505c2c2ffda3fe12af4d8f323be.tar.xz
org.eclipse.mylyn.tasks-fb465fd26be2b505c2c2ffda3fe12af4d8f323be.zip
RESOLVED - bug 220314: double click on repository attachment does not respect default workbench editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=220314
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/DownloadAndOpenTaskAttachmentJob.java22
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/Messages.java2
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskAttachmentEditorViewer.java26
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/messages.properties1
4 files changed, 40 insertions, 11 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/DownloadAndOpenTaskAttachmentJob.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/DownloadAndOpenTaskAttachmentJob.java
index bf7c7b93a..e29515b28 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/DownloadAndOpenTaskAttachmentJob.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/DownloadAndOpenTaskAttachmentJob.java
@@ -14,6 +14,7 @@ package org.eclipse.mylyn.internal.tasks.ui;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.concurrent.atomic.AtomicReference;
@@ -22,7 +23,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
@@ -36,23 +38,31 @@ import org.eclipse.ui.PartInitException;
/**
* @author Peter Stibrany
*/
-class DownloadAndOpenTaskAttachmentJob extends Job {
+class DownloadAndOpenTaskAttachmentJob implements IRunnableWithProgress {
private final ITaskAttachment attachment;
private final IWorkbenchPage page;
private final String editorID;
- DownloadAndOpenTaskAttachmentJob(String jobName, ITaskAttachment attachment, IWorkbenchPage page, String editorID) {
- super(jobName);
+ private final String jobName;
+ DownloadAndOpenTaskAttachmentJob(String jobName, ITaskAttachment attachment, IWorkbenchPage page, String editorID) {
+ this.jobName = jobName;
this.attachment = attachment;
this.page = page;
this.editorID = editorID;
}
- @Override
- protected IStatus run(IProgressMonitor monitor) {
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ monitor.beginTask(jobName, IProgressMonitor.UNKNOWN);
+ IStatus result = execute(new SubProgressMonitor(monitor, 100));
+ if (result != null && !result.isOK()) {
+ throw new InvocationTargetException(new CoreException(result));
+ }
+ }
+
+ protected IStatus execute(IProgressMonitor monitor) {
final String attachmentFilename = AttachmentUtil.getAttachmentFilename(attachment);
File file = null;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/Messages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/Messages.java
index 3a8af1f15..f0eccd482 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/Messages.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/Messages.java
@@ -70,8 +70,8 @@ public class Messages extends NLS {
public static String ScheduleTaskMenuContributor_Schedule_for;
public static String TaskActivationExternalizationParticipant_Task_Activation_History;
-
public static String TaskAttachmentEditorViewer_openingAttachment;
+ public static String TaskAttachmentEditorViewer_ErrorDownloadingAttachment;
public static String TaskAttachmentViewerBrowser_browser;
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskAttachmentEditorViewer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskAttachmentEditorViewer.java
index 58410e316..76c94ff87 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskAttachmentEditorViewer.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskAttachmentEditorViewer.java
@@ -11,13 +11,18 @@
package org.eclipse.mylyn.internal.tasks.ui;
+import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.internal.tasks.ui.util.AttachmentUtil;
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.progress.IProgressService;
/**
* @author Peter Stibrany
@@ -38,12 +43,25 @@ public class TaskAttachmentEditorViewer implements ITaskAttachmentViewer {
return descriptor.getLabel();
}
- public void openAttachment(IWorkbenchPage page, ITaskAttachment attachment) throws CoreException {
+ public void openAttachment(final IWorkbenchPage page, final ITaskAttachment attachment) throws CoreException {
+
DownloadAndOpenTaskAttachmentJob job = new DownloadAndOpenTaskAttachmentJob(
MessageFormat.format(Messages.TaskAttachmentEditorViewer_openingAttachment,
AttachmentUtil.getAttachmentFilename(attachment)), attachment, page, descriptor.getId());
- job.setUser(true);
- job.schedule();
- }
+ IProgressService service = page.getWorkbenchWindow().getWorkbench().getProgressService();
+ try {
+ service.run(true, true, job);
+ } catch (InvocationTargetException e) {
+ if (e.getTargetException() instanceof CoreException) {
+ StatusHandler.log(((CoreException) e.getTargetException()).getStatus());
+ } else {
+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
+ Messages.TaskAttachmentEditorViewer_ErrorDownloadingAttachment, e));
+ }
+
+ } catch (InterruptedException e) {
+ // ignore, since it was canceled
+ }
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/messages.properties b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/messages.properties
index 9346ba4ef..6df0e3615 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/messages.properties
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/messages.properties
@@ -90,4 +90,5 @@ AbstractRetrieveTitleFromUrlJob_Retrieving_summary_from_URL=Retrieving summary f
FileStorage_unableToReadAttachmentFile=Unable to read attachment file
TaskAttachmentEditorViewer_openingAttachment=Opening attachment {0}
+TaskAttachmentEditorViewer_ErrorDownloadingAttachment=Error while downloading attachment.
TaskAttachmentViewerBrowser_browser=Browser

Back to the top