-
Notifications
You must be signed in to change notification settings - Fork 133
IEP-1754 Run ESP-IDF version detection asynchronously with progress reporting #1445
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,7 +6,12 @@ | |||||||||||||||
|
|
||||||||||||||||
| import java.util.List; | ||||||||||||||||
| import java.util.concurrent.CompletableFuture; | ||||||||||||||||
| import java.util.concurrent.Executors; | ||||||||||||||||
|
|
||||||||||||||||
| import org.eclipse.core.runtime.IProgressMonitor; | ||||||||||||||||
| import org.eclipse.core.runtime.IStatus; | ||||||||||||||||
| import org.eclipse.core.runtime.Status; | ||||||||||||||||
| import org.eclipse.core.runtime.jobs.Job; | ||||||||||||||||
| import org.eclipse.core.runtime.preferences.IEclipsePreferences; | ||||||||||||||||
| import org.eclipse.core.runtime.preferences.InstanceScope; | ||||||||||||||||
| import org.eclipse.jface.layout.TableColumnLayout; | ||||||||||||||||
|
|
@@ -81,16 +86,14 @@ private record IdfRow(IdfInstalled original, boolean isActive, String version, S | |||||||||||||||
| private EimJson eimJson; | ||||||||||||||||
|
|
||||||||||||||||
| private final EimIdfConfiguratinParser configParser; | ||||||||||||||||
| private final ToolInitializer toolInitializer; | ||||||||||||||||
|
|
||||||||||||||||
| private final IDFConsole idfConsole = new IDFConsole(); | ||||||||||||||||
| private IdfInstalled currentInstallingNode = null; | ||||||||||||||||
|
|
||||||||||||||||
| public ESPIDFMainTablePage(EimJson eimJson) | ||||||||||||||||
| { | ||||||||||||||||
| this.eimJson = eimJson; | ||||||||||||||||
| this.configParser = new EimIdfConfiguratinParser(); | ||||||||||||||||
| this.toolInitializer = new ToolInitializer(InstanceScope.INSTANCE.getNode(UIPlugin.PLUGIN_ID)); | ||||||||||||||||
| new ToolInitializer(InstanceScope.INSTANCE.getNode(UIPlugin.PLUGIN_ID)); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public Composite createPage(Composite parent) | ||||||||||||||||
|
|
@@ -423,44 +426,62 @@ public void refreshEditorUI() | |||||||||||||||
| if (container == null || container.isDisposed()) | ||||||||||||||||
| return; | ||||||||||||||||
|
|
||||||||||||||||
| CompletableFuture.supplyAsync(() -> { | ||||||||||||||||
| try | ||||||||||||||||
| Job refreshJob = new Job(Messages.ESPIDFMainTablePage_RefreshingIdfJobName) | ||||||||||||||||
| { | ||||||||||||||||
| @Override | ||||||||||||||||
| protected IStatus run(IProgressMonitor monitor) | ||||||||||||||||
| { | ||||||||||||||||
| var newJson = configParser.getEimJson(true); | ||||||||||||||||
| if (newJson != null && newJson.getIdfInstalled() != null) | ||||||||||||||||
| monitor.beginTask(Messages.ESPIDFMainTablePage_ScanningProcessTaskName, IProgressMonitor.UNKNOWN); | ||||||||||||||||
|
|
||||||||||||||||
| try | ||||||||||||||||
| { | ||||||||||||||||
| var gitPath = newJson.getGitPath(); | ||||||||||||||||
| return newJson.getIdfInstalled().stream() | ||||||||||||||||
| .map(idf -> new IdfRow(idf, ToolsUtility.isIdfInstalledActive(idf), | ||||||||||||||||
| ToolsUtility.getIdfVersion(idf, gitPath), idf.getName(), idf.getPath())) | ||||||||||||||||
| .toList(); | ||||||||||||||||
| var newJson = configParser.getEimJson(true); | ||||||||||||||||
| List<IdfRow> rows = List.of(); | ||||||||||||||||
|
|
||||||||||||||||
| if (newJson != null && newJson.getIdfInstalled() != null) | ||||||||||||||||
| { | ||||||||||||||||
| var gitPath = newJson.getGitPath(); | ||||||||||||||||
|
|
||||||||||||||||
| monitor.subTask(Messages.ESPIDFMainTablePage_DetectingEspIdfSubTaskName); | ||||||||||||||||
|
|
||||||||||||||||
| try (var executor = Executors.newVirtualThreadPerTaskExecutor()) | ||||||||||||||||
| { | ||||||||||||||||
| var futures = newJson.getIdfInstalled().stream().map(idf -> CompletableFuture.supplyAsync( | ||||||||||||||||
| () -> new IdfRow(idf, ToolsUtility.isIdfInstalledActive(idf), | ||||||||||||||||
| ToolsUtility.getIdfVersion(idf, gitPath), idf.getName(), idf.getPath()), | ||||||||||||||||
| executor)).toList(); | ||||||||||||||||
|
|
||||||||||||||||
| rows = futures.stream().map(CompletableFuture::join).toList(); | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| final List<IdfRow> finalRows = rows; | ||||||||||||||||
|
|
||||||||||||||||
| Display.getDefault().asyncExec(() -> { | ||||||||||||||||
| if (container.isDisposed()) | ||||||||||||||||
| return; | ||||||||||||||||
|
|
||||||||||||||||
| var currentSelection = tableViewer.getSelection(); | ||||||||||||||||
| currentInstallingNode = null; | ||||||||||||||||
|
|
||||||||||||||||
| tableViewer.setInput(finalRows); | ||||||||||||||||
| tableViewer.setSelection(currentSelection); | ||||||||||||||||
| updateButtonState(); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| return Status.OK_STATUS; | ||||||||||||||||
| } | ||||||||||||||||
| catch (Exception e) | ||||||||||||||||
| { | ||||||||||||||||
| Logger.log(e); | ||||||||||||||||
| return new Status(IStatus.ERROR, UIPlugin.PLUGIN_ID, Messages.ESPIDFMainTablePage_FailderRefreshMsg, e); | ||||||||||||||||
| } finally | ||||||||||||||||
| { | ||||||||||||||||
| monitor.done(); | ||||||||||||||||
|
Comment on lines
+478
to
+480
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Match the project brace style for The repository formatter requires block braces on the next line; split 🎨 Proposed formatting fix- } finally
+ }
+ finally
{
monitor.done();📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||
| } | ||||||||||||||||
| return List.<IdfRow>of(); | ||||||||||||||||
| } | ||||||||||||||||
| catch (Exception e) | ||||||||||||||||
| { | ||||||||||||||||
| throw new RuntimeException(e); | ||||||||||||||||
| } | ||||||||||||||||
| }).thenAcceptAsync(rows -> { | ||||||||||||||||
| if (container.isDisposed()) | ||||||||||||||||
| return; | ||||||||||||||||
| var currentSelection = tableViewer.getSelection(); | ||||||||||||||||
| this.currentInstallingNode = null; | ||||||||||||||||
| try | ||||||||||||||||
| { | ||||||||||||||||
| this.eimJson = configParser.getEimJson(false); | ||||||||||||||||
| } | ||||||||||||||||
| catch (Exception e) | ||||||||||||||||
| { | ||||||||||||||||
| Logger.log(e.toString()); | ||||||||||||||||
| } | ||||||||||||||||
| tableViewer.setInput(rows); | ||||||||||||||||
| tableViewer.setSelection(currentSelection); | ||||||||||||||||
| updateButtonState(); | ||||||||||||||||
| }, Display.getDefault()::asyncExec).exceptionally(ex -> { | ||||||||||||||||
| Logger.log(ex.getCause() != null ? ex.getCause().toString() : ex.toString()); | ||||||||||||||||
| return null; | ||||||||||||||||
| }); | ||||||||||||||||
| }; | ||||||||||||||||
| refreshJob.schedule(); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| public void setupInitialEspIdf() | ||||||||||||||||
|
|
||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep
eimJsonsynchronized with the refreshed configuration.Rows are rebuilt from
newJson, butperformToolsSetup()still uses the staleeimJsonfield when creatingSetupToolsInIde. Refresh the field on the UI thread before exposing the new rows.🐛 Proposed fix
🤖 Prompt for AI Agents