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 165581 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/tasks/core/AbstractRepositoryConnector.java (+4 lines)
Lines 63-68 Link Here
63
63
64
	public abstract String getTaskWebUrl(String repositoryUrl, String taskId);
64
	public abstract String getTaskWebUrl(String repositoryUrl, String taskId);
65
	
65
	
66
	public String[] getTaskIdsFromComment(TaskRepository repository, String comment) {
67
		return null;
68
	}
69
	
66
	public abstract boolean canCreateTaskFromKey(TaskRepository repository);
70
	public abstract boolean canCreateTaskFromKey(TaskRepository repository);
67
71
68
	public abstract boolean canCreateNewTask(TaskRepository repository);
72
	public abstract boolean canCreateNewTask(TaskRepository repository);
(-)src/org/eclipse/mylar/ide/tests/OpenCorrespondingTaskActionTest.java (-3 / +3 lines)
Lines 13-19 Link Here
13
13
14
import junit.framework.TestCase;
14
import junit.framework.TestCase;
15
15
16
import org.eclipse.mylar.internal.team.LinkedTaskInfoAdapterFactory;
16
import org.eclipse.mylar.internal.team.ui.actions.OpenCorrespondingTaskAction;
17
17
18
/**
18
/**
19
 * @author Mik Kersten
19
 * @author Mik Kersten
Lines 34-46 Link Here
34
34
35
	public void test07LegacyMatching() {
35
	public void test07LegacyMatching() {
36
		String label = "Progress on: 123: foo \nhttps://bugs.eclipse.org";
36
		String label = "Progress on: 123: foo \nhttps://bugs.eclipse.org";
37
		String id = LinkedTaskInfoAdapterFactory.getTaskIdFromLegacy07Label(label);
37
		String id = OpenCorrespondingTaskAction.getTaskIdFromLegacy07Label(label);
38
		assertEquals("123", id);
38
		assertEquals("123", id);
39
	}
39
	}
40
	
40
	
41
	public void testUrlMatching() {
41
	public void testUrlMatching() {
42
		String label = "bla bla\nhttp://foo.bar-123 bla bla";
42
		String label = "bla bla\nhttp://foo.bar-123 bla bla";
43
		String id = LinkedTaskInfoAdapterFactory.getUrlFromComment(label);
43
		String id = OpenCorrespondingTaskAction.getUrlFromComment(label);
44
		assertEquals("http://foo.bar-123", id);
44
		assertEquals("http://foo.bar-123", id);
45
	}
45
	}
46
	
46
	
(-)src/org/eclipse/mylar/internal/jira/core/JiraRepositoryConnector.java (+30 lines)
Lines 13-19 Link Here
13
13
14
import java.net.UnknownHostException;
14
import java.net.UnknownHostException;
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.HashSet;
16
import java.util.List;
17
import java.util.List;
18
import java.util.regex.Matcher;
19
import java.util.regex.Pattern;
17
20
18
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
Lines 37-42 Link Here
37
import org.tigris.jira.core.model.Issue;
40
import org.tigris.jira.core.model.Issue;
38
import org.tigris.jira.core.model.IssueType;
41
import org.tigris.jira.core.model.IssueType;
39
import org.tigris.jira.core.model.Priority;
42
import org.tigris.jira.core.model.Priority;
43
import org.tigris.jira.core.model.Project;
40
import org.tigris.jira.core.model.Version;
44
import org.tigris.jira.core.model.Version;
41
import org.tigris.jira.core.service.JiraServer;
45
import org.tigris.jira.core.service.JiraServer;
42
46
Lines 213-218 Link Here
213
	public String getTaskWebUrl(String repositoryUrl, String taskId) {
217
	public String getTaskWebUrl(String repositoryUrl, String taskId) {
214
		return repositoryUrl + DELIM_URL + taskId;
218
		return repositoryUrl + DELIM_URL + taskId;
215
	}
219
	}
220
	
221
	@Override
222
	public String[] getTaskIdsFromComment(TaskRepository repository, String comment) {
223
		JiraServer server = JiraServerFacade.getDefault().getJiraServer(repository);
224
		if (server != null) {
225
			// (?:(MNGECLIPSE-\d+?)|(SPR-\d+?))\D
226
			StringBuffer sb = new StringBuffer("(");
227
			String sep = "";
228
			for (Project project : server.getProjects()) {
229
				sb.append(sep).append("(?:"+project.getKey()+"\\-\\d+?)");
230
				sep = "|";
231
			}
232
			sb.append(")\\D");
233
			
234
			Pattern p = Pattern.compile(sb.toString(), Pattern.CASE_INSENSITIVE | Pattern.DOTALL | Pattern.MULTILINE);
235
			Matcher m = p.matcher(comment);
236
			HashSet<String> ids = new HashSet<String>();
237
			while(m.find()) {
238
				ids.add(m.group(1));
239
			}
240
			return ids.toArray(new String[ids.size()]);
241
		}
242
		
243
		return super.getTaskIdsFromComment(repository, comment);
244
	}
245
	
216
246
217
	public static void updateTaskDetails(String repositoryUrl, JiraTask task, Issue issue, boolean notifyOfChange) {
247
	public static void updateTaskDetails(String repositoryUrl, JiraTask task, Issue issue, boolean notifyOfChange) {
218
		if (issue.getKey() != null) {
248
		if (issue.getKey() != null) {
(-)META-INF/MANIFEST.MF (-5 / +1 lines)
Lines 11-21 Link Here
11
 org.eclipse.jdt.core,
11
 org.eclipse.jdt.core,
12
 org.eclipse.ui.forms,
12
 org.eclipse.ui.forms,
13
 org.eclipse.core.resources,
13
 org.eclipse.core.resources,
14
 org.eclipse.compare,
15
 org.eclipse.search,
14
 org.eclipse.search,
16
 org.eclipse.jface.text,
15
 org.eclipse.jface.text,
17
 org.eclipse.team.core,
18
 org.eclipse.team.ui,
19
 org.eclipse.mylar.context.core,
16
 org.eclipse.mylar.context.core,
20
 org.eclipse.mylar.context.ui,
17
 org.eclipse.mylar.context.ui,
21
 org.eclipse.mylar.tasks.ui,
18
 org.eclipse.mylar.tasks.ui,
Lines 23-30 Link Here
23
 org.eclipse.mylar.bugzilla.ui,
20
 org.eclipse.mylar.bugzilla.ui,
24
 org.eclipse.mylar.tasks.core,
21
 org.eclipse.mylar.tasks.core,
25
 org.eclipse.mylar.monitor,
22
 org.eclipse.mylar.monitor,
26
 org.eclipse.mylar.java,
23
 org.eclipse.mylar.java
27
 org.eclipse.mylar.team
28
Eclipse-AutoStart: true
24
Eclipse-AutoStart: true
29
Bundle-Vendor: Eclipse.org
25
Bundle-Vendor: Eclipse.org
30
Export-Package: org.eclipse.mylar.internal.sandbox,
26
Export-Package: org.eclipse.mylar.internal.sandbox,
(-)src/org/eclipse/mylar/internal/sandbox/team/SubclipseLinkedTaskInfoWrapper.java (-105 lines)
Removed Link Here
1
///*******************************************************************************
2
// * Copyright (c) 2004 - 2006 Mylar committers 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
//
9
//package org.eclipse.mylar.internal.sandbox.team;
10
//
11
//import org.eclipse.core.resources.IResource;
12
//import org.eclipse.core.runtime.IAdapterFactory;
13
//import org.eclipse.core.runtime.IAdapterManager;
14
//import org.eclipse.mylar.internal.team.ILinkedTaskInfo;
15
//import org.eclipse.mylar.internal.team.LinkedTaskInfo;
16
//import org.eclipse.mylar.tasks.core.TaskRepository;
17
//import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
18
//import org.eclipse.team.core.TeamException;
19
//import org.eclipse.team.internal.core.subscribers.ChangeSet;
20
//import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
21
//import org.eclipse.team.internal.ui.synchronize.SyncInfoModelElement;
22
//import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;
23
//import org.tigris.subversion.subclipse.core.ISVNRemoteResource;
24
//import org.tigris.subversion.subclipse.core.sync.SVNStatusSyncInfo;
25
//
26
///**
27
// * Wrapper class used to isolate Subclibse dependencies 
28
// * 
29
// * @author Eugene Kuleshov
30
// */
31
//public class SubclipseLinkedTaskInfoWrapper {
32
//
33
//	public static void init(IAdapterManager adapterManager, IAdapterFactory factory) {
34
//		// XXX put back
35
//		Class logEntryClass = org.tigris.subversion.subclipse.core.history.LogEntry.class;
36
//		adapterManager.registerAdapters(FACTORY, logEntryClass);
37
//	}
38
//
39
//	private static ILinkedTaskInfo adaptSubclipseChangeset(ChangeSetDiffNode diff, ChangeSet set) {
40
//        SynchronizeModelElement diffContainer = (SynchronizeModelElement) diff.getChildren()[0];
41
//
42
//        IResource res = diffContainer.getResource();
43
//
44
//        SyncInfoModelElement melement = (SyncInfoModelElement) diffContainer.getChildren()[0];
45
//
46
//        // Specific to Subclipse
47
//        SVNStatusSyncInfo info = (SVNStatusSyncInfo) melement.getSyncInfo();
48
//
49
//        ISVNRemoteResource remoteResource = (ISVNRemoteResource) info.getRemote();
50
//        SVNRevision rev = remoteResource.getLastChangedRevision();
51
//
52
//		String comment;
53
//		try {
54
//			ISVNLogMessage[] messages = remoteResource.getLogMessages(rev, rev, SVNRevision.START, false, false, 1);
55
//			comment = messages[0].getMessage();
56
//		} catch (TeamException ex) {
57
//			comment = diff.getSet().getComment();
58
//		}
59
//		return adaptFromComment(diff, res, comment);
60
//	}
61
//
62
//	private static ILinkedTaskInfo adaptSubclipseLogEntry(Object object) {
63
//		org.tigris.subversion.subclipse.core.history.LogEntry logEntry = 
64
//			(org.tigris.subversion.subclipse.core.history.LogEntry) object;
65
//
66
//		String comment = logEntry.getComment();
67
//		IResource res = logEntry.getResource().getResource();
68
//		
69
//		return adaptFromComment(object, res, comment);
70
//	}
71
//
72
//	private static ILinkedTaskInfo adaptFromComment(Object object, IResource res, String comment) {
73
//		ProjectProperties props = null;
74
//		try {
75
//			props = ProjectProperties.getProjectProperties(res);
76
//		} catch (TeamException ex) {
77
//			// ignore?
78
//		}
79
//		
80
//		String[] urls = null;
81
//		String repositoryUrl = null;
82
//		if(props!=null) {
83
//			repositoryUrl = getRepositoryUrl(props.getUrl());
84
//			urls = props.getLinkList(comment).getUrls();
85
//		}
86
//		if (urls == null || urls.length == 0) {
87
//			// we can do better job then this method
88
//			urls = ProjectProperties.getUrls(comment).getUrls();
89
//		}
90
//		if (urls != null && urls.length > 0) {
91
//			return new LinkedTaskInfo(repositoryUrl, null, urls[0]);
92
//		}
93
//		return null;
94
//	}
95
//
96
//	private static String getRepositoryUrl(String url) {
97
//		for (TaskRepository repository : TasksUiPlugin.getRepositoryManager().getAllRepositories()) {
98
//			if(url.startsWith(repository.getUrl())) {
99
//				return repository.getUrl();
100
//			}
101
//		}
102
//		return null;
103
//	}
104
//	
105
//}
(-)src/org/eclipse/mylar/internal/team/ui/actions/OpenCorrespondingTaskAction.java (-132 / +120 lines)
Lines 11-62 Link Here
11
11
12
package org.eclipse.mylar.internal.team.ui.actions;
12
package org.eclipse.mylar.internal.team.ui.actions;
13
13
14
import org.eclipse.compare.structuremergeviewer.IDiffElement;
15
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IWorkspaceRoot;
18
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IAdaptable;
20
import org.eclipse.core.runtime.Path;
15
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.jface.action.Action;
16
import org.eclipse.jface.action.Action;
22
import org.eclipse.jface.action.IAction;
17
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.jface.viewers.ISelection;
19
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.StructuredSelection;
20
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.mylar.internal.tasks.ui.TaskListImages;
21
import org.eclipse.mylar.internal.tasks.ui.TaskListImages;
26
import org.eclipse.mylar.internal.tasks.ui.TasksUiUtil;
22
import org.eclipse.mylar.internal.tasks.ui.TasksUiUtil;
27
import org.eclipse.mylar.internal.team.ContextChangeSet;
23
import org.eclipse.mylar.internal.team.ILinkedTaskInfo;
24
import org.eclipse.mylar.internal.team.LinkedTaskInfo;
25
import org.eclipse.mylar.internal.team.template.CommitTemplateManager;
28
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
26
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
29
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
27
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
30
import org.eclipse.mylar.tasks.core.ITask;
28
import org.eclipse.mylar.tasks.core.ITask;
31
import org.eclipse.mylar.tasks.core.TaskRepository;
29
import org.eclipse.mylar.tasks.core.TaskRepository;
32
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi;
30
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
33
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
31
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
34
import org.eclipse.mylar.team.MylarTeamPlugin;
32
import org.eclipse.mylar.team.MylarTeamPlugin;
35
import org.eclipse.team.core.history.IFileRevision;
36
import org.eclipse.team.core.variants.IResourceVariant;
37
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
38
import org.eclipse.team.internal.ccvs.core.mapping.CVSCheckedInChangeSet;
39
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
40
import org.eclipse.team.internal.core.subscribers.DiffChangeSet;
41
import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
42
import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;
43
import org.eclipse.ui.IViewActionDelegate;
33
import org.eclipse.ui.IViewActionDelegate;
44
import org.eclipse.ui.IViewPart;
34
import org.eclipse.ui.IViewPart;
35
import org.eclipse.ui.PlatformUI;
45
import org.eclipse.ui.internal.ObjectPluginAction;
36
import org.eclipse.ui.internal.ObjectPluginAction;
46
37
47
/**
38
/**
39
 * Action used to open linked task
40
 * 
48
 * @author Mik Kersten
41
 * @author Mik Kersten
42
 * @author Eugene Kuleshov
49
 */
