Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsuen2008-02-17 12:28:42 +0000
committerrsuen2008-02-17 12:28:42 +0000
commit98c7738f1f65cb9c2e71a31380eabb414db8e69e (patch)
treeb58cf338fdc31ddc010c2e035b154e029bceba3c /incubation/bundles
parentc3751fb72b53bf4ab72d66e6510c4c22d527c37c (diff)
downloadorg.eclipse.ecf-98c7738f1f65cb9c2e71a31380eabb414db8e69e.tar.gz
org.eclipse.ecf-98c7738f1f65cb9c2e71a31380eabb414db8e69e.tar.xz
org.eclipse.ecf-98c7738f1f65cb9c2e71a31380eabb414db8e69e.zip
Don't bother using a temporary file now that Mylyn has new added new API for working with streams directly.
Diffstat (limited to 'incubation/bundles')
-rwxr-xr-xincubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/SendContextContributionItem.java40
1 files changed, 8 insertions, 32 deletions
diff --git a/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/SendContextContributionItem.java b/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/SendContextContributionItem.java
index e6b6bbb62..4923de781 100755
--- a/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/SendContextContributionItem.java
+++ b/incubation/bundles/org.eclipse.ecf.mylyn.ui/src/org/eclipse/ecf/internal/mylyn/ui/SendContextContributionItem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
+ * Copyright (c) 2007, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.ecf.internal.mylyn.ui;
-import java.io.*;
-import java.net.URLEncoder;
+import java.io.ByteArrayOutputStream;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.*;
@@ -26,7 +25,6 @@ import org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuContributionItem;
import org.eclipse.ecf.presence.ui.menu.AbstractRosterMenuHandler;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.viewers.*;
-import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants;
import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
import org.eclipse.ui.IWorkbenchPart;
@@ -40,14 +38,6 @@ public class SendContextContributionItem extends AbstractRosterMenuContributionI
setTopMenuImageDescriptor(Activator.getDefault().getImageRegistry().getDescriptor("IMG_SHARED_TASK"));
}
- private String encodeName(AbstractTask task) {
- try {
- return URLEncoder.encode(task.getHandleIdentifier(), ITasksUiConstants.FILENAME_ENCODING);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- }
-
protected IContributionItem[] createContributionItemsForPresenceContainer(IPresenceContainerAdapter presenceContainerAdapter) {
// if this IPCA doesn't support the datashare APIs, we should not create any contribution items
IChannelContainerAdapter channelAdapter = (IChannelContainerAdapter) presenceContainerAdapter.getAdapter(IChannelContainerAdapter.class);
@@ -90,30 +80,16 @@ public class SendContextContributionItem extends AbstractRosterMenuContributionI
final AbstractTask task = (AbstractTask) element;
Job job = new Job("Send Task") {
protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Sending task...", 100);
- File tmpDir = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
- File outputFile = new File(tmpDir, encodeName(task));
- TasksUiPlugin.getTaskListManager().getTaskListWriter().writeTask(task, outputFile);
- monitor.worked(30);
- FileInputStream stream = null;
+ monitor.beginTask("Sending task...", 5);
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ TasksUiPlugin.getTaskListManager().getTaskListWriter().writeTask(task, stream);
+ monitor.worked(2);
try {
- byte[] data = new byte[(int) outputFile.length()];
- stream = new FileInputStream(outputFile);
- stream.read(data);
- monitor.worked(30);
- channel.sendMessage(getRosterEntry().getUser().getID(), data);
- monitor.worked(40);
+ channel.sendMessage(getRosterEntry().getUser().getID(), stream.toByteArray());
+ monitor.worked(3);
} catch (Exception e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "An error occurred while sending the task.", e);
} finally {
- try {
- if (stream != null) {
- stream.close();
- }
- } catch (Exception e) {
- // ignored
- }
- outputFile.delete();
monitor.done();
}
return Status.OK_STATUS;

Back to the top