Lines 38-46
Link Here
|
38 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
38 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
39 |
import org.eclipse.mylyn.tasks.core.ITask; |
39 |
import org.eclipse.mylyn.tasks.core.ITask; |
40 |
import org.eclipse.mylyn.tasks.core.ITaskContainer; |
40 |
import org.eclipse.mylyn.tasks.core.ITaskContainer; |
|
|
41 |
import org.eclipse.mylyn.tasks.ui.TaskDropListener.Operation; |
41 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
42 |
import org.eclipse.mylyn.tasks.ui.TasksUiUtil; |
42 |
import org.eclipse.swt.dnd.DND; |
43 |
import org.eclipse.swt.dnd.DND; |
43 |
import org.eclipse.swt.dnd.DropTargetEvent; |
|
|
44 |
import org.eclipse.swt.dnd.FileTransfer; |
44 |
import org.eclipse.swt.dnd.FileTransfer; |
45 |
import org.eclipse.swt.dnd.TextTransfer; |
45 |
import org.eclipse.swt.dnd.TextTransfer; |
46 |
import org.eclipse.swt.dnd.TransferData; |
46 |
import org.eclipse.swt.dnd.TransferData; |
Lines 51-56
Link Here
|
51 |
* @author Mik Kersten |
51 |
* @author Mik Kersten |
52 |
* @author Rob Elves (added URL based task creation support) |
52 |
* @author Rob Elves (added URL based task creation support) |
53 |
* @author Jevgeni Holodkov |
53 |
* @author Jevgeni Holodkov |
|
|
54 |
* @author Sam Davis |
54 |
*/ |
55 |
*/ |
55 |
public class TaskListDropAdapter extends ViewerDropAdapter { |
56 |
public class TaskListDropAdapter extends ViewerDropAdapter { |
56 |
|
57 |
|
Lines 64-81
Link Here
|
64 |
} |
65 |
} |
65 |
|
66 |
|
66 |
@Override |
67 |
@Override |
67 |
public void dragOver(DropTargetEvent event) { |
|
|
68 |
// support dragging from sources only supporting DROP_LINK |
69 |
if (event.detail == DND.DROP_NONE && (event.operations & DND.DROP_LINK) == DND.DROP_LINK) { |
70 |
event.detail = DND.DROP_LINK; |
71 |
} |
72 |
super.dragOver(event); |
73 |
} |
74 |
|
75 |
@Override |
76 |
public boolean performDrop(final Object data) { |
68 |
public boolean performDrop(final Object data) { |
77 |
List<ITask> tasksToMove = new ArrayList<ITask>(); |
69 |
List<ITask> tasksToMove = new ArrayList<ITask>(); |
78 |
|
|
|
79 |
if (localTransfer) { |
70 |
if (localTransfer) { |
80 |
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); |
71 |
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); |
81 |
List<ITask> tasks = TasksUiInternal.getTasksFromSelection(selection); |
72 |
List<ITask> tasks = TasksUiInternal.getTasksFromSelection(selection); |
Lines 107-155
Link Here
|
107 |
} |
98 |
} |
108 |
} |
99 |
} |
109 |
} else { |
100 |
} else { |
110 |
for (ITask task : tasksToMove) { |
101 |
if (currentTarget instanceof ITask && getCurrentLocation() == ViewerDropAdapter.LOCATION_ON |
111 |
if (currentTarget instanceof UncategorizedTaskContainer) { |
102 |
&& getCurrentOperation() != DND.DROP_MOVE) { |
112 |
moveTask(task, (UncategorizedTaskContainer) currentTarget); |
103 |
TasksUiInternal.getTaskDropHandler().loadTaskDropListeners(); |
113 |
} else if (currentTarget instanceof TaskCategory) { |
104 |
Operation operation = (getCurrentOperation() == DND.DROP_COPY) ? Operation.COPY : Operation.LINK; |
114 |
moveTask(task, (TaskCategory) currentTarget); |
105 |
TasksUiInternal.getTaskDropHandler().fireTaskDropped(tasksToMove, (ITask) currentTarget, operation); |
115 |
} else if (currentTarget instanceof UnmatchedTaskContainer) { |
106 |
} else { |
116 |
if (((UnmatchedTaskContainer) currentTarget).getRepositoryUrl().equals(task.getRepositoryUrl())) { |
107 |
for (ITask task : tasksToMove) { |
117 |
moveTask(task, (AbstractTaskCategory) currentTarget); |
108 |
if (currentTarget instanceof UncategorizedTaskContainer) { |
118 |
} |
109 |
moveTask(task, (UncategorizedTaskContainer) currentTarget); |
119 |
} else if (currentTarget instanceof ITask) { |
110 |
} else if (currentTarget instanceof TaskCategory) { |
120 |
ITask targetTask = (ITask) currentTarget; |
111 |
moveTask(task, (TaskCategory) currentTarget); |
121 |
TaskListView view = TaskListView.getFromActivePerspective(); |
112 |
} else if (currentTarget instanceof UnmatchedTaskContainer) { |
122 |
if ((getCurrentLocation() == LOCATION_BEFORE || getCurrentLocation() == LOCATION_AFTER) |
113 |
if (((UnmatchedTaskContainer) currentTarget).getRepositoryUrl().equals(task.getRepositoryUrl())) { |
123 |
&& view != null && view.isScheduledPresentation()) { |
114 |
moveTask(task, (AbstractTaskCategory) currentTarget); |
124 |
if (targetTask instanceof AbstractTask) { |
|
|
125 |
DateRange targetDate = ((AbstractTask) targetTask).getScheduledForDate(); |
126 |
TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, targetDate); |
127 |
} |
115 |
} |
128 |
} else { |
116 |
} else if (currentTarget instanceof ITask) { |
129 |
AbstractTaskCategory targetCategory = null; |
117 |
ITask targetTask = (ITask) currentTarget; |
130 |
// TODO: TaskCategory only used what about AbstractTaskCategory descendants? |
118 |
TaskListView view = TaskListView.getFromActivePerspective(); |
131 |
ITaskContainer container = TaskCategory.getParentTaskCategory(targetTask); |
119 |
if ((getCurrentLocation() == LOCATION_BEFORE || getCurrentLocation() == LOCATION_AFTER) |
132 |
if (container instanceof TaskCategory || container instanceof UncategorizedTaskContainer) { |
120 |
&& view != null && view.isScheduledPresentation()) { |
133 |
targetCategory = (AbstractTaskCategory) container; |
121 |
if (targetTask instanceof AbstractTask) { |
134 |
} else if (container instanceof UnmatchedTaskContainer) { |
122 |
DateRange targetDate = ((AbstractTask) targetTask).getScheduledForDate(); |
135 |
if (((UnmatchedTaskContainer) container).getRepositoryUrl().equals(task.getRepositoryUrl())) { |
123 |
TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, targetDate); |
|
|
124 |
} |
125 |
} else { |
126 |
AbstractTaskCategory targetCategory = null; |
127 |
// TODO: TaskCategory only used what about AbstractTaskCategory descendants? |
128 |
ITaskContainer container = TaskCategory.getParentTaskCategory(targetTask); |
129 |
if (container instanceof TaskCategory || container instanceof UncategorizedTaskContainer) { |
136 |
targetCategory = (AbstractTaskCategory) container; |
130 |
targetCategory = (AbstractTaskCategory) container; |
|
|
131 |
} else if (container instanceof UnmatchedTaskContainer) { |
132 |
if (((UnmatchedTaskContainer) container).getRepositoryUrl().equals( |
133 |
task.getRepositoryUrl())) { |
134 |
targetCategory = (AbstractTaskCategory) container; |
135 |
} |
136 |
} |
137 |
if (targetCategory != null) { |
138 |
moveTask(task, targetCategory); |
137 |
} |
139 |
} |
138 |
} |
140 |
} |
139 |
if (targetCategory != null) { |
141 |
} else if (currentTarget instanceof ScheduledTaskContainer) { |
140 |
moveTask(task, targetCategory); |
142 |
ScheduledTaskContainer container = (ScheduledTaskContainer) currentTarget; |
|
|
143 |
if (container instanceof Unscheduled) { |
144 |
TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, null); |
145 |
} else if (isValidTarget(container)) { |
146 |
TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, |
147 |
container.getDateRange()); |
141 |
} |
148 |
} |
|
|
149 |
} else if (currentTarget == null) { |
150 |
moveTask(task, TasksUiPlugin.getTaskList().getDefaultCategory()); |
142 |
} |
151 |
} |
143 |
} else if (currentTarget instanceof ScheduledTaskContainer) { |
|
|
144 |
ScheduledTaskContainer container = (ScheduledTaskContainer) currentTarget; |
145 |
if (container instanceof Unscheduled) { |
146 |
TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, null); |
147 |
} else if (isValidTarget(container)) { |
148 |
TasksUiPlugin.getTaskActivityManager().setScheduledFor((AbstractTask) task, |
149 |
container.getDateRange()); |
150 |
} |
151 |
} else if (currentTarget == null) { |
152 |
moveTask(task, TasksUiPlugin.getTaskList().getDefaultCategory()); |
153 |
} |
152 |
} |
154 |
} |
153 |
} |
155 |
} |
154 |
} |
Lines 260-265
Link Here
|
260 |
return true; |
259 |
return true; |
261 |
} else if (target instanceof LocalTask && getCurrentLocation() == ViewerDropAdapter.LOCATION_ON) { |
260 |
} else if (target instanceof LocalTask && getCurrentLocation() == ViewerDropAdapter.LOCATION_ON) { |
262 |
return true; |
261 |
return true; |
|
|
262 |
} else if (target instanceof ITask && getCurrentLocation() == ViewerDropAdapter.LOCATION_ON |
263 |
&& getCurrentOperation() != DND.DROP_MOVE) { |
264 |
return true; |
263 |
} else { |
265 |
} else { |
264 |
return false; |
266 |
return false; |
265 |
} |
267 |
} |