43
 */
50
public class OpenCorrespondingTaskAction extends Action implements IViewActionDelegate {
44
public class OpenCorrespondingTaskAction extends Action implements IViewActionDelegate {
51
45
52
	private static final String LABEL = "Open Corresponding Task";
46
	private static final String LABEL = "Open Corresponding Task";
53
47
54
	private ISelection selection;
55
56
	private static final String PREFIX_HTTP = "http://";
48
	private static final String PREFIX_HTTP = "http://";
57
49
58
	private static final String PREFIX_HTTPS = "https://";
50
	private static final String PREFIX_HTTPS = "https://";
59
51
52
	private ISelection selection;
53
60
	public OpenCorrespondingTaskAction() {
54
	public OpenCorrespondingTaskAction() {
61
		setText(LABEL);
55
		setText(LABEL);
62
		setToolTipText(LABEL);
56
		setToolTipText(LABEL);
Lines 86-206 Link Here
86
80
87
	private void run(StructuredSelection selection) {
81
	private void run(StructuredSelection selection) {
88
		Object element = selection.getFirstElement();
82
		Object element = selection.getFirstElement();
89
		boolean opened = false;
90
83
91
		if (element instanceof ChangeSetDiffNode) {
84
		ILinkedTaskInfo info = null;
92
			ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element;
85
		if (element instanceof ILinkedTaskInfo) {
93
			if (diffNode.getSet() instanceof ContextChangeSet) {
86
			info = (ILinkedTaskInfo) element;
94
				ITask task = ((ContextChangeSet) diffNode.getSet()).getTask();
87
		} else if (element instanceof IAdaptable) {
95
				TasksUiUtil.openEditor(task, false);
88
			info = (ILinkedTaskInfo) ((IAdaptable) element).getAdapter(ILinkedTaskInfo.class);
96
				opened = true;
89
		}
97
			} 
90
		if (info == null) {
98
		} else if (element instanceof ContextChangeSet) {
91
			info = (ILinkedTaskInfo) Platform.getAdapterManager().getAdapter(element, ILinkedTaskInfo.class);
99
			ITask task = ((ContextChangeSet) element).getTask();
100
			if (task != null) {
101
				TasksUiUtil.openEditor(task, false);
102
				opened = true;
103
			}
104
		}
92
		}
105
93
106
		if (!opened) {
94
		if (info != null) {
107
			IProject project = findCorrespondingProject(element);
95
			info = reconsile(info);
108
			String comment = getCommentFromSelection(element);
96
			if (info.getTask() != null) {
109
			
97
				// XXX which one to use?
110
			if (comment != null) {
98
				// TaskUiUtil.openEditor(info.getTask(), false);
111
				String id = MylarTeamPlugin.getDefault().getCommitTemplateManager()
99
				TasksUiUtil.refreshAndOpenTaskListElement(info.getTask());
112
						.getTaskIdFromCommentOrLabel(comment);
100
				return;
113
				if (id == null) {
101
			}
114
					id = getTaskIdFromLegacy07Label(comment);
102
			if (info.getRepositoryUrl() != null && info.getTaskId() != null) {
115
				}
103
				TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(info.getRepositoryUrl());
116
				
104
				if (repository != null) {
117
				if (project != null) {
105
					if (TasksUiUtil.openRepositoryTask(repository, info.getTaskId())) {
118
					TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, false);
106
						return;
119
					if (repository != null) {
120
						AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(repository.getKind());
121
						if (connectorUi != null && id != null) {
122
							opened = TasksUiUtil.openRepositoryTask(repository, id);
123
						}
124
					}
107
					}
125
				}
108
				}
109
			}
110
			if (info.getTaskFullUrl() != null) {
111
				TasksUiUtil.openUrl(info.getTaskFullUrl());
112
				return;
113
			}
114
		}
126
115
127
				// try opening via URL if present
116
		// TODO show Open Remote Task dialog?
128
				if (!opened) {
117
		MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
129
					String fullUrl = getUrlFromComment(comment);
118
				"Unable to open correspond task", "Unable to open correspond task");
130
119
	}
131
					String repositoryUrl = null;
132
					if (fullUrl != null) {
133
						AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager()
134
								.getConnectorForRepositoryTaskUrl(fullUrl);
135
						if (connector != null) {
136
							repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl);
137
						}
138
					} else {
139
						ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask();
140
						if (task instanceof AbstractRepositoryTask) {
141
							repositoryUrl = ((AbstractRepositoryTask) task).getRepositoryUrl();
142
						} else if (TasksUiPlugin.getRepositoryManager().getAllRepositories().size() == 1) {
143
							repositoryUrl = TasksUiPlugin.getRepositoryManager().getAllRepositories().get(0).getUrl();
144
						}
145
					}
146
120
147
					opened = TasksUiUtil.openRepositoryTask(repositoryUrl, id, fullUrl);
121
	public void selectionChanged(IAction action, ISelection selection) {
148
					if (!opened) {
122
		this.selection = selection;
149
						TasksUiUtil.openUrl(fullUrl);
123
	}
150
					}
124
151
				}
125
	/**
126
	 * Reconcile <code>ILinkedTaskInfo</code> data.
127
	 * 
128
	 * This is used in order to keep LinkedTaskInfo lightweight with minimal
129
	 * dependencies.
130
	 */
131
	private ILinkedTaskInfo reconsile(ILinkedTaskInfo info) {
132
		ITask task = info.getTask();
133
		if (task != null) {
134
			return info;
135
		}
136
137
		String repositoryUrl = info.getRepositoryUrl();
138
		String taskId = info.getTaskId();
139
		String taskFullUrl = info.getTaskFullUrl();
140
		String comment = info.getComment();
141
142
		TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
143
144
		TaskRepository repository = null;
145
		if(repositoryUrl!=null) {
146
			repository = repositoryManager.getRepository(repositoryUrl);
147
		}
148
149
		AbstractRepositoryConnector connector = null;
150
		if(taskFullUrl!=null) {
151
			connector = repositoryManager.getConnectorForRepositoryTaskUrl(taskFullUrl);
152
		}		
153
		if (connector == null && repository!=null) {
154
			connector = repositoryManager.getRepositoryConnector(repository.getKind());
155
		}
156
157
		if (repositoryUrl == null && connector != null) {
158
			repositoryUrl = connector.getRepositoryUrlFromTaskUrl(taskFullUrl);
159
		}
160
161
		if (taskId == null && connector != null) {
162
			taskId = connector.getTaskIdFromTaskUrl(taskFullUrl);
163
		}
164
		if (taskId == null && repository != null && comment != null) {
165
			String[] ids = connector.getTaskIdsFromComment(repository, comment);
166
			if (ids != null && ids.length > 0) {
167
				taskId = ids[0];
168
			}
169
		}
170
		if (taskId == null && comment!=null) {
171
			CommitTemplateManager commitTemplateManager = MylarTeamPlugin.getDefault().getCommitTemplateManager();
172
			taskId = commitTemplateManager.getTaskIdFromCommentOrLabel(comment);
173
			if (taskId == null) {
174
				taskId = getTaskIdFromLegacy07Label(comment);
152
			}
175
			}
153
		}
176
		}
154
	}
155
177
156
	private String getCommentFromSelection(Object element) {
178
		if (taskFullUrl == null && repositoryUrl != null && taskId != null && connector != null) {
157
		if (element instanceof DiffChangeSet) {
179
			taskFullUrl = connector.getTaskWebUrl(repositoryUrl, taskId);
158
			return ((CVSCheckedInChangeSet) element).getComment();
159
		} else if (element instanceof ChangeSetDiffNode) {
160
			return ((ChangeSetDiffNode) element).getName();
161
		} else if (element instanceof LogEntry) {
162
			return ((LogEntry) element).getComment();
163
		} else if (element instanceof IFileRevision) {
164
			return ((IFileRevision) element).getComment();
165
		}
180
		}
166
		return null;
167
	}
168
181
169
	private IProject findCorrespondingProject(Object element) {
182
		if (task == null) {
170
		if (element instanceof DiffChangeSet) {
183
			if (taskId != null && repositoryUrl != null) {
171
			IResource[] resources = ((DiffChangeSet) element).getResources();
184
				// XXX fix this hack (jira ids don't work here)
172
			if (resources.length > 0) {
185
				if(!taskId.contains(AbstractRepositoryTask.HANDLE_DELIM)) {
173
				// TODO: only checks first resource
186
					String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
174
				return resources[0].getProject();
187
					task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(handle);
175
			}
176
		} else if (element instanceof SynchronizeModelElement) {
177
			SynchronizeModelElement modelElement = (SynchronizeModelElement)element;
178
			IResource resource = modelElement.getResource();
179
			if (resource != null) {
180
				return resource.getProject();
181
			} else {
182
				IDiffElement[] elements = modelElement.getChildren();
183
				if (elements.length > 0) {
184
					// TODO: only checks first diff
185
					if (elements[0] instanceof SynchronizeModelElement) {
186
						return ((SynchronizeModelElement)elements[0]).getResource().getProject();
187
					}
188
				}
188
				}
189
			}
189
			}
190
		} else if (element instanceof IAdaptable) {
190
			if (task == null && taskFullUrl != null) {
191
			// TODO: there must be a better way to get at the local resource
191
				// search by fullUrl
192
			IResourceVariant resourceVariant = (IResourceVariant) ((IAdaptable) element)
192
				for (ITask currTask : TasksUiPlugin.getTaskListManager().getTaskList().getAllTasks()) {
193
					.getAdapter(IResourceVariant.class);
193
					if (currTask instanceof AbstractRepositoryTask) {
194
			if (resourceVariant != null && resourceVariant instanceof RemoteResource) {
194
						String currUrl = ((AbstractRepositoryTask) currTask).getUrl();
195
				RemoteResource remoteResource = (RemoteResource) resourceVariant;
195
						if (taskFullUrl.equals(currUrl)) {
196
				String path = remoteResource.getRepositoryRelativePath();
196
							return new LinkedTaskInfo(currTask);
197
				IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
197
						}
198
				return root.getProject(new Path(path).removeFirstSegments(1).uptoSegment(1).toString());
198
					}
199
				}
199
			}
200
			}
200
		} else {
201
			
202
		}
201
		}
203
		return null;
202
		if (task != null) {
203
			return new LinkedTaskInfo(task);
204
		}
205
206
		return new LinkedTaskInfo(repositoryUrl, taskId, taskFullUrl, comment);
204
	}
207
	}
205
208
206
	public static String getUrlFromComment(String comment) {
209
	public static String getUrlFromComment(String comment) {
Lines 247-266 Link Here
247
		}
250
		}
248
		return null;
251
		return null;
249
	}
