diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index da4eab2..8702bec 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -2,14 +2,14 @@ Git Flow Integration Gitflow Git Flow Integration - 0.3.4 + 0.3.5 VCS Integration Opher Vishnia com.intellij.modules.vcs Git4Idea - + diff --git a/README.md b/README.md index 434c7c5..7545d48 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,15 @@ The plugin is available via the IntelliJ plugin manager. Just search for "Git Fl (The plugin requires that you have [Vanilla Git Flow](https://github.com/nvie/gitflow) \ [AVH edition](https://github.com/petervanderdoes/gitflow) installed) +**Mac/Linux users:** + +If you're running into issues like getting +`Gitflow is not installed` +or +`git: 'flow' is not a git command. See 'git --help'.` + +Please be sure to check out [this thread](https://github.com/OpherV/gitflow4idea/issues/7) + ## Caveats @@ -47,7 +56,7 @@ I have worked hard on this plugin on my spare time. If you feel it is useful to ## License This plugin is under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html). -Copyright 2013, Opher Vishnia. +Copyright 2013-2014, Opher Vishnia. [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/OpherV/gitflow4idea/trend.png)](https://bitdeli.com/free "Bitdeli Badge") diff --git a/src/gitflow/Gitflow.java b/src/gitflow/Gitflow.java index 41fddb5..3bc4560 100644 --- a/src/gitflow/Gitflow.java +++ b/src/gitflow/Gitflow.java @@ -8,8 +8,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - /** * * diff --git a/src/gitflow/GitflowComponent.java b/src/gitflow/GitflowComponent.java index db33ddc..bd7ff82 100644 --- a/src/gitflow/GitflowComponent.java +++ b/src/gitflow/GitflowComponent.java @@ -3,7 +3,6 @@ import com.intellij.dvcs.DvcsUtil; import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsListener; import com.intellij.openapi.vcs.VcsRoot; diff --git a/src/gitflow/GitflowConfigUtil.java b/src/gitflow/GitflowConfigUtil.java index 17847b4..e907e72 100644 --- a/src/gitflow/GitflowConfigUtil.java +++ b/src/gitflow/GitflowConfigUtil.java @@ -1,12 +1,12 @@ package gitflow; +import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.project.Project; import git4idea.branch.GitBranchUtil; import git4idea.config.GitConfigUtil; import git4idea.repo.GitRepository; -import git4idea.util.GitUIUtil; +import gitflow.ui.NotifyUtil; /** * @@ -35,7 +35,7 @@ public static String getMasterBranch(Project project){ masterBranch = GitConfigUtil.getValue(project, root, BRANCH_MASTER); } catch (VcsException e) { - GitUIUtil.notifyError(project,"Config error",null,false,e); + NotifyUtil.notifyError(project, "Config error", e); } return masterBranch; @@ -50,7 +50,7 @@ public static String getDevelopBranch(Project project){ developBranch = GitConfigUtil.getValue(project, root, BRANCH_DEVELOP); } catch (VcsException e) { - GitUIUtil.notifyError(project,"Config error",null,false,e); + NotifyUtil.notifyError(project, "Config error", e); } return developBranch; @@ -66,7 +66,7 @@ public static String getFeaturePrefix(Project project){ featurePrefix = GitConfigUtil.getValue(project,root,PREFIX_FEATURE); } catch (VcsException e) { - GitUIUtil.notifyError(project,"Config error",null,false,e); + NotifyUtil.notifyError(project, "Config error", e); } return featurePrefix; } @@ -81,7 +81,7 @@ public static String getReleasePrefix(Project project){ releasePrefix = GitConfigUtil.getValue(project,root,PREFIX_RELEASE); } catch (VcsException e) { - GitUIUtil.notifyError(project,"Config error",null,false,e); + NotifyUtil.notifyError(project, "Config error", e); } return releasePrefix; } @@ -96,7 +96,7 @@ public static String getHotfixPrefix(Project project){ hotfixPrefix = GitConfigUtil.getValue(project,root,PREFIX_HOTFIX); } catch (VcsException e) { - GitUIUtil.notifyError(project,"Config error",null,false,e); + NotifyUtil.notifyError(project, "Config error", e); } return hotfixPrefix; } @@ -128,7 +128,7 @@ public static void setMasterBranch(Project project, String branchName) try { GitConfigUtil.setValue(project, root, BRANCH_MASTER, branchName); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } @@ -139,7 +139,7 @@ public static void setDevelopBranch(Project project, String branchName) { try { GitConfigUtil.setValue(project, root, BRANCH_DEVELOP, branchName); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } @@ -150,7 +150,7 @@ public static void setReleasePrefix(Project project, String prefix) { try { GitConfigUtil.setValue(project, root, PREFIX_RELEASE, prefix); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } @@ -161,7 +161,7 @@ public static void setFeaturePrefix(Project project, String prefix) { try { GitConfigUtil.setValue(project, root, PREFIX_FEATURE, prefix); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } @@ -172,7 +172,7 @@ public static void setHotfixPrefix(Project project, String prefix) { try { GitConfigUtil.setValue(project, root, PREFIX_HOTFIX, prefix); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } @@ -183,7 +183,7 @@ public static void setSupportPrefix(Project project, String prefix) { try { GitConfigUtil.setValue(project, root, PREFIX_SUPPORT, prefix); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } @@ -194,7 +194,7 @@ public static void setVersionPrefix(Project project, String prefix) { try { GitConfigUtil.setValue(project, root, PREFIX_VERSIONTAG, prefix); } catch (VcsException e) { - GitUIUtil.notifyError(project, "Config error", null, false, e); + NotifyUtil.notifyError(project, "Config error", e); } } } diff --git a/src/gitflow/GitflowImpl.java b/src/gitflow/GitflowImpl.java index 1bcea6a..c997358 100644 --- a/src/gitflow/GitflowImpl.java +++ b/src/gitflow/GitflowImpl.java @@ -236,9 +236,10 @@ public GitCommandResult finishRelease(@NotNull GitRepository repository, else{ h.addParameters("-m"); h.addParameters(tagMessage); - h.addParameters(releaseName); } + h.addParameters(releaseName); + for (GitLineHandlerListener listener : listeners) { h.addLineListener(listener); } diff --git a/src/gitflow/actions/FinishFeatureAction.java b/src/gitflow/actions/FinishFeatureAction.java index df10d5a..2ec537a 100644 --- a/src/gitflow/actions/FinishFeatureAction.java +++ b/src/gitflow/actions/FinishFeatureAction.java @@ -8,8 +8,8 @@ import git4idea.branch.GitBranchUtil; import git4idea.commands.GitCommandResult; import git4idea.merge.GitMerger; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class FinishFeatureAction extends GitflowAction { @@ -49,17 +49,15 @@ public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.finishFeature(repo,featureName,errorLineHandler); - if (result.success()){ + if (result.success()) { String finishedFeatureMessage = String.format("The feature branch '%s%s' was merged into '%s'", featurePrefix, featureName, developBranch); - GitUIUtil.notifySuccess(myProject, featureName, finishedFeatureMessage); + NotifyUtil.notifySuccess(myProject, featureName, finishedFeatureMessage); } else if(errorLineHandler.hasMergeError){ } else { - - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); - + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } } @@ -93,8 +91,8 @@ public void onSuccess() { try { gitMerger.mergeCommit(gitMerger.getMergingRoots()); } catch (VcsException e1) { - GitUIUtil.notifyError(myProject,"Error","Error committing merge result"); - e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + NotifyUtil.notifyError(myProject, "Error", "Error committing merge result"); + e1.printStackTrace(); } FinishFeatureAction completeFinishFeatureAction = new FinishFeatureAction(featureName); diff --git a/src/gitflow/actions/FinishHotfixAction.java b/src/gitflow/actions/FinishHotfixAction.java index 3b4fd46..6843b46 100644 --- a/src/gitflow/actions/FinishHotfixAction.java +++ b/src/gitflow/actions/FinishHotfixAction.java @@ -6,9 +6,9 @@ import com.intellij.openapi.ui.Messages; import git4idea.branch.GitBranchUtil; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; import gitflow.GitflowConfigurable; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class FinishHotfixAction extends GitflowAction { @@ -41,12 +41,12 @@ public void actionPerformed(AnActionEvent e) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result= myGitflow.finishHotfix(repo, hotfixName, tagMessage, errorLineHandler); - if (result.success()){ + if (result.success()) { String finishedHotfixMessage = String.format("The hotfix branch '%s%s' was merged into '%s' and '%s'", hotfixPrefix, hotfixName, developBranch, masterBranch); - GitUIUtil.notifySuccess(myProject, hotfixName, finishedHotfixMessage); + NotifyUtil.notifySuccess(myProject, hotfixName, finishedHotfixMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/FinishReleaseAction.java b/src/gitflow/actions/FinishReleaseAction.java index 570afc9..50f84b6 100644 --- a/src/gitflow/actions/FinishReleaseAction.java +++ b/src/gitflow/actions/FinishReleaseAction.java @@ -6,9 +6,9 @@ import com.intellij.openapi.ui.Messages; import git4idea.branch.GitBranchUtil; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; import gitflow.GitflowConfigurable; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class FinishReleaseAction extends GitflowAction { @@ -57,12 +57,12 @@ public void actionPerformed(AnActionEvent e) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.finishRelease(repo, releaseName, tagMessage, errorLineHandler); - if (result.success()){ + if (result.success()) { String finishedReleaseMessage = String.format("The release branch '%s%s' was merged into '%s' and '%s'", featurePrefix, releaseName, developBranch, masterBranch); - GitUIUtil.notifySuccess(myProject, releaseName, finishedReleaseMessage); + NotifyUtil.notifySuccess(myProject, releaseName, finishedReleaseMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } diff --git a/src/gitflow/actions/GitflowActions.java b/src/gitflow/actions/GitflowActions.java index dc576ef..764f447 100644 --- a/src/gitflow/actions/GitflowActions.java +++ b/src/gitflow/actions/GitflowActions.java @@ -1,32 +1,16 @@ package gitflow.actions; import com.intellij.ide.DataManager; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.progress.ProgressIndicator; -import com.intellij.openapi.progress.Task; -import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; -import com.intellij.openapi.ui.Messages; -import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFileManager; -import git4idea.GitVcs; import git4idea.branch.GitBranchUtil; -import git4idea.commands.GitCommandResult; -import git4idea.merge.GitMerger; -import git4idea.repo.GitRemote; import git4idea.repo.GitRepository; -import git4idea.util.GitUIUtil; -import git4idea.validators.GitNewBranchNameValidator; -import gitflow.*; -import gitflow.ui.GitflowBranchChooseDialog; +import gitflow.Gitflow; +import gitflow.GitflowBranchUtil; +import gitflow.GitflowConfigUtil; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.ArrayList; -import java.util.Iterator; /** * All actions associated with Gitflow diff --git a/src/gitflow/actions/GitflowErrorsListener.java b/src/gitflow/actions/GitflowErrorsListener.java index ff902ba..d28fd50 100644 --- a/src/gitflow/actions/GitflowErrorsListener.java +++ b/src/gitflow/actions/GitflowErrorsListener.java @@ -2,7 +2,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import git4idea.util.GitUIUtil; +import gitflow.ui.NotifyUtil; public class GitflowErrorsListener extends GitflowLineHandler{ @@ -14,11 +14,11 @@ public class GitflowErrorsListener extends GitflowLineHandler{ @Override public void onLineAvailable(String line, Key outputType) { - if (line.contains("'flow' is not a git command")){ - GitUIUtil.notifyError(myProject, "Error", "Gitflow is not installed"); + if (line.contains("'flow' is not a git command")) { + NotifyUtil.notifyError(myProject, "Error", "Gitflow is not installed"); } - if (line.contains("Not a gitflow-enabled repo yet")){ - GitUIUtil.notifyError(myProject,"Error","Not a gitflow-enabled repo yet. Please init git flow"); + if (line.contains("Not a gitflow-enabled repo yet")) { + NotifyUtil.notifyError(myProject, "Error", "Not a gitflow-enabled repo yet. Please init git flow"); } if (line.contains("There were merge conflicts")){ hasMergeError=true; diff --git a/src/gitflow/actions/InitRepoAction.java b/src/gitflow/actions/InitRepoAction.java index 5102723..76a61bd 100644 --- a/src/gitflow/actions/InitRepoAction.java +++ b/src/gitflow/actions/InitRepoAction.java @@ -3,21 +3,13 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; -import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.util.Key; -import git4idea.branch.GitBranchUtil; import git4idea.commands.GitCommandResult; -import git4idea.repo.GitRepository; -import git4idea.util.GitUIUtil; import gitflow.GitflowInitOptions; -import gitflow.actions.GitflowAction; -import gitflow.actions.GitflowErrorsListener; -import gitflow.actions.GitflowLineHandler; import gitflow.ui.GitflowInitOptionsDialog; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; - public class InitRepoAction extends GitflowAction { InitRepoAction() { @@ -43,9 +35,9 @@ public void run(@NotNull ProgressIndicator indicator) { if (result.success()) { String publishedFeatureMessage = String.format("Initialized gitflow repo"); - GitUIUtil.notifySuccess(myProject, publishedFeatureMessage, ""); + NotifyUtil.notifySuccess(myProject, publishedFeatureMessage, ""); } else { - GitUIUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/PublishFeatureAction.java b/src/gitflow/actions/PublishFeatureAction.java index 234b598..0e8a648 100644 --- a/src/gitflow/actions/PublishFeatureAction.java +++ b/src/gitflow/actions/PublishFeatureAction.java @@ -4,8 +4,8 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class PublishFeatureAction extends GitflowAction { @@ -24,12 +24,12 @@ public void actionPerformed(AnActionEvent anActionEvent) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.publishFeature(repo,featureName,new GitflowErrorsListener(myProject)); - if (result.success()){ + if (result.success()) { String publishedFeatureMessage = String.format("A new remote branch '%s%s' was created", featurePrefix, featureName); - GitUIUtil.notifySuccess(myProject, featureName, publishedFeatureMessage); + NotifyUtil.notifySuccess(myProject, featureName, publishedFeatureMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/PublishHotfixAction.java b/src/gitflow/actions/PublishHotfixAction.java index 43a5b5f..20c8423 100644 --- a/src/gitflow/actions/PublishHotfixAction.java +++ b/src/gitflow/actions/PublishHotfixAction.java @@ -3,12 +3,9 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; -import com.intellij.openapi.project.DumbAwareAction; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; -import gitflow.actions.GitflowAction; -import gitflow.actions.GitflowErrorsListener; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class PublishHotfixAction extends GitflowAction { @@ -30,9 +27,9 @@ public void run(@NotNull ProgressIndicator indicator) { if (result.success()) { String publishedHotfixMessage = String.format("A new remote branch '%s%s' was created", hotfixPrefix, hotfixName); - GitUIUtil.notifySuccess(myProject, hotfixName, publishedHotfixMessage); + NotifyUtil.notifySuccess(myProject, hotfixName, publishedHotfixMessage); } else { - GitUIUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/PublishReleaseAction.java b/src/gitflow/actions/PublishReleaseAction.java index 63ac699..e34b418 100644 --- a/src/gitflow/actions/PublishReleaseAction.java +++ b/src/gitflow/actions/PublishReleaseAction.java @@ -4,8 +4,8 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class PublishReleaseAction extends GitflowAction { @@ -26,12 +26,12 @@ public void actionPerformed(AnActionEvent anActionEvent) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.publishRelease(repo, releaseName, errorLineHandler); - if (result.success()){ + if (result.success()) { String publishedReleaseMessage = String.format("A new remote branch '%s%s' was created", releasePrefix, releaseName); - GitUIUtil.notifySuccess(myProject, releaseName, publishedReleaseMessage); + NotifyUtil.notifySuccess(myProject, releaseName, publishedReleaseMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/StartFeatureAction.java b/src/gitflow/actions/StartFeatureAction.java index 4e6b4b9..d08f02c 100644 --- a/src/gitflow/actions/StartFeatureAction.java +++ b/src/gitflow/actions/StartFeatureAction.java @@ -5,8 +5,8 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.ui.Messages; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import git4idea.validators.GitNewBranchNameValidator; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class StartFeatureAction extends GitflowAction { @@ -31,12 +31,12 @@ public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.startFeature(repo,featureName,new GitflowErrorsListener(myProject)); - if (result.success()){ + if (result.success()) { String startedFeatureMessage = String.format("A new branch '%s%s' was created, based on '%s'", featurePrefix, featureName, developBranch); - GitUIUtil.notifySuccess(myProject, featureName, startedFeatureMessage); + NotifyUtil.notifySuccess(myProject, featureName, startedFeatureMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/StartHotfixAction.java b/src/gitflow/actions/StartHotfixAction.java index 21b8268..e898f21 100644 --- a/src/gitflow/actions/StartHotfixAction.java +++ b/src/gitflow/actions/StartHotfixAction.java @@ -5,8 +5,8 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.ui.Messages; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import git4idea.validators.GitNewBranchNameValidator; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; public class StartHotfixAction extends GitflowAction { @@ -30,12 +30,12 @@ public void actionPerformed(AnActionEvent e) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.startHotfix(repo, hotfixName, errorLineHandler); - if (result.success()){ + if (result.success()) { String startedHotfixMessage = String.format("A new hotfix '%s%s' was created, based on '%s'", hotfixPrefix, hotfixName, masterBranch); - GitUIUtil.notifySuccess(myProject, hotfixName, startedHotfixMessage); + NotifyUtil.notifySuccess(myProject, hotfixName, startedHotfixMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/StartReleaseAction.java b/src/gitflow/actions/StartReleaseAction.java index b4e6a7d..c4cbedc 100644 --- a/src/gitflow/actions/StartReleaseAction.java +++ b/src/gitflow/actions/StartReleaseAction.java @@ -5,13 +5,10 @@ import com.intellij.openapi.progress.Task; import com.intellij.openapi.ui.Messages; import git4idea.commands.GitCommandResult; -import git4idea.repo.GitRepository; -import git4idea.util.GitUIUtil; import git4idea.validators.GitNewBranchNameValidator; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; -import java.util.ArrayList; - public class StartReleaseAction extends GitflowAction { StartReleaseAction() { @@ -32,12 +29,12 @@ public void actionPerformed(AnActionEvent e) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result= myGitflow.startRelease(repo, releaseName, errorLineHandler); - if (result.success()){ + if (result.success()) { String startedReleaseMessage = String.format("A new release '%s%s' was created, based on '%s'", releasePrefix, releaseName, developBranch); - GitUIUtil.notifySuccess(myProject, releaseName, startedReleaseMessage); + NotifyUtil.notifySuccess(myProject, releaseName, startedReleaseMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); diff --git a/src/gitflow/actions/TrackFeatureAction.java b/src/gitflow/actions/TrackFeatureAction.java index f964ab4..cf3eef7 100644 --- a/src/gitflow/actions/TrackFeatureAction.java +++ b/src/gitflow/actions/TrackFeatureAction.java @@ -1,16 +1,13 @@ package gitflow.actions; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; -import git4idea.GitVcs; import git4idea.commands.GitCommandResult; import git4idea.repo.GitRemote; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; import gitflow.ui.GitflowBranchChooseDialog; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -52,13 +49,12 @@ public void actionPerformed(AnActionEvent e) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.trackFeature(repo, featureName, remote, errorLineHandler); - if (result.success()){ + if (result.success()) { String trackedFeatureMessage = String.format("A new branch '%s%s' was created", featurePrefix, featureName); - GitUIUtil.notifySuccess(myProject, featureName, trackedFeatureMessage); - + NotifyUtil.notifySuccess(myProject, featureName, trackedFeatureMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); @@ -67,8 +63,8 @@ public void run(@NotNull ProgressIndicator indicator) { }.queue(); } } - else{ - new Notification(GitVcs.IMPORTANT_ERROR_NOTIFICATION.getDisplayId(), "Error", "No remote branches", NotificationType.ERROR).notify(myProject); + else { + NotifyUtil.notifyError(myProject, "Error", "No remote branches"); } } diff --git a/src/gitflow/actions/TrackReleaseAction.java b/src/gitflow/actions/TrackReleaseAction.java index 3e1b351..ad33a06 100644 --- a/src/gitflow/actions/TrackReleaseAction.java +++ b/src/gitflow/actions/TrackReleaseAction.java @@ -1,15 +1,12 @@ package gitflow.actions; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.Task; -import git4idea.GitVcs; import git4idea.commands.GitCommandResult; -import git4idea.util.GitUIUtil; import gitflow.GitflowConfigUtil; import gitflow.ui.GitflowBranchChooseDialog; +import gitflow.ui.NotifyUtil; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -50,12 +47,12 @@ public void actionPerformed(AnActionEvent e) { public void run(@NotNull ProgressIndicator indicator) { GitCommandResult result = myGitflow.trackRelease(repo, releaseName, errorLineHandler); - if (result.success()){ + if (result.success()) { String trackedReleaseMessage = String.format(" A new remote tracking branch '%s%s' was created", releasePrefix, releaseName); - GitUIUtil.notifySuccess(myProject, releaseName, trackedReleaseMessage); + NotifyUtil.notifySuccess(myProject, releaseName, trackedReleaseMessage); } - else{ - GitUIUtil.notifyError(myProject,"Error","Please have a look at the Version Control console for more details"); + else { + NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details"); } repo.update(); @@ -63,8 +60,8 @@ public void run(@NotNull ProgressIndicator indicator) { }.queue(); } } - else{ - new Notification(GitVcs.IMPORTANT_ERROR_NOTIFICATION.getDisplayId(), "Error", "No remote branches", NotificationType.ERROR).notify(myProject); + else { + NotifyUtil.notifyError(myProject, "Error", "No remote branches"); } } diff --git a/src/gitflow/ui/GitflowWidget.java b/src/gitflow/ui/GitflowWidget.java index 9f9b1dd..ff4555d 100644 --- a/src/gitflow/ui/GitflowWidget.java +++ b/src/gitflow/ui/GitflowWidget.java @@ -15,6 +15,7 @@ */ package gitflow.ui; +import com.intellij.openapi.actionSystem.ActionGroup; import com.intellij.openapi.actionSystem.impl.SimpleDataContext; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.fileEditor.FileEditorManager; @@ -26,13 +27,12 @@ import com.intellij.openapi.wm.impl.status.EditorBasedWidget; import com.intellij.ui.popup.PopupFactoryImpl; import com.intellij.util.Consumer; -import com.intellij.openapi.actionSystem.ActionGroup; import git4idea.GitUtil; import git4idea.branch.GitBranchUtil; -import gitflow.actions.GitflowActions; import git4idea.repo.GitRepository; import git4idea.repo.GitRepositoryChangeListener; import git4idea.ui.branch.GitBranchWidget; +import gitflow.actions.GitflowActions; import org.jetbrains.annotations.NotNull; import java.awt.event.MouseEvent; diff --git a/src/gitflow/ui/NotifyUtil.java b/src/gitflow/ui/NotifyUtil.java new file mode 100644 index 0000000..81798fa --- /dev/null +++ b/src/gitflow/ui/NotifyUtil.java @@ -0,0 +1,33 @@ +package gitflow.ui; + +import com.intellij.notification.NotificationDisplayType; +import com.intellij.notification.NotificationGroup; +import com.intellij.notification.NotificationType; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.ToolWindowId; + +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 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); + } +}