mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-136499 Introduce the concept of "Presentable ID" in Task Management API
This commit is contained in:
@@ -33,15 +33,29 @@ public abstract class Task {
|
||||
/**
|
||||
* Global unique task identifier, e.g. IDEA-00001. It's important that its format is consistent with
|
||||
* {@link TaskRepository#extractId(String)}, because otherwise task won't be updated on its activation.
|
||||
* Note that this ID is used to find issues and to compare them, so (ideally) it has to be unique.
|
||||
*
|
||||
* In some cases task server doesn't offer such global ID (but, for instance, pair (project-name, per-project-id) instead) or it's not
|
||||
* what users want to see in UI (e.g. notorious <tt>id</tt> and <tt>iid</tt> in Gitlab). In this case you should generate artificial ID
|
||||
* for internal usage and implement {@link #getPresentableId()}.
|
||||
*
|
||||
* @return unique global ID as described
|
||||
*
|
||||
* @see com.intellij.tasks.TaskRepository#extractId(String)
|
||||
* @see com.intellij.tasks.TaskManager#activateTask(Task, boolean)
|
||||
* @see #getPresentableId()
|
||||
* @see TaskRepository#extractId(String)
|
||||
* @see TaskManager#activateTask(Task, boolean)
|
||||
*/
|
||||
@NotNull
|
||||
public abstract String getId();
|
||||
|
||||
|
||||
/**
|
||||
* @return ID in the form that is suitable for commit messages, dialogs, completion items, etc.
|
||||
*/
|
||||
@NotNull
|
||||
public String getPresentableId() {
|
||||
return getId();
|
||||
}
|
||||
/**
|
||||
* Short task description.
|
||||
* @return description
|
||||
@@ -100,7 +114,7 @@ public abstract class Task {
|
||||
public final String toString() {
|
||||
String text;
|
||||
if (isIssue()) {
|
||||
text = getId() + ": " + getSummary();
|
||||
text = getPresentableId() + ": " + getSummary();
|
||||
} else {
|
||||
text = getSummary();
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ public abstract class TaskRepository {
|
||||
@Nullable
|
||||
public String getTaskComment(@NotNull Task task) {
|
||||
return isShouldFormatCommitMessage()
|
||||
? myCommitMessageFormat.replace("{id}", task.getId()).replace("{summary}", task.getSummary())
|
||||
? myCommitMessageFormat.replace("{id}", task.getPresentableId()).replace("{summary}", task.getSummary())
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class EditTaskDialog extends DialogWrapper {
|
||||
protected EditTaskDialog(Project project, LocalTaskImpl task) {
|
||||
super(project);
|
||||
myTask = task;
|
||||
setTitle("Edit Task " + (task.isIssue() ? task.getId() : ""));
|
||||
setTitle("Edit Task " + (task.isIssue() ? task.getPresentableId() : ""));
|
||||
|
||||
// mySummary.putClientProperty(DialogWrapperPeer.HAVE_INITIAL_SELECTION, "");
|
||||
mySummary.setText(task.getSummary());
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class TaskAutoCompletionListProvider extends TextFieldWithAutoCompletionL
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getLookupString(@NotNull final Task task) {
|
||||
return task.getId();
|
||||
return task.getPresentableId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,7 +56,7 @@ public class TaskSearchSupport {
|
||||
final Matcher matcher = getMatcher(pattern);
|
||||
return ContainerUtil.mapNotNull(tasks, new NullableFunction<Task, Task>() {
|
||||
public Task fun(Task task) {
|
||||
return matcher.matches(task.getId()) || matcher.matches(task.getSummary()) ? task : null;
|
||||
return matcher.matches(task.getPresentableId()) || matcher.matches(task.getSummary()) ? task : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TaskDocumentationProvider extends AbstractDocumentationProvider imp
|
||||
final Task task = ((TaskPsiElement)element).getTask();
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append("<b>Summary:</b> ").append(task.getSummary()).append("<br>");
|
||||
builder.append("<b>Id:</b> ").append(task.getId()).append("<br>");
|
||||
builder.append("<b>Id:</b> ").append(task.getPresentableId()).append("<br>");
|
||||
if (task.getCreated() != null) {
|
||||
builder.append("<b>Created at:</b> ").append(task.getCreated()).append("<br>");
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public class LocalTaskImpl extends LocalTask {
|
||||
|
||||
private String myProject = null;
|
||||
private String myNumber = "";
|
||||
private String myPresentableId = "";
|
||||
|
||||
private boolean myIssue = false;
|
||||
private TaskRepository myRepository = null;
|
||||
@@ -161,6 +162,7 @@ public class LocalTaskImpl extends LocalTask {
|
||||
|
||||
myProject = issue.getProject();
|
||||
myNumber = issue.getNumber();
|
||||
myPresentableId = issue.getPresentableId();
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
@@ -394,4 +396,14 @@ public class LocalTaskImpl extends LocalTask {
|
||||
public void setProject(@Nullable String project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void setPresentableId(@NotNull String presentableId) {
|
||||
myPresentableId = presentableId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableId() {
|
||||
return StringUtil.isEmpty(myPresentableId) ? getId() : myPresentableId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
|
||||
if (task.isIssue()) {
|
||||
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new Runnable() {
|
||||
public void run() {
|
||||
ProgressManager.getInstance().run(new com.intellij.openapi.progress.Task.Backgroundable(myProject, "Updating " + task.getId()) {
|
||||
ProgressManager.getInstance().run(new com.intellij.openapi.progress.Task.Backgroundable(myProject, "Updating " + task.getPresentableId()) {
|
||||
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
updateIssue(task.getId());
|
||||
|
||||
@@ -72,7 +72,7 @@ public class TaskUtil {
|
||||
|
||||
public static String formatTask(@NotNull Task task, String format) {
|
||||
return format
|
||||
.replace("{id}", task.getId())
|
||||
.replace("{id}", task.getPresentableId())
|
||||
.replace("{number}", task.getNumber())
|
||||
.replace("{project}", StringUtil.notNullize(task.getProject()))
|
||||
.replace("{summary}", task.getSummary());
|
||||
@@ -90,7 +90,7 @@ public class TaskUtil {
|
||||
public static String getTrimmedSummary(Task task) {
|
||||
String text;
|
||||
if (task.isIssue()) {
|
||||
text = task.getId() + ": " + task.getSummary();
|
||||
text = task.getPresentableId() + ": " + task.getSummary();
|
||||
}
|
||||
else {
|
||||
text = task.getSummary();
|
||||
|
||||
Reference in New Issue
Block a user