252
	}
250
	
251
252
//	private Object findParent(ISynchronizeModelElement element) {
253
//		if (element instanceof ChangeSetDiffNode) {
254
//			return element;
255
//		} else if (element.getParent() instanceof ISynchronizeModelElement) {
256
//			return findParent((ISynchronizeModelElement) element.getParent());
257
//		}
258
//		return null;
259
//	}
260
	
261
262
	public void selectionChanged(IAction action, ISelection selection) {
263
		this.selection = selection;
264
	}
265
253
266
}
254
}
(-)src/org/eclipse/mylar/internal/team/LinkedTaskInfo.java (-65 / +15 lines)
Lines 11-22 Link Here
11
11
12
package org.eclipse.mylar.internal.team;
12
package org.eclipse.mylar.internal.team;
13
13
14
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector;
15
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
16
import org.eclipse.mylar.tasks.core.ITask;
14
import org.eclipse.mylar.tasks.core.ITask;
17
import org.eclipse.mylar.tasks.core.TaskRepository;
18
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
19
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
20
15
21
/**
16
/**
22
 * Default implementation of {@link ILinkedTaskInfo}
17
 * Default implementation of {@link ILinkedTaskInfo}
Lines 25-104 Link Here
25
 */
20
 */
26
public class LinkedTaskInfo implements ILinkedTaskInfo {
21
public class LinkedTaskInfo implements ILinkedTaskInfo {
27
22
23
	private ITask task;
24
	
25
	private String repositoryUrl;
26
	
28
	private String taskId;
27
	private String taskId;
29
28
30
	private String taskFullUrl;
29
	private String taskFullUrl;
31
30
32
	private String repositoryUrl;
31
	private String comment;
33
32
	
34
	private ITask task;
35
33
36
	public LinkedTaskInfo(ITask task) {
34
	public LinkedTaskInfo(ITask task) {
37
		init(task, //
35
		this.task = task;
38
				AbstractRepositoryTask.getRepositoryUrl(task.getHandleIdentifier()), //
39
				AbstractRepositoryTask.getTaskId(task.getHandleIdentifier()), //
40
				task.getUrl());
41
	}
36
	}
42
37
43
	public LinkedTaskInfo(String taskFullUrl) {
38
	public LinkedTaskInfo(String taskFullUrl) {
44
		init(null, null, null, taskFullUrl);
39
		this.taskFullUrl = taskFullUrl;
45
	}
46
47
	public LinkedTaskInfo(String repositoryUrl, String taskId, String taskFullUrl) {
48
		init(null, repositoryUrl, taskId, taskFullUrl);
49
	}
40
	}
50
41
51
	private void init(ITask task, String repositoryUrl, String taskId, String taskFullUrl) {
42
	public LinkedTaskInfo(String repositoryUrl, String taskId, String taskFullUrl, String comment) {
52
		// TODO should this even be here?
53
54
		TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
55
		AbstractRepositoryConnector connector = repositoryManager.getConnectorForRepositoryTaskUrl(taskFullUrl);
56
		if (connector == null && repositoryUrl != null) {
57
			TaskRepository repository = repositoryManager.getRepository(repositoryUrl);
58
			if (repository != null) {
59
				connector = repositoryManager.getRepositoryConnector(repository.getKind());
60
			}
61
		}
62
63
		if (repositoryUrl == null && connector != null) {
64
			repositoryUrl = connector.getRepositoryUrlFromTaskUrl(taskFullUrl);
65
		}
66
67
		if (taskId == null && connector != null) {
68
			taskId = connector.getTaskIdFromTaskUrl(taskFullUrl);
69
		}
70
71
		if (taskFullUrl == null && repositoryUrl != null && taskId != null && connector != null) {
72
			taskFullUrl = connector.getTaskWebUrl(repositoryUrl, taskId);
73
		}
74
		
75
		if (task == null) {
76
			if (taskId != null && repositoryUrl != null) {
77
				String handle = AbstractRepositoryTask.getHandle(repositoryUrl, taskId);
78
				task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(handle);
79
			}
80
			if (task == null && taskFullUrl != null) {
81
				// search by fullUrl
82
				for (ITask currTask : TasksUiPlugin.getTaskListManager().getTaskList().getAllTasks()) {
83
					if (currTask instanceof AbstractRepositoryTask) {
84
						String currUrl = ((AbstractRepositoryTask) currTask).getUrl();
85
						if (taskFullUrl.equals(currUrl)) {
86
							task = currTask;
87
							break;
88
						}
89
					}
90
				}
91
			}
92
		}
93
94
		if (taskFullUrl == null && task != null) {
95
			taskFullUrl = task.getUrl();
96
		}
97
98
		this.task = task;
99
		this.repositoryUrl = repositoryUrl;
43
		this.repositoryUrl = repositoryUrl;
100
		this.taskId = taskId;
44
		this.taskId = taskId;
101
		this.taskFullUrl = taskFullUrl;
45
		this.taskFullUrl = taskFullUrl;
46
		this.comment = comment;
102
	}
47
	}
103
48
104
	public String getRepositoryUrl() {
49
	public String getRepositoryUrl() {
Lines 117-120 Link Here
117
		return taskId;
62
		return taskId;
118
	}
63
	}
119
64
65
	public String getComment() {
66
		return comment;
67
	}
68
120
}
69
}
70
(-)src/org/eclipse/mylar/internal/team/LinkedTaskInfoAdapterFactory.java (-179 / +94 lines)
Lines 11-17 Link Here
11
11
12
package org.eclipse.mylar.internal.team;
12
package org.eclipse.mylar.internal.team;
13
13
14
import org.eclipse.compare.structuremergeviewer.DiffNode;
15
import org.eclipse.compare.structuremergeviewer.IDiffElement;
14
import org.eclipse.compare.structuremergeviewer.IDiffElement;
16
import org.eclipse.core.resources.IProject;
15
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
16
import org.eclipse.core.resources.IResource;
Lines 20-33 Link Here
20
import org.eclipse.core.runtime.IAdapterFactory;
19
import org.eclipse.core.runtime.IAdapterFactory;
21
import org.eclipse.core.runtime.IAdapterManager;
20
import org.eclipse.core.runtime.IAdapterManager;
22
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.mylar.internal.team.template.CommitTemplateManager;
24
import org.eclipse.mylar.tasks.core.TaskRepository;
22
import org.eclipse.mylar.tasks.core.TaskRepository;
25
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
23
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
26
import org.eclipse.mylar.team.MylarTeamPlugin;
27
import org.eclipse.team.core.history.IFileRevision;
24
import org.eclipse.team.core.history.IFileRevision;
28
import org.eclipse.team.core.variants.IResourceVariant;
25
import org.eclipse.team.core.variants.IResourceVariant;
29
import org.eclipse.team.internal.ccvs.core.CVSException;
26
import org.eclipse.team.internal.ccvs.core.CVSException;
30
import org.eclipse.team.internal.ccvs.core.ICVSResource;
27
import org.eclipse.team.internal.ccvs.core.ICVSResource;
28
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
31
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
29
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
32
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
30
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
33
import org.eclipse.team.internal.core.subscribers.ChangeSet;
31
import org.eclipse.team.internal.core.subscribers.ChangeSet;
Lines 35-43 Link Here
35
import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
33
import org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode;
36
import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;
34
import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;
37
35
38
39
/**
36
/**
40
 * Adapter factory used to create adapters for <code>LinkedTaskInfo</code> 
37
 * Adapter factory used to create adapters for <code>LinkedTaskInfo</code>
41
 * 
38
 * 
42
 * @author Eugene Kuleshov
39
 * @author Eugene Kuleshov
43
 */
