View | Details | Raw Unified | Return to bug 333930 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.mylyn.tasks.core/plugin.xml (+1 lines)
Lines 13-18 Link Here
13
<plugin>
13
<plugin>
14
   <extension-point id="templates" name="templates" schema="schema/templates.exsd"/>
14
   <extension-point id="templates" name="templates" schema="schema/templates.exsd"/>
15
   <extension-point id="synchronizationParticipants" name="Synchronization Participants" schema="schema/synchronizationParticipants.exsd"/>
15
   <extension-point id="synchronizationParticipants" name="Synchronization Participants" schema="schema/synchronizationParticipants.exsd"/>
16
   <extension-point id="submitListener" name="org.eclipse.mylyn.tasks.core" schema="schema/submitListener.exsd"/>
16
   
17
   
17
   <!--
18
   <!--
18
   <extension 
19
   <extension 
(-)a/org.eclipse.mylyn.tasks.core/schema/submitListener.exsd (+90 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.mylyn.tasks.core" xmlns="http://www.w3.org/2001/XMLSchema">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.mylyn.tasks.core" id="submitListener" name="org.eclipse.mylyn.tasks.core"/>
7
      </appInfo>
8
      <documentation>
9
         Provides notification of task submission.
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <annotation>
15
         <appInfo>
16
            <meta.element />
17
         </appInfo>
18
      </annotation>
19
      <complexType>
20
         <sequence minOccurs="1" maxOccurs="unbounded">
21
            <element ref="SubmitListener"/>
22
         </sequence>
23
         <attribute name="point" type="string" use="required">
24
            <annotation>
25
               <documentation>
26
                  
27
               </documentation>
28
            </annotation>
29
         </attribute>
30
         <attribute name="id" type="string">
31
            <annotation>
32
               <documentation>
33
                  
34
               </documentation>
35
            </annotation>
36
         </attribute>
37
         <attribute name="name" type="string">
38
            <annotation>
39
               <documentation>
40
                  
41
               </documentation>
42
               <appInfo>
43
                  <meta.attribute translatable="true"/>
44
               </appInfo>
45
            </annotation>
46
         </attribute>
47
      </complexType>
48
   </element>
49
50
   <element name="SubmitListener">
51
      <complexType>
52
         <attribute name="class" type="string">
53
            <annotation>
54
               <documentation>
55
                  
56
               </documentation>
57
               <appInfo>
58
                  <meta.attribute kind="java" basedOn=":org.eclipse.mylyn.tasks.core.ITaskSubmitListener"/>
59
               </appInfo>
60
            </annotation>
61
         </attribute>
62
      </complexType>
63
   </element>
64
65
   <annotation>
66
      <appInfo>
67
         <meta.section type="since"/>
68
      </appInfo>
69
      <documentation>
70
         3.7
71
      </documentation>
72
   </annotation>
73
74
75
76
77
   <annotation>
78
      <appInfo>
79
         <meta.section type="copyright"/>
80
      </appInfo>
81
      <documentation>
82
         Copyright (c) 2004, 2009 Tasktop Technologies and others.
83
All rights reserved. This program and the accompanying materials
84
are made available under the terms of the Eclipse Public License v1.0
85
which accompanies this distribution, and is available at
86
http://www.eclipse.org/legal/epl-v10.html
87
      </documentation>
88
   </annotation>
89
90
</schema>
(-)a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/SubmitTaskJob.java (-1 / +61 lines)
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(),
(-)a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/ITaskSubmitListener.java (+23 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Tasktop Technologies and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Tasktop Technologies - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.tasks.core;
13
14
import org.eclipse.core.runtime.IProgressMonitor;
15
16
/**
17
 * @author Sam Davis
18
 */
19
public interface ITaskSubmitListener {
20
21
	public void taskSubmitted(ITask task, IProgressMonitor monitor);
22
23
}

Return to bug 333930