16
16
package gitflow .ui ;
17
17
18
18
import com .intellij .ide .BrowserUtil ;
19
+ import com .intellij .ide .DataManager ;
20
+ import com .intellij .openapi .actionSystem .DataContext ;
19
21
import com .intellij .openapi .actionSystem .impl .SimpleDataContext ;
20
22
import com .intellij .openapi .application .ApplicationManager ;
21
23
import com .intellij .openapi .fileEditor .FileEditorManager ;
25
27
import com .intellij .openapi .ui .Messages ;
26
28
import com .intellij .openapi .ui .popup .ListPopup ;
27
29
import com .intellij .openapi .vfs .VirtualFile ;
30
+ import com .intellij .openapi .wm .IdeFocusManager ;
28
31
import com .intellij .openapi .wm .StatusBar ;
29
32
import com .intellij .openapi .wm .StatusBarWidget ;
30
33
import com .intellij .openapi .wm .WindowManager ;
34
+ import com .intellij .openapi .wm .impl .status .EditorBasedWidget ;
31
35
import com .intellij .ui .awt .RelativePoint ;
32
36
import com .intellij .ui .popup .PopupFactoryImpl ;
33
37
import com .intellij .util .Consumer ;
34
38
import com .intellij .openapi .vcs .VcsRoot ;
35
39
import com .intellij .openapi .vcs .ProjectLevelVcsManager ;
36
40
37
- import gitflow .GitflowBranchUtil ;
38
- import gitflow .GitflowBranchUtilManager ;
39
- import gitflow .GitflowVersionTester ;
41
+ import git4idea .GitBranch ;
42
+ import gitflow .*;
40
43
import gitflow .actions .GitflowPopupGroup ;
41
44
import org .jetbrains .annotations .NotNull ;
42
45
import org .jetbrains .annotations .Nullable ;
@@ -107,9 +110,10 @@ public void repositoryChanged(@NotNull GitRepository repository) {
107
110
}
108
111
109
112
@ Nullable
110
- @ Override
113
+ @ Override
111
114
public ListPopup getPopupStep () {
112
- Project project = getProject ();
115
+ Project project = IDEAUtils .getActiveProject ();
116
+
113
117
if (project == null ) {
114
118
return null ;
115
119
}
@@ -118,7 +122,17 @@ public ListPopup getPopupStep() {
118
122
return null ;
119
123
}
120
124
121
- ListPopup listPopup = new PopupFactoryImpl .ActionGroupPopup ("Gitflow Actions" , popupGroup .getActionGroup (), SimpleDataContext .getProjectContext (project ), false , false , false , true , null , -1 ,
125
+ Component focusOwner = KeyboardFocusManager .getCurrentKeyboardFocusManager ().getFocusOwner ();
126
+ if (focusOwner == null ) {
127
+ IdeFocusManager focusManager = IdeFocusManager .getInstance (project );
128
+ Window frame = focusManager .getLastFocusedIdeWindow ();
129
+ if (frame != null ) {
130
+ focusOwner = focusManager .getLastFocusedFor (frame );
131
+ }
132
+ }
133
+
134
+ DataContext dataContext = DataManager .getInstance ().getDataContext (focusOwner );
135
+ ListPopup listPopup = new PopupFactoryImpl .ActionGroupPopup ("Gitflow Actions" , popupGroup .getActionGroup (), dataContext , false , false , false , true , null , -1 ,
122
136
null , null );
123
137
124
138
return listPopup ;
0 commit comments