40
 */
Lines 48-59 Link Here
48
45
49
	private static IAdapterFactory FACTORY = new LinkedTaskInfoAdapterFactory();
46
	private static IAdapterFactory FACTORY = new LinkedTaskInfoAdapterFactory();
50
47
51
	private static final String PREFIX_HTTP = "http://";
52
53
    private static final String PREFIX_HTTPS = "https://";
54
48
55
//    private static boolean haveSubclipse;
56
    
57
	public static void registerAdapters() {
49
	public static void registerAdapters() {
58
		IAdapterManager adapterManager = Platform.getAdapterManager();
50
		IAdapterManager adapterManager = Platform.getAdapterManager();
59
51
Lines 62-116 Link Here
62
54
63
		// Team public
55
		// Team public
64
		adapterManager.registerAdapters(FACTORY, IFileRevision.class);
56
		adapterManager.registerAdapters(FACTORY, IFileRevision.class);
65
		adapterManager.registerAdapters(FACTORY, DiffNode.class);
66
57
67
		// Team internal
58
		// Team internal
68
		adapterManager.registerAdapters(FACTORY, DiffChangeSet.class); // CVSCheckedInChangeSet ???
59
		adapterManager.registerAdapters(FACTORY, DiffChangeSet.class); // CVSCheckedInChangeSet
69
		adapterManager.registerAdapters(FACTORY, ChangeSetDiffNode.class);
60
		adapterManager.registerAdapters(FACTORY, ChangeSetDiffNode.class);
70
		adapterManager.registerAdapters(FACTORY, SynchronizeModelElement.class);
61
		adapterManager.registerAdapters(FACTORY, SynchronizeModelElement.class);
71
		
62
72
		// Team CVS internal; is it used? Maybe CVS History view in Eclipse 3.1?
63
		// Team CVS internal; is it used? Maybe CVS History view in Eclipse 3.1?
73
		adapterManager.registerAdapters(FACTORY, org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry.class);
64
		adapterManager.registerAdapters(FACTORY, LogEntry.class);
74
		
75
		// Subclipse		
76
//		try {
77
//			SubclipseWrapper.init(adapterManager, FACTORY);
78
//			haveSubclipse = true;
79
//		} catch (Throwable ex) {
80
//			// ignore
81
//		}  
82
	}
65
	}
