Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 117517 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/internal/team/TeamRespositoriesManager.java (-3 / +3 lines)
Lines 64-71 Link Here
64
64
65
	private void readExtensions() {
65
	private void readExtensions() {
66
		ArrayList<AbstractTeamRepositoryProvider> providerList = new ArrayList<AbstractTeamRepositoryProvider>();
66
		ArrayList<AbstractTeamRepositoryProvider> providerList = new ArrayList<AbstractTeamRepositoryProvider>();
67
		IExtensionPoint teamProvider = Platform.getExtensionRegistry().getExtensionPoint(
67
		IExtensionPoint teamProvider = Platform.getExtensionRegistry().getExtensionPoint(MylarTeamPlugin.PLUGIN_ID,
68
				MylarTeamPlugin.PLUGIN_ID, EXT_POINT_TEAM_REPOSITORY_PROVIDER);
68
				EXT_POINT_TEAM_REPOSITORY_PROVIDER);
69
		IExtension[] extensions = teamProvider.getExtensions();
69
		IExtension[] extensions = teamProvider.getExtensions();
70
		for (int i = 0; i < extensions.length; i++) {
70
		for (int i = 0; i < extensions.length; i++) {
71
			IExtension extension = extensions[i];
71
			IExtension extension = extensions[i];
Lines 81-87 Link Here
81
								.createExecutableExtension(ATTR_CLASS);
81
								.createExecutableExtension(ATTR_CLASS);
82
						providerList.add(provider);
82
						providerList.add(provider);
83
					} catch (CoreException e) {
83
					} catch (CoreException e) {
84
						// ignore, we 
84
						// ignore, we
85
						MylarStatusHandler.log(e, MessageFormat.format(
85
						MylarStatusHandler.log(e, MessageFormat.format(
86
								"Error while initializing repository contribution {0} from plugin {1}.", element
86
								"Error while initializing repository contribution {0} from plugin {1}.", element
87
										.getAttribute(ATTR_CLASS), element.getContributor().getName()));
87
										.getAttribute(ATTR_CLASS), element.getContributor().getName()));
(-)src/org/eclipse/mylar/internal/team/ContextChangeSetManager.java (-19 / +20 lines)
Lines 76-86 Link Here
76
	private Map<String, ContextChangeSet> activeChangeSets = new HashMap<String, ContextChangeSet>();
76
	private Map<String, ContextChangeSet> activeChangeSets = new HashMap<String, ContextChangeSet>();
77
77
78
	private ITaskActivityListener TASK_ACTIVITY_LISTENER = new ITaskActivityListener() {
78
	private ITaskActivityListener TASK_ACTIVITY_LISTENER = new ITaskActivityListener() {
79
		
79
80
		public void taskListRead() {
80
		public void taskListRead() {
81
			initContextChangeSets();
81
			initContextChangeSets();
82
		}
82
		}
83
		
83
84
		public void taskActivated(ITask task) {
84
		public void taskActivated(ITask task) {
85
			// ignore
85
			// ignore
86
		}
86
		}
Lines 90-107 Link Here
90
		}
90
		}
91
91
92
		public void taskDeactivated(ITask task) {
92
		public void taskDeactivated(ITask task) {
93
			// ignore			
93
			// ignore
94
		}
94
		}
95
95
96
		public void activityChanged(DateRangeContainer week) {
96
		public void activityChanged(DateRangeContainer week) {
97
			// ignore	
97
			// ignore
98
		}
98
		}
99
99
100
		public void calendarChanged() {
100
		public void calendarChanged() {
101
			// ignore
101
			// ignore
102
		}
102
		}
103
	};
103
	};
104
	
104
105
	private ITaskListChangeListener TASK_CHANGE_LISTENER = new ITaskListChangeListener() {
105
	private ITaskListChangeListener TASK_CHANGE_LISTENER = new ITaskListChangeListener() {
106
106
107
		public void localInfoChanged(ITask task) {
107
		public void localInfoChanged(ITask task) {
Lines 154-160 Link Here
154
		List<AbstractTeamRepositoryProvider> providerList = TeamRespositoriesManager.getInstance().getProviders();
154
		List<AbstractTeamRepositoryProvider> providerList = TeamRespositoriesManager.getInstance().getProviders();
155
		for (AbstractTeamRepositoryProvider provider : providerList) {
155
		for (AbstractTeamRepositoryProvider provider : providerList) {
156
			ActiveChangeSetManager changeSetManager = provider.getActiveChangeSetManager();
156
			ActiveChangeSetManager changeSetManager = provider.getActiveChangeSetManager();
157
			if(null != changeSetManager)
157
			if (null != changeSetManager)
158
				collectors.add(changeSetManager);
158
				collectors.add(changeSetManager);
159
		}
159
		}
160
	}
160
	}
Lines 239-254 Link Here
239
					ContextChangeSet contextChangeSet = new ContextChangeSet(task, collector);
239
					ContextChangeSet contextChangeSet = new ContextChangeSet(task, collector);
240
					List<IResource> interestingResources = MylarResourcesPlugin.getDefault().getInterestingResources();
240
					List<IResource> interestingResources = MylarResourcesPlugin.getDefault().getInterestingResources();
241
					contextChangeSet.add(interestingResources.toArray(new IResource[interestingResources.size()]));
241
					contextChangeSet.add(interestingResources.toArray(new IResource[interestingResources.size()]));
242
	
242
243
					activeChangeSets.put(task.getHandleIdentifier(), contextChangeSet);
243
					activeChangeSets.put(task.getHandleIdentifier(), contextChangeSet);
244
244
245
					if (!collector.contains(contextChangeSet)) {
245
					if (!collector.contains(contextChangeSet)) {
246
						collector.add(contextChangeSet);
246
						collector.add(contextChangeSet);
247
					}
247
					}
248
//					collector.makeDefault(contextChangeSet);
248
					// collector.makeDefault(contextChangeSet);
249
//					IdeUiUtil.forceSynchronizeViewUpdate();
249
					// IdeUiUtil.forceSynchronizeViewUpdate();
250
//					DiffChangeEvent event = new DiffChangeEvent(contextChangeSet.getDiffTree());
250
					// DiffChangeEvent event = new
251
//					collector.diffsChanged(event, new NullProgressMonitor());
251
					// DiffChangeEvent(contextChangeSet.getDiffTree());
252
					// collector.diffsChanged(event, new NullProgressMonitor());
252
				}
253
				}
253
			}
254
			}
254
		} catch (Exception e) {
255
		} catch (Exception e) {
Lines 320-333 Link Here
320
								}
321
								}
321
							}
322
							}
322
						}
323
						}
323
//						if (shouldRemove(element)) {
324
						// if (shouldRemove(element)) {
324
//							ChangeSet[] sets = collector.getSets();
325
						// ChangeSet[] sets = collector.getSets();
325
//							for (int i = 0; i < sets.length; i++) {
326
						// for (int i = 0; i < sets.length; i++) {
326
//								if (sets[i] instanceof MylarActiveChangeSet) {
327
						// if (sets[i] instanceof MylarActiveChangeSet) {
327
//									sets[i].remove(resource);
328
						// sets[i].remove(resource);
328
//								}
329
						// }
329
//							}
330
						// }
330
//						}
331
						// }
331
					}
332
					}
332
				}
333
				}
333
			} catch (Exception e) {
334
			} catch (Exception e) {
(-)src/org/eclipse/mylar/internal/team/ContextChangeSet.java (-44 / +54 lines)
Lines 7-30 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
9
 *     University Of British Columbia - initial API and implementation
10
 *     Eike Stepper - template based commit templates
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.team;
12
package org.eclipse.mylar.internal.team;
13
13
14
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.HashSet;
17
import java.util.List;
18
import java.util.Set;
19
20
import org.eclipse.core.resources.IResource;
14
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
22
import org.eclipse.core.resources.mapping.ResourceMapping;
16
import org.eclipse.core.resources.mapping.ResourceMapping;
23
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.core.runtime.CoreException;
24
import org.eclipse.core.runtime.IAdaptable;
18
import org.eclipse.core.runtime.IAdaptable;
25
import org.eclipse.mylar.context.core.InteractionEvent;
19
import org.eclipse.mylar.context.core.InteractionEvent;
20
import org.eclipse.mylar.context.core.MylarStatusHandler;
26
import org.eclipse.mylar.resources.MylarResourcesPlugin;
21
import org.eclipse.mylar.resources.MylarResourcesPlugin;
27
import org.eclipse.mylar.tasks.core.ITask;
22
import org.eclipse.mylar.tasks.core.ITask;
23
import org.eclipse.mylar.team.ITemplateHandlersManager;
28
import org.eclipse.mylar.team.MylarTeamPlugin;
24
import org.eclipse.mylar.team.MylarTeamPlugin;
29
import org.eclipse.team.core.TeamException;
25
import org.eclipse.team.core.TeamException;
30
import org.eclipse.team.core.diff.IDiff;
26
import org.eclipse.team.core.diff.IDiff;
Lines 35-40 Link Here
35
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
31
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
36
import org.osgi.service.prefs.Preferences;
32
import org.osgi.service.prefs.Preferences;
37
33
34
import java.util.ArrayList;
35
import java.util.Arrays;
36
import java.util.HashSet;
37
import java.util.List;
38
import java.util.Set;
39
import java.util.regex.Matcher;
40
import java.util.regex.Pattern;
41
38
/**
42
/**
39
 * @author Mik Kersten
43
 * @author Mik Kersten
40
 */
44
 */
Lines 65-71 Link Here
65
	public boolean isUserCreated() {
69
	public boolean isUserCreated() {
66
		return true;
70
		return true;
67
	}
71
	}
68
	
72
69
	public void initTitle() {
73
	public void initTitle() {
70
		super.setName(task.getDescription());
74
		super.setName(task.getDescription());
71
		super.setTitle(task.getDescription());
75
		super.setTitle(task.getDescription());
Lines 97-109 Link Here
97
101
98
	@Override
102
	@Override
99
	public String getComment() {
103
	public String getComment() {
100
		String completedPrefix = MylarTeamPlugin.getDefault().getPreferenceStore().getString(
104
		String completedTemplate = MylarTeamPlugin.getDefault().getPreferenceStore().getString(
101
				MylarTeamPlugin.COMMIT_PREFIX_COMPLETED);
105
				MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED);
102
		String progressPrefix = MylarTeamPlugin.getDefault().getPreferenceStore().getString(
106
		String progressTemplate = MylarTeamPlugin.getDefault().getPreferenceStore().getString(
103
				MylarTeamPlugin.COMMIT_PREFIX_PROGRESS);
107
				MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS);
104
		String comment = "";
108
		return ITemplateHandlersManager.INSTANCE.generateComment(task, completedTemplate, progressTemplate);
105
		comment = generateComment(task, completedPrefix, progressPrefix);
106
		return comment;
107
	}
109
	}
108
110
109
	@Override
111
	@Override
Lines 122-144 Link Here
122
		IResource resource = getResourceFromDiff(diff);
124
		IResource resource = getResourceFromDiff(diff);
123
		if (!suppressInterestContribution && resource != null) {
125
		if (!suppressInterestContribution && resource != null) {
124
			Set<IResource> resources = new HashSet<IResource>();
126
			Set<IResource> resources = new HashSet<IResource>();
125
			resources.add(resource); 
127
			resources.add(resource);
126
			if (MylarResourcesPlugin.getDefault() != null) {
128
			if (MylarResourcesPlugin.getDefault() != null) {
127
				MylarResourcesPlugin.getDefault().getInterestUpdater().addResourceToContext(resources, InteractionEvent.Kind.SELECTION);
129
				MylarResourcesPlugin.getDefault().getInterestUpdater().addResourceToContext(resources,
130
						InteractionEvent.Kind.SELECTION);
128
			}
131
			}
129
		}
132
		}
130
	}
133
	}
131
134
132
	private IResource getResourceFromDiff(IDiff diff) {
135
	private IResource getResourceFromDiff(IDiff diff) {
133
		if (diff instanceof ResourceDiff) {
136
		if (diff instanceof ResourceDiff) {
134
			return ((ResourceDiff)diff).getResource();
137
			return ((ResourceDiff) diff).getResource();
135
		} else if (diff instanceof ThreeWayDiff) {
138
		} else if (diff instanceof ThreeWayDiff) {
136
			ThreeWayDiff threeWayDiff = (ThreeWayDiff)diff;
139
			ThreeWayDiff threeWayDiff = (ThreeWayDiff) diff;
137
			return ResourcesPlugin.getWorkspace().getRoot().findMember(threeWayDiff.getPath());
140
			return ResourcesPlugin.getWorkspace().getRoot().findMember(threeWayDiff.getPath());
138
		} else {
141
		} else {
139
			return null;
142
			return null;
140
		}
143
		}
141
	} 
144
	}
142
145
143
	@Override
146
	@Override
144
	public void add(IDiff[] diffs) {
147
	public void add(IDiff[] diffs) {
Lines 172-178 Link Here
172
		Set<IResource> allResources = new HashSet<IResource>();
175
		Set<IResource> allResources = new HashSet<IResource>();
173
		allResources.addAll(Arrays.asList(super.getResources()));
176
		allResources.addAll(Arrays.asList(super.getResources()));
174
		if (MylarResourcesPlugin.getDefault() != null && task.isActive()) {
177
		if (MylarResourcesPlugin.getDefault() != null && task.isActive()) {
175
			// TODO: if super is always managed correctly should remove following line
178
			// TODO: if super is always managed correctly should remove
179
			// following line
176
			allResources.addAll(MylarResourcesPlugin.getDefault().getInterestingResources());
180
			allResources.addAll(MylarResourcesPlugin.getDefault().getInterestingResources());
177
		}
181
		}
178
		return new ArrayList<IResource>(allResources);
182
		return new ArrayList<IResource>(allResources);
Lines 185-226 Link Here
185
		return getAllResourcesInChangeContext().contains(local);
189
		return getAllResourcesInChangeContext().contains(local);
186
	}
190
	}
187
191
188
	public static String generateComment(ITask task, String completedPrefix, String progressPrefix) {
192
	public static String generateComment(ITask task, String completedTemplate, String progressTemplate) {
189
		String comment;
193
		return ITemplateHandlersManager.INSTANCE.generateComment(task, completedTemplate, progressTemplate);
190
		completedPrefix = fixUpDelimIfPresent(completedPrefix);
194
	}
191
		progressPrefix = fixUpDelimIfPresent(progressPrefix);
195
192
		if (task.isCompleted()) {
196
	public static String getTaskIdFromCommentOrLabel(String commentOrLabel) {
193
			comment = completedPrefix + PREFIX_DELIM;
197
		String id = getTaskIdFromComment(commentOrLabel);
194
		} else {
198
		if (id == null) {
195
			comment = progressPrefix + PREFIX_DELIM;
199
			id = getTaskIdFromLabel(commentOrLabel);
196
		}
197
		comment += task.getDescription();
198
		String url = task.getUrl();
199
		if (url != null && !url.equals("") && !url.endsWith("//")) {
200
			comment += " \n" + url;
201
		}
200
		}
202
		return comment;
201
202
		return id;
203
	}
203
	}
204
204
205
	private static String fixUpDelimIfPresent(String prefix) {
205
	public static String getTaskIdFromComment(String comment) {
206
		if (prefix.endsWith(":") || prefix.endsWith(PREFIX_DELIM)) {
206
		try {
207
			prefix = prefix.substring(0, prefix.lastIndexOf(':'));
207
			String regex = MylarTeamPlugin.getDefault().getPreferenceStore().getString(
208
					MylarTeamPlugin.COMMIT_REGEX_TASK_ID);
209
210
			Pattern pattern = Pattern.compile(regex);
211
			Matcher matcher = pattern.matcher(comment);
212
			if (matcher.find()) {
213
				return matcher.group(1);
214
			}
215
		} catch (Exception ex) {
216
			MylarStatusHandler.log(ex, "Problem while parsing task id from comment");
208
		}
217
		}
209
		return prefix;
218
219
		return null;
210
	}
220
	}
211
221
212
	public static String getTaskIdFromCommentOrLabel(String comment) {
222
	public static String getTaskIdFromLabel(String label) {
213
		int firstDelimIndex = comment.indexOf(PREFIX_DELIM);
223
		int firstDelimIndex = label.indexOf(PREFIX_DELIM);
214
		if (firstDelimIndex != -1) {
224
		if (firstDelimIndex != -1) {
215
			int idStart = firstDelimIndex + PREFIX_DELIM.length();
225
			int idStart = firstDelimIndex + PREFIX_DELIM.length();
216
			int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + PREFIX_DELIM.length());// comment.indexOf(PREFIX_DELIM);
226
			int idEnd = label.indexOf(PREFIX_DELIM, firstDelimIndex + PREFIX_DELIM.length());// comment.indexOf(PREFIX_DELIM);
217
			if (idEnd != -1 && idStart < idEnd) {
227
			if (idEnd != -1 && idStart < idEnd) {
218
				String id = comment.substring(idStart, idEnd);
228
				String id = label.substring(idStart, idEnd);
219
				if (id != null)
229
				if (id != null)
220
					return id.trim();
230
					return id.trim();
221
			} else {
231
			} else {
222
				// change set label
232
				// change set label
223
				return comment.substring(0, firstDelimIndex);
233
				return label.substring(0, firstDelimIndex);
224
			}
234
			}
225
		}
235
		}
226
		return null;
236
		return null;
(-)src/org/eclipse/mylar/internal/team/ui/actions/OpenCorrespondingTaskAction.java (-5 / +5 lines)
Lines 76-91 Link Here
76
			// find change set if available
76
			// find change set if available
77
			element = findParent((ISynchronizeModelElement) element);
77
			element = findParent((ISynchronizeModelElement) element);
78
		}
78
		}
