Skip to content

Fix for #6171 #8220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ Wagner Silvestre <[email protected]>
Eli Albert <[email protected]>
Mohamed El Sayed <[email protected]>
Edwin Ludik <[email protected]>
Japnit Singh <[email protected]>
2 changes: 2 additions & 0 deletions flutter-idea/src/io/flutter/run/LaunchState.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import io.flutter.run.daemon.DaemonConsoleView;
import io.flutter.run.daemon.DeviceService;
import io.flutter.run.daemon.FlutterApp;
import io.flutter.toolwindow.ToolWindowBadgeUpdater;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -156,6 +157,7 @@ protected RunContentDescriptor launch(@NotNull ExecutionEnvironment env) throws
final FlutterLaunchMode launchMode = FlutterLaunchMode.fromEnv(env);
final RunContentDescriptor descriptor;
if (launchMode.supportsDebugConnection()) {
ToolWindowBadgeUpdater.updateBadgedIcon(app, project);
descriptor = createDebugSession(env, app, result).getRunContentDescriptor();
}
else {
Expand Down
56 changes: 56 additions & 0 deletions flutter-idea/src/io/flutter/toolwindow/ToolWindowBadgeUpdater.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2025 The Chromium Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
package io.flutter.toolwindow;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowId;
import com.intellij.openapi.wm.ToolWindowManager;
import com.intellij.ui.BadgeIcon;
import io.flutter.run.common.RunMode;
import io.flutter.run.daemon.FlutterApp;

import java.awt.Color;
import java.awt.Paint;
import java.util.Objects;
import javax.swing.Icon;

public class ToolWindowBadgeUpdater {
public static final Paint BADGE_PAINT = Color.decode("#5ca963");

/**
* Updates the tool window icons for RUN or DEBUG mode with a green badge.
*
* @param app The FlutterApp instance running in a given mode.
* @param project The current IntelliJ project context.
*/
public static void updateBadgedIcon(FlutterApp app, Project project) {
final ToolWindowManager manager = ToolWindowManager.getInstance(Objects.requireNonNull(project));
final ToolWindow runToolWindow = manager.getToolWindow(ToolWindowId.RUN);
final ToolWindow debugToolWindow = manager.getToolWindow(ToolWindowId.DEBUG);

if(Objects.requireNonNull(app).getMode() == RunMode.RUN) {
if (runToolWindow != null) {
manager.invokeLater(() -> {
Icon baseIcon = AllIcons.Toolwindows.ToolWindowRun;
BadgeIcon iconWithBadge = new BadgeIcon(baseIcon, BADGE_PAINT);

runToolWindow.setIcon(iconWithBadge);
});
}
}
else if(app.getMode() == RunMode.DEBUG) {
manager.invokeLater(() -> {
Icon baseIcon = AllIcons.Toolwindows.ToolWindowDebugger;
BadgeIcon iconWithBadge = new BadgeIcon(baseIcon, BADGE_PAINT);

Objects.requireNonNull(debugToolWindow).setIcon(iconWithBadge);
});
}

}
}