Lines 19-30
Link Here
|
19 |
import org.eclipse.jface.text.TextViewer; |
19 |
import org.eclipse.jface.text.TextViewer; |
20 |
import org.eclipse.jface.text.hyperlink.IHyperlink; |
20 |
import org.eclipse.jface.text.hyperlink.IHyperlink; |
21 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
21 |
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin; |
|
|
22 |
import org.eclipse.mylyn.internal.tasks.core.AbstractTask; |
22 |
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager; |
23 |
import org.eclipse.mylyn.internal.tasks.core.TaskRepositoryManager; |
23 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; |
24 |
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin; |
24 |
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkDetector; |
25 |
import org.eclipse.mylyn.internal.tasks.ui.editors.TaskHyperlinkDetector; |
25 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
26 |
import org.eclipse.mylyn.tasks.core.TaskRepository; |
26 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
27 |
import org.eclipse.mylyn.tasks.core.data.TaskAttribute; |
27 |
import org.eclipse.mylyn.tasks.ui.TaskHyperlink; |
28 |
import org.eclipse.mylyn.tasks.ui.TaskHyperlink; |
|
|
29 |
import org.eclipse.mylyn.tasks.ui.TasksUi; |
28 |
import org.eclipse.swt.SWT; |
30 |
import org.eclipse.swt.SWT; |
29 |
import org.eclipse.swt.widgets.Shell; |
31 |
import org.eclipse.swt.widgets.Shell; |
30 |
|
32 |
|
Lines 44-116
Link Here
|
44 |
|
46 |
|
45 |
private static final String ATTACHMENT_NEW = "Created attachment" + ATTACHMENT_NUMBER; |
47 |
private static final String ATTACHMENT_NEW = "Created attachment" + ATTACHMENT_NUMBER; |
46 |
|
48 |
|
47 |
private final String TASK_FORMAT_1 = "task#1"; |
49 |
private final String TASK_FORMAT_1 = "task#123"; |
48 |
|
50 |
|
49 |
private final String TASK_FORMAT_2 = "task# 1"; |
51 |
private final String TASK_FORMAT_2 = "task# 123"; |
50 |
|
52 |
|
51 |
private final String TASK_FORMAT_3 = "task1"; |
53 |
private final String TASK_FORMAT_3 = "task123"; |
52 |
|
54 |
|
53 |
private final String TASK_FORMAT_4 = "task #1"; |
55 |
private final String TASK_FORMAT_4 = "task #123"; |
54 |
|
56 |
|
55 |
private final String BUG_FORMAT_1 = "bug# 1"; |
57 |
private final String BUG_FORMAT_1 = "bug# 123"; |
56 |
|
58 |
|
57 |
private final String BUG_FORMAT_2 = "bug # 1"; |
59 |
private final String BUG_FORMAT_2 = "bug # 123"; |
58 |
|
60 |
|
59 |
private final String BUG_FORMAT_3 = "bug1"; |
61 |
private final String BUG_FORMAT_3 = "bug123"; |
60 |
|
62 |
|
61 |
private final String BUG_FORMAT_4 = "bug #1"; |
63 |
private final String BUG_FORMAT_4 = "bug #123"; |
62 |
|
64 |
|
63 |
private final String BUG_FORMAT_1_2 = "bug# 2"; |
65 |
private final String BUG_FORMAT_1_2 = "bug# 2"; |
64 |
|
66 |
|
65 |
private final String TASK_FORMAT_1_COMMENT_1 = "task#123c#44556677"; |
67 |
private final String TASK_FORMAT_1_COMMENT_1 = "task#123c#44556677"; |
66 |
|
68 |
|
67 |
private final String TASK_FORMAT_2_COMMENT_1 = "task# 1c#44556677"; |
69 |
private final String TASK_FORMAT_2_COMMENT_1 = "task# 123c#44556677"; |
68 |
|
70 |
|
69 |
private final String TASK_FORMAT_3_COMMENT_1 = "task1c#44556677"; |
71 |
private final String TASK_FORMAT_3_COMMENT_1 = "task123c#44556677"; |
70 |
|
72 |
|
71 |
private final String TASK_FORMAT_4_COMMENT_1 = "task #1c#44556677"; |
73 |
private final String TASK_FORMAT_4_COMMENT_1 = "task #123c#44556677"; |
72 |
|
74 |
|
73 |
private final String BUG_FORMAT_1_COMMENT_1 = "bug# 1c#44556677"; |
75 |
private final String BUG_FORMAT_1_COMMENT_1 = "bug# 123c#44556677"; |
74 |
|
76 |
|
75 |
private final String BUG_FORMAT_2_COMMENT_1 = "bug # 1c#44556677"; |
77 |
private final String BUG_FORMAT_2_COMMENT_1 = "bug # 123c#44556677"; |
76 |
|
78 |
|
77 |
private final String BUG_FORMAT_3_COMMENT_1 = "bug1c#44556677"; |
79 |
private final String BUG_FORMAT_3_COMMENT_1 = "bug123c#44556677"; |
78 |
|
80 |
|
79 |
private final String BUG_FORMAT_4_COMMENT_1 = "bug #1c#44556677"; |
81 |
private final String BUG_FORMAT_4_COMMENT_1 = "bug #123c#44556677"; |
80 |
|
82 |
|
81 |
private final String TASK_FORMAT_1_COMMENT_2 = "task#123 comment #44556677"; |
83 |
private final String TASK_FORMAT_1_COMMENT_2 = "task#123 comment #44556677"; |
82 |
|
84 |
|
83 |
private final String TASK_FORMAT_2_COMMENT_2 = "task# 1 comment #44556677"; |
85 |
private final String TASK_FORMAT_2_COMMENT_2 = "task# 123 comment #44556677"; |
84 |
|
86 |
|
85 |
private final String TASK_FORMAT_3_COMMENT_2 = "task1 comment #44556677"; |
87 |
private final String TASK_FORMAT_3_COMMENT_2 = "task123 comment #44556677"; |
86 |
|
88 |
|
87 |
private final String TASK_FORMAT_4_COMMENT_2 = "task #1 comment #44556677"; |
89 |
private final String TASK_FORMAT_4_COMMENT_2 = "task #123 comment #44556677"; |
88 |
|
90 |
|
89 |
private final String BUG_FORMAT_1_COMMENT_2 = "bug# 1 comment #44556677"; |
91 |
private final String BUG_FORMAT_1_COMMENT_2 = "bug# 123 comment #44556677"; |
90 |
|
92 |
|
91 |
private final String BUG_FORMAT_2_COMMENT_2 = "bug # 1 comment #44556677"; |
93 |
private final String BUG_FORMAT_2_COMMENT_2 = "bug # 123 comment #44556677"; |
92 |
|
94 |
|
93 |
private final String BUG_FORMAT_3_COMMENT_2 = "bug1 comment #44556677"; |
95 |
private final String BUG_FORMAT_3_COMMENT_2 = "bug123 comment #44556677"; |
94 |
|
96 |
|
95 |
private final String BUG_FORMAT_4_COMMENT_2 = "bug #1 comment #44556677"; |
97 |
private final String BUG_FORMAT_4_COMMENT_2 = "bug #123 comment #44556677"; |
96 |
|
98 |
|
97 |
private final String TASK_FORMAT_1_COMMENT_3 = "task#123 comment#44556677"; |
99 |
private final String TASK_FORMAT_1_COMMENT_3 = "task#123 comment#44556677"; |
98 |
|
100 |
|
99 |
private final String TASK_FORMAT_2_COMMENT_3 = "task# 1 comment#44556677"; |
101 |
private final String TASK_FORMAT_2_COMMENT_3 = "task# 123 comment#44556677"; |
100 |
|
102 |
|
101 |
private final String TASK_FORMAT_3_COMMENT_3 = "task1 comment#44556677"; |
103 |
private final String TASK_FORMAT_3_COMMENT_3 = "task123 comment#44556677"; |
102 |
|
104 |
|
103 |
private final String TASK_FORMAT_4_COMMENT_3 = "task #1 comment#44556677"; |
105 |
private final String TASK_FORMAT_4_COMMENT_3 = "task #123 comment#44556677"; |
104 |
|
106 |
|
105 |
private final String BUG_FORMAT_1_COMMENT_3 = "bug# 1 comment#44556677"; |
107 |
private final String BUG_FORMAT_1_COMMENT_3 = "bug# 123 comment#44556677"; |
106 |
|
108 |
|
107 |
private final String BUG_FORMAT_2_COMMENT_3 = "bug # 1 comment#44556677"; |
109 |
private final String BUG_FORMAT_2_COMMENT_3 = "bug # 123 comment#44556677"; |
108 |
|
110 |
|
109 |
private final String BUG_FORMAT_3_COMMENT_3 = "bug1 comment#44556677"; |
111 |
private final String BUG_FORMAT_3_COMMENT_3 = "bug123 comment#44556677"; |
110 |
|
112 |
|
111 |
private final String BUG_FORMAT_4_COMMENT_3 = "bug #1 comment#44556677"; |
113 |
private final String BUG_FORMAT_4_COMMENT_3 = "bug #123 comment#44556677"; |
|
|
114 |
|
115 |
private final String TASK_FORMAT_1_COMMENT_4 = "task#123 comment # 44556677"; |
116 |
|
117 |
private final String TASK_FORMAT_2_COMMENT_4 = "task# 123 comment # 44556677"; |
118 |
|
119 |
private final String TASK_FORMAT_3_COMMENT_4 = "task123 comment # 44556677"; |
120 |
|
121 |
private final String TASK_FORMAT_4_COMMENT_4 = "task #123 comment # 44556677"; |
122 |
|
123 |
private final String BUG_FORMAT_1_COMMENT_4 = "bug# 123 comment # 44556677"; |
124 |
|
125 |
private final String BUG_FORMAT_2_COMMENT_4 = "bug # 123 comment # 44556677"; |
126 |
|
127 |
private final String BUG_FORMAT_3_COMMENT_4 = "bug123 comment # 44556677"; |
128 |
|
129 |
private final String BUG_FORMAT_4_COMMENT_4 = "bug #123 comment # 44556677"; |
130 |
|
131 |
private final String COMMENT_1 = "comment#44556677"; |
132 |
|
133 |
private final String COMMENT_2 = "comment #44556677"; |
134 |
|
135 |
private final String COMMENT_3 = "comment # 44556677"; |
136 |
|
137 |
private final String COMMENT_4 = "comment# 44556677"; |
138 |
|
139 |
private final String COMMENT_5 = "comment 44556677"; |
112 |
|
140 |
|
113 |
//private BugzillaTaskHyperlinkDetector detector = new BugzillaTaskHyperlinkDetector(); |
|
|
114 |
private TaskHyperlinkDetector detector; |
141 |
private TaskHyperlinkDetector detector; |
115 |
|
142 |
|
116 |
private TaskRepository repository1; |
143 |
private TaskRepository repository1; |
Lines 119-134
Link Here
|
119 |
|
146 |
|
120 |
private TextViewer viewer; |
147 |
private TextViewer viewer; |
121 |
|
148 |
|
122 |
private String[] formats; |
|
|
123 |
|
124 |
private String[] commentFormats; |
149 |
private String[] commentFormats; |
125 |
|
150 |
|
|
|
151 |
private String[] bugFormats; |
152 |
|
153 |
private String[] bugCommentFormats; |
154 |
|
126 |
private TaskRepositoryManager repositoryManager; |
155 |
private TaskRepositoryManager repositoryManager; |
127 |
|
156 |
|
128 |
private Shell shell; |
157 |
private Shell shell; |
129 |
|
158 |
|
130 |
protected TaskRepository activeRepository; |
159 |
protected TaskRepository activeRepository; |
131 |
|
160 |
|
|
|
161 |
protected AbstractTask task; |
162 |
|
132 |
@Override |
163 |
@Override |
133 |
protected void setUp() throws Exception { |
164 |
protected void setUp() throws Exception { |
134 |
super.setUp(); |
165 |
super.setUp(); |
Lines 137-147
Link Here
|
137 |
|
168 |
|
138 |
repository1 = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "repository_url1"); |
169 |
repository1 = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "repository_url1"); |
139 |
repository2 = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "repository_url2"); |
170 |
repository2 = new TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "repository_url2"); |
140 |
|
171 |
task = (AbstractTask) TasksUi.getRepositoryModel().createTask(repository1, "123"); |
141 |
detector.setContext(new IAdaptable() { |
172 |
detector.setContext(new IAdaptable() { |
142 |
@SuppressWarnings("rawtypes") |
173 |
@SuppressWarnings("rawtypes") |
143 |
public Object getAdapter(Class adapter) { |
174 |
public Object getAdapter(Class adapter) { |
144 |
return (adapter == TaskRepository.class) ? activeRepository : null; |
175 |
if (adapter == TaskRepository.class) { |
|
|
176 |
return activeRepository; |
177 |
} else if (adapter == AbstractTask.class) { |
178 |
return task; |
179 |
} |
180 |
return null; |
145 |
} |
181 |
} |
146 |
}); |
182 |
}); |
147 |
setRepository(repository1); |
183 |
setRepository(repository1); |
Lines 152-166
Link Here
|
152 |
repositoryManager = TasksUiPlugin.getRepositoryManager(); |
188 |
repositoryManager = TasksUiPlugin.getRepositoryManager(); |
153 |
repositoryManager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath()); |
189 |
repositoryManager.clearRepositories(TasksUiPlugin.getDefault().getRepositoriesFilePath()); |
154 |
|
190 |
|
155 |
formats = new String[] { TASK_FORMAT_1, TASK_FORMAT_2, TASK_FORMAT_3, TASK_FORMAT_4, BUG_FORMAT_1, |
191 |
commentFormats = new String[] { COMMENT_1, COMMENT_2, COMMENT_3, COMMENT_4 }; |
|
|
192 |
bugFormats = new String[] { TASK_FORMAT_1, TASK_FORMAT_2, TASK_FORMAT_3, TASK_FORMAT_4, BUG_FORMAT_1, |
156 |
BUG_FORMAT_2, BUG_FORMAT_3, BUG_FORMAT_4 }; |
193 |
BUG_FORMAT_2, BUG_FORMAT_3, BUG_FORMAT_4 }; |
157 |
commentFormats = new String[] { TASK_FORMAT_1_COMMENT_1, TASK_FORMAT_2_COMMENT_1, TASK_FORMAT_3_COMMENT_1, |
194 |
bugCommentFormats = new String[] { TASK_FORMAT_1_COMMENT_1, TASK_FORMAT_2_COMMENT_1, TASK_FORMAT_3_COMMENT_1, |
158 |
TASK_FORMAT_4_COMMENT_1, BUG_FORMAT_1_COMMENT_1, BUG_FORMAT_2_COMMENT_1, BUG_FORMAT_3_COMMENT_1, |
195 |
TASK_FORMAT_4_COMMENT_1, BUG_FORMAT_1_COMMENT_1, BUG_FORMAT_2_COMMENT_1, BUG_FORMAT_3_COMMENT_1, |
159 |
BUG_FORMAT_4_COMMENT_1, TASK_FORMAT_1_COMMENT_2, TASK_FORMAT_2_COMMENT_2, TASK_FORMAT_3_COMMENT_2, |
196 |
BUG_FORMAT_4_COMMENT_1, TASK_FORMAT_1_COMMENT_2, TASK_FORMAT_2_COMMENT_2, TASK_FORMAT_3_COMMENT_2, |
160 |
TASK_FORMAT_4_COMMENT_2, BUG_FORMAT_1_COMMENT_2, BUG_FORMAT_2_COMMENT_2, BUG_FORMAT_3_COMMENT_2, |
197 |
TASK_FORMAT_4_COMMENT_2, BUG_FORMAT_1_COMMENT_2, BUG_FORMAT_2_COMMENT_2, BUG_FORMAT_3_COMMENT_2, |
161 |
BUG_FORMAT_4_COMMENT_2, TASK_FORMAT_1_COMMENT_3, TASK_FORMAT_2_COMMENT_3, TASK_FORMAT_3_COMMENT_3, |
198 |
BUG_FORMAT_4_COMMENT_2, TASK_FORMAT_1_COMMENT_3, TASK_FORMAT_2_COMMENT_3, TASK_FORMAT_3_COMMENT_3, |
162 |
TASK_FORMAT_4_COMMENT_3, BUG_FORMAT_1_COMMENT_3, BUG_FORMAT_2_COMMENT_3, BUG_FORMAT_3_COMMENT_3, |
199 |
TASK_FORMAT_4_COMMENT_3, BUG_FORMAT_1_COMMENT_3, BUG_FORMAT_2_COMMENT_3, BUG_FORMAT_3_COMMENT_3, |
163 |
BUG_FORMAT_4_COMMENT_3 }; |
200 |
BUG_FORMAT_4_COMMENT_3, TASK_FORMAT_1_COMMENT_4, TASK_FORMAT_2_COMMENT_4, TASK_FORMAT_3_COMMENT_4, |
|
|
201 |
TASK_FORMAT_4_COMMENT_4, BUG_FORMAT_1_COMMENT_4, BUG_FORMAT_2_COMMENT_4, BUG_FORMAT_3_COMMENT_4, |
202 |
BUG_FORMAT_4_COMMENT_4 }; |
164 |
} |
203 |
} |
165 |
|
204 |
|
166 |
private void setRepository(final TaskRepository repository) { |
205 |
private void setRepository(final TaskRepository repository) { |
Lines 178-194
Link Here
|
178 |
} |
217 |
} |
179 |
|
218 |
|
180 |
public void testBeginningWithSpecialChars() { |
219 |
public void testBeginningWithSpecialChars() { |
181 |
for (String format : formats) { |
220 |
for (String format : bugFormats) { |
182 |
String testString = "First line\n:" + format + " is at the beginning"; |
221 |
String testString = "First line\n:" + format + " is at the beginning"; |
183 |
viewer.setDocument(new Document(testString)); |
222 |
viewer.setDocument(new Document(testString)); |
184 |
Region region = new Region(0, testString.length()); |
223 |
Region region = new Region(0, testString.length()); |
185 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
224 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
186 |
assertNotNull(links); |
225 |
assertNotNull(links); |
187 |
assertEquals(1, links.length); |
226 |
assertEquals(1, links.length); |
188 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
227 |
assertTrue(links[0] instanceof TaskHyperlink); |
189 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
228 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
229 |
assertEquals("123", taskLink.getTaskId()); |
230 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
231 |
Object comment = taskLink.getSelection(); |
190 |
assertNull(comment); |
232 |
assertNull(comment); |
191 |
} |
233 |
} |
|
|
234 |
for (String format : bugCommentFormats) { |
235 |
String testString = "First line\n:" + format + " is at the beginning"; |
236 |
viewer.setDocument(new Document(testString)); |
237 |
Region region = new Region(0, testString.length()); |
238 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
239 |
assertNotNull(links); |
240 |
assertEquals(1, links.length); |
241 |
assertTrue(links[0] instanceof TaskHyperlink); |
242 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
243 |
assertEquals("123", taskLink.getTaskId()); |
244 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
245 |
Object comment = taskLink.getSelection(); |
246 |
assertNotNull(comment); |
247 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
248 |
} |
192 |
for (String format : commentFormats) { |
249 |
for (String format : commentFormats) { |
193 |
String testString = "First line\n:" + format + " is at the beginning"; |
250 |
String testString = "First line\n:" + format + " is at the beginning"; |
194 |
viewer.setDocument(new Document(testString)); |
251 |
viewer.setDocument(new Document(testString)); |
Lines 196-220
Link Here
|
196 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
253 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
197 |
assertNotNull(links); |
254 |
assertNotNull(links); |
198 |
assertEquals(1, links.length); |
255 |
assertEquals(1, links.length); |
199 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
256 |
assertTrue(links[0] instanceof TaskHyperlink); |
200 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
257 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
258 |
assertEquals("123", taskLink.getTaskId()); |
259 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
260 |
Object comment = taskLink.getSelection(); |
201 |
assertNotNull(comment); |
261 |
assertNotNull(comment); |
202 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
262 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
203 |
} |
263 |
} |
204 |
} |
264 |
} |
205 |
|
265 |
|
206 |
public void testBeginningOfSecondLine() { |
266 |
public void testBeginningOfSecondLine() { |
207 |
for (String format : formats) { |
267 |
for (String format : bugFormats) { |
208 |
String testString = "First line\n" + format + " is at the beginning"; |
268 |
String testString = "First line\n" + format + " is at the beginning"; |
209 |
viewer.setDocument(new Document(testString)); |
269 |
viewer.setDocument(new Document(testString)); |
210 |
Region region = new Region(0, testString.length()); |
270 |
Region region = new Region(0, testString.length()); |
211 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
271 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
212 |
assertNotNull(links); |
272 |
assertNotNull(links); |
213 |
assertEquals(1, links.length); |
273 |
assertEquals(1, links.length); |
214 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
274 |
assertTrue(links[0] instanceof TaskHyperlink); |
215 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
275 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
276 |
assertEquals("123", taskLink.getTaskId()); |
277 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
278 |
Object comment = taskLink.getSelection(); |
216 |
assertNull(comment); |
279 |
assertNull(comment); |
217 |
} |
280 |
} |
|
|
281 |
for (String format : bugCommentFormats) { |
282 |
String testString = "First line\n" + format + " is at the beginning"; |
283 |
viewer.setDocument(new Document(testString)); |
284 |
Region region = new Region(0, testString.length()); |
285 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
286 |
assertNotNull(links); |
287 |
assertEquals(1, links.length); |
288 |
assertTrue(links[0] instanceof TaskHyperlink); |
289 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
290 |
assertEquals("123", taskLink.getTaskId()); |
291 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
292 |
Object comment = taskLink.getSelection(); |
293 |
assertNotNull(comment); |
294 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
295 |
} |
218 |
for (String format : commentFormats) { |
296 |
for (String format : commentFormats) { |
219 |
String testString = "First line\n" + format + " is at the beginning"; |
297 |
String testString = "First line\n" + format + " is at the beginning"; |
220 |
viewer.setDocument(new Document(testString)); |
298 |
viewer.setDocument(new Document(testString)); |
Lines 222-246
Link Here
|
222 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
300 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
223 |
assertNotNull(links); |
301 |
assertNotNull(links); |
224 |
assertEquals(1, links.length); |
302 |
assertEquals(1, links.length); |
225 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
303 |
assertTrue(links[0] instanceof TaskHyperlink); |
226 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
304 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
305 |
assertEquals("123", taskLink.getTaskId()); |
306 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
307 |
Object comment = taskLink.getSelection(); |
227 |
assertNotNull(comment); |
308 |
assertNotNull(comment); |
228 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
309 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
229 |
} |
310 |
} |
230 |
} |
311 |
} |
231 |
|
312 |
|
232 |
public void testBeginningOfSecondLineWithisWhitespace() { |
313 |
public void testBeginningOfSecondLineWithisWhitespace() { |
233 |
for (String format : formats) { |
314 |
for (String format : bugFormats) { |
234 |
String testString = "First line\n \t " + format + " is at the beginning"; |
315 |
String testString = "First line\n \t " + format + " is at the beginning"; |
235 |
viewer.setDocument(new Document(testString)); |
316 |
viewer.setDocument(new Document(testString)); |
236 |
Region region = new Region(0, testString.length()); |
317 |
Region region = new Region(0, testString.length()); |
237 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
318 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
238 |
assertNotNull(links); |
319 |
assertNotNull(links); |
239 |
assertEquals(1, links.length); |
320 |
assertEquals(1, links.length); |
240 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
321 |
assertTrue(links[0] instanceof TaskHyperlink); |
241 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
322 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
323 |
assertEquals("123", taskLink.getTaskId()); |
324 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
325 |
Object comment = taskLink.getSelection(); |
242 |
assertNull(comment); |
326 |
assertNull(comment); |
243 |
} |
327 |
} |
|
|
328 |
for (String format : bugCommentFormats) { |
329 |
String testString = "First line\n \t " + format + " is at the beginning"; |
330 |
viewer.setDocument(new Document(testString)); |
331 |
Region region = new Region(0, testString.length()); |
332 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
333 |
assertNotNull(links); |
334 |
assertEquals(1, links.length); |
335 |
assertTrue(links[0] instanceof TaskHyperlink); |
336 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
337 |
assertEquals("123", taskLink.getTaskId()); |
338 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
339 |
Object comment = taskLink.getSelection(); |
340 |
assertNotNull(comment); |
341 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
342 |
} |
244 |
for (String format : commentFormats) { |
343 |
for (String format : commentFormats) { |
245 |
String testString = "First line\n \t " + format + " is at the beginning"; |
344 |
String testString = "First line\n \t " + format + " is at the beginning"; |
246 |
viewer.setDocument(new Document(testString)); |
345 |
viewer.setDocument(new Document(testString)); |
Lines 248-272
Link Here
|
248 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
347 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
249 |
assertNotNull(links); |
348 |
assertNotNull(links); |
250 |
assertEquals(1, links.length); |
349 |
assertEquals(1, links.length); |
251 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
350 |
assertTrue(links[0] instanceof TaskHyperlink); |
252 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
351 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
352 |
assertEquals("123", taskLink.getTaskId()); |
353 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
354 |
Object comment = taskLink.getSelection(); |
253 |
assertNotNull(comment); |
355 |
assertNotNull(comment); |
254 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
356 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
255 |
} |
357 |
} |
256 |
} |
358 |
} |
257 |
|
359 |
|
258 |
public void testBeginning() { |
360 |
public void testBeginning() { |
259 |
for (String format : formats) { |
361 |
for (String format : bugFormats) { |
260 |
String testString = format + " is at the beginning"; |
362 |
String testString = format + " is at the beginning"; |
261 |
viewer.setDocument(new Document(testString)); |
363 |
viewer.setDocument(new Document(testString)); |
262 |
Region region = new Region(0, testString.length()); |
364 |
Region region = new Region(0, testString.length()); |
263 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
365 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
264 |
assertNotNull(links); |
366 |
assertNotNull(links); |
265 |
assertEquals(1, links.length); |
367 |
assertEquals(1, links.length); |
266 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
368 |
assertTrue(links[0] instanceof TaskHyperlink); |
267 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
369 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
370 |
assertEquals("123", taskLink.getTaskId()); |
371 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
372 |
Object comment = taskLink.getSelection(); |
268 |
assertNull(comment); |
373 |
assertNull(comment); |
269 |
} |
374 |
} |
|
|
375 |
for (String format : bugCommentFormats) { |
376 |
String testString = format + " is at the beginning"; |
377 |
viewer.setDocument(new Document(testString)); |
378 |
Region region = new Region(0, testString.length()); |
379 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
380 |
assertNotNull(links); |
381 |
assertEquals(1, links.length); |
382 |
assertTrue(links[0] instanceof TaskHyperlink); |
383 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
384 |
assertEquals("123", taskLink.getTaskId()); |
385 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
386 |
Object comment = taskLink.getSelection(); |
387 |
assertNotNull(comment); |
388 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
389 |
} |
270 |
for (String format : commentFormats) { |
390 |
for (String format : commentFormats) { |
271 |
String testString = format + " is at the beginning"; |
391 |
String testString = format + " is at the beginning"; |
272 |
viewer.setDocument(new Document(testString)); |
392 |
viewer.setDocument(new Document(testString)); |
Lines 274-288
Link Here
|
274 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
394 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
275 |
assertNotNull(links); |
395 |
assertNotNull(links); |
276 |
assertEquals(1, links.length); |
396 |
assertEquals(1, links.length); |
277 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
397 |
assertTrue(links[0] instanceof TaskHyperlink); |
278 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
398 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
399 |
assertEquals("123", taskLink.getTaskId()); |
400 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
401 |
Object comment = taskLink.getSelection(); |
279 |
assertNotNull(comment); |
402 |
assertNotNull(comment); |
280 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
403 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
281 |
} |
404 |
} |
282 |
} |
405 |
} |
283 |
|
406 |
|
284 |
public void testEnd() { |
407 |
public void testEnd() { |
285 |
for (String format : formats) { |
408 |
for (String format : bugFormats) { |
286 |
String testString = "is ends with " + format; |
409 |
String testString = "is ends with " + format; |
287 |
viewer.setDocument(new Document(testString)); |
410 |
viewer.setDocument(new Document(testString)); |
288 |
int i = testString.indexOf(format); |
411 |
int i = testString.indexOf(format); |
Lines 290-299
Link Here
|
290 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
413 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
291 |
assertNotNull(links); |
414 |
assertNotNull(links); |
292 |
assertEquals(1, links.length); |
415 |
assertEquals(1, links.length); |
293 |
assertEquals(i, links[0].getHyperlinkRegion().getOffset()); |
416 |
assertTrue(links[0] instanceof TaskHyperlink); |
294 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
417 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
418 |
assertEquals("123", taskLink.getTaskId()); |
419 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
420 |
Object comment = taskLink.getSelection(); |
295 |
assertNull(comment); |
421 |
assertNull(comment); |
296 |
} |
422 |
} |
|
|
423 |
for (String format : bugCommentFormats) { |
424 |
String testString = "is ends with " + format; |
425 |
viewer.setDocument(new Document(testString)); |
426 |
int i = testString.indexOf(format); |
427 |
Region region = new Region(i, testString.length() - i); |
428 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
429 |
assertNotNull(links); |
430 |
assertEquals(1, links.length); |
431 |
assertTrue(links[0] instanceof TaskHyperlink); |
432 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
433 |
assertEquals("123", taskLink.getTaskId()); |
434 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
435 |
Object comment = taskLink.getSelection(); |
436 |
assertNotNull(comment); |
437 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
438 |
} |
297 |
for (String format : commentFormats) { |
439 |
for (String format : commentFormats) { |
298 |
String testString = "is ends with " + format; |
440 |
String testString = "is ends with " + format; |
299 |
viewer.setDocument(new Document(testString)); |
441 |
viewer.setDocument(new Document(testString)); |
Lines 301-315
Link Here
|
301 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
443 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
302 |
assertNotNull(links); |
444 |
assertNotNull(links); |
303 |
assertEquals(1, links.length); |
445 |
assertEquals(1, links.length); |
304 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
446 |
assertTrue(links[0] instanceof TaskHyperlink); |
305 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
447 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
448 |
assertEquals("123", taskLink.getTaskId()); |
449 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
450 |
Object comment = taskLink.getSelection(); |
306 |
assertNotNull(comment); |
451 |
assertNotNull(comment); |
307 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
452 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
308 |
} |
453 |
} |
309 |
} |
454 |
} |
310 |
|
455 |
|
311 |
public void testMiddle() { |
456 |
public void testMiddle() { |
312 |
for (String format : formats) { |
457 |
for (String format : bugFormats) { |
313 |
String testString = "is a " + format + " in the middle"; |
458 |
String testString = "is a " + format + " in the middle"; |
314 |
viewer.setDocument(new Document(testString)); |
459 |
viewer.setDocument(new Document(testString)); |
315 |
int i = testString.indexOf(format); |
460 |
int i = testString.indexOf(format); |
Lines 317-326
Link Here
|
317 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
462 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
318 |
assertNotNull(links); |
463 |
assertNotNull(links); |
319 |
assertEquals(1, links.length); |
464 |
assertEquals(1, links.length); |
320 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
465 |
assertTrue(links[0] instanceof TaskHyperlink); |
321 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
466 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
467 |
assertEquals("123", taskLink.getTaskId()); |
468 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
469 |
Object comment = taskLink.getSelection(); |
322 |
assertNull(comment); |
470 |
assertNull(comment); |
323 |
} |
471 |
} |
|
|
472 |
for (String format : bugCommentFormats) { |
473 |
String testString = "is a " + format + " in the middle"; |
474 |
viewer.setDocument(new Document(testString)); |
475 |
Region region = new Region(0, testString.length()); |
476 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
477 |
assertNotNull(links); |
478 |
assertEquals(1, links.length); |
479 |
assertTrue(links[0] instanceof TaskHyperlink); |
480 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
481 |
assertEquals("123", taskLink.getTaskId()); |
482 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
483 |
Object comment = taskLink.getSelection(); |
484 |
assertNotNull(comment); |
485 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
486 |
} |
324 |
for (String format : commentFormats) { |
487 |
for (String format : commentFormats) { |
325 |
String testString = "is a " + format + " in the middle"; |
488 |
String testString = "is a " + format + " in the middle"; |
326 |
viewer.setDocument(new Document(testString)); |
489 |
viewer.setDocument(new Document(testString)); |
Lines 328-335
Link Here
|
328 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
491 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
329 |
assertNotNull(links); |
492 |
assertNotNull(links); |
330 |
assertEquals(1, links.length); |
493 |
assertEquals(1, links.length); |
331 |
assertEquals(testString.indexOf(format), links[0].getHyperlinkRegion().getOffset()); |
494 |
assertTrue(links[0] instanceof TaskHyperlink); |
332 |
Object comment = ((TaskHyperlink) links[0]).getSelection(); |
495 |
TaskHyperlink taskLink = (TaskHyperlink) links[0]; |
|
|
496 |
assertEquals("123", taskLink.getTaskId()); |
497 |
assertEquals(testString.indexOf(format), taskLink.getHyperlinkRegion().getOffset()); |
498 |
Object comment = taskLink.getSelection(); |
333 |
assertNotNull(comment); |
499 |
assertNotNull(comment); |
334 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
500 |
assertEquals(TaskAttribute.PREFIX_COMMENT + "44556677", comment); |
335 |
} |
501 |
} |
Lines 473-479
Link Here
|
473 |
public void testAttachmentOld() { |
639 |
public void testAttachmentOld() { |
474 |
String testString = ATTACHMENT_OLD; |
640 |
String testString = ATTACHMENT_OLD; |
475 |
viewer.setDocument(new Document(testString)); |
641 |
viewer.setDocument(new Document(testString)); |
476 |
int i = testString.indexOf(ATTACHMENT_NUMBER); |
|
|
477 |
Region region = new Region(0, testString.length()); |
642 |
Region region = new Region(0, testString.length()); |
478 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
643 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
479 |
assertNotNull(links); |
644 |
assertNotNull(links); |
Lines 484-490
Link Here
|
484 |
public void testAttachmentNew() { |
649 |
public void testAttachmentNew() { |
485 |
String testString = ATTACHMENT_NEW; |
650 |
String testString = ATTACHMENT_NEW; |
486 |
viewer.setDocument(new Document(testString)); |
651 |
viewer.setDocument(new Document(testString)); |
487 |
int i = testString.indexOf(ATTACHMENT_NUMBER); |
|
|
488 |
Region region = new Region(0, testString.length()); |
652 |
Region region = new Region(0, testString.length()); |
489 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
653 |
IHyperlink[] links = detector.detectHyperlinks(viewer, region, false); |
490 |
assertNotNull(links); |
654 |
assertNotNull(links); |