Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions src/main/java/gitflow/ui/GitflowTaskDialogPanelProvider.java
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
package gitflow.ui;
import com.intellij.openapi.project.Project;
import com.intellij.tasks.LocalTask;
import com.intellij.tasks.Task;
import com.intellij.tasks.TaskManager;
import com.intellij.tasks.actions.vcs.VcsTaskDialogPanelProvider;
import com.intellij.tasks.ui.TaskDialogPanel;
import com.intellij.tasks.ui.TaskDialogPanelProvider;
import git4idea.branch.GitBranchUtil;
import git4idea.repo.GitRepository;
import gitflow.GitflowBranchUtil;
import gitflow.GitflowBranchUtilManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.function.BiFunction;
import java.util.function.Function;

public class GitflowTaskDialogPanelProvider extends TaskDialogPanelProvider {

@Deprecated
@Nullable
@Override
public TaskDialogPanel getOpenTaskPanel(@NotNull Project project, @NotNull Task task) {
return null;
}

public class GitflowTaskDialogPanelProvider extends VcsTaskDialogPanelProvider {
@Nullable
@Override
public TaskDialogPanel getOpenTaskPanel(@NotNull Project project, @NotNull LocalTask task) {
GitRepository currentRepo = GitBranchUtil.getCurrentRepository(project);
GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(currentRepo);
if (branchUtil.hasGitflow()) {
return TaskManager.getManager(project).isVcsEnabled() ? new GitflowOpenTaskPanel(project, task, currentRepo) : null;
}
else{
return null;
}
return getTaskPanel(
project,
task,
(p, t) -> (r -> new GitflowOpenTaskPanel(p, t, r))
);
}

@Nullable
@Override
public TaskDialogPanel getCloseTaskPanel(@NotNull Project project, @NotNull LocalTask task) {
return getTaskPanel(
project,
task,
(p, t) -> (r -> new GitflowCloseTaskPanel(p, t, r))
);
}

private TaskDialogPanel getTaskPanel(@NotNull Project project, @NotNull LocalTask task, BiFunction<Project, LocalTask, Function<GitRepository, TaskDialogPanel>> zz) {
GitRepository currentRepo = GitBranchUtil.getCurrentRepository(project);
GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(currentRepo);

if (branchUtil.hasGitflow()) {
return TaskManager.getManager(project).isVcsEnabled() ? new GitflowCloseTaskPanel(project, task, currentRepo) : null;
}
else{
return null;
}
return branchUtil != null && branchUtil.hasGitflow() && TaskManager.getManager(project).isVcsEnabled()
? zz.apply(project, task).apply(currentRepo)
: null;
}

}