83
	
66
84
	public static void unregisterAdapters() {
67
	public static void unregisterAdapters() {
85
		Platform.getAdapterManager().unregisterAdapters(FACTORY); 
68
		Platform.getAdapterManager().unregisterAdapters(FACTORY);
86
	}
69
	}
87
    
70
88
	
89
	private LinkedTaskInfoAdapterFactory() {
71
	private LinkedTaskInfoAdapterFactory() {
90
	}
72
	}
91
	
73
92
	@SuppressWarnings("unchecked")
74
	@SuppressWarnings("unchecked")
93
	public Object getAdapter(Object object, Class adapterType) {
75
	public Object getAdapter(Object object, Class adapterType) {
94
		if(!ILinkedTaskInfo.class.equals(adapterType)) {
76
		if (!ILinkedTaskInfo.class.equals(adapterType)) {
95
			return null;
77
			return null;
96
		}
78
		}
97
			
79
98
		if(object instanceof ChangeSetDiffNode) {
80
		if (object instanceof ChangeSetDiffNode) {
99
			return adaptChangeSetDiffNode(object);
81
			return adaptChangeSetDiffNode(object);
100
		}
82
		}
101
		
83
102
		if(object instanceof DiffNode) {
103
			return getAdapter(((DiffNode) object).getParent(), adapterType);
104
		}
105
		
106
//		if(haveSubclipse &&
107
//				"org.tigris.subversion.subclipse.core.history.LogEntry".equals(object.getClass().getName())) {
108
//			ILinkedTaskInfo info = SubclipseWrapper.adaptSubclipseLogEntry(object);
109
//			if(info!=null) {
110
//				return info;
111
//			}
112
//		}
113
		
114
		// TODO add other adapted types
84
		// TODO add other adapted types
115
85
116
		return adaptFromComment(object);
86
		return adaptFromComment(object);
Lines 122-278 Link Here
122
	}
92
	}
