Skip to content

Commit 49e585b

Browse files
authored
[fix] RestartFlutterDaemonAction menu item rendering in the device selector (#8266)
Programmatic invocation of the default constructor was creating an instance that didn't have the benefit of having text and icon set by the `plugin.xml` contribution. This adds a new "factory" method (kinda) for dynamic creations. ![image](https://github.com/user-attachments/assets/11a1eb80-8b92-4be2-95f5-cef375bcefea) Fixes: #8264 --- - [x] I’ve reviewed the contributor guide and applied the relevant portions to this PR. <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview) for general expectations for PRs. - Larger or significant changes should be discussed in an issue before creating a PR. - Dart contributions to our repos should follow the [Dart style guide](https://dart.dev/guides/language/effective-dart) and use `dart format`. - Java and Kotlin contributions should strive to follow Java and Kotlin best practices ([discussion](#8098)). </details>
1 parent 27f9ebb commit 49e585b

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

flutter-idea/src/io/flutter/actions/DeviceSelectorAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private void updateActions(@NotNull Project project, Presentation presentation)
202202
}
203203
if (!FlutterModuleUtils.hasInternalDartSdkPath(project)) {
204204
actions.add(new Separator());
205-
actions.add(new RestartFlutterDaemonAction());
205+
actions.add(RestartFlutterDaemonAction.forDeviceSelector());
206206
}
207207
ActivityTracker.getInstance().inc();
208208
}

flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,38 @@
99
import com.intellij.openapi.actionSystem.AnAction;
1010
import com.intellij.openapi.actionSystem.AnActionEvent;
1111
import com.intellij.openapi.project.Project;
12+
import com.intellij.openapi.util.NlsActions;
13+
import icons.FlutterIcons;
1214
import io.flutter.run.daemon.DeviceService;
1315
import org.jetbrains.annotations.NotNull;
16+
import org.jetbrains.annotations.Nullable;
17+
18+
import javax.swing.*;
1419

1520
public class RestartFlutterDaemonAction extends AnAction {
21+
22+
/**
23+
* Create a `RestartFlutterDaemonAction` for presentation in the device selector.
24+
*/
25+
public static RestartFlutterDaemonAction forDeviceSelector() {
26+
return new RestartFlutterDaemonAction("Restart Flutter Daemon", FlutterIcons.Flutter);
27+
}
28+
29+
/**
30+
* A default constructor, invoked by plugin.xml contributions.
31+
*/
32+
RestartFlutterDaemonAction() {
33+
super();
34+
}
35+
36+
/**
37+
* A constructor for dynamic invocation.
38+
*/
39+
private RestartFlutterDaemonAction(@Nullable @NlsActions.ActionText String text,
40+
@Nullable Icon icon) {
41+
super(text, text, icon);
42+
}
43+
1644
@Override
1745
public void actionPerformed(AnActionEvent event) {
1846
final Project project = event.getProject();

0 commit comments

Comments
 (0)