Lines 11-31
Link Here
|
11 |
|
11 |
|
12 |
package org.eclipse.mylyn.internal.tasks.core.sync; |
12 |
package org.eclipse.mylyn.internal.tasks.core.sync; |
13 |
|
13 |
|
|
|
14 |
import java.util.ArrayList; |
15 |
import java.util.List; |
14 |
import java.util.Set; |
16 |
import java.util.Set; |
15 |
|
17 |
|
16 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.runtime.CoreException; |
|
|
19 |
import org.eclipse.core.runtime.IConfigurationElement; |
20 |
import org.eclipse.core.runtime.IExtensionRegistry; |
17 |
import org.eclipse.core.runtime.IProgressMonitor; |
21 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
22 |
import org.eclipse.core.runtime.ISafeRunnable; |
18 |
import org.eclipse.core.runtime.IStatus; |
23 |
import org.eclipse.core.runtime.IStatus; |
19 |
import org.eclipse.core.runtime.OperationCanceledException; |
24 |
import org.eclipse.core.runtime.OperationCanceledException; |
|
|
25 |
import org.eclipse.core.runtime.Platform; |
26 |
import org.eclipse.core.runtime.SafeRunner; |
20 |
import org.eclipse.core.runtime.Status; |
27 |
import org.eclipse.core.runtime.Status; |
|
|
28 |
import org.eclipse.mylyn.commons.core.IDelegatingProgressMonitor; |
21 |
import org.eclipse.mylyn.commons.core.StatusHandler; |
29 |
import org.eclipse.mylyn.commons.core.StatusHandler; |
22 |
import org.eclipse.mylyn.commons.net.Policy; |
30 |
import org.eclipse.mylyn.commons.net.Policy; |
23 |
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; |
31 |
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants; |
24 |
import org.eclipse.mylyn.internal.tasks.core.TaskTask; |
|
|
25 |
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants.MutexSchedulingRule; |
32 |
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants.MutexSchedulingRule; |
|
|
33 |
import org.eclipse.mylyn.internal.tasks.core.TaskTask; |
26 |
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager; |
34 |
import org.eclipse.mylyn.internal.tasks.core.data.TaskDataManager; |
27 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
35 |
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector; |
28 |
import org.eclipse.mylyn.tasks.core.ITask; |
36 |
import org.eclipse.mylyn.tasks.core.ITask; |
|
|
37 |
import org.eclipse.mylyn.tasks.core.ITaskSubmitListener; |
29 |
import org.eclipse.mylyn.tasks.core.RepositoryResponse; |
38 |
import org.eclipse.mylyn.tasks.core.RepositoryResponse; |
30 |
import org.eclipse.mylyn.tasks.core.RepositoryStatus; |
39 |
import org.eclipse.mylyn.tasks.core.RepositoryStatus; |
31 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
40 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
Lines 38-43
Link Here
|
38 |
* @author Steffen Pingel |
47 |
* @author Steffen Pingel |
39 |
*/ |
48 |
*/ |
40 |
public class SubmitTaskJob extends SubmitJob { |
49 |
public class SubmitTaskJob extends SubmitJob { |
|
|
50 |
|
51 |
private static final String EXTENSION_SUBMIT_LISTENER = "org.eclipse.mylyn.tasks.core.submitListener"; //$NON-NLS-1$ |
52 |
|
53 |
private static final String ATTR_CLASS = "class"; //$NON-NLS-1$ |
54 |
|
55 |
/** |
56 |
* listeners provided by extension point |
57 |
*/ |
58 |
private static List<ITaskSubmitListener> listeners; |
41 |
|
59 |
|
42 |
private final TaskRepository taskRepository; |
60 |
private final TaskRepository taskRepository; |
43 |
|
61 |
|
Lines 65-70
Link Here
|
65 |
this.taskData = taskData; |
83 |
this.taskData = taskData; |
66 |
this.oldAttributes = oldAttributes; |
84 |
this.oldAttributes = oldAttributes; |
67 |
setRule(new MutexSchedulingRule()); |
85 |
setRule(new MutexSchedulingRule()); |
|
|
86 |
loadListeners(); |
87 |
} |
88 |
|
89 |
private synchronized static void loadListeners() { |
90 |
if (listeners == null) { |
91 |
listeners = new ArrayList<ITaskSubmitListener>(); |
92 |
IExtensionRegistry registry = Platform.getExtensionRegistry(); |
93 |
IConfigurationElement[] configurationElements = registry.getConfigurationElementsFor(EXTENSION_SUBMIT_LISTENER); |
94 |
for (IConfigurationElement element : configurationElements) { |
95 |
try { |
96 |
Object listener = element.createExecutableExtension(ATTR_CLASS); |
97 |
if (listener instanceof ITaskSubmitListener) { |
98 |
listeners.add((ITaskSubmitListener) listener); |
99 |
} else { |
100 |
StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, |
101 |
"Specified submit listener is not of type ITaskSubmitListener.", new Exception())); //$NON-NLS-1$ |
102 |
} |
103 |
} catch (Exception e) { |
104 |
StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, |
105 |
"Could not create submit listener.", e)); //$NON-NLS-1$ |
106 |
} |
107 |
} |
108 |
} |
68 |
} |
109 |
} |
69 |
|
110 |
|
70 |
@Override |
111 |
@Override |
Lines 96-101
Link Here
|
96 |
task = createTask(monitor, updatedTaskData); |
137 |
task = createTask(monitor, updatedTaskData); |
97 |
taskDataManager.putSubmittedTaskData(task, updatedTaskData, monitor); |
138 |
taskDataManager.putSubmittedTaskData(task, updatedTaskData, monitor); |
98 |
fireTaskSynchronized(monitor); |
139 |
fireTaskSynchronized(monitor); |
|
|
140 |
fireTaskSubmissionComplete(monitor); |
99 |
} catch (CoreException e) { |
141 |
} catch (CoreException e) { |
100 |
errorStatus = e.getStatus(); |
142 |
errorStatus = e.getStatus(); |
101 |
} catch (OperationCanceledException e) { |
143 |
} catch (OperationCanceledException e) { |
Lines 115-120
Link Here
|
115 |
} |
157 |
} |
116 |
} |
158 |
} |
117 |
|
159 |
|
|
|
160 |
/** |
161 |
* @since 3.7 |
162 |
*/ |
163 |
protected void fireTaskSubmissionComplete(final IDelegatingProgressMonitor monitor) { |
164 |
for (final ITaskSubmitListener listener : listeners) { |
165 |
SafeRunner.run(new ISafeRunnable() { |
166 |
public void run() throws Exception { |
167 |
listener.taskSubmitted(task, Policy.subMonitorFor(monitor, 100)); |
168 |
} |
169 |
|
170 |
public void handleException(Throwable e) { |
171 |
StatusHandler.log(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, |
172 |
"Error thrown by ITaskSubmitListener", e)); //$NON-NLS-1$ |
173 |
} |
174 |
}); |
175 |
} |
176 |
} |
177 |
|
118 |
private ITask createTask(IProgressMonitor monitor, TaskData updatedTaskData) throws CoreException { |
178 |
private ITask createTask(IProgressMonitor monitor, TaskData updatedTaskData) throws CoreException { |
119 |
if (taskData.isNew()) { |
179 |
if (taskData.isNew()) { |
120 |
task = new TaskTask(connector.getConnectorKind(), taskRepository.getRepositoryUrl(), |
180 |
task = new TaskTask(connector.getConnectorKind(), taskRepository.getRepositoryUrl(), |