Skip to content

Commit 931d23a

Browse files
authored
[CQ] de-duplicate panel label replacement logic (#8232)
Opportunistic de-duplication. --- - [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 f3e7eeb commit 931d23a

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

flutter-idea/src/io/flutter/view/EmbeddedBrowser.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,7 @@ protected void showLabels(List<LabelInput> labels, ContentManager contentManager
207207
}
208208

209209
private void replacePanelLabel(JComponent label, ContentManager contentManager) {
210-
OpenApiUtils.safeInvokeLater(() -> {
211-
if (contentManager.isDisposed()) {
212-
return;
213-
}
214-
215-
final JPanel panel = new JPanel(new BorderLayout());
216-
panel.add(label, BorderLayout.CENTER);
217-
final Content content = contentManager.getFactory().createContent(panel, null, false);
218-
contentManager.removeAllContents(true);
219-
contentManager.addContent(content);
220-
});
210+
new ViewUtils().replacePanelLabel(contentManager, label);
221211
}
222212

223213
private BrowserTab openBrowserTabFor(String tabName, ToolWindow toolWindow) {

flutter-idea/src/io/flutter/view/ViewUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ public void presentClickableLabel(ToolWindow toolWindow, List<LabelInput> labels
7979
}
8080

8181
public void replacePanelLabel(ToolWindow toolWindow, JComponent label) {
82+
replacePanelLabel(toolWindow.getContentManager(), label);
83+
}
84+
85+
public void replacePanelLabel(ContentManager contentManager, JComponent label) {
8286
OpenApiUtils.safeInvokeLater(() -> {
83-
final ContentManager contentManager = toolWindow.getContentManager();
8487
if (contentManager.isDisposed()) {
8588
return;
8689
}

0 commit comments

Comments
 (0)