123
93
124
	private ILinkedTaskInfo adaptChangeSetDiffNode(Object object) {
94
	private ILinkedTaskInfo adaptChangeSetDiffNode(Object object) {
125
        ChangeSetDiffNode diffNode = (ChangeSetDiffNode) object;
95
		ChangeSetDiffNode diffNode = (ChangeSetDiffNode) object;
126
        ChangeSet set = diffNode.getSet();
96
		ChangeSet set = diffNode.getSet();
127
        if (set instanceof ContextChangeSet) {
97
128
            return new LinkedTaskInfo(((ContextChangeSet) set).getTask());
98
		Object adapter = null;
129
        } 
99
		if (set instanceof IAdaptable) {
130
//        else if(haveSubclipse && set.getClass().getName().startsWith("org.tigris")) {
100
			adapter = ((IAdaptable) set).getAdapter(ILinkedTaskInfo.class);
131
//            ILinkedTaskInfo info = SubclipseWrapper.adaptSubclipseChangeset(diffNode, set);
101
		}
132
//			if(info!=null) {
102
		if (adapter == null) {
133
//				return info;
103
			adapter = Platform.getAdapterManager().getAdapter(set, ILinkedTaskInfo.class);
134
//			}
104
		}
135
//        }
105
		if (adapter != null) {
106
			return (ILinkedTaskInfo) adapter;
107
		}
136
108
137
        return adaptFromComment(object);
109
		return adaptFromComment(object);
138
	}
110
	}
139
111
140
	private ILinkedTaskInfo adaptFromComment(Object object) {
112
	private ILinkedTaskInfo adaptFromComment(Object object) {
141
		String comment = getCommentFromElement(object);
113
		String comment = getCommentForElement(object);
114
		if (comment == null) {
115
			return null;
116
		}
142
		
117
		
143
		CommitTemplateManager commitTemplateManager = MylarTeamPlugin.getDefault().getCommitTemplateManager();
118
		IResource resource = getResourceForElement(object);
144
		String taskId = commitTemplateManager.getTaskIdFromCommentOrLabel(comment);
119
		if (resource != null) {
145
		if (taskId == null) {
120
			TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(resource, false);
146
			taskId = getTaskIdFromLegacy07Label(comment);
121
			if (repository != null) {
122
				return new LinkedTaskInfo(repository.getUrl(), null, null, comment);
123
			}
147
		}
124
		}
148
125
149
		IProject project = findCorrespondingProject(object);
126
		return new LinkedTaskInfo(null, null, null, comment);
150
		if (project != null) {
127
	}
151
			TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, false);
128
152
			if (repository != null && taskId!=null) {
129
	private static String getCommentForElement(Object element) {
153
				return new LinkedTaskInfo(repository.getUrl(), taskId, null);
130
		if (element instanceof DiffChangeSet) {
154
			}
131
			return ((DiffChangeSet) element).getComment();
132
		} else if (element instanceof ChangeSetDiffNode) {
133
			return ((ChangeSetDiffNode) element).getName();
134
		} else if (element instanceof IFileRevision) {
135
			return ((IFileRevision) element).getComment();
136
		} else if (element instanceof LogEntry) {
137
			return ((LogEntry) element).getComment();
155
		}
138
		}
156
		
139
		return null;
157
		String fullTaskUrl = getUrlFromComment(comment);
158
        if(fullTaskUrl!=null) {
159
        	return new LinkedTaskInfo(fullTaskUrl);
160
        }
161
        
162
        return null;
163
	}
140
	}
164
	
165
    private String getCommentFromElement(Object element) {
166
        if (element instanceof DiffChangeSet) {
167
            return ((DiffChangeSet) element).getComment();
168
        } else if (element instanceof ChangeSetDiffNode) {
169
            return ((ChangeSetDiffNode) element).getName();
170
        } else if (element instanceof IFileRevision) {
171
        	return ((IFileRevision) element).getComment();
172
        } else if (element instanceof org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry) {
173
            return ((org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry) element).getComment();
174
        } else if (element instanceof org.tigris.subversion.subclipse.core.history.LogEntry) {
175
            return ((org.tigris.subversion.subclipse.core.history.LogEntry) element).getComment();
176
        }
177
        return null;
178
    }
179
	
180
	
181
	//
