From 7ccaf40a0a4b684a7e8af08ee0adaf0231c8197f Mon Sep 17 00:00:00 2001 From: pq Date: Thu, 12 Jun 2025 14:45:47 -0700 Subject: [PATCH] [fix] `RestartFlutterDaemonAction` menu item rendering in the device selector --- .../flutter/actions/DeviceSelectorAction.java | 2 +- .../actions/RestartFlutterDaemonAction.java | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/flutter-idea/src/io/flutter/actions/DeviceSelectorAction.java b/flutter-idea/src/io/flutter/actions/DeviceSelectorAction.java index 615bdfc844..0673d2c395 100644 --- a/flutter-idea/src/io/flutter/actions/DeviceSelectorAction.java +++ b/flutter-idea/src/io/flutter/actions/DeviceSelectorAction.java @@ -202,7 +202,7 @@ private void updateActions(@NotNull Project project, Presentation presentation) } if (!FlutterModuleUtils.hasInternalDartSdkPath(project)) { actions.add(new Separator()); - actions.add(new RestartFlutterDaemonAction()); + actions.add(RestartFlutterDaemonAction.forDeviceSelector()); } ActivityTracker.getInstance().inc(); } diff --git a/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java b/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java index e429b83d27..6f41721275 100644 --- a/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java +++ b/flutter-idea/src/io/flutter/actions/RestartFlutterDaemonAction.java @@ -9,10 +9,38 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.NlsActions; +import icons.FlutterIcons; import io.flutter.run.daemon.DeviceService; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; public class RestartFlutterDaemonAction extends AnAction { + + /** + * Create a `RestartFlutterDaemonAction` for presentation in the device selector. + */ + public static RestartFlutterDaemonAction forDeviceSelector() { + return new RestartFlutterDaemonAction("Restart Flutter Daemon", FlutterIcons.Flutter); + } + + /** + * A default constructor, invoked by plugin.xml contributions. + */ + RestartFlutterDaemonAction() { + super(); + } + + /** + * A constructor for dynamic invocation. + */ + private RestartFlutterDaemonAction(@Nullable @NlsActions.ActionText String text, + @Nullable Icon icon) { + super(text, text, icon); + } + @Override public void actionPerformed(AnActionEvent event) { final Project project = event.getProject();