Skip to content

Commit 622ceea

Browse files
cj-radcliffhelin24dependabot[bot]pq
authored
Refactor combo box with browse (#384)
* Refactor combo box with browse and reset functionality * Checkpointing: Updating the code to use async file loading. Working but still throwing an exception. * Fixing EDT exception * Try 2026.1.1 (not verified) (#360) * Try 2026.1.1 (not verified) * Add java version resolver * Use newer version * Upgrade again * Use v1 * Update baselines * Fix tests by adding caret * Update kotlin * Remove old comment * Bump gradle-wrapper from 9.4.1 to 9.5.0 in /third_party (#366) Bumps [gradle-wrapper](https://github.com/gradle/gradle) from 9.4.1 to 9.5.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/gradle/gradle/releases">gradle-wrapper's releases</a>.</em></p> <blockquote> <h2>9.5.0</h2> <p>The Gradle team is excited to announce Gradle 9.5.0.</p> <p>Here are the highlights of this release:</p> <ul> <li>Task provenance in reports and failure messages</li> <li>Type-safe accessors for precompiled Kotlin Settings plugins</li> </ul> <p><a href="https://docs.gradle.org/9.5.0/release-notes.html">Read the Release Notes</a></p> <p>We would like to thank the following community members for their contributions to this release of Gradle: <a href="https://github.com/atm1020">atm1020</a>, <a href="https://github.com/mataha">mataha</a>, <a href="https://github.com/aSemy">Adam</a>, <a href="https://github.com/kelemen">Attila Kelemen</a>, <a href="https://github.com/britter">Benedikt Ritter</a>, <a href="https://github.com/Vampire">Björn Kautler</a>, <a href="https://github.com/budindepunk">Caro Silva Rode</a>, <a href="https://github.com/chanani">CHANHAN</a>, <a href="https://github.com/DmitryNez">Dmitry Nezavitin</a>, <a href="https://github.com/Juneezee">Eng Zer Jun</a>, <a href="https://github.com/KugelLibelle">KugelLibelle</a>, <a href="https://github.com/vmadalin">Madalin Valceleanu</a>, <a href="https://github.com/quijote">Markus Gaisbauer</a>, <a href="https://github.com/koppor">Oliver Kopp</a>, <a href="https://github.com/hfhbd">Philip Wedemann</a>, <a href="https://github.com/ploober">ploober</a>, <a href="https://github.com/rpalcolea">Roberto Perez Alcolea</a>, <a href="https://github.com/R0h1tAnand">Rohit Anand</a>, <a href="https://github.com/Suvrat1629">Suvrat Acharya</a>, <a href="https://github.com/usv240">Ujwal Suresh Vanjare</a>, <a href="https://github.com/urdak">Victor Merkulov</a></p> <h2>Upgrade instructions</h2> <p>Switch your build to use Gradle 9.5.0 by updating your wrapper:</p> <pre><code>./gradlew wrapper --gradle-version=9.5.0 &amp;&amp; ./gradlew wrapper </code></pre> <p>See the Gradle <a href="https://docs.gradle.org/9.5.0/userguide/upgrading_version_9.html">9.x upgrade guide</a> to learn about deprecations, breaking changes and other considerations when upgrading.</p> <p>For Java, Groovy, Kotlin and Android compatibility, see the <a href="https://docs.gradle.org/9.5.0/userguide/compatibility.html">full compatibility notes</a>.</p> <h2>Reporting problems</h2> <p>If you find a problem with this release, please file a bug on <a href="https://github.com/gradle/gradle/issues">GitHub Issues</a> adhering to our issue guidelines. If you're not sure you're encountering a bug, please use the <a href="https://discuss.gradle.org/c/help-discuss">forum</a>.</p> <p>We hope you will build happiness with Gradle, and we look forward to your feedback via <a href="https://twitter.com/gradle">Twitter</a> or on <a href="https://github.com/gradle">GitHub</a>.</p> <h2>9.5.0 RC4</h2> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/gradle/gradle/commit/3fe117d68f3907790f3809f121aa36303a9151f8"><code>3fe117d</code></a> Update jdks.yaml (<a href="https://redirect.github.com/gradle/gradle/issues/37703">#37703</a>)</li> <li><a href="https://github.com/gradle/gradle/commit/33d145af6fbe7cf7c9d84646b6d7f32fea91d5e2"><code>33d145a</code></a> Update jdks.yaml</li> <li><a href="https://github.com/gradle/gradle/commit/f7a05d1ed48442eb5da4d6e2b6593da55cdec1da"><code>f7a05d1</code></a> Update Gradle wrapper to version 9.5.0-rc-4 (<a href="https://redirect.github.com/gradle/gradle/issues/37654">#37654</a>)</li> <li><a href="https://github.com/gradle/gradle/commit/266facdcbcb0b4c60120cc118eaf0f652bfcdfe5"><code>266facd</code></a> Update Gradle wrapper to version 9.5.0-rc-4</li> <li><a href="https://github.com/gradle/gradle/commit/0ad6dd8e143455707e444aa7e3d38327a3366513"><code>0ad6dd8</code></a> Suppress OSC taskbar reset on plain/piped stdout (<a href="https://redirect.github.com/gradle/gradle/issues/37646">#37646</a>)</li> <li><a href="https://github.com/gradle/gradle/commit/966025d5850d46c9158a2f25e4096222277ecf57"><code>966025d</code></a> Suppress OSC taskbar reset on plain/piped stdout</li> <li><a href="https://github.com/gradle/gradle/commit/e7455734449e422accebf44cf7b31bf93e3a770c"><code>e745573</code></a> Polish IP docs (<a href="https://redirect.github.com/gradle/gradle/issues/37642">#37642</a>)</li> <li><a href="https://github.com/gradle/gradle/commit/d5cfd079acd2c8f1182edd6ec23dbab571132d0a"><code>d5cfd07</code></a> Ensure BuildOperationQueue will progress without extra leases (<a href="https://redirect.github.com/gradle/gradle/issues/37629">#37629</a>)</li> <li><a href="https://github.com/gradle/gradle/commit/acdf0c36fa13ba09a7ff5b51f79b9af4b1a097ee"><code>acdf0c3</code></a> Ensure BuildOperationQueue will progress without extra leases</li> <li><a href="https://github.com/gradle/gradle/commit/f7d0e4f6f7896426a8b24091388e4c252b62faef"><code>f7d0e4f</code></a> Rename anchor</li> <li>Additional commits viewable in <a href="https://github.com/gradle/gradle/compare/v9.4.1...v9.5.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=gradle-wrapper&package-manager=gradle&previous-version=9.4.1&new-version=9.5.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> * [infra] trigger kokoro builds w/ the “kokoro:run” label (#370) Fixes: #369 --- <details> <summary>Contribution guidelines:</summary><br> - See our [contributor guide]([https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md) 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](flutter/flutter-intellij#8098)). </details> * Finalizing refactor * Addressing comments in PR: #372 (comment) * Simplified logic as per PR comments * Fixing requested issues with PR * Updating to eliminate newly introduced plugin verification error * Rolling back accidental changes. * Fixing newly introduced verification error * Readding deleted comments * Removing flutter plugin to avoid any circular dependencies. * Rename DartComboBoxWithBrowseButton to BasicComboBoxWithBrowseButton * Removing the aggressive addition to checkValid calls * Rolling back restart because it is deprecated and threw a verify error * updating baselines Adding windows version of update_baselines.bat * Refactor combo box with browse and reset functionality * Checkpointing: Updating the code to use async file loading. Working but still throwing an exception. * Fixing EDT exception * Finalizing refactor * Addressing comments in PR: #372 (comment) * Simplified logic as per PR comments * Fixing requested issues with PR * Updating to eliminate newly introduced plugin verification error * Rolling back accidental changes. * Fixing newly introduced verification error * Readding deleted comments * Removing flutter plugin to avoid any circular dependencies. * Rename DartComboBoxWithBrowseButton to BasicComboBoxWithBrowseButton * Removing the aggressive addition to checkValid calls * Rolling back restart because it is deprecated and threw a verify error * updating baselines Adding windows version of update_baselines.bat * reverting gradlew.bat * Updated baseline --------- Co-authored-by: Helin Shiah <helinx@google.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Phil Quitslund <pq@users.noreply.github.com>
1 parent 95cba90 commit 622ceea

15 files changed

Lines changed: 406 additions & 382 deletions

third_party/gradlew.bat

Lines changed: 82 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third_party/src/main/java/com/jetbrains/lang/dart/ide/runner/server/ui/DartRemoteDebugConfigurationEditor.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<text resource-bundle="messages/DartBundle" key="remote.debug.search.sources.in"/>
3232
</properties>
3333
</component>
34-
<component id="e3762" class="com.intellij.ui.ComboboxWithBrowseButton" binding="myDartProjectCombo">
34+
<component id="e3762" class="com.jetbrains.lang.dart.ui.BasicComboBoxWithBrowseButton" binding="myDartProjectCombo" custom-create="true">
3535
<constraints>
3636
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
3737
<minimum-size width="100" height="-1"/>

third_party/src/main/java/com/jetbrains/lang/dart/ide/runner/server/ui/DartRemoteDebugConfigurationEditor.java

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
22
package com.jetbrains.lang.dart.ide.runner.server.ui;
33

4+
import com.intellij.openapi.application.ModalityState;
5+
import com.intellij.openapi.application.ReadAction;
46
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
57
import com.intellij.openapi.options.SettingsEditor;
8+
import com.intellij.openapi.progress.ProgressManager;
69
import com.intellij.openapi.project.Project;
710
import com.intellij.openapi.roots.ProjectRootManager;
8-
import com.intellij.openapi.ui.TextComponentAccessor;
911
import com.intellij.openapi.util.io.FileUtil;
1012
import com.intellij.openapi.vfs.LocalFileSystem;
1113
import com.intellij.openapi.vfs.VirtualFile;
1214
import com.intellij.psi.search.FileTypeIndex;
1315
import com.intellij.psi.search.FilenameIndex;
1416
import com.intellij.psi.search.GlobalSearchScope;
1517
import com.intellij.psi.search.GlobalSearchScopesCore;
16-
import com.intellij.ui.ComboboxWithBrowseButton;
1718
import com.intellij.ui.SimpleListCellRenderer;
1819
import com.intellij.ui.components.JBLabel;
20+
import com.intellij.util.concurrency.AppExecutorUtil;
21+
import com.jetbrains.lang.dart.DartBundle;
1922
import com.jetbrains.lang.dart.DartFileType;
2023
import com.jetbrains.lang.dart.ide.runner.server.DartRemoteDebugConfiguration;
2124
import com.jetbrains.lang.dart.ide.runner.server.DartRemoteDebugParameters;
25+
import com.jetbrains.lang.dart.ui.BasicComboBoxWithBrowseButton;
2226
import com.jetbrains.lang.dart.util.PubspecYamlUtil;
2327
import org.jetbrains.annotations.NotNull;
2428
import org.jetbrains.annotations.Nullable;
@@ -32,50 +36,55 @@
3236
public class DartRemoteDebugConfigurationEditor extends SettingsEditor<DartRemoteDebugConfiguration> {
3337

3438
private JPanel myMainPanel;
35-
private ComboboxWithBrowseButton myDartProjectCombo;
39+
private BasicComboBoxWithBrowseButton<NameAndPath> myDartProjectCombo;
3640
private JBLabel myHintLabel;
3741

42+
private final Project myProject;
3843
private final SortedSet<NameAndPath> myComboItems = new TreeSet<>();
3944

4045
public DartRemoteDebugConfigurationEditor(final @NotNull Project project) {
46+
myProject = project;
47+
myDartProjectCombo.addBrowseFolderListener(DartBundle.message("button.browse.dialog.title.select.dart.project.path"),
48+
myProject,
49+
FileChooserDescriptorFactory.createSingleFolderDescriptor()
50+
.withTitle(DartBundle.message("button.browse.dialog.title.select.dart.project.path")),
51+
this::resolveNameAndPath,
52+
this::applySelectedProjectPath);
4153
initDartProjectsCombo(project);
4254
myHintLabel.setCopyable(true);
4355
}
4456

4557
private void initDartProjectsCombo(final @NotNull Project project) {
46-
myDartProjectCombo.getComboBox().setRenderer(SimpleListCellRenderer.create("", NameAndPath::getPresentableText));
58+
myDartProjectCombo.setRenderer(SimpleListCellRenderer.create("", NameAndPath::getPresentableText));
4759

48-
if (!project.isDefault()) {
60+
if (project.isDefault()) return;
61+
62+
ReadAction.nonBlocking(() -> {
63+
SortedSet<NameAndPath> items = new TreeSet<>();
4964
for (VirtualFile pubspecFile : FilenameIndex.getVirtualFilesByName(PUBSPEC_YAML, GlobalSearchScope.projectScope(project))) {
50-
myComboItems.add(new NameAndPath(PubspecYamlUtil.getDartProjectName(pubspecFile), pubspecFile.getParent().getPath()));
65+
ProgressManager.checkCanceled();
66+
items.add(new NameAndPath(PubspecYamlUtil.getDartProjectName(pubspecFile), pubspecFile.getParent().getPath()));
5167
}
5268

53-
if (myComboItems.isEmpty()) {
69+
if (items.isEmpty()) {
5470
for (VirtualFile contentRoot : ProjectRootManager.getInstance(project).getContentRoots()) {
71+
ProgressManager.checkCanceled();
5572
if (FileTypeIndex.containsFileOfType(DartFileType.INSTANCE, GlobalSearchScopesCore.directoryScope(project, contentRoot, true))) {
56-
myComboItems.add(new NameAndPath(null, contentRoot.getPath()));
73+
items.add(new NameAndPath(null, contentRoot.getPath()));
5774
}
5875
}
5976
}
60-
}
61-
62-
myDartProjectCombo.getComboBox().setModel(new DefaultComboBoxModel<>(myComboItems.toArray()));
63-
64-
myDartProjectCombo.addBrowseFolderListener(
65-
project,
66-
FileChooserDescriptorFactory.createSingleFolderDescriptor(),
67-
new TextComponentAccessor<>() {
68-
@Override
69-
public String getText(final JComboBox combo) {
70-
final Object item = combo.getSelectedItem();
71-
return item instanceof NameAndPath ? ((NameAndPath)item).myPath : "";
72-
}
73-
74-
@Override
75-
public void setText(final JComboBox combo, final @NotNull String path) {
76-
setSelectedProjectPath(FileUtil.toSystemIndependentName(path));
77+
return items;
78+
})
79+
.finishOnUiThread(ModalityState.any(), items -> {
80+
final Object selectedItem = myDartProjectCombo.getSelectedItem();
81+
myComboItems.addAll(items);
82+
myDartProjectCombo.setModel(new DefaultComboBoxModel<>(myComboItems.toArray(NameAndPath[]::new)));
83+
if (selectedItem != null) {
84+
myDartProjectCombo.setSelectedItem(selectedItem);
7785
}
78-
});
86+
})
87+
.submit(AppExecutorUtil.getAppExecutorService());
7988
}
8089

8190
@Override
@@ -92,23 +101,34 @@ protected void resetEditorFrom(final @NotNull DartRemoteDebugConfiguration confi
92101
private void setSelectedProjectPath(final @NotNull String projectPath) {
93102
if (projectPath.isEmpty()) return;
94103

104+
ReadAction.nonBlocking(() -> resolveNameAndPath(projectPath))
105+
.finishOnUiThread(ModalityState.any(), this::applySelectedProjectPath)
106+
.submit(AppExecutorUtil.getAppExecutorService());
107+
}
108+
109+
private @NotNull NameAndPath resolveNameAndPath(final @NotNull String projectPath) {
95110
final VirtualFile pubspecFile = LocalFileSystem.getInstance().findFileByPath(projectPath + "/" + PUBSPEC_YAML);
96111
final String projectName = pubspecFile == null ? null : PubspecYamlUtil.getDartProjectName(pubspecFile);
97-
final NameAndPath item = new NameAndPath(projectName, projectPath);
112+
return new NameAndPath(projectName, projectPath);
113+
}
98114

115+
private void applySelectedProjectPath(final @NotNull NameAndPath item) {
99116
if (!myComboItems.contains(item)) {
100117
myComboItems.add(item);
101-
myDartProjectCombo.getComboBox().setModel(new DefaultComboBoxModel(myComboItems.toArray()));
118+
myDartProjectCombo.setModel(new DefaultComboBoxModel<>(myComboItems.toArray(NameAndPath[]::new)));
102119
}
103-
104-
myDartProjectCombo.getComboBox().setSelectedItem(item);
120+
myDartProjectCombo.setSelectedItem(item);
105121
}
106122

107123
@Override
108124
protected void applyEditorTo(final @NotNull DartRemoteDebugConfiguration config) {
109125
final DartRemoteDebugParameters params = config.getParameters();
110-
final Object selectedItem = myDartProjectCombo.getComboBox().getSelectedItem();
111-
params.setDartProjectPath(selectedItem instanceof NameAndPath ? ((NameAndPath)selectedItem).myPath : "");
126+
final Object selectedItem = myDartProjectCombo.getSelectedItem();
127+
params.setDartProjectPath(selectedItem == null ? "" : selectedItem.toString().trim());
128+
}
129+
130+
private void createUIComponents() {
131+
myDartProjectCombo = new BasicComboBoxWithBrowseButton<>();
112132
}
113133

114134
private static class NameAndPath implements Comparable<NameAndPath> {
@@ -126,7 +146,7 @@ public String getPresentableText() {
126146

127147
@Override
128148
public String toString() {
129-
return getPresentableText();
149+
return myPath;
130150
}
131151

132152
@Override

third_party/src/main/java/com/jetbrains/lang/dart/projectWizard/DartGeneratorPeer.form

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<text resource-bundle="messages/DartBundle" key="dart.sdk.path.label"/>
2626
</properties>
2727
</component>
28-
<component id="b09db" class="com.intellij.ui.ComboboxWithBrowseButton" binding="mySdkPathComboWithBrowse" custom-create="true">
28+
<component id="b09db" class="com.jetbrains.lang.dart.ui.BasicComboBoxWithBrowseButton" binding="mySdkPathComboWithBrowse" custom-create="true">
2929
<constraints>
3030
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
3131
</constraints>

0 commit comments

Comments
 (0)