File tree 1 file changed +10
-2
lines changed
flutter-idea/src/io/flutter/actions
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,15 @@ abstract public class FlutterAppAction extends DumbAwareAction {
23
23
@ NotNull private final Computable <Boolean > myIsApplicable ;
24
24
@ NotNull private final String myActionId ;
25
25
26
+ // The current action event.
27
+ private AnActionEvent myEvent ;
26
28
private final FlutterApp .FlutterAppListener myListener = new FlutterApp .FlutterAppListener () {
27
29
@ Override
28
30
public void stateChanged (FlutterApp .State newState ) {
29
- getTemplatePresentation ().setEnabled (myApp .isStarted () && myIsApplicable .compute ());
31
+ // Access the action presentation through the most recently cached action event.
32
+ if (myEvent != null ) {
33
+ myEvent .getPresentation ().setEnabled (myApp .isStarted () && Boolean .TRUE .equals (myIsApplicable .compute ()));
34
+ }
30
35
}
31
36
};
32
37
private boolean myIsListening = false ;
@@ -71,10 +76,13 @@ private void updateActionRegistration(boolean isConnected) {
71
76
public void update (@ NotNull final AnActionEvent e ) {
72
77
updateActionRegistration (myApp .isConnected ());
73
78
74
- final boolean isConnected = myIsApplicable .compute ();
79
+ final boolean isConnected = Boolean . TRUE . equals ( myIsApplicable .compute () );
75
80
final boolean supportsReload = myApp .getMode ().supportsReload ();
76
81
e .getPresentation ().setEnabled (myApp .isStarted () && isConnected && supportsReload );
77
82
83
+ // Cache the current event so that listeners can access its presentation.
84
+ myEvent = e ;
85
+
78
86
if (isConnected ) {
79
87
if (!myIsListening ) {
80
88
getApp ().addStateListener (myListener );
You can’t perform that action at this time.
0 commit comments