blob: 0a0dea347070c954f7c425bea81e8c0c077b869f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
/*******************************************************************************
* Copyright (c) 2004, 2008 Eugene Kuleshov and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eugene Kuleshov - initial API and implementation
* Tasktop Technologies - improvements
*******************************************************************************/
package org.eclipse.mylyn.tasks.ui;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.mylyn.tasks.core.TaskRepository;
/**
* Immutable. Encapsulates information for linking to tasks from text.
*
* @author Eugene Kuleshov
* @author Steffen Pingel
* @noextend This class is not intended to be subclassed by clients.
*/
public final class TaskHyperlink implements IHyperlink {
private final IRegion region;
private final TaskRepository repository;
private final String taskId;
public TaskHyperlink(IRegion region, TaskRepository repository, String taskId) {
this.region = region;
this.repository = repository;
this.taskId = taskId;
}
public IRegion getHyperlinkRegion() {
return region;
}
public String getTaskId() {
return taskId;
}
public String getTypeLabel() {
return null;
}
/**
* @Since 2.1
* @return
*/
public TaskRepository getRepository() {
return repository;
}
public String getHyperlinkText() {
return "Open Task " + taskId;
}
public void open() {
if (repository != null) {
TasksUiUtil.openTask(repository, taskId);
} else {
MessageDialog.openError(null, "Mylyn", "Could not determine repository for report");
}
}
}
|