// Path: src/main/java/gitflow/ui/NotifyUtil.java
// public class NotifyUtil
// {
//     private static final NotificationGroup TOOLWINDOW_NOTIFICATION = NotificationGroup.toolWindowGroup(
//             "Gitflow Errors", ToolWindowId.VCS, true);
//     private static final NotificationGroup STICKY_NOTIFICATION = new NotificationGroup(
//             "Gitflow Errors", NotificationDisplayType.STICKY_BALLOON, true);
//     private static final NotificationGroup BALLOON_NOTIFICATION = new NotificationGroup(
//             "Gitflow Notifications", NotificationDisplayType.BALLOON, true);
// 
//     public static void notifySuccess(Project project, String title, String message) {
//         notify(NotificationType.INFORMATION, BALLOON_NOTIFICATION, project, title, message);
//     }
// 
// 	public static void notifyInfo(Project project, String title, String message) {
// 		notify(NotificationType.INFORMATION, TOOLWINDOW_NOTIFICATION, project, title, message);
// 	}
// 
//     public static void notifyError(Project project, String title, String message) {
//         notify(NotificationType.ERROR, TOOLWINDOW_NOTIFICATION, project, title, message);
//     }
// 
//     public static void notifyError(Project project, String title, Exception exception) {
//         notify(NotificationType.ERROR, STICKY_NOTIFICATION, project, title, exception.getMessage());
//     }
// 
//     private static void notify(NotificationType type, NotificationGroup group, Project project, String title, String message) {
//         group.createNotification(title, message, type, null).notify(project);
//     }
// }


import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.ui.Messages;
import git4idea.commands.GitCommandResult;
import git4idea.repo.GitRepository;
import git4idea.validators.GitNewBranchNameValidator;
import gitflow.ui.NotifyUtil;
import org.jetbrains.annotations.NotNull;
package gitflow.actions;


public class StartReleaseAction extends AbstractStartAction {

    StartReleaseAction() {
        super("Start Release");
    }

    StartReleaseAction(GitRepository repo) {
        super(repo,"Start Release");
    }

    @Override
    public void actionPerformed(AnActionEvent e) {
        super.actionPerformed(e);

        final String releaseName = Messages.showInputDialog(myProject, "Enter the name of new release:", "New Release", Messages.getQuestionIcon(), "",
                GitNewBranchNameValidator.newInstance(repos));
        final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);

        if (releaseName == null){
            // user clicked cancel
        }
        else if (releaseName.isEmpty()){
            Messages.showWarningDialog(myProject, "You must provide a name for the release", "Whoops");
        }
        else {
            new Task.Backgroundable(myProject,"Starting release "+releaseName,false){
                @Override
                public void run(@NotNull ProgressIndicator indicator) {
                    GitCommandResult result=  myGitflow.startRelease(myRepo, releaseName, errorLineHandler);

                    if (result.success()) {
                        String startedReleaseMessage = String.format("A new release '%s%s' was created, based on '%s'", branchUtil.getPrefixRelease(), releaseName, branchUtil.getBranchnameDevelop());
// Path: src/main/java/gitflow/ui/NotifyUtil.java
// public class NotifyUtil
// {
//     private static final NotificationGroup TOOLWINDOW_NOTIFICATION = NotificationGroup.toolWindowGroup(
//             "Gitflow Errors", ToolWindowId.VCS, true);
//     private static final NotificationGroup STICKY_NOTIFICATION = new NotificationGroup(
//             "Gitflow Errors", NotificationDisplayType.STICKY_BALLOON, true);
//     private static final NotificationGroup BALLOON_NOTIFICATION = new NotificationGroup(
//             "Gitflow Notifications", NotificationDisplayType.BALLOON, true);
// 
//     public static void notifySuccess(Project project, String title, String message) {
//         notify(NotificationType.INFORMATION, BALLOON_NOTIFICATION, project, title, message);
//     }
// 
// 	public static void notifyInfo(Project project, String title, String message) {
// 		notify(NotificationType.INFORMATION, TOOLWINDOW_NOTIFICATION, project, title, message);
// 	}
// 
//     public static void notifyError(Project project, String title, String message) {
//         notify(NotificationType.ERROR, TOOLWINDOW_NOTIFICATION, project, title, message);
//     }
// 
//     public static void notifyError(Project project, String title, Exception exception) {
//         notify(NotificationType.ERROR, STICKY_NOTIFICATION, project, title, exception.getMessage());
//     }
// 
//     private static void notify(NotificationType type, NotificationGroup group, Project project, String title, String message) {
//         group.createNotification(title, message, type, null).notify(project);
//     }
// }


// Path: src/main/java/gitflow/actions/StartReleaseAction.java
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.ui.Messages;
import git4idea.commands.GitCommandResult;
import git4idea.repo.GitRepository;
import git4idea.validators.GitNewBranchNameValidator;
import gitflow.ui.NotifyUtil;
import org.jetbrains.annotations.NotNull;

package gitflow.actions;


public class StartReleaseAction extends AbstractStartAction {

    StartReleaseAction() {
        super("Start Release");
    }

    StartReleaseAction(GitRepository repo) {
        super(repo,"Start Release");
    }

    @Override
    public void actionPerformed(AnActionEvent e) {
        super.actionPerformed(e);

        final String releaseName = Messages.showInputDialog(myProject, "Enter the name of new release:", "New Release", Messages.getQuestionIcon(), "",
                GitNewBranchNameValidator.newInstance(repos));
        final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);

        if (releaseName == null){
            // user clicked cancel
        }
        else if (releaseName.isEmpty()){
            Messages.showWarningDialog(myProject, "You must provide a name for the release", "Whoops");
        }
        else {
            new Task.Backgroundable(myProject,"Starting release "+releaseName,false){
                @Override
                public void run(@NotNull ProgressIndicator indicator) {
                    GitCommandResult result=  myGitflow.startRelease(myRepo, releaseName, errorLineHandler);

                    if (result.success()) {
                        String startedReleaseMessage = String.format("A new release '%s%s' was created, based on '%s'", branchUtil.getPrefixRelease(), releaseName, branchUtil.getBranchnameDevelop());
                        NotifyUtil.notifySuccess(myProject, releaseName, startedReleaseMessage);