|
1 | 1 | package gitflow; |
2 | 2 |
|
| 3 | +import com.intellij.openapi.application.ApplicationManager; |
3 | 4 | import com.intellij.openapi.components.ProjectComponent; |
4 | 5 | import com.intellij.openapi.project.Project; |
5 | 6 | import com.intellij.openapi.vcs.ProjectLevelVcsManager; |
6 | 7 | import com.intellij.openapi.vcs.VcsListener; |
7 | 8 | import com.intellij.openapi.vcs.VcsRoot; |
8 | 9 | import com.intellij.openapi.wm.StatusBar; |
| 10 | +import com.intellij.openapi.wm.StatusBarWidget; |
9 | 11 | import com.intellij.openapi.wm.WindowManager; |
10 | 12 | import com.intellij.util.messages.MessageBus; |
11 | 13 | import git4idea.GitVcs; |
| 14 | +import gitflow.ui.GitflowUnsupportedVersionWidget; |
12 | 15 | import gitflow.ui.GitflowWidget; |
13 | 16 | import org.jetbrains.annotations.NotNull; |
14 | 17 |
|
| 18 | + |
15 | 19 | /** |
16 | 20 | * @author Opher Vishnia / opherv.com / opherv@gmail.com |
17 | 21 | */ |
@@ -48,25 +52,32 @@ public void projectClosed() { |
48 | 52 |
|
49 | 53 | @Override |
50 | 54 | public void directoryMappingChanged() { |
51 | | - VcsRoot[] vcsRoots=ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots(); |
| 55 | + VcsRoot[] vcsRoots = ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots(); |
| 56 | + StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); |
52 | 57 |
|
53 | 58 | //git repo present |
54 | | - if (vcsRoots.length>0 && vcsRoots[0].getVcs() instanceof GitVcs){ |
| 59 | + if (vcsRoots.length > 0 && vcsRoots[0].getVcs() instanceof GitVcs) { |
| 60 | + |
| 61 | + |
| 62 | + StatusBarWidget widgetToAdd; |
55 | 63 |
|
56 | 64 | //make sure to not reinitialize the widget if it's already present |
57 | | - if (myGitflowWidget == null) { |
| 65 | + if (GitflowVersionTester.isSupportedVersion() && myGitflowWidget == null) { |
58 | 66 | myGitflowWidget = new GitflowWidget(myProject); |
59 | | - StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); |
60 | | - if (statusBar != null) { |
61 | | - statusBar.addWidget(myGitflowWidget, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject); |
62 | | - } |
| 67 | + widgetToAdd = (StatusBarWidget) myGitflowWidget; |
| 68 | + } else { |
| 69 | + widgetToAdd = new GitflowUnsupportedVersionWidget(myProject); |
63 | 70 | } |
64 | | - } |
65 | | - else{ |
66 | | - if (myGitflowWidget!=null){ |
| 71 | + |
| 72 | + if (statusBar != null) { |
| 73 | + statusBar.addWidget(widgetToAdd, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject); |
| 74 | + } |
| 75 | + } else { |
| 76 | + if (myGitflowWidget != null) { |
67 | 77 | myGitflowWidget.deactivate(); |
68 | 78 | } |
69 | 79 | myGitflowWidget = null; |
70 | 80 | } |
71 | 81 | } |
| 82 | + |
72 | 83 | } |
0 commit comments