Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2012-02-15 18:31:41 -0500
committerSteffen Pingel2012-02-15 18:31:41 -0500
commit89aa41132c570c96eb9eb0a4c03cf67c7f99532c (patch)
tree86d8af9d17f816e769b6edc5a70e04d402b67f36 /org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks
parent0bcb41110f882073ae9a96bb5a1ded863df48a01 (diff)
downloadorg.eclipse.mylyn.tasks-89aa41132c570c96eb9eb0a4c03cf67c7f99532c.tar.gz
org.eclipse.mylyn.tasks-89aa41132c570c96eb9eb0a4c03cf67c7f99532c.tar.xz
org.eclipse.mylyn.tasks-89aa41132c570c96eb9eb0a4c03cf67c7f99532c.zip
NEW - bug 370283: [api] allow clients to be notified of drop events in
the task list https://bugs.eclipse.org/bugs/show_bug.cgi?id=370283 Change-Id: I05ed4d215f9d72895d9cc70ce8db6ed9ffb1721b
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskDropListener.java77
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java4
2 files changed, 80 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskDropListener.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskDropListener.java
new file mode 100644
index 000000000..8171f872f
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskDropListener.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.ui;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.mylyn.tasks.core.ITask;
+
+/**
+ * Clients can contribute an extension of this class to be notified when one task is dropped on a repository task in the
+ * task list, or when a task is dropped on a task editor.
+ *
+ * @author Sam Davis
+ * @since 3.7
+ */
+public abstract class TaskDropListener {
+
+ public static enum Operation {
+ COPY, LINK, DROP_ON_TASK_EDITOR
+ };
+
+ public static class TaskDropEvent {
+
+ private final Collection<ITask> tasks;
+
+ private final ITask target;
+
+ private final Operation operation;
+
+ public TaskDropEvent(Collection<ITask> tasks, ITask target, Operation operation) {
+ this.tasks = Collections.unmodifiableList(new ArrayList<ITask>(tasks));
+ this.target = target;
+ this.operation = operation;
+ }
+
+ /**
+ * @return the tasks that were dropped
+ */
+ public Collection<ITask> getTasks() {
+ return tasks;
+ }
+
+ /**
+ * @return the target task
+ */
+ public ITask getTarget() {
+ return target;
+ }
+
+ /**
+ * @return the drop operation that triggered this event
+ */
+ public Operation getOperation() {
+ return operation;
+ }
+
+ }
+
+ /**
+ * Called when a task drop event occurs.
+ *
+ * @param event
+ */
+ public abstract void tasksDropped(TaskDropEvent event);
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java
index 965d6f075..9ba55ab8e 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java
@@ -41,6 +41,7 @@ import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -1487,9 +1488,10 @@ public abstract class AbstractTaskEditorPage extends TaskFormPage implements ISe
}
DropTarget target = new DropTarget(control, DND.DROP_COPY | DND.DROP_DEFAULT);
+ LocalSelectionTransfer localSelectionTransfer = LocalSelectionTransfer.getTransfer();
final TextTransfer textTransfer = TextTransfer.getInstance();
final FileTransfer fileTransfer = FileTransfer.getInstance();
- Transfer[] types = new Transfer[] { textTransfer, fileTransfer };
+ Transfer[] types = new Transfer[] { localSelectionTransfer, textTransfer, fileTransfer };
target.setTransfer(types);
if (defaultDropListener == null) {
defaultDropListener = new TaskAttachmentDropListener(this);

Back to the top