Skip to content

Commit be3b047

Browse files
authored
Fix for #6171 (#8220)
- Added live indicator when run or debug flutter app in the tool window tab. --- - [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 41befe0 commit be3b047

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ Wagner Silvestre <[email protected]>
2424
Eli Albert <[email protected]>
2525
Mohamed El Sayed <[email protected]>
2626
Edwin Ludik <[email protected]>
27+
Japnit Singh <[email protected]>

flutter-idea/src/io/flutter/run/LaunchState.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import io.flutter.run.daemon.DaemonConsoleView;
5151
import io.flutter.run.daemon.DeviceService;
5252
import io.flutter.run.daemon.FlutterApp;
53+
import io.flutter.toolwindow.ToolWindowBadgeUpdater;
5354
import org.jetbrains.annotations.NotNull;
5455
import org.jetbrains.annotations.Nullable;
5556

@@ -156,6 +157,7 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
156157
final FlutterLaunchMode launchMode = FlutterLaunchMode.fromEnv(env);
157158
final RunContentDescriptor descriptor;
158159
if (launchMode.supportsDebugConnection()) {
160+
ToolWindowBadgeUpdater.updateBadgedIcon(app, project);
159161
descriptor = createDebugSession(env, app, result).getRunContentDescriptor();
160162
}
161163
else {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright 2025 The Chromium Authors. All rights reserved.
3+
* Use of this source code is governed by a BSD-style license that can be
4+
* found in the LICENSE file.
5+
*/
6+
package io.flutter.toolwindow;
7+
8+
import com.intellij.icons.AllIcons;
9+
import com.intellij.openapi.project.Project;
10+
import com.intellij.openapi.wm.ToolWindow;
11+
import com.intellij.openapi.wm.ToolWindowId;
12+
import com.intellij.openapi.wm.ToolWindowManager;
13+
import com.intellij.ui.BadgeIcon;
14+
import io.flutter.run.common.RunMode;
15+
import io.flutter.run.daemon.FlutterApp;
16+
17+
import java.awt.Color;
18+
import java.awt.Paint;
19+
import java.util.Objects;
20+
import javax.swing.Icon;
21+
22+
public class ToolWindowBadgeUpdater {
23+
public static final Paint BADGE_PAINT = Color.decode("#5ca963");
24+
25+
/**
26+
* Updates the tool window icons for RUN or DEBUG mode with a green badge.
27+
*
28+
* @param app The FlutterApp instance running in a given mode.
29+
* @param project The current IntelliJ project context.
30+
*/
31+
public static void updateBadgedIcon(FlutterApp app, Project project) {
32+
final ToolWindowManager manager = ToolWindowManager.getInstance(Objects.requireNonNull(project));
33+
final ToolWindow runToolWindow = manager.getToolWindow(ToolWindowId.RUN);
34+
final ToolWindow debugToolWindow = manager.getToolWindow(ToolWindowId.DEBUG);
35+
36+
if(Objects.requireNonNull(app).getMode() == RunMode.RUN) {
37+
if (runToolWindow != null) {
38+
manager.invokeLater(() -> {
39+
Icon baseIcon = AllIcons.Toolwindows.ToolWindowRun;
40+
BadgeIcon iconWithBadge = new BadgeIcon(baseIcon, BADGE_PAINT);
41+
42+
runToolWindow.setIcon(iconWithBadge);
43+
});
44+
}
45+
}
46+
else if(app.getMode() == RunMode.DEBUG) {
47+
manager.invokeLater(() -> {
48+
Icon baseIcon = AllIcons.Toolwindows.ToolWindowDebugger;
49+
BadgeIcon iconWithBadge = new BadgeIcon(baseIcon, BADGE_PAINT);
50+
51+
Objects.requireNonNull(debugToolWindow).setIcon(iconWithBadge);
52+
});
53+
}
54+
55+
}
56+
}

0 commit comments

Comments
 (0)