182
141
183
    public static String getUrlFromComment(String comment) {
142
	private static IResource getResourceForElement(Object element) {
184
        int httpIndex = comment.indexOf(PREFIX_HTTP);
143
		if (element instanceof DiffChangeSet) {
185
        int httpsIndex = comment.indexOf(PREFIX_HTTPS);
144
			IResource[] resources = ((DiffChangeSet) element).getResources();
186
        int idStart = -1;
145
			if (resources.length > 0) {
187
        if (httpIndex != -1) {
146
				// TODO: only checks first resource
188
            idStart = httpIndex;
147
				return resources[0];
189
        } else if (httpsIndex != -1) {
148
			}
190
            idStart = httpsIndex;
149
		} 
191
        }
150
		if (element instanceof SynchronizeModelElement) {
192
        if (idStart != -1) {
151
			SynchronizeModelElement modelElement = (SynchronizeModelElement) element;
193
            int idEnd = comment.indexOf(' ', idStart);
152
			IResource resource = modelElement.getResource();
194
            if (idEnd == -1) {
153
			if (resource != null) {
195
                return comment.substring(idStart);
154
				return resource;
196
            } else if (idEnd != -1 && idStart < idEnd) {
155
			} else {
197
                return comment.substring(idStart, idEnd);
156
				IDiffElement[] elements = modelElement.getChildren();
198
            }
157
				if (elements.length > 0) {
199
        }
158
					// TODO: only checks first diff
200
        return null;
159
					if (elements[0] instanceof SynchronizeModelElement) {
201
    }
160
						return ((SynchronizeModelElement) elements[0]).getResource();
202
161
					}
203
    public static String getTaskIdFromLegacy07Label(String comment) {
162
				}
204
        String PREFIX_DELIM = ":";
163
			}
205
        String PREFIX_START_1 = "Progress on:";
164
		} 
206
        String PREFIX_START_2 = "Completed:";
165
		if (element instanceof IAdaptable) {
207
        String usedPrefix = PREFIX_START_1;
166
			IAdaptable adaptable = (IAdaptable) element;
208
        int firstDelimIndex = comment.indexOf(PREFIX_START_1);
209
        if (firstDelimIndex == -1) {
210
            firstDelimIndex = comment.indexOf(PREFIX_START_2);
211
            usedPrefix = PREFIX_START_2;
212
        }
213
        if (firstDelimIndex != -1) {
214
            int idStart = firstDelimIndex + usedPrefix.length();
215
            int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + usedPrefix.length());// comment.indexOf(PREFIX_DELIM);
216
            if (idEnd != -1 && idStart < idEnd) {
217
                String id = comment.substring(idStart, idEnd);
218
                if (id != null) {
219
                    return id.trim();
220
                }
221
            } else {
222
                return comment.substring(0, firstDelimIndex);
223
            }
224
        }
225
        return null;
226
    }
227
	
228
    private static IProject findCorrespondingProject(Object element) {
229
        if (element instanceof DiffChangeSet) {
230
            IResource[] resources = ((DiffChangeSet) element).getResources();
231
            if (resources.length > 0) {
232
                // TODO: only checks first resource
233
                return resources[0].getProject();
234
            }
235
        } else if (element instanceof SynchronizeModelElement) {
236
            SynchronizeModelElement modelElement = (SynchronizeModelElement)element;
237
            IResource resource = modelElement.getResource();
238
            if (resource != null) {
239
                return resource.getProject();
240
            } else {
241
                IDiffElement[] elements = modelElement.getChildren();
242
                if (elements.length > 0) {
243
                    // TODO: only checks first diff
244
                    if (elements[0] instanceof SynchronizeModelElement) {
245
                        return ((SynchronizeModelElement)elements[0]).getResource().getProject();
246
                    }
247
                }
248
            }
249
        } else if (element instanceof IAdaptable) {
250
        	IAdaptable adaptable = (IAdaptable) element;
251
			IResourceVariant resourceVariant = (IResourceVariant) adaptable.getAdapter(IResourceVariant.class);
167
			IResourceVariant resourceVariant = (IResourceVariant) adaptable.getAdapter(IResourceVariant.class);
252
            if (resourceVariant != null && resourceVariant instanceof RemoteResource) {
168
			if (resourceVariant != null && resourceVariant instanceof RemoteResource) {
253
            	RemoteResource remoteResource = (RemoteResource) resourceVariant;
169
				RemoteResource remoteResource = (RemoteResource) resourceVariant;
254
            	// TODO is there a better way then iterating trough all projects?
170
				// TODO is there a better way then iterating trough all projects?
255
                String path = remoteResource.getRepositoryRelativePath();
171
				String path = remoteResource.getRepositoryRelativePath();
256
                for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
172
				for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
257
                	if(project.isAccessible()) {
173
					if (project.isAccessible()) {
258
                		ICVSResource cvsResource = CVSWorkspaceRoot.getCVSFolderFor(project);
174
						ICVSResource cvsResource = CVSWorkspaceRoot.getCVSFolderFor(project);
259
                		try {
175
						try {
260
							if(cvsResource!=null && path.startsWith(cvsResource.getRepositoryRelativePath())) {
176
							if (cvsResource != null && path.startsWith(cvsResource.getRepositoryRelativePath())) {
261
								return project;
177
								return project;
262
							}
178
							}
263
						} catch (CVSException ex) {
179
						} catch (CVSException ex) {
264
							// ignore
180
							// ignore
265
						}
181
						}
266
                	}
182
					}
267
                }
183
				}
268
                
184
			}
269
                return null;
185
		}
270
            }
186
271
        } else {
187
		// TODO any other resource types?
272
        	// TODO
188
273
        	
189
		return null;
274
        }
190
	}
275
        return null;
191
	
276
    }  
277
}
192
}
278
193
(-)src/org/eclipse/mylar/internal/team/ContextChangeSet.java (+2 lines)
Lines 210-215 Link Here
210
			return new ChangeSetResourceMapping(this);
210
			return new ChangeSetResourceMapping(this);
211
		} else if (adapter == ITask.class) {
211
		} else if (adapter == ITask.class) {
212
			return task;
212
			return task;
213
		} else if (adapter == ILinkedTaskInfo.class) {
214
			return new LinkedTaskInfo(getTask());
213
		} else {
215
		} else {
214
			return null;
216
			return null;
215
		}
217
		}
(-)src/org/eclipse/mylar/internal/team/ILinkedTaskInfo.java (+2 lines)
Lines 30-33 Link Here
30
	
30
	
31
	ITask getTask();
31
	ITask getTask();
32
	
32
	
33
	String getComment();
34
	
33
}
35
}
(-)META-INF/MANIFEST.MF (-3 lines)
Lines 10-17 Link Here
10
 org.eclipse.team.cvs.ui,
10
 org.eclipse.team.cvs.ui,
11
 org.eclipse.team.cvs.core,
11
 org.eclipse.team.cvs.core,
12
 org.eclipse.team.ui,
12
 org.eclipse.team.ui,
13
 org.tigris.subversion.subclipse.core;resolution:=optional,
14
 org.tigris.subversion.subclipse.ui;resolution:=optional,
15
 org.eclipse.jface,
13
 org.eclipse.jface,
16
 org.eclipse.core.resources,
14
 org.eclipse.core.resources,
17
 org.eclipse.core.runtime,
15
 org.eclipse.core.runtime,
Lines 27-33 Link Here
27
Eclipse-LazyStart: true
25
Eclipse-LazyStart: true
28
Export-Package: org.eclipse.mylar.internal.team,
26
Export-Package: org.eclipse.mylar.internal.team,
29
 org.eclipse.mylar.internal.team.ccvs,
27
 org.eclipse.mylar.internal.team.ccvs,
30
 org.eclipse.mylar.internal.team.subclipse,
31
 org.eclipse.mylar.internal.team.template,
28
 org.eclipse.mylar.internal.team.template,
32
 org.eclipse.mylar.internal.team.ui,
29
 org.eclipse.mylar.internal.team.ui,
33
 org.eclipse.mylar.internal.team.ui.actions,
30
 org.eclipse.mylar.internal.team.ui.actions,
(-)plugin.xml (-16 / +24 lines)
Lines 8-14 Link Here
8
   <extension
8
   <extension
9
         point="org.eclipse.mylar.team.providers">
9
         point="org.eclipse.mylar.team.providers">
10
      <repository class="org.eclipse.mylar.internal.team.ccvs.CvsRepositoryProvider"/>
10
      <repository class="org.eclipse.mylar.internal.team.ccvs.CvsRepositoryProvider"/>
11
      <repository class="org.eclipse.mylar.internal.team.subclipse.SubclipseTeamRepositoryProvider"/>
12
   </extension>
11
   </extension>
13
    
12
    
14
   <extension
13
   <extension
Lines 29-34 Link Here
29
    </extension>
28
    </extension>
30
    
29
    
31
     <extension point="org.eclipse.ui.popupMenus"> 
30
     <extension point="org.eclipse.ui.popupMenus"> 
31
32
     	<objectContribution
33
				id="org.eclipse.mylar.ui.team.synchronize.open.report"
34
				objectClass="org.eclipse.mylar.internal.team.ILinkedTaskInfo"
35
				adaptable="true">
36
			<action
37
				class="org.eclipse.mylar.internal.team.ui.actions.OpenCorrespondingTaskAction"
38
				enablesFor="1" 
39
				icon="icons/elcl16/task-repository.gif"
40
				id="org.eclipse.mylar.ui.team.synchronize.contribution.open.report"
41
				label="Open Corresponding Task"
42
				menubarPath="mylar"
43
				tooltip="Open Corresponding Task">
44
			</action> 
45
		</objectContribution>
46
47
        <!--
32
		<objectContribution
48
		<objectContribution
