|
Lines 11-253
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; |
| 23 |
import org.eclipse.jface.viewers.ISelection; |
18 |
import org.eclipse.jface.viewers.ISelection; |
| 24 |
import org.eclipse.jface.viewers.StructuredSelection; |
19 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 25 |
import org.eclipse.mylar.internal.tasks.ui.TaskListImages; |
20 |
import org.eclipse.mylar.internal.tasks.ui.TaskListImages; |
| 26 |
import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil; |
21 |
import org.eclipse.mylar.internal.tasks.ui.TaskUiUtil; |
| 27 |
import org.eclipse.mylar.internal.team.ContextChangeSet; |
22 |
import org.eclipse.mylar.internal.team.ILinkedTaskInfo; |
| 28 |
import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; |
|
|
| 29 |
import org.eclipse.mylar.tasks.core.AbstractRepositoryTask; |
| 30 |
import org.eclipse.mylar.tasks.core.ITask; |
| 31 |
import org.eclipse.mylar.tasks.core.TaskRepository; |
23 |
import org.eclipse.mylar.tasks.core.TaskRepository; |
| 32 |
import org.eclipse.mylar.tasks.ui.AbstractRepositoryConnectorUi; |
|
|
| 33 |
import org.eclipse.mylar.tasks.ui.TasksUiPlugin; |
24 |
import org.eclipse.mylar.tasks.ui.TasksUiPlugin; |
| 34 |
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; |
25 |
import org.eclipse.ui.IViewActionDelegate; |
| 44 |
import org.eclipse.ui.IViewPart; |
26 |
import org.eclipse.ui.IViewPart; |
| 45 |
import org.eclipse.ui.internal.ObjectPluginAction; |
27 |
import org.eclipse.ui.internal.ObjectPluginAction; |
| 46 |
|
28 |
|
| 47 |
/** |
29 |
/** |
| 48 |
* @author Mik Kersten |
30 |
* @author Mik Kersten |
|
|
31 |
* @author Eugene Kuleshov |
| 49 |
*/ |
32 |
*/ |
| 50 |
public class OpenCorrespondingTaskAction extends Action implements IViewActionDelegate { |
33 |
public class OpenCorrespondingTaskAction extends Action implements IViewActionDelegate { |
| 51 |
|
34 |
|
| 52 |
private static final String LABEL = "Open Corresponding Task"; |
35 |
private static final String LABEL = "Open Corresponding Task"; |
| 53 |
|
36 |
|
| 54 |
private ISelection selection; |
37 |
private ISelection selection; |
| 55 |
|
38 |
|
| 56 |
private static final String PREFIX_HTTP = "http://"; |
39 |
// private static final String PREFIX_HTTP = "http://"; |
| 57 |
|
40 |
|
| 58 |
private static final String PREFIX_HTTPS = "https://"; |
41 |
// private static final String PREFIX_HTTPS = "https://"; |
| 59 |
|
42 |
|
| 60 |
public OpenCorrespondingTaskAction() { |
43 |
public OpenCorrespondingTaskAction() { |
| 61 |
setText(LABEL); |
44 |
setText(LABEL); |
| 62 |
setToolTipText(LABEL); |
45 |
setToolTipText(LABEL); |
| 63 |
setImageDescriptor(TaskListImages.TASK_REPOSITORY); |
46 |
setImageDescriptor(TaskListImages.TASK_REPOSITORY); |
| 64 |
} |
47 |
} |
| 65 |
|
48 |
|
| 66 |
public void init(IViewPart view) { |
49 |
public void init(IViewPart view) { |
| 67 |
// ignore |
50 |
// ignore |
| 68 |
} |
51 |
} |
| 69 |
|
52 |
|
| 70 |
@Override |
53 |
@Override |
| 71 |
public void run() { |
54 |
public void run() { |
| 72 |
if (selection instanceof StructuredSelection) { |
55 |
if (selection instanceof StructuredSelection) { |
| 73 |
run((StructuredSelection) selection); |
56 |
run((StructuredSelection) selection); |
|
|
57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
public void run(IAction action) { |
| 61 |
if (action instanceof ObjectPluginAction) { |
| 62 |
ObjectPluginAction objectAction = (ObjectPluginAction) action; |
| 63 |
if (objectAction.getSelection() instanceof StructuredSelection) { |
| 64 |
StructuredSelection selection = (StructuredSelection) objectAction.getSelection(); |
| 65 |
run(selection); |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
private void run(StructuredSelection selection) { |
| 71 |
Object element = selection.getFirstElement(); |
| 72 |
|
| 73 |
ILinkedTaskInfo info = null; |
| 74 |
if (element instanceof IAdaptable) { |
| 75 |
info = (ILinkedTaskInfo) ((IAdaptable) element).getAdapter(ILinkedTaskInfo.class); |
| 74 |
} |
76 |
} |
| 75 |
} |
77 |
if (info == null) { |
| 76 |
|
78 |
info = (ILinkedTaskInfo) Platform.getAdapterManager().getAdapter(element, ILinkedTaskInfo.class); |
| 77 |
public void run(IAction action) { |
|
|
| 78 |
if (action instanceof ObjectPluginAction) { |
| 79 |
ObjectPluginAction objectAction = (ObjectPluginAction) action; |
| 80 |
if (objectAction.getSelection() instanceof StructuredSelection) { |
| 81 |
StructuredSelection selection = (StructuredSelection) objectAction.getSelection(); |
| 82 |
run(selection); |
| 83 |
} |
| 84 |
} |
79 |
} |
| 85 |
} |
80 |
|
| 86 |
|
81 |
if (info != null) { |
| 87 |
private void run(StructuredSelection selection) { |
82 |
if(info.getTask()!=null) { |
| 88 |
Object element = selection.getFirstElement(); |
83 |
// TODO Which one to use? |
| 89 |
boolean opened = false; |
84 |
// TaskUiUtil.openEditor(info.getTask(), false); |
| 90 |
|
85 |
TaskUiUtil.refreshAndOpenTaskListElement(info.getTask()); |
| 91 |
if (element instanceof ChangeSetDiffNode) { |
86 |
return; |
| 92 |
ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element; |
87 |
} |
| 93 |
if (diffNode.getSet() instanceof ContextChangeSet) { |
88 |
if(info.getRepositoryUrl()!=null && info.getTaskId()!=null) { |
| 94 |
ITask task = ((ContextChangeSet) diffNode.getSet()).getTask(); |
89 |
TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(info.getRepositoryUrl()); |
| 95 |
TaskUiUtil.openEditor(task, false); |
90 |
if(repository!=null) { |
| 96 |
opened = true; |
91 |
if(TaskUiUtil.openRepositoryTask(repository, info.getTaskId())) { |
| 97 |
} |
92 |
return; |
| 98 |
} else if (element instanceof ContextChangeSet) { |
93 |
} |
| 99 |
ITask task = ((ContextChangeSet) element).getTask(); |
94 |
} |
| 100 |
if (task != null) { |
95 |
} |
| 101 |
TaskUiUtil.openEditor(task, false); |
96 |
if(info.getTaskFullUrl()!=null) { |
| 102 |
opened = true; |
97 |
TaskUiUtil.openUrl(info.getTaskFullUrl()); |
|
|
98 |
return; |
| 103 |
} |
99 |
} |
| 104 |
} |
100 |
} |
| 105 |
|
101 |
|
| 106 |
if (!opened) { |
102 |
// TODO show Open Remote Task dialog? |
| 107 |
IProject project = findCorrespondingProject(element); |
103 |
|
| 108 |
String comment = getCommentFromSelection(element); |
104 |
return; |
| 109 |
|
105 |
/* |
| 110 |
if (comment != null) { |
106 |
if (element instanceof ChangeSetDiffNode) { |
| 111 |
String id = MylarTeamPlugin.getDefault().getCommitTemplateManager() |
107 |
ChangeSetDiffNode diffNode = (ChangeSetDiffNode) element; |
| 112 |
.getTaskIdFromCommentOrLabel(comment); |
108 |
ChangeSet set = diffNode.getSet(); |
| 113 |
if (id == null) { |
109 |
if (set instanceof ContextChangeSet) { |
| 114 |
id = getTaskIdFromLegacy07Label(comment); |
110 |
ITask task = ((ContextChangeSet) set).getTask(); |
| 115 |
} |
111 |
TaskUiUtil.openEditor(task, false); |
| 116 |
|
112 |
return; |
|
|
113 |
} else { |
| 114 |
if(set.getClass().getName().startsWith("org.tigris")) { |
| 115 |
if(openIssueFromSubclipseChangeset(diffNode, set)) { |
| 116 |
return; |
| 117 |
} |
| 118 |
} |
| 119 |
} |
| 120 |
} else if (element instanceof ContextChangeSet) { |
| 121 |
ITask task = ((ContextChangeSet) element).getTask(); |
| 122 |
if (task != null) { |
| 123 |
TaskUiUtil.openEditor(task, false); |
| 124 |
return; |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
String comment = getCommentFromSelection(element); |
| 129 |
if (comment != null) { |
| 130 |
String id = MylarTeamPlugin.getDefault().getCommitTemplateManager() |
| 131 |
.getTaskIdFromCommentOrLabel(comment); |
| 132 |
if (id == null) { |
| 133 |
id = getTaskIdFromLegacy07Label(comment); |
| 134 |
} |
| 135 |
|
| 136 |
boolean opened = false; |
| 137 |
if (id != null) { |
| 138 |
IProject project = findCorrespondingProject(element); |
| 117 |
if (project != null) { |
139 |
if (project != null) { |
| 118 |
TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, false); |
140 |
TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project, false); |
| 119 |
if (repository != null) { |
141 |
if (repository != null) { |
| 120 |
AbstractRepositoryConnectorUi connectorUi = TasksUiPlugin.getRepositoryUi(repository.getKind()); |
142 |
opened = TaskUiUtil.openRepositoryTask(repository, id); |
| 121 |
if (connectorUi != null && id != null) { |
|
|
| 122 |
opened = TaskUiUtil.openRepositoryTask(repository, id); |
| 123 |
} |
| 124 |
} |
143 |
} |
| 125 |
} |
144 |
} |
|
|
145 |
} |
| 126 |
|
146 |
|
| 127 |
// try opening via URL if present |
147 |
// try opening via URL if present |
| 128 |
if (!opened) { |
148 |
if (!opened) { |
| 129 |
String fullUrl = getUrlFromComment(comment); |
149 |
String fullUrl = getUrlFromComment(comment); |
| 130 |
|
150 |
|
| 131 |
String repositoryUrl = null; |
151 |
String repositoryUrl = null; |
| 132 |
if (fullUrl != null) { |
152 |
if (fullUrl != null) { |
| 133 |
AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() |
153 |
AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager() |
| 134 |
.getConnectorForRepositoryTaskUrl(fullUrl); |
154 |
.getConnectorForRepositoryTaskUrl(fullUrl); |
| 135 |
if (connector != null) { |
155 |
if (connector != null) { |
| 136 |
repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl); |
156 |
repositoryUrl = connector.getRepositoryUrlFromTaskUrl(fullUrl); |
| 137 |
} |
157 |
} |
| 138 |
} else { |
158 |
} else { |
| 139 |
ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask(); |
159 |
// WTF?! opening a random task? |
| 140 |
if (task instanceof AbstractRepositoryTask) { |
160 |
ITask task = TasksUiPlugin.getTaskListManager().getTaskList().getActiveTask(); |
| 141 |
repositoryUrl = ((AbstractRepositoryTask) task).getRepositoryUrl(); |
161 |
if (task instanceof AbstractRepositoryTask) { |
| 142 |
} else if (TasksUiPlugin.getRepositoryManager().getAllRepositories().size() == 1) { |
162 |
repositoryUrl = ((AbstractRepositoryTask) task).getRepositoryUrl(); |
| 143 |
repositoryUrl = TasksUiPlugin.getRepositoryManager().getAllRepositories().get(0).getUrl(); |
163 |
} else if (TasksUiPlugin.getRepositoryManager().getAllRepositories().size() == 1) { |
| 144 |
} |
164 |
repositoryUrl = TasksUiPlugin.getRepositoryManager().getAllRepositories().get(0).getUrl(); |
| 145 |
} |
165 |
} |
|
|
166 |
} |
| 146 |
|
167 |
|
|
|
168 |
if ((repositoryUrl != null && id != null) || fullUrl != null) { |
| 147 |
opened = TaskUiUtil.openRepositoryTask(repositoryUrl, id, fullUrl); |
169 |
opened = TaskUiUtil.openRepositoryTask(repositoryUrl, id, fullUrl); |
| 148 |
if (!opened) { |
170 |
if (!opened && fullUrl != null) { |
| 149 |
TaskUiUtil.openUrl(fullUrl); |
171 |
TaskUiUtil.openUrl(fullUrl); |
| 150 |
} |
172 |
} |
| 151 |
} |
173 |
} |
| 152 |
} |
174 |
} |
| 153 |
} |
175 |
} |
| 154 |
} |
176 |
*/ |
|
|
177 |
} |
| 155 |
|
178 |
|
| 156 |
private String getCommentFromSelection(Object element) { |
179 |
/* |
| 157 |
if (element instanceof DiffChangeSet) { |
180 |
private boolean openIssueFromSubclipseChangeset(ChangeSetDiffNode diff, ChangeSet set) { |
| 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 |
} |
| 166 |
return null; |
| 167 |
} |
| 168 |
|
| 169 |
private IProject findCorrespondingProject(Object element) { |
| 170 |
if (element instanceof DiffChangeSet) { |
| 171 |
IResource[] resources = ((DiffChangeSet) element).getResources(); |
| 172 |
if (resources.length > 0) { |
| 173 |
// TODO: only checks first resource |
| 174 |
return resources[0].getProject(); |
| 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 |
} |
| 189 |
} |
| 190 |
} else if (element instanceof IAdaptable) { |
| 191 |
// TODO: there must be a better way to get at the local resource |
| 192 |
IResourceVariant resourceVariant = (IResourceVariant) ((IAdaptable) element) |
| 193 |
.getAdapter(IResourceVariant.class); |
| 194 |
if (resourceVariant != null && resourceVariant instanceof RemoteResource) { |
| 195 |
RemoteResource remoteResource = (RemoteResource) resourceVariant; |
| 196 |
String path = remoteResource.getRepositoryRelativePath(); |
| 197 |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); |
| 198 |
return root.getProject(new Path(path).removeFirstSegments(1).uptoSegment(1).toString()); |
| 199 |
} |
| 200 |
} else { |
| 201 |
|
| 202 |
} |
| 203 |
return null; |
| 204 |
} |
| 205 |
|
181 |
|
| 206 |
public static String getUrlFromComment(String comment) { |
182 |
SynchronizeModelElement diffContainer = (SynchronizeModelElement) diff.getChildren()[0]; |
| 207 |
int httpIndex = comment.indexOf(PREFIX_HTTP); |
|
|
| 208 |
int httpsIndex = comment.indexOf(PREFIX_HTTPS); |
| 209 |
int idStart = -1; |
| 210 |
if (httpIndex != -1) { |
| 211 |
idStart = httpIndex; |
| 212 |
} else if (httpsIndex != -1) { |
| 213 |
idStart = httpsIndex; |
| 214 |
} |
| 215 |
if (idStart != -1) { |
| 216 |
int idEnd = comment.indexOf(' ', idStart); |
| 217 |
if (idEnd == -1) { |
| 218 |
return comment.substring(idStart); |
| 219 |
} else if (idEnd != -1 && idStart < idEnd) { |
| 220 |
return comment.substring(idStart, idEnd); |
| 221 |
} |
| 222 |
} |
| 223 |
return null; |
| 224 |
} |
| 225 |
|
183 |
|
| 226 |
public static String getTaskIdFromLegacy07Label(String comment) { |
184 |
IResource res = diffContainer.getResource(); |
| 227 |
String PREFIX_DELIM = ":"; |
185 |
|
| 228 |
String PREFIX_START_1 = "Progress on:"; |
186 |
SyncInfoModelElement melement = (SyncInfoModelElement) diffContainer.getChildren()[0]; |
| 229 |
String PREFIX_START_2 = "Completed:"; |
187 |
|
| 230 |
String usedPrefix = PREFIX_START_1; |
188 |
// Specific to Subclipse |
| 231 |
int firstDelimIndex = comment.indexOf(PREFIX_START_1); |
189 |
SVNStatusSyncInfo info = (SVNStatusSyncInfo) melement.getSyncInfo(); |
| 232 |
if (firstDelimIndex == -1) { |
190 |
|
| 233 |
firstDelimIndex = comment.indexOf(PREFIX_START_2); |
191 |
ISVNRemoteResource remoteResource = (ISVNRemoteResource) info.getRemote(); |
| 234 |
usedPrefix = PREFIX_START_2; |
192 |
SVNRevision rev = remoteResource.getLastChangedRevision(); |
| 235 |
} |
193 |
|
| 236 |
if (firstDelimIndex != -1) { |
194 |
String comment; |
| 237 |
int idStart = firstDelimIndex + usedPrefix.length(); |
195 |
try { |
| 238 |
int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + usedPrefix.length());// comment.indexOf(PREFIX_DELIM); |
196 |
ISVNLogMessage[] messages = remoteResource.getLogMessages(rev, rev, SVNRevision.START, false, false, 1); |
| 239 |
if (idEnd != -1 && idStart < idEnd) { |
197 |
comment = messages[0].getMessage(); |
| 240 |
String id = comment.substring(idStart, idEnd); |
198 |
} catch (TeamException ex) { |
| 241 |
if (id != null) { |
199 |
comment = diff.getSet().getComment(); |
| 242 |
return id.trim(); |
200 |
} |
| 243 |
} |
201 |
|
| 244 |
} else { |
202 |
ProjectProperties props = null; |
| 245 |
return comment.substring(0, firstDelimIndex); |
203 |
try { |
| 246 |
} |
204 |
props = ProjectProperties.getProjectProperties(res); |
|
|
205 |
} catch (TeamException ex) { |
| 206 |
// ignore? |
| 207 |
} |
| 208 |
String[] urls = null; |
| 209 |
if(props!=null) { |
| 210 |
urls = props.getLinkList(comment).getUrls(); |
| 247 |
} |
211 |
} |
| 248 |
return null; |
212 |
if (urls == null || urls.length == 0) { |
| 249 |
} |
213 |
urls = ProjectProperties.getUrls(comment).getUrls(); |
| 250 |
|
214 |
} |
|
|
215 |
if (urls != null && urls.length > 0) { |
| 216 |
String taskUrl = urls[0]; |
| 217 |
TaskUiUtil.openRepositoryTask(null, null, taskUrl); |
| 218 |
return true; |
| 219 |
} |
| 220 |
return false; |
| 221 |
} |
| 222 |
|
| 223 |
private String getCommentFromSelection(Object element) { |
| 224 |
if (element instanceof DiffChangeSet) { |
| 225 |
return ((CVSCheckedInChangeSet) element).getComment(); |
| 226 |
} else if (element instanceof ChangeSetDiffNode) { |
| 227 |
return ((ChangeSetDiffNode) element).getName(); |
| 228 |
} else if (element instanceof LogEntry) { |
| 229 |
return ((LogEntry) element).getComment(); |
| 230 |
} else if (element instanceof IFileRevision) { |
| 231 |
return ((IFileRevision) element).getComment(); |
| 232 |
} |
| 233 |
return null; |
| 234 |
} |
| 235 |
|
| 236 |
private IProject findCorrespondingProject(Object element) { |
| 237 |
if (element instanceof DiffChangeSet) { |
| 238 |
IResource[] resources = ((DiffChangeSet) element).getResources(); |
| 239 |
if (resources.length > 0) { |
| 240 |
// TODO: only checks first resource |
| 241 |
return resources[0].getProject(); |
| 242 |
} |
| 243 |
} else if (element instanceof SynchronizeModelElement) { |
| 244 |
SynchronizeModelElement modelElement = (SynchronizeModelElement)element; |
| 245 |
IResource resource = modelElement.getResource(); |
| 246 |
if (resource != null) { |
| 247 |
return resource.getProject(); |
| 248 |
} else { |
| 249 |
IDiffElement[] elements = modelElement.getChildren(); |
| 250 |
if (elements.length > 0) { |
| 251 |
// TODO: only checks first diff |
| 252 |
if (elements[0] instanceof SynchronizeModelElement) { |
| 253 |
return ((SynchronizeModelElement)elements[0]).getResource().getProject(); |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
} else if (element instanceof IAdaptable) { |
| 258 |
// TODO: there must be a better way to get at the local resource |
| 259 |
IResourceVariant resourceVariant = (IResourceVariant) ((IAdaptable) element) |
| 260 |
.getAdapter(IResourceVariant.class); |
| 261 |
if (resourceVariant != null && resourceVariant instanceof RemoteResource) { |
| 262 |
RemoteResource remoteResource = (RemoteResource) resourceVariant; |
| 263 |
String path = remoteResource.getRepositoryRelativePath(); |
| 264 |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); |
| 265 |
return root.getProject(new Path(path).removeFirstSegments(1).uptoSegment(1).toString()); |
| 266 |
} |
| 267 |
} else { |
| 268 |
|
| 269 |
} |
| 270 |
return null; |
| 271 |
} |
| 272 |
|
| 273 |
public static String getUrlFromComment(String comment) { |
| 274 |
int httpIndex = comment.indexOf(PREFIX_HTTP); |
| 275 |
int httpsIndex = comment.indexOf(PREFIX_HTTPS); |
| 276 |
int idStart = -1; |
| 277 |
if (httpIndex != -1) { |
| 278 |
idStart = httpIndex; |
| 279 |
} else if (httpsIndex != -1) { |
| 280 |
idStart = httpsIndex; |
| 281 |
} |
| 282 |
if (idStart != -1) { |
| 283 |
int idEnd = comment.indexOf(' ', idStart); |
| 284 |
if (idEnd == -1) { |
| 285 |
return comment.substring(idStart); |
| 286 |
} else if (idEnd != -1 && idStart < idEnd) { |
| 287 |
return comment.substring(idStart, idEnd); |
| 288 |
} |
| 289 |
} |
| 290 |
return null; |
| 291 |
} |
| 292 |
|
| 293 |
public static String getTaskIdFromLegacy07Label(String comment) { |
| 294 |
String PREFIX_DELIM = ":"; |
| 295 |
String PREFIX_START_1 = "Progress on:"; |
| 296 |
String PREFIX_START_2 = "Completed:"; |
| 297 |
String usedPrefix = PREFIX_START_1; |
| 298 |
int firstDelimIndex = comment.indexOf(PREFIX_START_1); |
| 299 |
if (firstDelimIndex == -1) { |
| 300 |
firstDelimIndex = comment.indexOf(PREFIX_START_2); |
| 301 |
usedPrefix = PREFIX_START_2; |
| 302 |
} |
| 303 |
if (firstDelimIndex != -1) { |
| 304 |
int idStart = firstDelimIndex + usedPrefix.length(); |
| 305 |
int idEnd = comment.indexOf(PREFIX_DELIM, firstDelimIndex + usedPrefix.length());// comment.indexOf(PREFIX_DELIM); |
| 306 |
if (idEnd != -1 && idStart < idEnd) { |
| 307 |
String id = comment.substring(idStart, idEnd); |
| 308 |
if (id != null) { |
| 309 |
return id.trim(); |
| 310 |
} |
| 311 |
} else { |
| 312 |
return comment.substring(0, firstDelimIndex); |
| 313 |
} |
| 314 |
} |
| 315 |
return null; |
| 316 |
} |
| 317 |
*/ |
| 251 |
|
318 |
|
| 252 |
// private Object findParent(ISynchronizeModelElement element) { |
319 |
// private Object findParent(ISynchronizeModelElement element) { |
| 253 |
// if (element instanceof ChangeSetDiffNode) { |
320 |
// if (element instanceof ChangeSetDiffNode) { |
|
Lines 257-266
Link Here
|
| 257 |
// } |
324 |
// } |
| 258 |
// return null; |
325 |
// return null; |
| 259 |
// } |
326 |
// } |
| 260 |
|
|
|
| 261 |
|
327 |
|
| 262 |
public void selectionChanged(IAction action, ISelection selection) { |
328 |
|
| 263 |
this.selection = selection; |
329 |
public void selectionChanged(IAction action, ISelection selection) { |
| 264 |
} |
330 |
this.selection = selection; |
|
|
331 |
} |
| 265 |
|
332 |
|
| 266 |
} |
333 |
} |