Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 145204 Details for
Bug 258840
allow to drag attachments out of the attachments section
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
non-working patch
clipboard.txt (text/plain), 8.77 KB, created by
Steffen Pingel
on 2009-08-20 19:16:16 EDT
(
hide
)
Description:
non-working patch
Filename:
MIME Type:
Creator:
Steffen Pingel
Created:
2009-08-20 19:16:16 EDT
Size:
8.77 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java,v >retrieving revision 1.41 >diff -u -r1.41 TaskEditorAttachmentPart.java >--- src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java 24 Jul 2009 12:05:45 -0000 1.41 >+++ src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java 20 Aug 2009 23:18:14 -0000 >@@ -23,6 +23,7 @@ > import org.eclipse.jface.action.MenuManager; > import org.eclipse.jface.action.ToolBarManager; > import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.util.LocalSelectionTransfer; > import org.eclipse.jface.viewers.ArrayContentProvider; > import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; > import org.eclipse.jface.viewers.IOpenListener; >@@ -34,6 +35,7 @@ > import org.eclipse.jface.window.ToolTip; > import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages; > import org.eclipse.mylyn.internal.tasks.core.TaskAttachment; >+import org.eclipse.mylyn.internal.tasks.ui.util.TaskAttachmentDragSourceListener; > import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiMenus; > import org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.Mode; > import org.eclipse.mylyn.tasks.core.ITaskAttachment; >@@ -41,6 +43,12 @@ > import org.eclipse.mylyn.tasks.ui.TasksUiUtil; > import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPart; > import org.eclipse.swt.SWT; >+import org.eclipse.swt.dnd.DND; >+import org.eclipse.swt.dnd.DragSource; >+import org.eclipse.swt.dnd.FileTransfer; >+import org.eclipse.swt.dnd.TextTransfer; >+import org.eclipse.swt.dnd.Transfer; >+import org.eclipse.swt.dnd.URLTransfer; > import org.eclipse.swt.events.SelectionAdapter; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.layout.GridData; >@@ -156,6 +164,13 @@ > getTaskEditorPage().getEditorSite().registerContextMenu(ID_POPUP_MENU, menuManager, attachmentsViewer, true); > Menu menu = menuManager.createContextMenu(attachmentsTable); > attachmentsTable.setMenu(menu); >+ >+ Transfer[] transferTypes = new Transfer[] { LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance(), >+ TextTransfer.getInstance(), URLTransfer.getInstance() }; >+ TaskAttachmentDragSourceListener dragSourceListener = new TaskAttachmentDragSourceListener(attachmentsViewer); >+ DragSource source = new DragSource(attachmentsViewer.getControl(), DND.DROP_MOVE | DND.DROP_LINK); >+ source.setTransfer(transferTypes); >+ source.addDragListener(dragSourceListener); > } > > private void createButtons(Composite attachmentsComposite, FormToolkit toolkit) { >Index: src/org/eclipse/mylyn/internal/tasks/ui/actions/SaveAttachmentsAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/SaveAttachmentsAction.java,v >retrieving revision 1.1 >diff -u -r1.1 SaveAttachmentsAction.java >--- src/org/eclipse/mylyn/internal/tasks/ui/actions/SaveAttachmentsAction.java 28 May 2009 09:13:39 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/tasks/ui/actions/SaveAttachmentsAction.java 20 Aug 2009 23:18:14 -0000 >@@ -160,7 +160,7 @@ > } > } > >- private String getAttachmentFilename(ITaskAttachment attachment) { >+ public static String getAttachmentFilename(ITaskAttachment attachment) { > String fname = attachment.getFileName(); > // default name if none is found > if (fname.equals("")) { //$NON-NLS-1$ >Index: src/org/eclipse/mylyn/internal/tasks/ui/util/TaskAttachmentDragSourceListener.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/util/TaskAttachmentDragSourceListener.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/util/TaskAttachmentDragSourceListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/util/TaskAttachmentDragSourceListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,130 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2009 Tasktop Technologies 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tasktop Technologies - initial API and implementation >+ * Jevgeni Holodkov - improvements >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.util; >+ >+import java.io.File; >+import java.io.IOException; >+import java.util.ArrayList; >+import java.util.Iterator; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jface.util.LocalSelectionTransfer; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.ISelectionProvider; >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.mylyn.commons.core.StatusHandler; >+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; >+import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction; >+import org.eclipse.mylyn.internal.tasks.ui.actions.SaveAttachmentsAction; >+import org.eclipse.mylyn.tasks.core.ITaskAttachment; >+import org.eclipse.swt.dnd.DragSourceAdapter; >+import org.eclipse.swt.dnd.DragSourceEvent; >+import org.eclipse.swt.dnd.FileTransfer; >+import org.eclipse.swt.dnd.TextTransfer; >+import org.eclipse.swt.dnd.URLTransfer; >+ >+/** >+ * @author Steffen Pingel >+ */ >+public class TaskAttachmentDragSourceListener extends DragSourceAdapter { >+ >+ private IStructuredSelection currentSelection; >+ >+ private final ISelectionProvider selectionProvider; >+ >+ public TaskAttachmentDragSourceListener(ISelectionProvider selectionProvider) { >+ this.selectionProvider = selectionProvider; >+ } >+ >+ @Override >+ public void dragStart(DragSourceEvent event) { >+ ISelection selection = selectionProvider.getSelection(); >+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) { >+ this.currentSelection = (IStructuredSelection) selection; >+ } else { >+ this.currentSelection = null; >+ event.doit = false; >+ } >+ } >+ >+ private List<ITaskAttachment> getAttachments(IStructuredSelection selection) { >+ List<ITaskAttachment> attachments = new ArrayList<ITaskAttachment>(); >+ Iterator<?> it = currentSelection.iterator(); >+ while (it.hasNext()) { >+ Object item = it.next(); >+ if (item instanceof ITaskAttachment) { >+ attachments.add((ITaskAttachment) item); >+ } >+ } >+ return attachments; >+ } >+ >+ @Override >+ public void dragSetData(DragSourceEvent event) { >+ if (currentSelection == null || currentSelection.isEmpty()) { >+ event.doit = false; >+ return; >+ } >+ >+ if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) { >+ LocalSelectionTransfer.getTransfer().setSelection(currentSelection); >+ } else if (FileTransfer.getInstance().isSupportedType(event.dataType)) { >+ List<ITaskAttachment> attachments = getAttachments(currentSelection); >+ if (!attachments.isEmpty()) { >+ String[] paths = new String[attachments.size()]; >+ File directory; >+ try { >+ directory = File.createTempFile("attachments", null); //$NON-NLS-1$ >+ } catch (IOException e) { >+ StatusHandler.log(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, >+ "Problems encountered dragging attachment", //$NON-NLS-1$ >+ e)); >+ event.doit = false; >+ return; >+ } >+ directory.delete(); >+ directory.mkdirs(); >+ int i = 0; >+ for (ITaskAttachment attachment : attachments) { >+ String filename = SaveAttachmentsAction.getAttachmentFilename(attachment); >+ File file = new File(directory, filename); >+ DownloadAttachmentJob job = new DownloadAttachmentJob(attachment, file); >+ job.setUser(true); >+ job.schedule(); >+ paths[i] = file.getAbsolutePath(); >+ i++; >+ } >+ event.data = paths; >+ } else { >+ event.doit = false; >+ } >+ } else if (TextTransfer.getInstance().isSupportedType(event.dataType)) { >+ event.data = CopyTaskDetailsAction.getTextForTask(currentSelection.getFirstElement()); >+ } else if (URLTransfer.getInstance().isSupportedType(event.dataType)) { >+ List<ITaskAttachment> attachments = getAttachments(currentSelection); >+ if (!attachments.isEmpty()) { >+ event.data = attachments.get(0).getUrl(); >+ } >+ } >+ } >+ >+ @Override >+ public void dragFinished(DragSourceEvent event) { >+ if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) { >+ LocalSelectionTransfer.getTransfer().setSelection(null); >+ } >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 258840
: 145204 |
145205