79
		
79
80
		if (element instanceof ContextChangeSet) {
80
		if (element instanceof ContextChangeSet) {
81
			ITask task = ((ContextChangeSet)element).getTask();
81
			ITask task = ((ContextChangeSet) element).getTask();
82
			if (task != null) {
82
			if (task != null) {
83
				TaskUiUtil.openEditor(task, false);
83
				TaskUiUtil.openEditor(task, false);
84
				resolved = true;
84
				resolved = true;
85
			}
85
			}
86
		} else {
86
		} else {
87
			if (element instanceof CVSCheckedInChangeSet) {
87
			if (element instanceof CVSCheckedInChangeSet) {
88
				comment = ((CVSCheckedInChangeSet)element).getComment();
88
				comment = ((CVSCheckedInChangeSet) element).getComment();
89
			} else if (element instanceof ChangeSetDiffNode) {
89
			} else if (element instanceof ChangeSetDiffNode) {
90
				ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element;
90
				ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element;
91
				if (diffNode.getSet() instanceof ContextChangeSet) {
91
				if (diffNode.getSet() instanceof ContextChangeSet) {
Lines 99-105 Link Here
99
				comment = ((LogEntry) element).getComment();
99
				comment = ((LogEntry) element).getComment();
100
			} else if (element instanceof IFileRevision) {
100
			} else if (element instanceof IFileRevision) {
101
				comment = ((IFileRevision) element).getComment();
101
				comment = ((IFileRevision) element).getComment();
102
			} 
102
			}
103
			if (comment != null) {
103
			if (comment != null) {
104
				String fullUrl = ContextChangeSet.getUrlFromComment(comment);
104
				String fullUrl = ContextChangeSet.getUrlFromComment(comment);
105
				String repositoryUrl = null;
105
				String repositoryUrl = null;
Lines 119-125 Link Here
119
				}
119
				}
120
				String id = ContextChangeSet.getTaskIdFromCommentOrLabel(comment);
120
				String id = ContextChangeSet.getTaskIdFromCommentOrLabel(comment);
121
				resolved = TaskUiUtil.openRepositoryTask(repositoryUrl, id, fullUrl);
121
				resolved = TaskUiUtil.openRepositoryTask(repositoryUrl, id, fullUrl);
122
	
122
123
				if (!resolved) {
123
				if (!resolved) {
124
					TaskUiUtil.openUrl(fullUrl);
124
					TaskUiUtil.openUrl(fullUrl);
125
					resolved = true;
125
					resolved = true;
(-)src/org/eclipse/mylar/internal/team/ui/actions/TaskResourceMappingActionProvider.java (-9 / +9 lines)
Lines 22-39 Link Here
22
public class TaskResourceMappingActionProvider extends CommonActionProvider {
22
public class TaskResourceMappingActionProvider extends CommonActionProvider {
23
23
24
	private OpenCorrespondingTaskAction openCorrespondingAction = new OpenCorrespondingTaskAction();
24
	private OpenCorrespondingTaskAction openCorrespondingAction = new OpenCorrespondingTaskAction();
25
	
25
26
	public void fillContextMenu(IMenuManager menuManager) {
26
	public void fillContextMenu(IMenuManager menuManager) {
27
		IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
27
		IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
28
		openCorrespondingAction.selectionChanged(openCorrespondingAction, selection);
28
		openCorrespondingAction.selectionChanged(openCorrespondingAction, selection);
29
		
29
30
		menuManager.insertAfter(ICommonMenuConstants.GROUP_ADDITIONS, openCorrespondingAction);
30
		menuManager.insertAfter(ICommonMenuConstants.GROUP_ADDITIONS, openCorrespondingAction);
31
		
31
32
//		openCorrespondingAction.selectionChanged(selection);
32
		// openCorrespondingAction.selectionChanged(selection);
33
//		if (openCorrespondingAction.isEnabled()) {
33
		// if (openCorrespondingAction.isEnabled()) {
34
//			menuManager.insertAfter(ICommonMenuConstants.GROUP_OPEN, openAction);
34
		// menuManager.insertAfter(ICommonMenuConstants.GROUP_OPEN, openAction);
35
//		}
35
		// }
36
//		menuManager.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
36
		// menuManager.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
37
	}
37
	}
38
	
38
39
}
39
}
(-)src/org/eclipse/mylar/team/AbstractTeamRepositoryProvider.java (-12 / +17 lines)
Lines 38-61 Link Here
38
38
39
	/**
39
	/**
40
	 * Determines if the team provider manages at least one of the resources and
40
	 * Determines if the team provider manages at least one of the resources and
41
	 * at least one of the resources has an 'outgoing' state (locally changed).  If
41
	 * at least one of the resources has an 'outgoing' state (locally changed).
42
	 * this method returns <code>true</code>, the team provider may be later asked
42
	 * If this method returns <code>true</code>, the team provider may be
43
	 * to {@link #commit} them.  The set of resources may contain resources from
43
	 * later asked to {@link #commit} them. The set of resources may contain
44
	 * projects that are not managed by your provider or not managed at all.
44
	 * resources from projects that are not managed by your provider or not
45
	 * managed at all.
46
	 * 
45
	 * @param resources
47
	 * @param resources
46
	 * @return <code>true</code> if the team provider manages at least one of the
48
	 * @return <code>true</code> if the team provider manages at least one of
47
	 * resources or <code>false</code> otherwise.
49
	 *         the resources or <code>false</code> otherwise.
48
	 */
50
	 */
49
	public boolean hasOutgoingChanges(IResource[] resources) {
51
	public boolean hasOutgoingChanges(IResource[] resources) {
50
		return false;
52
		return false;
51
	}
53
	}
52
	
54
53
	/**
55
	/**
54
	 * Asks the team provider to commit a set of resources that may be managed by
56
	 * Asks the team provider to commit a set of resources that may be managed
55
	 * the team provider.  It is up to the team provider to only operate on resources
57
	 * by the team provider. It is up to the team provider to only operate on
56
	 * that are being managed by it.  The set of resources may contain resources from
58
	 * resources that are being managed by it. The set of resources may contain
57
	 * projects that are not managed by your provider or not managed at all.
59
	 * resources from projects that are not managed by your provider or not
58
	 * @param resources Set of resources that need to be committed
60
	 * managed at all.
61
	 * 
62
	 * @param resources
63
	 *            Set of resources that need to be committed
59
	 */
64
	 */
60
	public void commit(IResource[] resources) {
65
	public void commit(IResource[] resources) {
61
	}
66
	}
(-)src/org/eclipse/mylar/team/MylarTeamPlugin.java (-13 / +31 lines)
Lines 1-3 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia 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
 *     University Of British Columbia - initial API and implementation
10
 *     Eike Stepper - template based commit templates
11
 *******************************************************************************/
1
package org.eclipse.mylar.team;
12
package org.eclipse.mylar.team;
2
13
3
import org.eclipse.mylar.context.core.MylarStatusHandler;
14
import org.eclipse.mylar.context.core.MylarStatusHandler;
Lines 20-32 Link Here
20
31
21
	public static final String CHANGE_SET_MANAGE = "org.eclipse.mylar.team.changesets.manage";
32
	public static final String CHANGE_SET_MANAGE = "org.eclipse.mylar.team.changesets.manage";
22
33
23
	public static final String COMMIT_PREFIX_COMPLETED = "org.eclipse.mylar.team.commit.template.completed";
34
	public static final String COMMIT_TEMPLATE_COMPLETED = "org.eclipse.mylar.team.commit.template.completed";
24
35
25
	public static final String COMMIT_PREFIX_PROGRESS = "org.eclipse.mylar.team.commit.template.progress";
36
	public static final String COMMIT_TEMPLATE_PROGRESS = "org.eclipse.mylar.team.commit.template.progress";
26
37
27
	public static final String DEFAULT_PREFIX_PROGRESS = "Progress on:";
38
	public static final String COMMIT_REGEX_TASK_ID = "org.eclipse.mylar.team.commit.regex";
28
39
29
	public static final String DEFAULT_PREFIX_COMPLETED = "Completed:";
40
	public static final String COMMIT_REGEX_AUTO_GUESS = "org.eclipse.mylar.team.commit.regex.auto.guess";
41
42
	public static final String DEFAULT_TEMPLATE_PROGRESS = "[${task.id}] ${task.summary} ${task.url}";
43
44
	public static final String DEFAULT_TEMPLATE_COMPLETED = "[${task.id}] ${task.summary} (COMPLETED) ${task.url}";
45
46
	public static final String DEFAULT_REGEX_TASK_ID = "\\[(\\d+)\\].*";
47
48
	public static final boolean DEFAULT_REGEX_AUTO_GUESS = true;
30
49
31
	public MylarTeamPlugin() {
50
	public MylarTeamPlugin() {
32
		INSTANCE = this;
51
		INSTANCE = this;
Lines 38-60 Link Here
38
57
39
		PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
58
		PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
40
			public void run() {
59
			public void run() {
41
				try { 
60
				try {
42
					changeSetManager = new ContextChangeSetManager();
61
					changeSetManager = new ContextChangeSetManager();
43
					if (getPreferenceStore().getBoolean(CHANGE_SET_MANAGE)) {
62
					if (getPreferenceStore().getBoolean(CHANGE_SET_MANAGE)) {
44
						changeSetManager.enable();
63
						changeSetManager.enable();
45
					}
64
					}
46
				} catch (Exception e) {
65
				} catch (Exception e) {
47
					MylarStatusHandler.fail(e, "Mylar Team start failed",
66
					MylarStatusHandler.fail(e, "Mylar Team start failed", false);
48
							false);
49
				}
67
				}
50
			}
68
			}
51
		});
69
		});
52
	}
70
	}
53
71
54
	public void earlyStartup() {
72
	public void earlyStartup() {
55
		// all done in start	
73
		// all done in start
56
	}
74
	}
57
	
75
58
	public void stop(BundleContext context) throws Exception {
76
	public void stop(BundleContext context) throws Exception {
59
		INSTANCE = null;
77
		INSTANCE = null;
60
		super.stop(context);
78
		super.stop(context);
Lines 63-72 Link Here
63
81
64
	private void initPreferenceDefaults() {
82
	private void initPreferenceDefaults() {
65
		getPreferenceStore().setDefault(CHANGE_SET_MANAGE, true);
83
		getPreferenceStore().setDefault(CHANGE_SET_MANAGE, true);
66
		getPreferenceStore().setDefault(COMMIT_PREFIX_COMPLETED,
84
		getPreferenceStore().setDefault(COMMIT_TEMPLATE_COMPLETED, DEFAULT_TEMPLATE_COMPLETED);
67
				DEFAULT_PREFIX_COMPLETED);
85
		getPreferenceStore().setDefault(COMMIT_TEMPLATE_PROGRESS, DEFAULT_TEMPLATE_PROGRESS);
68
		getPreferenceStore().setDefault(COMMIT_PREFIX_PROGRESS,
86
		getPreferenceStore().setDefault(COMMIT_REGEX_TASK_ID, DEFAULT_REGEX_TASK_ID);
69
				DEFAULT_PREFIX_PROGRESS);
87
		getPreferenceStore().setDefault(COMMIT_REGEX_AUTO_GUESS, DEFAULT_REGEX_AUTO_GUESS);
70
	}
88
	}
71
89
72
	public static MylarTeamPlugin getDefault() {
90
	public static MylarTeamPlugin getDefault() {
(-)plugin.xml (+89 lines)
Lines 3-8 Link Here
3
<?eclipse version="3.0"?>
3
<?eclipse version="3.0"?>
4
<plugin>
4
<plugin>
5
   <extension-point id="providers" name="Mylar Team Providers" schema="schema/providers.exsd"/>
5
   <extension-point id="providers" name="Mylar Team Providers" schema="schema/providers.exsd"/>
6
   <extension-point id="templateHandlers" name="Mylar Template Handlers" schema="schema/templateHandlers.exsd"/>
6
    
7
    
7
   <extension
8
   <extension
8
         point="org.eclipse.mylar.team.providers">
9
         point="org.eclipse.mylar.team.providers">
Lines 152-155 Link Here
152
	   </viewerActionBinding>
153
	   </viewerActionBinding>
153
	</extension>
154
	</extension>
154
	
155
	
156
    <extension
157
          point="org.eclipse.mylar.team.templateHandlers">
158
       <templateHandler
159
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$RepositoryKind"
160
             description="Provides the repository kind of a Mylar task."
161
             recognizedKeyword="repository.kind"/>
162
       <templateHandler
163
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$RepositoryURL"
164
             description="Provides the repository URL of a Mylar task."
165
             recognizedKeyword="repository.url"/>
166
       <templateHandler
167
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskAssignee"
168
             description="Provides the user a Mylar task is assigned to, if available."
169
             recognizedKeyword="task.assignee"/>
170
       <templateHandler
171
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskCC"
172
             description="Provides the comma separated CC list of a Mylar task, if available."
173
             recognizedKeyword="task.cc"/>
174
       <templateHandler
175
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskDescription"
176
             description="Provides the description of a Mylar task."
177
             recognizedKeyword="task.description"/>
178
       <templateHandler
179
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskHandle"
180
             description="Provides the handle of a Mylar task."
181
             recognizedKeyword="task.handle"/>
182
       <templateHandler
183
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskID"
184
             description="Provides the ID of a Mylar task."
185
             recognizedKeyword="task.id"/>
186
       <templateHandler
187
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskKeywords"
188
             description="Provides the comma separated keyword list of a Mylar task, if available."
189
             recognizedKeyword="task.keywords"/>
190
       <templateHandler
191
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskLastModified"
192
             description="Provides the date of last modification of a Mylar task, if available."
193
             recognizedKeyword="task.lastmodified"/>
194
       <templateHandler
195
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskNotes"
196
             description="Provides the notes of a Mylar task."
197
             recognizedKeyword="task.notes"/>
198
       <templateHandler
199
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskPriority"
200
             description="Provides the priority of a Mylar task."
201
             recognizedKeyword="task.priority"/>
202
       <templateHandler
203
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskProduct"
204
             description="Provides the prroduct a Mylar task belongs to, if available."
205
             recognizedKeyword="task.product"/>
206
       <templateHandler
207
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskReporter"
208
             description="Provides the user who reported a Mylar task, if available."
209
             recognizedKeyword="task.reporter"/>
210
       <templateHandler
211
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskResolution"
212
             description="Provides the resolution of a Mylar task, if available."
213
             recognizedKeyword="task.resolution"/>
214
       <templateHandler
215
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskStatus"
216
             description="Provides the status of a Mylar task, if available."
217
             recognizedKeyword="task.status"/>
218
       <templateHandler
219
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskSummary"
220
             description="Provides the summary or description of a Mylar task, whichever is available."
221
             recognizedKeyword="task.summary"/>
222
       <templateHandler
223
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskType"
224
             description="Provides the type of a Mylar task."
225
             recognizedKeyword="task.type"/>
226
       <templateHandler
227
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$TaskURL"
228
             description="Provides the URL of a Mylar task."
229
             recognizedKeyword="task.url"/>
230
       <templateHandler
231
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$Date$TaskCompletion"
232
             description="Provides the completion date of a Mylar task."
233
             recognizedKeyword="task.completiondate"/>
234
       <templateHandler
235
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$Date$TaskCreation"
236
             description="Provides the creation date of a Mylar task."
237
             recognizedKeyword="task.creationdate"/>
238
       <templateHandler
239
             class="org.eclipse.mylar.internal.team.template.TemplateHandler$Date$TaskReminder"
240
             description="Provides the reminder date of a Mylar task."
241
             recognizedKeyword="task.reminderdate"/>
242
    </extension>
243
	
155
</plugin>
244
</plugin>
(-)src/org/eclipse/mylar/internal/team/ccvs/CvsRepositoryProvider.java (-5 / +4 lines)
Lines 29-41 Link Here
29
 */
29
 */
30
public class CvsRepositoryProvider extends AbstractTeamRepositoryProvider {
30
public class CvsRepositoryProvider extends AbstractTeamRepositoryProvider {
31
	private static final String WIZARD_LABEL = "Commit Resources in Task Context";
31
	private static final String WIZARD_LABEL = "Commit Resources in Task Context";
32
	
32
33
	@Override
33
	@Override
34
	public ActiveChangeSetManager getActiveChangeSetManager() {
34
	public ActiveChangeSetManager getActiveChangeSetManager() {
35
		return (CVSActiveChangeSetCollector) CVSUIPlugin.getPlugin()
35
		return (CVSActiveChangeSetCollector) CVSUIPlugin.getPlugin().getChangeSetManager();
36
				.getChangeSetManager();
37
	}
36
	}
38
	
37
39
	@Override
38
	@Override
40
	public boolean hasOutgoingChanges(IResource[] resources) {
39
	public boolean hasOutgoingChanges(IResource[] resources) {
41
		try {
40
		try {
Lines 45-51 Link Here
45
			return false;
44
			return false;
46
		}
45
		}
47
	}
46
	}
48
	
47
49
	@Override
48
	@Override
50
	public void commit(IResource[] resources) {
49
	public void commit(IResource[] resources) {
51
		try {
50
		try {
(-)src/org/eclipse/mylar/internal/team/ui/ContextChangeSetDecorator.java (-3 / +2 lines)
Lines 26-33 Link Here
26
	public void decorate(Object element, IDecoration decoration) {
26
	public void decorate(Object element, IDecoration decoration) {
27
		if (element instanceof ContextChangeSet) {
27
		if (element instanceof ContextChangeSet) {
28
			decoration.addOverlay(ContextUiImages.MYLAR_OVERLAY, IDecoration.BOTTOM_RIGHT);
28
			decoration.addOverlay(ContextUiImages.MYLAR_OVERLAY, IDecoration.BOTTOM_RIGHT);
29
			ContextChangeSet changeSet = (ContextChangeSet)element;
29
			ContextChangeSet changeSet = (ContextChangeSet) element;
30
			if (changeSet.getTask().isActive()) {    
30
			if (changeSet.getTask().isActive()) {
31
				decoration.setFont(TaskListColorsAndFonts.BOLD);
31
				decoration.setFont(TaskListColorsAndFonts.BOLD);
32
			}
32
			}
33
		}
33
		}
Lines 50-54 Link Here
50
		// ignore
50
		// ignore
51
	}
51
	}
52
52
53
54
}
53
}
(-)src/org/eclipse/mylar/internal/team/ui/preferences/MylarTeamPreferencePage.java (-17 / +117 lines)
Lines 7-19 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
9
 *     University Of British Columbia - initial API and implementation
10
 *     Eike tepper - commit comment template preferences
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.mylar.internal.team.ui.preferences;
13
package org.eclipse.mylar.internal.team.ui.preferences;
13
14
15
import org.eclipse.jface.fieldassist.IContentProposalProvider;
16
import org.eclipse.jface.fieldassist.IControlContentAdapter;
17
import org.eclipse.jface.fieldassist.IControlCreator;
18
import org.eclipse.jface.fieldassist.TextContentAdapter;
14
import org.eclipse.jface.preference.PreferencePage;
19
import org.eclipse.jface.preference.PreferencePage;
20
import org.eclipse.mylar.internal.team.template.TemplateHandlerContentProposalProvider;
21
import org.eclipse.mylar.internal.team.ui.preferences.workaround.RegExContentProposalProvider;
22
import org.eclipse.mylar.team.ITemplateHandlersManager;
15
import org.eclipse.mylar.team.MylarTeamPlugin;
23
import org.eclipse.mylar.team.MylarTeamPlugin;
16
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.ModifyEvent;
26
import org.eclipse.swt.events.ModifyListener;
27
import org.eclipse.swt.events.SelectionEvent;
28
import org.eclipse.swt.events.SelectionListener;
17
import org.eclipse.swt.layout.GridData;
29
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.layout.GridLayout;
30
import org.eclipse.swt.layout.GridLayout;
19
import org.eclipse.swt.widgets.Button;
31
import org.eclipse.swt.widgets.Button;
Lines 24-40 Link Here
24
import org.eclipse.swt.widgets.Text;
36
import org.eclipse.swt.widgets.Text;
25
import org.eclipse.ui.IWorkbench;
37
import org.eclipse.ui.IWorkbench;
26
import org.eclipse.ui.IWorkbenchPreferencePage;
38
import org.eclipse.ui.IWorkbenchPreferencePage;
39
import org.eclipse.ui.fieldassist.ContentAssistField;
27
40
28
/**
41
/**
29
 * @author Mik Kersten
42
 * @author Mik Kersten
30
 */
43
 */
31
public class MylarTeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
44
public class MylarTeamPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
32
33
	private Button changeSetsManage;
45
	private Button changeSetsManage;
34
46
35
	private Text commitPrefixCompleted = null;
47
	private Text commitTemplateCompleted = null;
48
49
	private Text commitTemplateProgress = null;
50
51
	private Text regexText;
52
53
	private Button guessButton;
36
54
37
	private Text commitPrefixProgress = null;
55
	private Button autoGuessButton;
38
56
39
	public MylarTeamPreferencePage() {
57
	public MylarTeamPreferencePage() {
40
		super();
58
		super();
Lines 58-65 Link Here
58
76
59
	@Override
77
	@Override
60
	public boolean performOk() {
78
	public boolean performOk() {
61
		getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_PREFIX_COMPLETED, commitPrefixCompleted.getText());
79
		getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED, commitTemplateCompleted.getText());
62
		getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_PREFIX_PROGRESS, commitPrefixProgress.getText());
80
		getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS, commitTemplateProgress.getText());
81
		getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_REGEX_TASK_ID, regexText.getText());
82
		getPreferenceStore().setValue(MylarTeamPlugin.COMMIT_REGEX_AUTO_GUESS, autoGuessButton.getSelection());
63
		getPreferenceStore().setValue(MylarTeamPlugin.CHANGE_SET_MANAGE, changeSetsManage.getSelection());
83
		getPreferenceStore().setValue(MylarTeamPlugin.CHANGE_SET_MANAGE, changeSetsManage.getSelection());
64
84
65
		if (changeSetsManage.getSelection()) {
85
		if (changeSetsManage.getSelection()) {
Lines 77-84 Link Here
77
97
78
	public void performDefaults() {
98
	public void performDefaults() {
79
		super.performDefaults();
99
		super.performDefaults();
80
		commitPrefixCompleted.setText(getPreferenceStore().getDefaultString(MylarTeamPlugin.COMMIT_PREFIX_COMPLETED));
100
		commitTemplateCompleted.setText(getPreferenceStore()
81
		commitPrefixProgress.setText(getPreferenceStore().getDefaultString(MylarTeamPlugin.COMMIT_PREFIX_PROGRESS));
101
				.getDefaultString(MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED));
102
		commitTemplateProgress.setText(getPreferenceStore().getDefaultString(MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS));
82
		changeSetsManage.setSelection(getPreferenceStore().getDefaultBoolean(MylarTeamPlugin.CHANGE_SET_MANAGE));
103
		changeSetsManage.setSelection(getPreferenceStore().getDefaultBoolean(MylarTeamPlugin.CHANGE_SET_MANAGE));
83
	}
104
	}
84
105
Lines 109-128 Link Here
109
		group.setLayout(new GridLayout(2, false));
130
		group.setLayout(new GridLayout(2, false));
110
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
131
		group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
111
132
112
		Label completedLabel = createLabel(group, "Completed task prefix: ");
133
		Label completedLabel = createLabel(group, "Completed task template: ");
113
		completedLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
134
		completedLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
114
135
115
		String completedPrefix = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_PREFIX_COMPLETED);
136
		String completedTemplate = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_TEMPLATE_COMPLETED);
116
		commitPrefixCompleted = new Text(group, SWT.BORDER);
137
		commitTemplateCompleted = addTemplateField(group, completedTemplate,
117
		commitPrefixCompleted.setText(completedPrefix);
138
				new TemplateHandlerContentProposalProvider());
118
		commitPrefixCompleted.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
119
139
120
		Label progressLabel = createLabel(group, "In progress task prefix: ");
140
		Label progressLabel = createLabel(group, "In progress task template: ");
121
		progressLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
141
		progressLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
122
142
123
		String progressPrefix = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_PREFIX_PROGRESS);
143
		String progressTemplate = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_TEMPLATE_PROGRESS);
124
		commitPrefixProgress = new Text(group, SWT.BORDER);
144
		commitTemplateProgress = addTemplateField(group, progressTemplate, new TemplateHandlerContentProposalProvider());
125
		commitPrefixProgress.setText(progressPrefix);
145
		commitTemplateProgress.addModifyListener(new ModifyListener() {
126
		commitPrefixProgress.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
146
			public void modifyText(ModifyEvent e) {
147
				if (autoGuessButton.getSelection()) {
148
					guessRegex();
149
				}
150
			}
151
		});
152
153
		Label regexLabel = createLabel(group, "Regex to parse task id: ");
154
		regexLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
155
156
		GridLayout layout = new GridLayout(3, false);
157
		layout.marginHeight = 0;
158
		layout.marginWidth = 0;
159
160
		Composite composite = new Composite(group, SWT.NONE);
161
		composite.setLayout(layout);
162
		composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
163
164
		boolean autoGuess = getPreferenceStore().getBoolean(MylarTeamPlugin.COMMIT_REGEX_AUTO_GUESS);
165
		String regex = getPreferenceStore().getString(MylarTeamPlugin.COMMIT_REGEX_TASK_ID);
166
		regexText = addTemplateField(composite, regex, new RegExContentProposalProvider(true));
167
168
		guessButton = new Button(composite, SWT.PUSH);
169
		guessButton.setText("Guess");
170
		guessButton.setEnabled(!autoGuess);
171
		guessButton.addSelectionListener(new SelectionListener() {
172
			public void widgetDefaultSelected(SelectionEvent e) {
173
				widgetSelected(e);
174
			}
175
176
			public void widgetSelected(SelectionEvent e) {
177
				guessRegex();
178
			}
179
		});
180
181
		autoGuessButton = new Button(composite, SWT.CHECK);
182
		autoGuessButton.setText("Auto");
183
		autoGuessButton.setSelection(autoGuess);
184
		autoGuessButton.addSelectionListener(new SelectionListener() {
185
			public void widgetDefaultSelected(SelectionEvent e) {
186
				widgetSelected(e);
187
			}
188
189
			public void widgetSelected(SelectionEvent e) {
190
				if (autoGuessButton.getSelection()) {
191
					guessButton.setEnabled(false);
192
					guessRegex();
193
				} else {
194
					guessButton.setEnabled(true);
195
				}
196
			}
197
		});
198
	}
199
200
	private Text addTemplateField(final Composite parent, final String text, IContentProposalProvider provider) {
201
		IControlContentAdapter adapter = new TextContentAdapter();
202
		IControlCreator controlCreator = new IControlCreator() {
203
			public Control createControl(Composite parent, int style) {
204
				Text control = new Text(parent, style);
205
				control.setText(text);
206
				return control;
207
			}
208
		};
209
210
		ContentAssistField field = new ContentAssistField(parent, SWT.BORDER, controlCreator, adapter, provider, null,
211
				new char[] { '$' });
212
213
		GridData gd = new GridData();
214
		gd.horizontalAlignment = GridData.FILL;
215
		gd.grabExcessHorizontalSpace = true;
216
		gd.verticalAlignment = GridData.CENTER;
217
		gd.grabExcessVerticalSpace = false;
218
		field.getLayoutControl().setLayoutData(gd);
219
220
		return (Text) field.getControl();
221
	}
222
223
	protected void guessRegex() {
224
		String template = commitTemplateProgress.getText();
225
		String regex = ITemplateHandlersManager.INSTANCE.getTaskIDRegEx(template);
226
		regexText.setText(regex);
127
	}
227
	}
128
}
228
}
(-)src/org/eclipse/mylar/internal/team/subclipse/SubclipseTeamRepositoryProvider.java (-39 / +22 lines)
Lines 29-49 Link Here
29
	@Override
29
	@Override
30
	public ActiveChangeSetManager getActiveChangeSetManager() {
30
	public ActiveChangeSetManager getActiveChangeSetManager() {
31
		// collectors.add((CVSActiveChangeSetCollector)CVSUIPlugin.getPlugin().getChangeSetManager());
31
		// collectors.add((CVSActiveChangeSetCollector)CVSUIPlugin.getPlugin().getChangeSetManager());
32
		Bundle svnBundle = Platform
32
		Bundle svnBundle = Platform.getBundle("org.tigris.subversion.subclipse.core");
33
				.getBundle("org.tigris.subversion.subclipse.core");
34
		if (svnBundle != null) {
33
		if (svnBundle != null) {
35
			Method getChangeSetManagerMethod;
34
			Method getChangeSetManagerMethod;
36
			try {
35
			try {
37
				Class providerPlugin = svnBundle
36
				Class providerPlugin = svnBundle.loadClass("org.tigris.subversion.subclipse.core.SVNProviderPlugin"); // Class.forName("org.tigris.subversion.subclipse.core.SVNProviderPlugin");
38
						.loadClass("org.tigris.subversion.subclipse.core.SVNProviderPlugin"); // Class.forName("org.tigris.subversion.subclipse.core.SVNProviderPlugin");
37
				Method getPluginMethod = providerPlugin.getMethod("getPlugin", new Class[0]);
39
				Method getPluginMethod = providerPlugin.getMethod("getPlugin",
38
				Object pluginInstance = getPluginMethod.invoke(null, new Object[0]);
40
						new Class[0]);
39
				getChangeSetManagerMethod = providerPlugin.getDeclaredMethod("getChangeSetManager", new Class[0]);
41
				Object pluginInstance = getPluginMethod.invoke(null,
40
				Object manager = getChangeSetManagerMethod.invoke(pluginInstance, new Object[0]);
42
						new Object[0]);
43
				getChangeSetManagerMethod = providerPlugin.getDeclaredMethod(
44
						"getChangeSetManager", new Class[0]);
45
				Object manager = getChangeSetManagerMethod.invoke(
46
						pluginInstance, new Object[0]);
47
				if (manager instanceof ActiveChangeSetManager) {
41
				if (manager instanceof ActiveChangeSetManager) {
48
					return (ActiveChangeSetManager) manager;
42
					return (ActiveChangeSetManager) manager;
49
				}
43
				}
Lines 60-80 Link Here
60
			return false;
54
			return false;
61
55
62
		try {
56
		try {
63
			Class commitActionClass = Class
57
			Class commitActionClass = Class.forName("org.tigris.subversion.subclipse.ui.actions.CommitAction");
64
					.forName("org.tigris.subversion.subclipse.ui.actions.CommitAction");
58
			Constructor commitActionConstructor = commitActionClass.getConstructor(new Class[] { String.class });
65
			Constructor commitActionConstructor = commitActionClass
59
			Object commitAction = commitActionConstructor.newInstance(new Object[] { "" });
66
					.getConstructor(new Class[] { String.class });
60
			Method setSelectedResourcesMethod = commitActionClass.getMethod("setSelectedResources",
67
			Object commitAction = commitActionConstructor
61
					new Class[] { IResource[].class });
68
					.newInstance(new Object[] { "" });
62
			setSelectedResourcesMethod.invoke(commitAction, new Object[] { resources });
69
			Method setSelectedResourcesMethod = commitActionClass.getMethod(
63
70
					"setSelectedResources", new Class[] { IResource[].class });
64
			Method hasOutgoingChangesMethod = commitActionClass.getMethod("hasOutgoingChanges", new Class[0]);
71
			setSelectedResourcesMethod.invoke(commitAction,
65
			Boolean hasOutgoingChanges = (Boolean) hasOutgoingChangesMethod.invoke(commitAction, new Object[0]);
72
					new Object[] { resources });
73
74
			Method hasOutgoingChangesMethod = commitActionClass.getMethod(
75
					"hasOutgoingChanges", new Class[0]);
76
			Boolean hasOutgoingChanges = (Boolean) hasOutgoingChangesMethod
77
					.invoke(commitAction, new Object[0]);
78
66
79
			return hasOutgoingChanges.booleanValue();
67
			return hasOutgoingChanges.booleanValue();
80
		} catch (Throwable t) {
68
		} catch (Throwable t) {
Lines 90-108 Link Here
90
			return;
78
			return;
91
79
92
		try {
80
		try {
93
			Class commitActionClass = Class
81
			Class commitActionClass = Class.forName("org.tigris.subversion.subclipse.ui.actions.CommitAction");
94
					.forName("org.tigris.subversion.subclipse.ui.actions.CommitAction");
82
			Constructor commitActionConstructor = commitActionClass.getConstructor(new Class[] { String.class });
95
			Constructor commitActionConstructor = commitActionClass
83
			Object commitAction = commitActionConstructor.newInstance(new Object[] { "" });
96
					.getConstructor(new Class[] { String.class });
84
			Method setSelectedResourcesMethod = commitActionClass.getMethod("setSelectedResources",
97
			Object commitAction = commitActionConstructor
85
					new Class[] { IResource[].class });
98
					.newInstance(new Object[] { "" });
86
			setSelectedResourcesMethod.invoke(commitAction, new Object[] { resources });
99
			Method setSelectedResourcesMethod = commitActionClass.getMethod(
100
					"setSelectedResources", new Class[] { IResource[].class });
101
			setSelectedResourcesMethod.invoke(commitAction,
102
					new Object[] { resources });
103
87
104
			Method executeMethod = commitActionClass.getMethod("execute",
88
			Method executeMethod = commitActionClass.getMethod("execute", new Class[] { IAction.class });
105
					new Class[] { IAction.class });
106
			executeMethod.invoke(commitAction, new Object[] { null });
89
			executeMethod.invoke(commitAction, new Object[] { null });
107
		} catch (Throwable t) {
90
		} catch (Throwable t) {
108
			// nothing we can do
91
			// nothing we can do
(-)src/org/eclipse/mylar/internal/team/ui/preferences/workaround/RegExMessages.properties (+495 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2005 IBM Corporation 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
#     IBM Corporation - initial API and implementation
10
###############################################################################
11
12
## Content Assist for regular expressions ##
13
## Copied from org.eclipse.ui.texteditor.RegExMessages.properties.
14
## Needed by org.eclipse.mylar.internal.team.ui.preferences.workaround.RegExMessages.
15
## TODO Ask platform guys to open this API
16
# use \\\u0075 for a backslash-u
17
displayString_bs_bs= \\\\ - Backslash
18
additionalInfo_bs_bs= Backslash
19
displayString_bs_0= \\0nnn - Octal character code
20
additionalInfo_bs_0= Octal character code\n\nExamples:\n\\011 (tabulator)\n\\0112 (character J)
21
displayString_bs_x= \\xhh - Hex character code
22
additionalInfo_bs_x= Hexadecimal character code\n\nExamples:\n\\x09 (tabulator)\n\\x4A or \\x4a (character J)
23
displayString_bs_u= \\\u0075hhhh - Hex code for Unicode character
24
additionalInfo_bs_u= Hexadecimal code for Unicode character\n\nExamples:\n\\\u0075004A (character J)\n\\\u007503B2 (lowercase Greek letter beta: \u03B2)
25
displayString_bs_t= \\t - Tab
26
additionalInfo_bs_t= Tabulator (\\x09, decimal: 9)
27
displayString_bs_n= \\n - Newline
28
additionalInfo_bs_n= Newline (\\x0A, decimal: 10)
29
displayString_bs_r= \\r - CR
30
additionalInfo_bs_r= Carriage Return (\\x0D, decimal: 13)
31
displayString_bs_f= \\f - FF
32
additionalInfo_bs_f= Form Feed (\\x0C, decimal: 12)
33
displayString_bs_a= \\a - Beep
34
additionalInfo_bs_a= Beep, Bell, Alert (\\x07, decimal: 7)
35
displayString_bs_e= \\e - Esc
36
additionalInfo_bs_e= Escape (\\x1B, decimal: 27)
37
displayString_bs_c= \\c - Control character
38
additionalInfo_bs_c= Control character\n\nExample:\n\\cC (Ctrl+C)
39
40
displayString_dot= . - Any character
41
additionalInfo_dot= The dot matches any character except line terminators.\n\n\
42
To make the dot match line terminators as well, \n\
43
start the expression with the embedded flag expression \n\
44
"(?s)" (without quotes).
45
displayString_bs_d= \\d - A digit
46
additionalInfo_bs_d= A digit: [0-9]
47
displayString_bs_D= \\D - Not a digit
48
additionalInfo_bs_D= Not a digit: [^0-9]
49
displayString_bs_s= \\s - A whitespace
50
additionalInfo_bs_s= A whitespace: [ \\t\\n\\x0B\\f\\r]
51
displayString_bs_S= \\S - Not a whitespace
52
additionalInfo_bs_S= Not a whitespace: [^\\s]
53
displayString_bs_w= \\w - An alphanumeric (word character)
54
additionalInfo_bs_w= An alphanumeric (a word character): [a-zA-Z_0-9]
55
displayString_bs_W= \\W - Not an alphanumeric
56
additionalInfo_bs_W= Not an alphanumeric (not a word character): [^\\w]
57
58
displayString_start= ^ - Line start
59
additionalInfo_start= Line start (positional match)\n\nExample:\n\
60
The expression "^Eclipse" matches the term "Eclipse"\n\
61
only on the second line of text\n\
62
"The Eclipse Project\n\
63
Eclipse Platform".
64
displayString_end= $ - Line end
65
additionalInfo_end= Line end (positional match)\n\nExample:\n\
66
The expression "Eclipse$" matches the term "Eclipse"\n\
67
only on the second line of text\n\
68
"- Install the Eclipse Platform\n\
69
- Run Eclipse".
70
displayString_bs_b= \\b- Word beginning or end
71
additionalInfo_bs_b= Word beginning or end (positional match)\n\nExample:\n\
72
The expression "s\\b" matches only the last "s" of "glasses" in text\n\
73
"I lost my glasses."
74
displayString_bs_B= \\B - Not a word beginning or end
75
additionalInfo_bs_B= Not a word beginning or end (positional match)\n\nExample:\n\
76
The expression "\\BS" matches only "S" of "printString" in text\n\
77
"void print(String printString)".
78
displayString_bs_A= \\A - Start of input
79
additionalInfo_bs_A= Start of input (positional match)\n\nExample:\n\
80
The expression "\\ABC" matches only "BC" of "BCD" in text\n\
81
"BCD ABC\n\
82
BCDEF".
83
displayString_bs_G= \\G - Previous match's end
84
additionalInfo_bs_G= Previous match's end (positional match)\n\nExample:\n\
85
The expression "\\Ga" matches the first and then the second "a" in text\n\
86
"aardvark" (when starting from the beginning).
87
displayString_bs_Z= \\Z - End of input, does not consider last line terminator
88
additionalInfo_bs_Z= End of input, does not consider last line terminator (positional match)\n\n\
89
The expression matches at the end of the file, except for when the\n\
90
file ends in a line terminator, in which case it matches before that\n\
91
line terminator.\n\nExample:\n\
92
The expression "ing\\Z" matches "ing" in text\n\
93
"testing", as well as in text\n\
94
"testing\n\
95
", but doesn't match in text\n\
96
"testing\n\
97
\n\
98
"
99
displayString_bs_z= \\z - End of input
100
additionalInfo_bs_z= End of input (positional match)\n\nExample:\n\
101
The expression "ing\\z" matches "ing" in text\n\
102
"testing", but doesn't match in text\n\
103
"testing\n\
104
"
105
106
### repetition quantifiers ###
107
displayString_quest= ? - Greedy match 0 or 1 times
108
additionalInfo_quest= Greedy match 0 or 1 times.\n\n\
109
First tries to match the preceding token.\n\
110
Falls back to not matching if this choice made a full match impossible.\n\nExample:\n\
111
The expression "fo?" matches "f", "fo", and "fo" in text\n\
112
"f fo foo".
113
displayString_star= * - Greedy match 0 or more times
114
additionalInfo_star= Greedy match 0 or more times.\n\n\
115
First tries to match the preceding token as many times as possible.\n\
116
Falls back to matching it less often if this choice made a full match impossible.\n\nExamples:\n\
117
- The expression "fo*" matches "f", "fo", and "foo" in text\n\
118
"f fo foo".\n\
119
- The expression "fo*o\\d" matches all three words in text\n\
120
"fo1 foo2 fooo3".\n\
121
- The expression "<.*>" matches the whole text\n\
122
"<p><b>bold</b>".
123
displayString_plus= + - Greedy match 1 or more times
124
additionalInfo_plus= Greedy match 1 or more times\n\n\
125
First tries to match the preceding token as many times as possible.\n\
126
Falls back to matching it less often if this choice made a full match impossible.\n\nExamples:\n\
127
- The expression "fo+" matches "fo" and "foo" in text\n\
128
"f fo foo".\n\
129
- The expression "fo+o\\d" matches "foo2" and "fooo3" in text\n\
130
"fo1 foo2 fooo3".\n\
131
- The expression "<.+>" matches the whole text\n\
132
"<p><b>bold</b>", but does not match anywhere in "<>".
133
displayString_exact= {n} - Greedy match exactly n times
134
additionalInfo_exact= Greedy match exactly n times.\n\nExamples:\n\
135
- The expression "\\\\0[0-3][0-7]{2}" matches all three-digit octal character tokens.\n\
136
- The expression "\\b\\w{4}\\b" matches all four-letter-words\n\
137
such as "Java", "cool", or "food" (but not "dog").
138
displayString_least= {n,} - Greedy match >= n times
139
additionalInfo_least= Greedy match >= n times.\n\n\
140
First tries to match the preceding token as many times as possible.\n\
141
Falls back to matching it less often (but at least n times),\n\
142
if this choice made a full match impossible.\n\nExamples:\n\
143
- The expression "fo{2,}" matches "foo" and "fooo" in text\n\
144
"f fo foo fooo".\n\
145
- The expression "fo{2,}o\\d" matches "fooo3" and "foooo4" in text\n\
146
"fo1 foo2 fooo3 foooo4".\n\
147
- The expression "10{3,}[^0]" matches all powers of ten that are larger than one thousand.\n\n\
148
Note: The expressions "{0,}" and "*" are equivalent;\n\
149
likewise, "{1,}" is equivalent to "+".
150
displayString_count= {n,m} - Greedy match >= n times but <= m times
151
additionalInfo_count= Greedy match >= n times but <= m times.\n\n\
152
First tries to match the preceding token m times.\n\
153
Falls back to matching it less often (but at least n times),\n\
154
if this choice made a full match impossible.\n\nExamples:\n\
155
- The expression "fo{1,2}" matches "fo", "foo", and "foo" in text\n\
156
"f fo foo fooo".\n\
157
- The expression "fo{1,2}o\\d" matches "foo2" and "fooo3" in text\n\
158
"fo1 foo2 fooo3 foooo4".\n\
159
- The expression "^.{70,80}$" matches all the lines that contain\n\
160
between 70 and 80 characters (inclusive).
161
162
displayString_questLazy= ?? - Lazy match 0 or 1 times
163
additionalInfo_questLazy= Lazy match 0 or 1 times.\n\n\
164
First tries to not match the preceding token.\n\
165
Falls back to matching it if this choice made a full match impossible.\n\nExample:\n\
166
The expression "fo??" matches "f", "f", and "f" in text\n\
167
"f fo foo".
168
displayString_starLazy= *? - Lazy match 0 or more times
169
additionalInfo_starLazy= Lazy match 0 or more times.\n\n\
170
First tries to not match the preceding token.\n\
171
Falls back to matching it more often if this choice made a full match impossible.\n\nExamples:\n\
172
- The expression "fo*?" matches "f", "f", and "f" in text\n\
173
"f fo foo".\n\
174
- The expression "fo*?o\\d" matches all three words in text\n\
175
"fo1 foo2 fooo3".\n\
176
- The expression "<.*?>" matches "<p>", "<b>", and "</b>" in text\n\
177
"<p><b>bold</b>". Note: a more performant expression for finding\n\
178
xml tags is "<[^>]*>", which avoids backtracking.
179
displayString_plusLazy= +? - Lazy match 1 or more times
180
additionalInfo_plusLazy= Lazy match 1 or more times\n\n\
181
First tries to match the preceding token once.\n\
182
Falls back to matching it more often if this choice made a full match impossible.\n\nExamples:\n\
183
- The expression "fo+?" matches "fo" and "fo" in text\n\
184
"f fo foo".\n\
185
- The expression "fo+?o\\d" matches "foo2" and "fooo3" in text\n\
186
"fo1 foo2 fooo3".\n\
187
- The expression "<.+?>" matches "<p>", "<b>", and "</b>" in text\n\
188
"<p><b>bold</b>". Note: a more performant expression for finding\n\
189
xml tags is "<[^>]*>", which avoids backtracking.
190
displayString_exactLazy= {n}? - Lazy match exactly n times
191
additionalInfo_exactLazy= Lazy match exactly n times.\n\n\
192
This expression is equivalent to the expression\n\
193
{n} - Greedy match exactly n times.
194
displayString_leastLazy= {n,}? - Lazy match >= n times
195
additionalInfo_leastLazy= Lazy match >= n times.\n\n\
196
First tries to match the preceding token n times. Falls back to\n\
197
matching it more often, if this choice made a full match impossible.\n\nExamples:\n\
198
- The expression "fo{2,}?" matches "foo" and "foo" in text\n\
199
"f fo foo fooo".\n\
200
- The expression "fo{2,}?o\\d" matches "fooo3" and "foooo4" in text\n\
201
"fo1 foo2 fooo3 foooo4".\n\
202
- The expression "10{3,}?[^0]" matches all powers of ten that are larger than one thousand.\n\n\
203
Note: The expressions "{0,}?" and "*?" are equivalent;\n\
204
likewise, "{1,}?" is equivalent to "+?".
205
displayString_countLazy= {n,m}? - Lazy match >= n times but <= m times
206
additionalInfo_countLazy= Lazy match >= n times but <= m times.\n\n\
207
First tries to match the preceding token n times.\n\
208
Falls back to matching it more often (but at most m times),\n\
209
if this choice made a full match impossible.\n\nExamples:\n\
210
- The expression "fo{1,2}?" matches "fo", "fo", and "fo" in text\n\
211
"f fo foo fooo".\n\
212
- The expression "fo{1,2}?o\\d" matches "foo2" and "fooo3" in text\n\
213
"fo1 foo2 fooo3 foooo4".\n\
214
215
displayString_questPoss= ?+ - Possessive match 0 or 1 times (no backtracking)
216
additionalInfo_questPoss= Possessive match 0 or 1 times.\n\n\
217
Matches the preceding token if possible. Never backtracks,\n\
218
even if this choice renders a full match impossible.\n\nExample:\n\
219
The expression "fo?+o\\d" matches the first, but not the second line in text\n\
220
"fo1\n\
221
foo1".
222
displayString_starPoss= *+ Possessive match 0 or more times (no backtracking)
223
additionalInfo_starPoss= Possessive match 0 or more times.\n\n\
224
Tries to match the preceding token as many times as possible. Never backtracks,\n\
225
even if this choice renders a full match impossible.\n\nExamples:\n\
226
- The expression "fo*+" matches "f", "fo" and "foo" in text\n\
227
"f fo foo".\n\
228
- The expression "fo*+o\\d" matches nowhere in text\n\
229
"fo1 foo2 fooo3".\n\
230
- The expression "<.*+>" matches nowhere in text\n\
231
"<p><b>bold</b>".
232
displayString_plusPoss= ++ - Possessive match 1 or more times (no backtracking)
233
additionalInfo_plusPoss= Possessive match 1 or more times.\n\n\
234
Tries to match the preceding token as many times as possible. Never backtracks,\n\
235
even if this choice renders a full match impossible.\n\nExamples:\n\
236
- The expression "fo++" matches "fo" and "foo" in text\n\
237
"f fo foo".\n\
238
- The expression "fo++o\\d" matches nowhere in text\n\
239
"fo1 foo2 fooo3".\n\
240
- The expression "<.++>" matches nowhere in text\n\
241
"<p><b>bold</b>".
242
243
displayString_exactPoss= {n}+ - Possessive match exactly n times (no backtracking)
244
additionalInfo_exactPoss= Possessive match exactly n times.\n\n\
245
This expression is equivalent to the expression\n\
246
{n} - Greedy match exactly n times.
247
displayString_leastPoss= {n,}+ - Possessive match >= n times (no backtracking)
248
additionalInfo_leastPoss= Possessive match >= n times.\n\n\
249
Tries to match the preceding token as many times as possible, but at least n times.\n\
250
Never backtracks, even if this choice renders a full match impossible.\n\nExamples:\n\
251
- The expression "fo{2,}+" matches "foo" and "fooo" in text\n\
252
"f fo foo fooo".\n\
253
- The expression "fo{2,}?o\\d" matches nowhere in text\n\
254
"fo1 foo2 fooo3 foooo4".\n\
255
Note: The expressions "{0,}?" and "*?" are equivalent;\n\
256
likewise, "{1,}?" is equivalent to "+?".
257
258
displayString_countPoss= {n,m}+ - Possessive match >= n times but <= m times (no backtracking)
259
additionalInfo_countPoss= Possessive match >= n times but <= m times.\n\n\
260
Tries to match the preceding token as many times as possible, \n\
261
at least n times and at most m times.\n\
262
Never backtracks, even if this choice renders a full match impossible.\n\nExamples:\n\
263
- The expression "fo{1,2}+" matches "fo", "foo", and "foo" in text\n\
264
"f fo foo fooo".\n\
265
- The expression "fo{1,2}+o\\d" matches only "fooo3" in text\n\
266
"fo1 foo2 fooo3 foooo4".\n\
267
- The expression "^.{70,80}+$" matches all the lines that contain\n\
268
between 70 and 80 characters (inclusive).
269
270
displayString_alt= U|V - Alternation: U or V
271
additionalInfo_alt= Alternation.\n\n\
272
First tries to match subexpression U. Falls back and tries to match V if U didn't match.\n\nExamples:\n\
273
- The expression "A|B" applied to text "BA" first matches "B", then "A".\n\
274
- The expression "AB|BC|CD" applied to text "ABC BC DAB" matches, in sequence:\n\
275
"AB" in the first word, the second word "BC", "AB" at the very end.
276
displayString_group= (Expr) - Mark Expr as capturing group
277
additionalInfo_group= Mark Expr as capturing group.\n\n\
278
Capturing groups are numbered by counting their opening parentheses from left to right.\n\
279
In the expression "((A)(B(C)))", for example, there are four such groups:\n\
280
1   ((A)(B(C)))\n\
281
2   (A)\n\
282
3   (B(C))\n\
283
4   (C)\n\
284
\n\
285
Group zero always stands for the entire expression. During a match,\n\
286
each subsequence of the input sequence that matches such a group is saved.\n\
287
The captured subsequence i may be used later in the expression, via a back reference "\\i",\n\
288
and may also be used in the replace string via "$i".\n\
289
\n\
290
Note: Groups beginning with (? are pure, non-capturing groups that\n\
291
do not capture text and do not count towards the group total.
292
293
displayString_bs_i= \\i - Match of the capturing group i
294
additionalInfo_bs_i= Match of the capturing group i.\n\n\
295
\\i matches the subsequence that has already been saved as capturing group i.\n\
296
\\0 is not a valid group number in the regular expression.\n\nExample:\n\
297
The expression "(\\d+)\\+\\1" matches "10+10" in text "9+10+10+11".\n\
298
\n\
299
Note: in the replace string, $i stands for the capturing group i. 
300
301
displayString_bs= \\ - Quote next character
302
additionalInfo_bs= Quote next character\n\nExample:\n\
303
The expression "\\{\\n\\}" matches the text "{n}".
304
305
displayString_bs_Q= \\Q - Start quoting
306
additionalInfo_bs_Q= Start quoting\n\n\
307
All characters between \\Q and the next \\E are taken literally and are not interpreted.\n\nExample:\n\
308
The expression "\\Qnew int[] {42}\\E;" matches text "new int[] {42}".
309
displayString_bs_E= \\E - End quoting
310
additionalInfo_bs_E= End quoting\n\n\
311
All characters between \\Q and the next \\E are taken literally and are not interpreted.\n\nExample:\n\
312
The expression "\\Qnew int[] {42}\\E;" matches text "new int[] {42}".
313
314
displayString_set= [ecl] - Character set
315
additionalInfo_set= Character set\n\n\
316
Matches a single character out of the set.\n\nExample:\n\
317
The expression "[ecl]" matches "c" and "l" in text "cold".
318
displayString_setExcl= [^ecl] - Excluded character set
319
additionalInfo_setExcl= Excluded character set\n\n\
320
Matches a single character that is not one of the excluded characters.\n\nExamples:\n\
321
The expression "[^ecl]" matches "o" and "d" in text "cold".\n\
322
The expression "[a-z&&[^ecl]]" matches any character from a to z, excluding e, c, and l.
323
displayString_setRange= [c-l] - Character range
324
additionalInfo_setRange= Character range\n\n\
325
Matches a single character out of the range from 'c' to 'l'.\n\nExamples:\n\
326
The expression "[c-l]" matches "c", "l", and "d" in text "cold".\n\
327
The expression "[a-z&&[^ecl]]" matches any character from a to z, excluding e, c, and l.
328
displayString_setInter= && - Intersection of character sets
329
additionalInfo_setInter= Intersection of character sets\n\n\
330
Matches a character that is in both of the given sets.\n\nExample:\n\
331
The expression "[a-z&&[^ecl]]" matches any character from a to z, excluding e, c, and l.
332
333
displayString_posix= \\p{Class} - POSIX or Unicode character class
334
additionalInfo_posix= POSIX or Unicode character class\n\n\
335
Matches a character from the given character class 'Class'.\n\
336
Valid classes are:\n\
337
\n\
338
- POSIX character classes (US-ASCII only):\n\
339
\    Lower, Upper, ASCII, Alpha, Digit, Alnum, Punct,\n\
340
\    Graph, Print, Blank, Cntrl, XDigit, and Space.\n\
341
\n\
342
- Unicode blocks and categories, e.g.:\n\
343
\    BasicLatin\n\
344
\    Latin-1Supplement\n\
345
\    Greek\n\
346
\    Lu: Uppercase Letter\n\
347
\    Ll: Lowercase Letter\n\
348
\    L:  Letter\n\
349
\    N:  Number\n\
350
\    Z:  Separator\n\
351
\    LD: Letter or Digit\n\
352
\    L1: Latin-1
353
354
displayString_posixNot= \\P{Class} - Excluded POSIX or Unicode character class
355
additionalInfo_posixNot= Excluded POSIX or Unicode character class\n\n\
356
Negation of character set \\p{Class}. Example:\n\
357
\\P{ASCII} is equivalent to [^\\p{ASCII}] and matches all non-ASCII characters.\n\n\
358
Valid classes are:\n\
359
\n\
360
- POSIX character classes (US-ASCII only):\n\
361
\    Lower, Upper, ASCII, Alpha, Digit, Alnum, Punct,\n\
362
\    Graph, Print, Blank, Cntrl, XDigit, and Space.\n\
363
\n\
364
- Unicode blocks and categories, e.g.:\n\
365
\    BasicLatin\n\
366
\    Latin-1Supplement\n\
367
\    Greek\n\
368
\    Lu: Uppercase Letter\n\
369
\    Ll: Lowercase Letter\n\
370
\    L:  Letter\n\
371
\    N:  Number\n\
372
\    Z:  Separator\n\
373
\    LD: Letter or Digit\n\
374
\    L1: Latin-1
375
376
377
#Flags:
378
displayString_flag= (?ismd-ismd) - Turn flags on or off
379
additionalInfo_flag= Turn flags on and off for the rest of the matching process.\n\n\
380
Flags before the dash are turned on; those after the dash are turned off.\n\
381
The following flags are supported:\n\
382
- i: case-insensitive matching\n\
383
\n\
384
- s: single-line, or dotall matching mode:\n\
385
\        The expression . matches any character, including a line terminator.\n\
386
\n\
387
- m: multiline matching mode:\n\
388
\        The expressions ^ and $ match just after or just before,\n\
389
\        respectively, a line terminator or the end of the input sequence.\n\
390
\        By default these expressions only match at the beginning and the\n\
391
\        end of the entire input sequence.\n\
392
\n\
393
- d: Unix lines matching mode:\n\
394
\        Only the '\\n' line terminator\n\
395
\        is recognized in the behavior of ., ^, and $
396
# - u: unicode-aware case folding:\n\
397
#        Case-insensitive matching, when enabled, is done in a manner consistent\n\
398
#        with the Unicode Standard. By default, case-insensitive matching\n\
399
#        assumes that only characters in the US-ASCII charset are being matched.
400
# - c: canonical equivalence\n\
401
#        Two characters will be considered to match if, and only if, their full\n\
402
#        canonical decompositions match. The expression "a\\\u0075030A", for example,\n\
403
#        will match the string "a\u030A" when this flag is specified.\n\
404
#        By default, matching does not take canonical equivalence into account.
405
# - x: comments mode\n\
406
#        Whitespace is ignored, and embedded comments starting with\n\
407
#        # are ignored until the end of a line.\n\
408
409
displayString_flagExpr= (?ismd-ismd:Expr) - Turn flags on or off in Expr
410
additionalInfo_flagExpr= Turn flags on and off in Expr.\n\n\
411
Flags before the dash are turned on; those after the dash are turned off.\n\
412
The following flags are supported:\n\
413
- i: case-insensitive matching\n\
414
\n\
415
- s: single-line, or dotall matching mode:\n\
416
\        The expression . matches any character, including a line terminator.\n\
417
\n\
418
- m: multiline matching mode:\n\
419
\        The expressions ^ and $ match just after or just before,\n\
420
\        respectively, a line terminator or the end of the input sequence.\n\
421
\        By default these expressions only match at the beginning and the\n\
422
\        end of the entire input sequence.\n\
423
\n\
424
- d: Unix lines matching mode:\n\
425
\        Only the '\\n' line terminator\n\
426
\        is recognized in the behavior of ., ^, and $
427
428
429
#Noncapturing groups:
430
displayString_nonCap= (?:Expr) - Non-capturing group
431
additionalInfo_nonCap= Non-capturing group of regular expression Expr.\n\n\
432
The group is not saved in a back reference.\n\nExample:\n\
433
The expression "(?:\\w+) (\\d+)" matches "bug 42" in text "It's bug 42.".\n\
434
A back reference "$1" in the replace string will be replaced by "42".
435
436
displayString_atomicCap= (?>Expr) - Non-capturing atomic group
437
additionalInfo_atomicCap= Non-capturing atomic group of regular expression Expr.\n\n\
438
Matches the regular expression Expr once, but does not backtrack into the expression\n\
439
again if the first match did not prove to be successful later on.\n\
440
The group is not saved in a back reference.
441
442
#Lookaround:
443
displayString_posLookahead= (?=Expr) - Zero-width positive lookahead
444
additionalInfo_posLookahead= Expr, via zero-width positive lookahead.\n\n\
445
Matches a position (zero-width: does not consume the matched characters),\n\
446
where the next characters (-> lookahead)\n\
447
do match (-> positive) the embedded expression Expr.\n\nExamples:\n\
448
- The expression "var(?==)" matches only the first "var" in text "var=17; other=var;".\n\
449
- The expression "\\b(?=\\w{7}\\b)\\w*clip\\w*\\b" matches any\n\
450
seven-letter-word that contains "clip". It matches "Eclipse", but not "paperclip".
451
452
displayString_negLookahead= (?!Expr) - Zero-width negative lookahead
453
additionalInfo_negLookahead= Expr, via zero-width negative lookahead.\n\n\
454
Matches a position (zero-width: does not consume the matched characters),\n\
455
where the next characters (-> lookahead)\n\
456
do not match (-> negative) the embedded expression Expr.\n\nExamples:\n\
457
- The expression "var(?!=)" matches only the second "var" in text "var=17; other=var;".\n\
458
- The expression "\\b(?!\\w{5,7}\\b)\\w*clip\\w*\\b" matches any\n\
459
word that contains "clip" and consists of less than 5 or more than 7 characters.\n\
460
It matches "clip" and "paperclip", but not "Eclipse".
461
462
displayString_posLookbehind= (?<=Expr) - Zero-width positive lookbehind
463
additionalInfo_posLookbehind= Expr, via zero-width positive lookbehind.\n\n\
464
Matches a position (zero-width: does not consume the matched characters),\n\
465
where the previous characters (-> lookbehind)\n\
466
do match (-> positive) the embedded expression Expr.\n\nExample:\n\
467
- The expression "\\w{5,}+(?<=as)\\b" matches "alias" and "bananas",\n\
468
but does not match "peas", "apples", or "Alaska".
469
470
displayString_negLookbehind= (?<!Expr) - Zero-width negative lookbehind
471
additionalInfo_negLookbehind= Expr, via zero-width negative lookbehind.\n\n\
472
Matches a position (zero-width: does not consume the matched characters),\n\
473
where the previous characters (-> lookbehind)\n\
474
do not match (-> negative) the embedded expression Expr.\n\nExample:\n\
475
- The expression "\\w{5,}+(?<!as)\\b" matches "Eclipse" and "apples",\n\
476
but does not match "peas" or "bananas".
477
478
#Replace string:
479
displayString_dollar= $i - Match of the capturing group i
480
additionalInfo_dollar= Match of the capturing group i.\n\n\
481
$i is the string that has been saved as capturing group i.\n\
482
$0 is the subsequence matched by the entire expression.\n\
483
\n\
484
Note: in the find expression, \\i stands for the capturing group i. 
485
displayString_replace_bs= \\ - Quote next character
486
additionalInfo_replace_bs= Quote next character\n\nExamples:\n\
487
"\\$" will be replaced by "$".\n\
488
"\\a" will be replaced by "a".\n\
489
"\\\\" will be replaced by "\\".
490
displayString_tab= Tab - The tabulator character
491
additionalInfo_tab= The tabulator character (\\t in the find expression).
492
displayString_cr= CR - The carriage return character
493
additionalInfo_cr= The carriage return character (\\r or \\x0D in the find expression).
494
displayString_nl= Newline - The newline character
495
additionalInfo_nl= The newline character (\\n or \\x0A in the find expression).
(-)src/org/eclipse/mylar/internal/team/template/TemplateHandlersManager.java (+211 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
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
 *    Eike Stepper - initial API and implementation
10
 **************************************************************************/
11
package org.eclipse.mylar.internal.team.template;
12
13
import org.eclipse.core.runtime.IConfigurationElement;
14
import org.eclipse.core.runtime.IExtension;
15
import org.eclipse.core.runtime.IExtensionPoint;
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.mylar.context.core.MylarStatusHandler;
18
import org.eclipse.mylar.tasks.core.ITask;
19
import org.eclipse.mylar.team.ITemplateHandler;
20
import org.eclipse.mylar.team.ITemplateHandlersManager;
21
import org.eclipse.mylar.team.MylarTeamPlugin;
22
23
import java.text.MessageFormat;
24
import java.util.ArrayList;
25
26
/**
27
 * @author Eike Stepper
28
 */
29
public class TemplateHandlersManager implements ITemplateHandlersManager {
30
	private static final String ATTR_CLASS = "class";
31
32
	private static final String ATTR_DESCRIPTION = "description";
33
34
	private static final String ATTR_RECOGNIZED_KEYWORD = "recognizedKeyword";
35
36
	private static final String ELEM_TEMPLATE_HANDLER = "templateHandler";
37
38
	private static final String EXT_POINT_TEMPLATE_HANDLERS = "templateHandlers";
39
40
	public TemplateHandlersManager() {
41
	}
42
43
	public String getTaskIDRegEx(String template) {
44
		final String META_CHARS = "$()*+.< [\\]^{|}";
45
		final String TASK_ID_PLACEHOLDER = "\uffff";
46
		final String KEYWORD_PLACEHOLDER = "\ufffe";
47
48
		template = template.replaceFirst("\\$\\{task\\.id\\}", TASK_ID_PLACEHOLDER);
49
		template = replaceKeywords(template, KEYWORD_PLACEHOLDER);
50
		template = quoteChars(template, META_CHARS);
51
		template = template.replaceFirst(TASK_ID_PLACEHOLDER, "(\\\\d+)");
52
		template = template.replaceAll(KEYWORD_PLACEHOLDER, ".*");
53
		return template;
54
	}
55
56
	private String replaceKeywords(String str, String placeholder) {
57
		String[] recognizedKeywords = getRecognizedKeywords();
58
		for (String keyword : recognizedKeywords) {
59
			str = str.replaceAll("\\$\\{" + keyword + "\\}", placeholder);
60
		}
61
		return str;
62
	}
63
64
	private String quoteChars(String str, String charsToQuote) {
65
		StringBuilder builder = new StringBuilder(str.length() * 2);
66
		for (int i = 0; i < str.length(); i++) {
67
			char c = str.charAt(i);
68
			if (charsToQuote.indexOf(c) != -1) {
69
				builder.append('\\');
70
			}
71
			builder.append(c);
72
		}
73
		return builder.toString();
74
	}
75
76
	public String[] getRecognizedKeywords() {
77
		final ArrayList<String> result = new ArrayList<String>();
78
		new ExtensionProcessor() {
79
			@Override
80
			protected Object processContribution(IConfigurationElement element, String keyword, String description,
81
					String className) throws Exception {
82
				result.add(keyword);
83
				return null;
84
			}
85
		}.run();
86
87
		return result.toArray(new String[result.size()]);
88
	}
89
90
	public String getHandlerDescription(final String keyword) {
91
		return (String) new ExtensionProcessor() {
92
			@Override
93
			protected Object processContribution(IConfigurationElement element, String foundKeyword,
94
					String description, String className) throws Exception {
95
				return keyword.equals(foundKeyword) ? description : null;
96
			}
97
		}.run();
98
	}
99
100
	public ITemplateHandler createHandler(final String keyword) {
101
		return (ITemplateHandler) new ExtensionProcessor() {
102
			@Override
103
			protected Object processContribution(IConfigurationElement element, String foundKeyword,
104
					String description, String className) throws Exception {
105
				if (keyword.equals(foundKeyword)) {
106
					ITemplateHandler handler = (ITemplateHandler) element.createExecutableExtension(ATTR_CLASS);
107
					if (handler instanceof TemplateHandler) {
108
						((TemplateHandler) handler).setDescription(description);
109
						((TemplateHandler) handler).setRecognizedKeyword(foundKeyword);
110
					} else {
111
						String recognizedKeyword = handler.getRecognizedKeyword();
112
						if (recognizedKeyword == null || !recognizedKeyword.equals(foundKeyword)) {
113
							throw new IllegalArgumentException("Keyword markup does not match handler implementation");
114
						}
115
					}
116
117
					return handler;
118
				}
119
120
				return null;
121
			}
122
		}.run();
123
	}
124
125
	public String generateComment(ITask task, String completedTemplate, String progressTemplate) {
126
		String template = task.isCompleted() ? completedTemplate : progressTemplate;
127
		return processKeywords(task, template);
128
	}
129
130
	private String processKeywords(ITask task, String template) {
131
		String[] segments = template.split("\\$\\{");
132
		StringBuffer buffer = new StringBuffer(segments[0]);
133
134
		for (int i = 1; i < segments.length; i++) {
135
			String segment = segments[i];
136
			String value = null;
137
			int brace = segment.indexOf('}');
138
			if (brace > 0) {
139
				String keyword = segment.substring(0, brace);
140
				value = processKeyword(task, keyword);
141
			}
142
143
			if (value != null) {
144
				buffer.append(value);
145
				buffer.append(segment.substring(brace + 1));
146
			} else {
147
				buffer.append("${");
148
				buffer.append(segment);
149
			}
150
		}
151
152
		return buffer.toString();
153
	}
154
155
	private String processKeyword(ITask task, String keyword) {
156
		try {
157
			ITemplateHandler handler = createHandler(keyword);
158
			if (handler != null) {
159
				return handler.getValue(task);
160
			}
161
		} catch (Exception ex) {
162
			MylarStatusHandler.log(ex, "Problem while dispatching to template handler for: " + keyword);
163
		}
164
165
		return null;
166
	}
167
168
	/**
169
	 * @author Eike Stepper
170
	 */
171
	private static class ExtensionProcessor {
172
		public Object run() {
173
			IExtensionPoint extPoint = Platform.getExtensionRegistry().getExtensionPoint(MylarTeamPlugin.PLUGIN_ID,
174
					EXT_POINT_TEMPLATE_HANDLERS);
175
			IExtension[] extensions = extPoint.getExtensions();
176
			for (int i = 0; i < extensions.length; i++) {
177
				IExtension extension = extensions[i];
178
				IConfigurationElement[] elements = extension.getConfigurationElements();
179
				for (int j = 0; j < elements.length; j++) {
180
					IConfigurationElement element = elements[j];
181
					if (ELEM_TEMPLATE_HANDLER.equals(element.getName())) {
182
						try {
183
							Object result = processContribution(element);
184
							if (result != null)
185
								return result;
186
						} catch (Exception ex) {
187
							final String msg = MessageFormat.format(
188
									"Error while processing template handler contribution {0} from plugin {1}.",
189
									element.getAttribute(ATTR_CLASS), element.getContributor().getName());
190
							MylarStatusHandler.log(ex, msg);
191
						}
192
					}
193
				}
194
			}
195
196
			return null;
197
		}
198
199
		protected Object processContribution(IConfigurationElement element) throws Exception {
200
			String keyword = element.getAttribute(ATTR_RECOGNIZED_KEYWORD);
201
			String description = element.getAttribute(ATTR_DESCRIPTION);
202
			String className = element.getAttribute(ATTR_CLASS);
203
			return processContribution(element, keyword, description, className);
204
		}
205
206
		protected Object processContribution(IConfigurationElement element, String keyword, String description,
207
				String className) throws Exception {
208
			return null;
209
		}
210
	}
211
}
(-)src/org/eclipse/mylar/team/ITemplateHandlersManager.java (+30 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
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
 *    Eike Stepper - initial API and implementation
10
 **************************************************************************/
11
package org.eclipse.mylar.team;
12
13
import org.eclipse.mylar.tasks.core.ITask;
14
15
/**
16
 * @author Eike Stepper
17
 */
18
public interface ITemplateHandlersManager {
19
	public static final ITemplateHandlersManager INSTANCE = new org.eclipse.mylar.internal.team.template.TemplateHandlersManager();
20
21
	public String[] getRecognizedKeywords();
22
23
	public String getHandlerDescription(String keyword);
24
25
	public ITemplateHandler createHandler(String keyword);
26
27
	public String generateComment(ITask task, String completedTemplate, String progressTemplate);
28
29
	public String getTaskIDRegEx(String template);
30
}
(-)src/org/eclipse/mylar/internal/team/ui/preferences/workaround/RegExMessages.java (+332 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.team.ui.preferences.workaround;
13
14
import org.eclipse.osgi.util.NLS;
15
16
/**
17
 * RegEx messages. Helper class to get NLSed messages.
18
 * <p>
19
 * Copied from org.eclipse.ui.texteditor.RegExMessages.
20
 * <p>
21
 * Needed by
22
 * org.eclipse.mylar.internal.team.ui.preferences.workaround.RegExContentProposalProvider.
23
 * <p>
24
 * TODO Ask platform guys to open this API
25
 * 
26
 * @since 3.1
27
 */
28
final class RegExMessages extends NLS {
29
30
	private static final String BUNDLE_NAME = RegExMessages.class.getName();
31
32
	private RegExMessages() {
33
		// Do not instantiate
34
	}
35
36
	static {
37
		reloadMessages();
38
	}
39
40
	static void reloadMessages() {
41
		NLS.initializeMessages(BUNDLE_NAME, RegExMessages.class);
42
	}
43
44
	// characters
45
	public static String displayString_bs_bs;
46
47
	public static String additionalInfo_bs_bs;
48
49
	public static String displayString_bs_0;
50
51
	public static String additionalInfo_bs_0;
52
53
	public static String displayString_bs_x;
54
55
	public static String additionalInfo_bs_x;
56
57
	public static String displayString_bs_u;
58
59
	public static String additionalInfo_bs_u;
60
61
	public static String displayString_bs_t;
62
63
	public static String additionalInfo_bs_t;
64
65
	public static String displayString_bs_n;
66
67
	public static String additionalInfo_bs_n;
68
69
	public static String displayString_bs_r;
70
71
	public static String additionalInfo_bs_r;
72
73
	public static String displayString_bs_f;
74
75
	public static String additionalInfo_bs_f;
76
77
	public static String displayString_bs_a;
78
79
	public static String additionalInfo_bs_a;
80
81
	public static String displayString_bs_e;
82
83
	public static String additionalInfo_bs_e;
84
85
	public static String displayString_bs_c;
86
87
	public static String additionalInfo_bs_c;
88
89
	// character classes
90
	public static String displayString_dot;
91
92
	public static String additionalInfo_dot;
93
94
	public static String displayString_bs_d;
95
96
	public static String additionalInfo_bs_d;
97
98
	public static String displayString_bs_D;
99
100
	public static String additionalInfo_bs_D;
101
102
	public static String displayString_bs_s;
103
104
	public static String additionalInfo_bs_s;
105
106
	public static String displayString_bs_S;
107
108
	public static String additionalInfo_bs_S;
109
110
	public static String displayString_bs_w;
111
112
	public static String additionalInfo_bs_w;
113
114
	public static String displayString_bs_W;
115
116
	public static String additionalInfo_bs_W;
117
118
	// boundary matchers
119
	public static String displayString_start;
120
121
	public static String additionalInfo_start;
122
123
	public static String displayString_end;
124
125
	public static String additionalInfo_end;
126
127
	public static String displayString_bs_b;
128
129
	public static String additionalInfo_bs_b;
130
131
	public static String displayString_bs_B;
132
133
	public static String additionalInfo_bs_B;
134
135
	public static String displayString_bs_A;
136
137
	public static String additionalInfo_bs_A;
138
139
	public static String displayString_bs_G;
140
141
	public static String additionalInfo_bs_G;
142
143
	public static String displayString_bs_Z;
144
145
	public static String additionalInfo_bs_Z;
146
147
	public static String displayString_bs_z;
148
149
	public static String additionalInfo_bs_z;
150
151
	// greedy quantifiers
152
	public static String displayString_quest;
153
154
	public static String additionalInfo_quest;
155
156
	public static String displayString_star;
157
158
	public static String additionalInfo_star;
159
160
	public static String displayString_plus;
161
162
	public static String additionalInfo_plus;
163
164
	public static String displayString_exact;
165
166
	public static String additionalInfo_exact;
167
168
	public static String displayString_least;
169
170
	public static String additionalInfo_least;
171
172
	public static String displayString_count;
173
174
	public static String additionalInfo_count;
175
176
	// lazy quantifiers
177
	public static String displayString_questLazy;
178
179
	public static String additionalInfo_questLazy;
180
181
	public static String displayString_starLazy;
182
183
	public static String additionalInfo_starLazy;
184
185
	public static String displayString_plusLazy;
186
187
	public static String additionalInfo_plusLazy;
188
189
	public static String displayString_exactLazy;
190
191
	public static String additionalInfo_exactLazy;
192
193
	public static String displayString_leastLazy;
194
195
	public static String additionalInfo_leastLazy;
196
197
	public static String displayString_countLazy;
198
199
	public static String additionalInfo_countLazy;
200
201
	// possessive quantifiers
202
	public static String displayString_questPoss;
203
204
	public static String additionalInfo_questPoss;
205
206
	public static String displayString_starPoss;
207
208
	public static String additionalInfo_starPoss;
209
210
	public static String displayString_plusPoss;
211
212
	public static String additionalInfo_plusPoss;
213
214
	public static String displayString_exactPoss;
215
216
	public static String additionalInfo_exactPoss;
217
218
	public static String displayString_leastPoss;
219
220
	public static String additionalInfo_leastPoss;
221
222
	public static String displayString_countPoss;
223
224
	public static String additionalInfo_countPoss;
225
226
	// alternative
227
	public static String displayString_alt;
228
229
	public static String additionalInfo_alt;
230
231
	// capturing groups
232
	public static String displayString_group;
233
234
	public static String additionalInfo_group;
235
236
	public static String displayString_bs_i;
237
238
	public static String additionalInfo_bs_i;
239
240
	// quoting
241
	public static String displayString_bs;
242
243
	public static String additionalInfo_bs;
244
245
	public static String displayString_bs_Q;
246
247
	public static String additionalInfo_bs_Q;
248
249
	public static String displayString_bs_E;
250
251
	public static String additionalInfo_bs_E;
252
253
	// character sets
254
	public static String displayString_set;
255
256
	public static String additionalInfo_set;
257
258
	public static String displayString_setExcl;
259
260
	public static String additionalInfo_setExcl;
261
262
	public static String displayString_setRange;
263
264
	public static String additionalInfo_setRange;
265
266
	public static String displayString_setInter;
267
268
	public static String additionalInfo_setInter;
269
270
	public static String displayString_posix;
271
272
	public static String additionalInfo_posix;
273
274
	public static String displayString_posixNot;
275
276
	public static String additionalInfo_posixNot;
277
278
	public static String displayString_flag;
279
280
	public static String additionalInfo_flag;
281
282
	public static String displayString_flagExpr;
283
284
	public static String additionalInfo_flagExpr;
285
286
	// non-capturing group
287
	public static String displayString_nonCap;
288
289
	public static String additionalInfo_nonCap;
290
291
	public static String displayString_atomicCap;
292
293
	public static String additionalInfo_atomicCap;
294
295
	// look-ahead
296
	public static String displayString_posLookahead;
297
298
	public static String additionalInfo_posLookahead;
299
300
	public static String displayString_negLookahead;
301
302
	public static String additionalInfo_negLookahead;
303
304
	public static String displayString_posLookbehind;
305
306
	public static String additionalInfo_posLookbehind;
307
308
	public static String displayString_negLookbehind;
309
310
	public static String additionalInfo_negLookbehind;
311
312
	// replace
313
	public static String displayString_dollar;
314
315
	public static String additionalInfo_dollar;
316
317
	public static String additionalInfo_replace_bs;
318
319
	public static String displayString_replace_bs;
320
321
	public static String displayString_tab;
322
323
	public static String additionalInfo_tab;
324
325
	public static String displayString_nl;
326
327
	public static String additionalInfo_nl;
328
329
	public static String displayString_cr;
330
331
	public static String additionalInfo_cr;
332
}
(-)src/org/eclipse/mylar/internal/team/ui/preferences/workaround/README.java (+21 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
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
 *    Eike Stepper - initial API and implementation
10
 **************************************************************************/
11
package org.eclipse.mylar.internal.team.ui.preferences.workaround;
12
13
/**
14
 * The classes in this package are copied from org.eclipse.ui.texteditor because
15
 * the class org.eclipse.ui.texteditor.RegExContentProposalProvider is not
16
 * public. TODO We should ask platform guys to open this API.
17
 * 
18
 * @author Eike Stepper
19
 */
20
public class README {
21
}
(-)schema/templateHandlers.exsd (+122 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.mylar.team">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.mylar.team" id="templateHandlers" name="Mylar Template Handlers"/>
7
      </appInfo>
8
      <documentation>
9
         [Enter description of this extension point.]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="templateHandler" minOccurs="1" maxOccurs="unbounded"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="templateHandler">
46
      <complexType>
47
         <attribute name="class" type="string" use="required">
48
            <annotation>
49
               <documentation>
50
                  
51
               </documentation>
52
               <appInfo>
53
                  <meta.attribute kind="java" basedOn="org.eclipse.mylar.team.ITemplateHandler"/>
54
               </appInfo>
55
            </annotation>
56
         </attribute>
57
         <attribute name="description" type="string">
58
            <annotation>
59
               <documentation>
60
                  
61
               </documentation>
62
               <appInfo>
63
                  <meta.attribute translatable="true"/>
64
               </appInfo>
65
            </annotation>
66
         </attribute>
67
         <attribute name="recognizedKeyword" type="string" use="required">
68
            <annotation>
69
               <documentation>
70
                  
71
               </documentation>
72
            </annotation>
73
         </attribute>
74
      </complexType>
75
   </element>
76
77
   <annotation>
78
      <appInfo>
79
         <meta.section type="since"/>
80
      </appInfo>
81
      <documentation>
82
         [Enter the first release in which this extension point appears.]
83
      </documentation>
84
   </annotation>
85
86
   <annotation>
87
      <appInfo>
88
         <meta.section type="examples"/>
89
      </appInfo>
90
      <documentation>
91
         [Enter extension point usage example here.]
92
      </documentation>
93
   </annotation>
94
95
   <annotation>
96
      <appInfo>
97
         <meta.section type="apiInfo"/>
98
      </appInfo>
99
      <documentation>
100
         [Enter API information here.]
101
      </documentation>
102
   </annotation>
103
104
   <annotation>
105
      <appInfo>
106
         <meta.section type="implementation"/>
107
      </appInfo>
108
      <documentation>
109
         [Enter information about supplied implementation of this extension point.]
110
      </documentation>
111
   </annotation>
112
113
   <annotation>
114
      <appInfo>
115
         <meta.section type="copyright"/>
116
      </appInfo>
117
      <documentation>
118
         
119
      </documentation>
120
   </annotation>
121
122
</schema>
(-)src/org/eclipse/mylar/team/ITemplateHandler.java (+24 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
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
 *    Eike Stepper - initial API and implementation
10
 **************************************************************************/
11
package org.eclipse.mylar.team;
12
13
import org.eclipse.mylar.tasks.core.ITask;
14
15
/**
16
 * @author Eike Stepper
17
 */
18
public interface ITemplateHandler {
19
	public String getDescription();
20
21
	public String getRecognizedKeyword();
22
23
	public String getValue(ITask task);
24
}
(-)src/org/eclipse/mylar/internal/team/template/TemplateHandler.java (+316 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
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
 *    Eike Stepper - initial API and implementation
10
 **************************************************************************/
11
package org.eclipse.mylar.internal.team.template;
12
13
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
14
import org.eclipse.mylar.tasks.core.ITask;
15
import org.eclipse.mylar.team.ITemplateHandler;
16
17
import java.util.List;
18
19
/**
20
 * @author Eike Stepper
21
 */
22
public abstract class TemplateHandler implements ITemplateHandler {
23
	protected String description;
24
25
	protected String recognizedKeyword;
26
27
	protected TemplateHandler() {
28
	}
29
30
	public String getDescription() {
31
		return description != null ? description : "Handler for '" + recognizedKeyword + "'";
32
	}
33
34
	public void setDescription(String description) {
35
		this.description = description;
36
	}
37
38
	public String getRecognizedKeyword() {
39
		return recognizedKeyword;
40
	}
41
42
	public void setRecognizedKeyword(String recognizedKeyword) {
43
		if (recognizedKeyword == null) {
44
			throw new IllegalArgumentException("Keyword to recognize must not be null"); //$NON-NLS-1$
45
		}
46
47
		this.recognizedKeyword = recognizedKeyword;
48
	}
49
50
	public static String implode(List<String> list, String separator) {
51
		StringBuilder builder = new StringBuilder();
52
		for (String cc : list) {
53
			if (builder.length() != 0) {
54
				builder.append(separator);
55
			}
56
57
			builder.append(cc);
58
		}
59
60
		return builder.toString();
61
	}
62
63
	/**
64
	 * @author Eike Stepper
65
	 */
66
	public static class RepositoryKind extends TemplateHandler {
67
		public String getValue(ITask task) {
68
			if (task instanceof AbstractRepositoryTask) {
69
				return ((AbstractRepositoryTask) task).getRepositoryKind();
70
			}
71
72
			return null;
73
		}
74
	}
75
76
	/**
77
	 * @author Eike Stepper
78
	 */
79
	public static class RepositoryURL extends TemplateHandler {
80
		public String getValue(ITask task) {
81
			if (task instanceof AbstractRepositoryTask) {
82
				return ((AbstractRepositoryTask) task).getRepositoryUrl();
83
			}
84
85
			return null;
86
		}
87
	}
88
89
	/**
90
	 * @author Eike Stepper
91
	 */
92
	public static class TaskProduct extends TemplateHandler {
93
		public String getValue(ITask task) {
94
			if (task instanceof AbstractRepositoryTask) {
95
				return ((AbstractRepositoryTask) task).getTaskData().getProduct();
96
			}
97
98
			return null;
99
		}
100
	}
101
102
	/**
103
	 * @author Eike Stepper
104
	 */
105
	public static class TaskAssignee extends TemplateHandler {
106
		public String getValue(ITask task) {
107
			if (task instanceof AbstractRepositoryTask) {
108
				return ((AbstractRepositoryTask) task).getTaskData().getAssignedTo();
109
			}
110
111
			return null;
112
		}
113
	}
114
115
	/**
116
	 * @author Eike Stepper
117
	 */
118
	public static class TaskReporter extends TemplateHandler {
119
		public String getValue(ITask task) {
120
			if (task instanceof AbstractRepositoryTask) {
121
				return ((AbstractRepositoryTask) task).getTaskData().getReporter();
122
			}
123
124
			return null;
125
		}
126
	}
127
128
	/**
129
	 * @author Eike Stepper
130
	 */
131
	public static class TaskResolution extends TemplateHandler {
132
		public String getValue(ITask task) {
133
			if (task instanceof AbstractRepositoryTask) {
134
				return ((AbstractRepositoryTask) task).getTaskData().getResolution();
135
			}
136
137
			return null;
138
		}
139
	}
140
141
	/**
142
	 * @author Eike Stepper
143
	 */
144
	public static class TaskStatus extends TemplateHandler {
145
		public String getValue(ITask task) {
146
			if (task instanceof AbstractRepositoryTask) {
147
				return ((AbstractRepositoryTask) task).getTaskData().getStatus();
148
			}
149
150
			return null;
151
		}
152
	}
153
154
	/**
155
	 * @author Eike Stepper
156
	 */
157
	public static class TaskCC extends TemplateHandler {
158
		public String getValue(ITask task) {
159
			if (task instanceof AbstractRepositoryTask) {
160
				List<String> list = ((AbstractRepositoryTask) task).getTaskData().getCC();
161
				return implode(list, ", ");
162
			}
163
164
			return null;
165
		}
166
	}
167
168
	/**
169
	 * @author Eike Stepper
170
	 */
171
	public static class TaskKeywords extends TemplateHandler {
172
		public String getValue(ITask task) {
173
			if (task instanceof AbstractRepositoryTask) {
174
				List<String> list = ((AbstractRepositoryTask) task).getTaskData().getKeywords();
175
				return implode(list, ", ");
176
			}
177
178
			return null;
179
		}
180
	}
181
182
	/**
183
	 * @author Eike Stepper
184
	 */
185
	public static class TaskLastModified extends TemplateHandler {
186
		public String getValue(ITask task) {
187
			if (task instanceof AbstractRepositoryTask) {
188
				return ((AbstractRepositoryTask) task).getTaskData().getLastModified();
189
			}
190
191
			return null;
192
		}
193
	}
194
195
	/**
196
	 * @author Eike Stepper
197
	 */
198
	public static class TaskSummary extends TemplateHandler {
199
		public String getValue(ITask task) {
200
			if (task instanceof AbstractRepositoryTask) {
201
				return ((AbstractRepositoryTask) task).getTaskData().getSummary();
202
			}
203
204
			return task.getDescription();
205
		}
206
	}
207
208
	/**
209
	 * @author Eike Stepper
210
	 */
211
	public static class TaskDescription extends TemplateHandler {
212
		public String getValue(ITask task) {
213
			return task.getDescription();
214
		}
215
	}
216
217
	/**
218
	 * @author Eike Stepper
219
	 */
220
	public static class TaskHandle extends TemplateHandler {
221
		public String getValue(ITask task) {
222
			return task.getHandleIdentifier();
223
		}
224
	}
225
226
	/**
227
	 * @author Eike Stepper
228
	 */
229
	public static class TaskID extends TemplateHandler {
230
		public String getValue(ITask task) {
231
			return AbstractRepositoryTask.getTaskId(task.getHandleIdentifier());
232
		}
233
	}
234
235
	/**
236
	 * @author Eike Stepper
237
	 */
238
	public static class TaskNotes extends TemplateHandler {
239
		public String getValue(ITask task) {
240
			return task.getNotes();
241
		}
242
	}
243
244
	/**
245
	 * @author Eike Stepper
246
	 */
247
	public static class TaskPriority extends TemplateHandler {
248
		public String getValue(ITask task) {
249
			return task.getPriority();
250
		}
251
	}
252
253
	/**
254
	 * @author Eike Stepper
255
	 */
256
	public static class TaskType extends TemplateHandler {
257
		public String getValue(ITask task) {
258
			return task.getTaskType();
259
		}
260
	}
261
262
	/**
263
	 * @author Eike Stepper
264
	 */
265
	public static class TaskURL extends TemplateHandler {
266
		public String getValue(ITask task) {
267
			return task.getUrl();
268
		}
269
	}
270
271
	/**
272
	 * @author Eike Stepper
273
	 */
274
	protected static abstract class Date extends TemplateHandler {
275
		public String getValue(ITask task) {
276
			java.util.Date date = getDate(task);
277
			return formatDate(date);
278
		}
279
280
		protected String formatDate(java.util.Date date) {
281
			return date.toString();
282
		}
283
284
		protected abstract java.util.Date getDate(ITask task);
285
286
		/**
287
		 * @author Eike Stepper
288
		 */
289
		public static class TaskCompletion extends Date {
290
			@Override
291
			protected java.util.Date getDate(ITask task) {
292
				return task.getCompletionDate();
293
			}
294
		}
295
296
		/**
297
		 * @author Eike Stepper
298
		 */
299
		public static class TaskCreation extends Date {
300
			@Override
301
			protected java.util.Date getDate(ITask task) {
302
				return task.getCreationDate();
303
			}
304
		}
305
306
		/**
307
		 * @author Eike Stepper
308
		 */
309
		public static class TaskReminder extends Date {
310
			@Override
311
			protected java.util.Date getDate(ITask task) {
312
				return task.getReminderDate();
313
			}
314
		}
315
	}
316
}
(-)src/org/eclipse/mylar/internal/team/template/TemplateHandlerContentProposalProvider.java (+132 lines)
Added Link Here
1
/***************************************************************************
2
 * Copyright (c) 2004, 2005, 2006 Eike Stepper, Germany.
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
 *    Eike Stepper - initial API and implementation
10
 **************************************************************************/
11
package org.eclipse.mylar.internal.team.template;
12
13
import org.eclipse.jface.fieldassist.IContentProposal;
14
import org.eclipse.jface.fieldassist.IContentProposalProvider;
15
import org.eclipse.mylar.team.ITemplateHandlersManager;
16
17
import java.util.ArrayList;
18
import java.util.List;
19
20
/**
21
 * @author Eike Stepper
22
 */
23
public class TemplateHandlerContentProposalProvider implements IContentProposalProvider {
24
	public IContentProposal[] getProposals(String contents, int position) {
25
		ProposalComputer proposalComputer = new ProposalComputer(contents, position);
26
		return proposalComputer.computeProposals();
27
	}
28
29
	/**
30
	 * @author Eike Stepper
31
	 */
32
	protected static class ProposalComputer {
33
		private String contents;
34
35
		private int position;
36
37
		private List<IContentProposal> result = new ArrayList<IContentProposal>();
38
39
		private String[] keywords;
40
41
		private String prefix;
42
43
		public ProposalComputer(String contents, int position) {
44
			this.contents = contents;
45
			this.position = position;
46
			initKeywords();
47
			initPrefix();
48
		}
49
50
		public IContentProposal[] computeProposals() {
51
			for (String keyword : keywords) {
52
				String proposal = getMatch(keyword);
53
				if (proposal != null) {
54
					addProposal(proposal, keyword);
55
				}
56
			}
57
58
			return result.toArray(new IContentProposal[result.size()]);
59
		}
60
61
		protected ITemplateHandlersManager getTemplateHandlersManager() {
62
			return ITemplateHandlersManager.INSTANCE;
63
		}
64
65
		private void initKeywords() {
66
			keywords = getTemplateHandlersManager().getRecognizedKeywords();
67
		}
68
69
		private void initPrefix() {
70
			prefix = "";
71
			String beforePosition = contents.substring(0, position);
72
			if (beforePosition.endsWith("$")) {
73
				prefix = "$";
74
			} else {
75
				int start = beforePosition.lastIndexOf("${");
76
				if (start >= 0) {
77
					int end = contents.indexOf('}', start);
78
					if (end >= position) {
79
						prefix = contents.substring(start, position);
80
					}
81
				}
82
			}
83
		}
84
85
		private String getMatch(String keyword) {
86
			String wholeProposal = "${" + keyword + "}";
87
			if (wholeProposal.startsWith(prefix)) {
88
				return wholeProposal.substring(prefix.length());
89
			}
90
91
			return null;
92
		}
93
94
		private void addProposal(String proposal, String keyword) {
95
			String description = getTemplateHandlersManager().getHandlerDescription(keyword);
96
			result.add(new Proposal(proposal, keyword, description));
97
		}
98
99
		/**
100
		 * @author Eike Stepper
101
		 */
102
		private static final class Proposal implements IContentProposal {
103
			private final String proposal;
104
105
			private final String keyword;
106
107
			private final String description;
108
109
			private Proposal(String proposal, String keyword, String description) {
110
				this.proposal = proposal;
111
				this.keyword = keyword;
112
				this.description = description;
113
			}
114
115
			public String getContent() {
116
				return proposal;
117
			}
118
119
			public int getCursorPosition() {
120
				return proposal.length();
121
			}
122
123
			public String getDescription() {
124
				return description;
125
			}
126
127
			public String getLabel() {
128
				return "${" + keyword + "}";
129
			}
130
		}
131
	}
132
}
(-)src/org/eclipse/mylar/internal/team/ui/preferences/workaround/RegExContentProposalProvider.java (+464 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation 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
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.team.ui.preferences.workaround;
13
14
import java.util.ArrayList;
15
16
import org.eclipse.jface.fieldassist.IContentProposal;
17
import org.eclipse.jface.fieldassist.IContentProposalProvider;
18
19
/**
20
 * Content assist proposal provider for regular expressions.
21
 * <p>
22
 * Note: Replaces <code>RegExContentAssistProcessor</code> which was
23
 * introduced in 3.0.
24
 * </p>
25
 * Copied from org.eclipse.ui.texteditor.RegExContentProposalProvider.
26
 * <p>
27
 * Needed by
28
 * org.eclipse.mylar.internal.team.ui.preferences.workaround.MylarTeamPreferencePage.
29
 * <p>
30
 * TODO Ask platform guys to open this API
31
 * 
32
 * @since 3.2
33
 */
34
public final class RegExContentProposalProvider implements IContentProposalProvider {
35
36
	/**
37
	 * Proposal computer.
38
	 */
39
	private static class ProposalComputer {
40
41
		private static class Proposal implements IContentProposal {
42
43
			private String fContent;
44
45
			private String fLabel;
46
47
			private String fDescription;
48
49
			private int fCursorPosition;
50
51
			Proposal(String content, String label, String description, int cursorPosition) {
52
				fContent = content;
53
				fLabel = label;
54
				fDescription = description;
55
				fCursorPosition = cursorPosition;
56
			}
57
58
			public String getContent() {
59
				return fContent;
60
			}
61
62
			public String getLabel() {
63
				return fLabel;
64
			}
65
66
			public String getDescription() {
67
				return fDescription;
68
			}
69
70
			public int getCursorPosition() {
71
				return fCursorPosition;
72
			}
73
		}
74
75
		/**
76
		 * The whole regular expression.
77
		 */
78
		private final String fExpression;
79
80
		/**
81
		 * The document offset.
82
		 */
83
		private final int fDocumentOffset;
84
85
		/**
86
		 * The high-priority proposals.
87
		 */
88
		private final ArrayList fPriorityProposals;
89
90
		/**
91
		 * The low-priority proposals.
92
		 */
93
		private final ArrayList fProposals;
94
95
		/**
96
		 * <code>true</code> iff <code>fExpression</code> ends with an open
97
		 * escape.
98
		 */
99
		private final boolean fIsEscape;
100
101
		/**
102
		 * Creates a new Proposal Computer.
103
		 * 
104
		 * @param contents
105
		 *            the contents of the subject control
106
		 * @param position
107
		 *            the cursor position
108
		 */
109
		public ProposalComputer(String contents, int position) {
110
			fExpression = contents;
111
			fDocumentOffset = position;
112
			fPriorityProposals = new ArrayList();
113
			fProposals = new ArrayList();
114
115
			boolean isEscape = false;
116
			esc: for (int i = position - 1; i >= 0; i--) {
117
				if (fExpression.charAt(i) == '\\')
118
					isEscape = !isEscape;
119
				else
120
					break esc;
121
			}
122
			fIsEscape = isEscape;
123
		}
124
125
		/**
126
		 * Computes applicable proposals for the find field.
127
		 * 
128
		 * @return the proposals
129
		 */
130
		public IContentProposal[] computeFindProposals() {
131
			// characters
132
			addBsProposal("\\\\", RegExMessages.displayString_bs_bs, RegExMessages.additionalInfo_bs_bs); //$NON-NLS-1$
133
			addBracketProposal("\\0", 2, RegExMessages.displayString_bs_0, RegExMessages.additionalInfo_bs_0); //$NON-NLS-1$
134
			addBracketProposal("\\x", 2, RegExMessages.displayString_bs_x, RegExMessages.additionalInfo_bs_x); //$NON-NLS-1$
135
			addBracketProposal("\\u", 2, RegExMessages.displayString_bs_u, RegExMessages.additionalInfo_bs_u); //$NON-NLS-1$
136
			addBsProposal("\\t", RegExMessages.displayString_bs_t, RegExMessages.additionalInfo_bs_t); //$NON-NLS-1$
137
			addBsProposal("\\n", RegExMessages.displayString_bs_n, RegExMessages.additionalInfo_bs_n); //$NON-NLS-1$
138
			addBsProposal("\\r", RegExMessages.displayString_bs_r, RegExMessages.additionalInfo_bs_r); //$NON-NLS-1$
139
			addBsProposal("\\f", RegExMessages.displayString_bs_f, RegExMessages.additionalInfo_bs_f); //$NON-NLS-1$
140
			addBsProposal("\\a", RegExMessages.displayString_bs_a, RegExMessages.additionalInfo_bs_a); //$NON-NLS-1$
141
			addBsProposal("\\e", RegExMessages.displayString_bs_e, RegExMessages.additionalInfo_bs_e); //$NON-NLS-1$
142
			addBsProposal("\\c", RegExMessages.displayString_bs_c, RegExMessages.additionalInfo_bs_c); //$NON-NLS-1$
143
144
			if (!fIsEscape)
145
				addBracketProposal(".", 1, RegExMessages.displayString_dot, RegExMessages.additionalInfo_dot); //$NON-NLS-1$
146
			addBsProposal("\\d", RegExMessages.displayString_bs_d, RegExMessages.additionalInfo_bs_d); //$NON-NLS-1$
147
			addBsProposal("\\D", RegExMessages.displayString_bs_D, RegExMessages.additionalInfo_bs_D); //$NON-NLS-1$
148
			addBsProposal("\\s", RegExMessages.displayString_bs_s, RegExMessages.additionalInfo_bs_s); //$NON-NLS-1$
149
			addBsProposal("\\S", RegExMessages.displayString_bs_S, RegExMessages.additionalInfo_bs_S); //$NON-NLS-1$
150
			addBsProposal("\\w", RegExMessages.displayString_bs_w, RegExMessages.additionalInfo_bs_w); //$NON-NLS-1$
151
			addBsProposal("\\W", RegExMessages.displayString_bs_W, RegExMessages.additionalInfo_bs_W); //$NON-NLS-1$
152
153
			// back reference
154
			addBsProposal("\\", RegExMessages.displayString_bs_i, RegExMessages.additionalInfo_bs_i); //$NON-NLS-1$
155
156
			// quoting
157
			addBsProposal("\\", RegExMessages.displayString_bs, RegExMessages.additionalInfo_bs); //$NON-NLS-1$
158
			addBsProposal("\\Q", RegExMessages.displayString_bs_Q, RegExMessages.additionalInfo_bs_Q); //$NON-NLS-1$
159
			addBsProposal("\\E", RegExMessages.displayString_bs_E, RegExMessages.additionalInfo_bs_E); //$NON-NLS-1$
160
161
			// character sets
162
			if (!fIsEscape) {
163
				addBracketProposal("[]", 1, RegExMessages.displayString_set, RegExMessages.additionalInfo_set); //$NON-NLS-1$
164
				addBracketProposal("[^]", 2, RegExMessages.displayString_setExcl, RegExMessages.additionalInfo_setExcl); //$NON-NLS-1$
165
				addBracketProposal(
166
						"[-]", 1, RegExMessages.displayString_setRange, RegExMessages.additionalInfo_setRange); //$NON-NLS-1$
167
				addProposal("&&", RegExMessages.displayString_setInter, RegExMessages.additionalInfo_setInter); //$NON-NLS-1$
168
			}
169
			if (!fIsEscape && fDocumentOffset > 0 && fExpression.charAt(fDocumentOffset - 1) == '\\') {
170
				addProposal("\\p{}", 3, RegExMessages.displayString_posix, RegExMessages.additionalInfo_posix); //$NON-NLS-1$
171
				addProposal("\\P{}", 3, RegExMessages.displayString_posixNot, RegExMessages.additionalInfo_posixNot); //$NON-NLS-1$
172
			} else {
173
				addBracketProposal("\\p{}", 3, RegExMessages.displayString_posix, RegExMessages.additionalInfo_posix); //$NON-NLS-1$
174
				addBracketProposal(
175
						"\\P{}", 3, RegExMessages.displayString_posixNot, RegExMessages.additionalInfo_posixNot); //$NON-NLS-1$
176
			}
177
178
			// addBsProposal("\\p{Lower}",
179
			// RegExMessages.displayString_bs_p{Lower},
180
			// RegExMessages.additionalInfo_bs_p{Lower}); //$NON-NLS-1$
181
			// addBsProposal("\\p{Upper}",
182
			// RegExMessages.displayString_bs_p{Upper},
183
			// RegExMessages.additionalInfo_bs_p{Upper}); //$NON-NLS-1$
184
			// addBsProposal("\\p{ASCII}",
185
			// RegExMessages.displayString_bs_p{ASCII},
186
			// RegExMessages.additionalInfo_bs_p{ASCII}); //$NON-NLS-1$
187
			// addBsProposal("\\p{Alpha}",
188
			// RegExMessages.displayString_bs_p{Alpha},
189
			// RegExMessages.additionalInfo_bs_p{Alpha}); //$NON-NLS-1$
190
			// addBsProposal("\\p{Digit}",
191
			// RegExMessages.displayString_bs_p{Digit},
192
			// RegExMessages.additionalInfo_bs_p{Digit}); //$NON-NLS-1$
193
			// addBsProposal("\\p{Alnum}",
194
			// RegExMessages.displayString_bs_p{Alnum},
195
			// RegExMessages.additionalInfo_bs_p{Alnum}); //$NON-NLS-1$
196
			// addBsProposal("\\p{Punct}",
197
			// RegExMessages.displayString_bs_p{Punct},
198
			// RegExMessages.additionalInfo_bs_p{Punct}); //$NON-NLS-1$
199
			// addBsProposal("\\p{Graph}",
200
			// RegExMessages.displayString_bs_p{Graph},
201
			// RegExMessages.additionalInfo_bs_p{Graph}); //$NON-NLS-1$
202
			// addBsProposal("\\p{Print}",
203
			// RegExMessages.displayString_bs_p{Print},
204
			// RegExMessages.additionalInfo_bs_p{Print}); //$NON-NLS-1$
205
			// addBsProposal("\\p{Blank}",
206
			// RegExMessages.displayString_bs_p{Blank},
207
			// RegExMessages.additionalInfo_bs_p{Blank}); //$NON-NLS-1$
208
			// addBsProposal("\\p{Cntrl}",
209
			// RegExMessages.displayString_bs_p{Cntrl},
210
			// RegExMessages.additionalInfo_bs_p{Cntrl}); //$NON-NLS-1$
211
			// addBsProposal("\\p{XDigit}",
212
			// RegExMessages.displayString_bs_p{XDigit},
213
			// RegExMessages.additionalInfo_bs_p{XDigit}); //$NON-NLS-1$
214
			// addBsProposal("\\p{Space}",
215
			// RegExMessages.displayString_bs_p{Space},
216
			// RegExMessages.additionalInfo_bs_p{Space}); //$NON-NLS-1$
217
			//
218
			// addBsProposal("\\p{InGreek}",
219
			// RegExMessages.displayString_bs_p{InGreek},
220
			// RegExMessages.additionalInfo_bs_p{InGreek}); //$NON-NLS-1$
221
			// addBsProposal("\\p{Lu}", RegExMessages.displayString_bs_p{Lu},
222
			// RegExMessages.additionalInfo_bs_p{Lu}); //$NON-NLS-1$
223
			// addBsProposal("\\p{Sc}", RegExMessages.displayString_bs_p{Sc},
224
			// RegExMessages.additionalInfo_bs_p{Sc}); //$NON-NLS-1$
225
			// addBsProposal("\\P{InGreek}",
226
			// RegExMessages.displayString_bs_P{InGreek},
227
			// RegExMessages.additionalInfo_bs_P{InGreek}); //$NON-NLS-1$
228
229
			// boundary matchers
230
			if (fDocumentOffset == 0) {
231
				addPriorityProposal("^", RegExMessages.displayString_start, RegExMessages.additionalInfo_start); //$NON-NLS-1$
232
			} else if (fDocumentOffset == 1 && fExpression.charAt(0) == '^') {
233
				addBracketProposal("^", 1, RegExMessages.displayString_start, RegExMessages.additionalInfo_start); //$NON-NLS-1$
234
			}
235
			if (fDocumentOffset == fExpression.length()) {
236
				addProposal("$", RegExMessages.displayString_end, RegExMessages.additionalInfo_end); //$NON-NLS-1$
237
			}
238
			addBsProposal("\\b", RegExMessages.displayString_bs_b, RegExMessages.additionalInfo_bs_b); //$NON-NLS-1$
239
			addBsProposal("\\B", RegExMessages.displayString_bs_B, RegExMessages.additionalInfo_bs_B); //$NON-NLS-1$
240
			addBsProposal("\\A", RegExMessages.displayString_bs_A, RegExMessages.additionalInfo_bs_A); //$NON-NLS-1$
241
			addBsProposal("\\G", RegExMessages.displayString_bs_G, RegExMessages.additionalInfo_bs_G); //$NON-NLS-1$
242
			addBsProposal("\\Z", RegExMessages.displayString_bs_Z, RegExMessages.additionalInfo_bs_Z); //$NON-NLS-1$
243
			addBsProposal("\\z", RegExMessages.displayString_bs_z, RegExMessages.additionalInfo_bs_z); //$NON-NLS-1$
244
245
			if (!fIsEscape) {
246
				// capturing groups
247
				addBracketProposal("()", 1, RegExMessages.displayString_group, RegExMessages.additionalInfo_group); //$NON-NLS-1$
248
249
				// flags
250
				addBracketProposal("(?)", 2, RegExMessages.displayString_flag, RegExMessages.additionalInfo_flag); //$NON-NLS-1$
251
				addBracketProposal(
252
						"(?:)", 3, RegExMessages.displayString_flagExpr, RegExMessages.additionalInfo_flagExpr); //$NON-NLS-1$
253
254
				// non-capturing group
255
				addBracketProposal("(?:)", 3, RegExMessages.displayString_nonCap, RegExMessages.additionalInfo_nonCap); //$NON-NLS-1$
256
				addBracketProposal(
257
						"(?>)", 3, RegExMessages.displayString_atomicCap, RegExMessages.additionalInfo_atomicCap); //$NON-NLS-1$
258
259
				// lookaraound
260
				addBracketProposal(
261
						"(?=)", 3, RegExMessages.displayString_posLookahead, RegExMessages.additionalInfo_posLookahead); //$NON-NLS-1$
262
				addBracketProposal(
263
						"(?!)", 3, RegExMessages.displayString_negLookahead, RegExMessages.additionalInfo_negLookahead); //$NON-NLS-1$
264
				addBracketProposal(
265
						"(?<=)", 4, RegExMessages.displayString_posLookbehind, RegExMessages.additionalInfo_posLookbehind); //$NON-NLS-1$
266
				addBracketProposal(
267
						"(?<!)", 4, RegExMessages.displayString_negLookbehind, RegExMessages.additionalInfo_negLookbehind); //$NON-NLS-1$
268
269
				// greedy quantifiers
270
				addBracketProposal("?", 1, RegExMessages.displayString_quest, RegExMessages.additionalInfo_quest); //$NON-NLS-1$
271
				addBracketProposal("*", 1, RegExMessages.displayString_star, RegExMessages.additionalInfo_star); //$NON-NLS-1$
272
				addBracketProposal("+", 1, RegExMessages.displayString_plus, RegExMessages.additionalInfo_plus); //$NON-NLS-1$
273
				addBracketProposal("{}", 1, RegExMessages.displayString_exact, RegExMessages.additionalInfo_exact); //$NON-NLS-1$
274
				addBracketProposal("{,}", 1, RegExMessages.displayString_least, RegExMessages.additionalInfo_least); //$NON-NLS-1$
275
				addBracketProposal("{,}", 1, RegExMessages.displayString_count, RegExMessages.additionalInfo_count); //$NON-NLS-1$
276
277
				// lazy quantifiers
278
				addBracketProposal(
279
						"??", 1, RegExMessages.displayString_questLazy, RegExMessages.additionalInfo_questLazy); //$NON-NLS-1$
280
				addBracketProposal("*?", 1, RegExMessages.displayString_starLazy, RegExMessages.additionalInfo_starLazy); //$NON-NLS-1$
281
				addBracketProposal("+?", 1, RegExMessages.displayString_plusLazy, RegExMessages.additionalInfo_plusLazy); //$NON-NLS-1$
282
				addBracketProposal(
283
						"{}?", 1, RegExMessages.displayString_exactLazy, RegExMessages.additionalInfo_exactLazy); //$NON-NLS-1$
284
				addBracketProposal(
285
						"{,}?", 1, RegExMessages.displayString_leastLazy, RegExMessages.additionalInfo_leastLazy); //$NON-NLS-1$
286
				addBracketProposal(
287
						"{,}?", 1, RegExMessages.displayString_countLazy, RegExMessages.additionalInfo_countLazy); //$NON-NLS-1$
288
289
				// possessive quantifiers
290
				addBracketProposal(
291
						"?+", 1, RegExMessages.displayString_questPoss, RegExMessages.additionalInfo_questPoss); //$NON-NLS-1$
292
				addBracketProposal("*+", 1, RegExMessages.displayString_starPoss, RegExMessages.additionalInfo_starPoss); //$NON-NLS-1$
293
				addBracketProposal("++", 1, RegExMessages.displayString_plusPoss, RegExMessages.additionalInfo_plusPoss); //$NON-NLS-1$
294
				addBracketProposal(
295
						"{}+", 1, RegExMessages.displayString_exactPoss, RegExMessages.additionalInfo_exactPoss); //$NON-NLS-1$
296
				addBracketProposal(
297
						"{,}+", 1, RegExMessages.displayString_leastPoss, RegExMessages.additionalInfo_leastPoss); //$NON-NLS-1$
298
				addBracketProposal(
299
						"{,}+", 1, RegExMessages.displayString_countPoss, RegExMessages.additionalInfo_countPoss); //$NON-NLS-1$
300
301
				// alternative
302
				addBracketProposal("|", 1, RegExMessages.displayString_alt, RegExMessages.additionalInfo_alt); //$NON-NLS-1$
303
			}
304
305
			fPriorityProposals.addAll(fProposals);
306
			return (IContentProposal[]) fPriorityProposals.toArray(new IContentProposal[fProposals.size()]);
307
		}
308
309
		/**
310
		 * Computes applicable proposals for the replace field.
311
		 * 
312
		 * @return the proposals
313
		 */
314
		public IContentProposal[] computeReplaceProposals() {
315
			if (fDocumentOffset > 0 && '$' == fExpression.charAt(fDocumentOffset - 1)) {
316
				addProposal("", RegExMessages.displayString_dollar, RegExMessages.additionalInfo_dollar); //$NON-NLS-1$
317
			} else {
318
				addProposal("$", RegExMessages.displayString_dollar, RegExMessages.additionalInfo_dollar); //$NON-NLS-1$
319
				addBsProposal("\\", RegExMessages.displayString_replace_bs, RegExMessages.additionalInfo_replace_bs); //$NON-NLS-1$
320
				addProposal("\t", RegExMessages.displayString_tab, RegExMessages.additionalInfo_tab); //$NON-NLS-1$
321
			}
322
			return (IContentProposal[]) fProposals.toArray(new IContentProposal[fProposals.size()]);
323
		}
324
325
		/**
326
		 * Adds a proposal.
327
		 * 
328
		 * @param proposal
329
		 *            the string to be inserted
330
		 * @param displayString
331
		 *            the proposal's label
332
		 * @param additionalInfo
333
		 *            the additional information
334
		 */
335
		private void addProposal(String proposal, String displayString, String additionalInfo) {
336
			fProposals.add(new Proposal(proposal, displayString, additionalInfo, proposal.length()));
337
		}
338
339
		/**
340
		 * Adds a proposal.
341
		 * 
342
		 * @param proposal
343
		 *            the string to be inserted
344
		 * @param cursorPosition
345
		 *            the cursor position after insertion, relative to the start
346
		 *            of the proposal
347
		 * @param displayString
348
		 *            the proposal's label
349
		 * @param additionalInfo
350
		 *            the additional information
351
		 */
352
		private void addProposal(String proposal, int cursorPosition, String displayString, String additionalInfo) {
353
			fProposals.add(new Proposal(proposal, displayString, additionalInfo, cursorPosition));
354
		}
355
356
		/**
357
		 * Adds a proposal to the priority proposals list.
358
		 * 
359
		 * @param proposal
360
		 *            the string to be inserted
361
		 * @param displayString
362
		 *            the proposal's label
363
		 * @param additionalInfo
364
		 *            the additional information
365
		 */
366
		private void addPriorityProposal(String proposal, String displayString, String additionalInfo) {
367
			fPriorityProposals.add(new Proposal(proposal, displayString, additionalInfo, proposal.length()));
368
		}
369
370
		/**
371
		 * Adds a proposal. Ensures that existing pre- and postfixes are not
372
		 * duplicated.
373
		 * 
374
		 * @param proposal
375
		 *            the string to be inserted
376
		 * @param cursorPosition
377
		 *            the cursor position after insertion, relative to the start
378
		 *            of the proposal
379
		 * @param displayString
380
		 *            the proposal's label
381
		 * @param additionalInfo
382
		 *            the additional information
383
		 */
384
		private void addBracketProposal(String proposal, int cursorPosition, String displayString, String additionalInfo) {
385
			String prolog = fExpression.substring(0, fDocumentOffset);
386
			if (!fIsEscape && prolog.endsWith("\\") && proposal.startsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$
387
				fProposals.add(new Proposal(proposal, displayString, additionalInfo, cursorPosition));
388
				return;
389
			}
390
			for (int i = 1; i <= cursorPosition; i++) {
391
				String prefix = proposal.substring(0, i);
392
				if (prolog.endsWith(prefix)) {
393
					String postfix = proposal.substring(cursorPosition);
394
					String epilog = fExpression.substring(fDocumentOffset);
395
					if (epilog.startsWith(postfix)) {
396
						fPriorityProposals.add(new Proposal(proposal.substring(i, cursorPosition), displayString,
397
								additionalInfo, cursorPosition - i));
398
					} else {
399
						fPriorityProposals.add(new Proposal(proposal.substring(i), displayString, additionalInfo,
400
								cursorPosition - i));
401
					}
402
					return;
403
				}
404
			}
405
			fProposals.add(new Proposal(proposal, displayString, additionalInfo, cursorPosition));
406
		}
407
408
		/**
409
		 * Adds a proposal that starts with a backslash. Ensures that the
410
		 * backslash is not repeated if already typed.
411
		 * 
412
		 * @param proposal
413
		 *            the string to be inserted
414
		 * @param displayString
415
		 *            the proposal's label
416
		 * @param additionalInfo
417
		 *            the additional information
418
		 */
419
		private void addBsProposal(String proposal, String displayString, String additionalInfo) {
420
			String prolog = fExpression.substring(0, fDocumentOffset);
421
			int position = proposal.length();
422
			// If the string already contains the backslash, do not include in
423
			// the proposal
424
			if (prolog.endsWith("\\")) { //$NON-NLS-1$
425
				position--;
426
				proposal = proposal.substring(1);
427
			}
428
429
			if (fIsEscape) {
430
				fPriorityProposals.add(new Proposal(proposal, displayString, additionalInfo, position));
431
			} else {
432
				addProposal(proposal, position, displayString, additionalInfo);
433
			}
434
		}
435
	}
436
437
	/**
438
	 * <code>true</code> iff the processor is for the find field.
439
	 * <code>false</code> iff the processor is for the replace field.
440
	 */
441
	private final boolean fIsFind;
442
443
	/**
444
	 * Creates a new completion proposal provider.
445
	 * 
446
	 * @param isFind
447
	 *            <code>true</code> if the provider is used for the 'find'
448
	 *            field <code>false</code> if the provider is used for the
449
	 *            'reaplce' field
450
	 */
451
	public RegExContentProposalProvider(boolean isFind) {
452
		fIsFind = isFind;
453
	}
454
455
	/*
456
	 * @see org.eclipse.jface.fieldassist.IContentProposalProvider#getProposals(java.lang.String,
457
	 *      int)
458
	 */
459
	public IContentProposal[] getProposals(String contents, int position) {
460
		if (fIsFind)
461
			return new ProposalComputer(contents, position).computeFindProposals();
462
		return new ProposalComputer(contents, position).computeReplaceProposals();
463
	}
464
}

Return to bug 117517