33
            objectClass="org.eclipse.team.ui.synchronize.ISynchronizeModelElement"
49
            objectClass="org.eclipse.team.ui.synchronize.ISynchronizeModelElement"
34
            id="org.eclipse.mylar.ui.team.synchronize.open.report">
50
            id="org.eclipse.mylar.ui.team.synchronize.open.report">
Lines 42-47 Link Here
42
	           tooltip="Open Corresponding Task"> 
58
	           tooltip="Open Corresponding Task"> 
43
	  		</action> 
59
	  		</action> 
44
	    </objectContribution>
60
	    </objectContribution>
61
	    -->
62
	   	
63
	   	<!-- is this from Eclipse 3.1 History view?
45
	   	<objectContribution
64
	   	<objectContribution
46
            objectClass="org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry"
65
            objectClass="org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry"
47
            id="org.eclipse.mylar.ui.team.history.open.report">
66
            id="org.eclipse.mylar.ui.team.history.open.report">
Lines 55-60 Link Here
55
	           tooltip="Open Corresponding Task"> 
74
	           tooltip="Open Corresponding Task"> 
56
	  		</action> 
75
	  		</action> 
57
	    </objectContribution>
76
	    </objectContribution>
77
	   	-->
78
		
79
		<!--
58
		<objectContribution
80
		<objectContribution
59
            objectClass="org.eclipse.team.core.history.IFileRevision"
81
            objectClass="org.eclipse.team.core.history.IFileRevision"
60
            id="org.eclipse.mylar.ui.team.synchronize.open.report">
82
            id="org.eclipse.mylar.ui.team.synchronize.open.report">
Lines 68-89 Link Here
68
	           tooltip="Open Corresponding Task"> 
90
	           tooltip="Open Corresponding Task"> 
69
	  		</action> 
91
	  		</action> 
70
	    </objectContribution>
92
	    </objectContribution>
93
	    -->
71
		
94
		
72
		<!-- Subclipse History view -->
73
		<objectContribution
74
            objectClass="org.tigris.subversion.subclipse.core.history.LogEntry"
75
            id="org.eclipse.mylar.ui.team.synchronize.open.report">
76
         <action
77
	           class="org.eclipse.mylar.internal.team.ui.actions.OpenCorrespondingTaskAction"
78
	           enablesFor="1" 
79
	           icon="icons/elcl16/task-repository.gif"
80
	           id="org.eclipse.mylar.ui.team.synchronize.contribution.open.report"
81
	           label="Open Corresponding Task"
82
	           menubarPath="mylar"
83
	           tooltip="Open Corresponding Task">
84
	  		</action> 
85
	    </objectContribution>
86
	    
87
	    <!--
95
	    <!--
88
		<objectContribution
96
		<objectContribution
89
            objectClass="org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode"
97
            objectClass="org.eclipse.team.internal.ui.synchronize.ChangeSetDiffNode"
(-)src/org/eclipse/mylar/internal/team/subclipse/SubclipseTeamRepositoryProvider.java (-97 lines)
Removed 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
 *     Gunnar Wagenknecht - initial API and implementation
11
 *******************************************************************************/
12
package org.eclipse.mylar.internal.team.subclipse;
13
14
import java.lang.reflect.Constructor;
15
import java.lang.reflect.Method;
16
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.Platform;
19
import org.eclipse.jface.action.IAction;
20
import org.eclipse.mylar.team.AbstractTeamRepositoryProvider;
21
import org.eclipse.team.internal.core.subscribers.ActiveChangeSetManager;
22
import org.osgi.framework.Bundle;
23
24
/**
25
 * Subclipse integration for Mylar.
26
 */
27
public class SubclipseTeamRepositoryProvider extends AbstractTeamRepositoryProvider {
28
29
	@SuppressWarnings("unchecked")
30
	@Override
31
	public ActiveChangeSetManager getActiveChangeSetManager() {
32
		// collectors.add((CVSActiveChangeSetCollector)CVSUIPlugin.getPlugin().getChangeSetManager());
33
		Bundle svnBundle = Platform.getBundle("org.tigris.subversion.subclipse.core");
34
		if (svnBundle != null) {
35
			Method getChangeSetManagerMethod;
36
			try {
37
				Class providerPlugin = svnBundle.loadClass("org.tigris.subversion.subclipse.core.SVNProviderPlugin"); // Class.forName("org.tigris.subversion.subclipse.core.SVNProviderPlugin");
38
				Method getPluginMethod = providerPlugin.getMethod("getPlugin", new Class[0]);
39
				Object pluginInstance = getPluginMethod.invoke(null, new Object[0]);
40
				getChangeSetManagerMethod = providerPlugin.getDeclaredMethod("getChangeSetManager", new Class[0]);
41
				Object manager = getChangeSetManagerMethod.invoke(pluginInstance, new Object[0]);
42
				if (manager instanceof ActiveChangeSetManager) {
43
					return (ActiveChangeSetManager) manager;
44
				}
45
			} catch (Throwable t) {
46
				// intore missing tigris collector
47
			}
48
		}
49
		return null;
50
	}
51
52
	@SuppressWarnings("unchecked")
53
	@Override
54
	public boolean hasOutgoingChanges(IResource[] resources) {
55
		if (Platform.getBundle("org.tigris.subversion.subclipse.core") == null)
56
			return false;
57
58
		try {
59
			Class commitActionClass = Class.forName("org.tigris.subversion.subclipse.ui.actions.CommitAction");
60
			Constructor commitActionConstructor = commitActionClass.getConstructor(new Class[] { String.class });
61
			Object commitAction = commitActionConstructor.newInstance(new Object[] { "" });
62
			Method setSelectedResourcesMethod = commitActionClass.getMethod("setSelectedResources",
63
					new Class[] { IResource[].class });
64
			setSelectedResourcesMethod.invoke(commitAction, new Object[] { resources });
65
66
			Method hasOutgoingChangesMethod = commitActionClass.getMethod("hasOutgoingChanges", new Class[0]);
67
			Boolean hasOutgoingChanges = (Boolean) hasOutgoingChangesMethod.invoke(commitAction, new Object[0]);
68
69
			return hasOutgoingChanges.booleanValue();
70
		} catch (Throwable t) {
71
			// Noting we can do
72
		}
73
74
		return false;
75
	}
76
77
	@SuppressWarnings("unchecked")
78
	@Override
79
	public void commit(IResource[] resources) {
80
		if (Platform.getBundle("org.tigris.subversion.subclipse.core") == null)
81
			return;
82
83
		try {
84
			Class commitActionClass = Class.forName("org.tigris.subversion.subclipse.ui.actions.CommitAction");
85
			Constructor commitActionConstructor = commitActionClass.getConstructor(new Class[] { String.class });
86
			Object commitAction = commitActionConstructor.newInstance(new Object[] { "" });
87
			Method setSelectedResourcesMethod = commitActionClass.getMethod("setSelectedResources",
88
					new Class[] { IResource[].class });
89
			setSelectedResourcesMethod.invoke(commitAction, new Object[] { resources });
90
91
			Method executeMethod = commitActionClass.getMethod("execute", new Class[] { IAction.class });
92
			executeMethod.invoke(commitAction, new Object[] { null });
93
		} catch (Throwable t) {
94
			// nothing we can do
95
		}
96
	}
97
}

Return to bug 165581