Repository navigation
Robust, asynchronous project loading #9680
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
jtulach
wants to merge
15
commits into
apache:master
Choose a base branch
from
jtulach:jtulach/OpenProjectLoading
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,284
−887
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
24a62f9
Separating OpenProjectLoading logic into its own class
jtulach 4a83c82
Making the ProjectsRootNodePhysicalViewTest more robust by holding pr…
jtulach 210017b
OpenProjectList.openProjects future must wait, but then return the mo…
jtulach 9160302
Recent templates shall not be handled by OpenProjectsLoading
jtulach 48cd059
No references to OpenProjectListSettings.getInstance() in OpenProject…
jtulach 2012809
Extracting communication interface to OpenProjectsLoading task
jtulach 5732822
Creating a dedicated OpenProjectOperation
jtulach 195dffb
Making OpenProjectListTest more reliable
jtulach cd28345
Request projects to open when creating OpenProjectsLoading
jtulach b2fcfde
Make sure the erasured type is Future
jtulach 0674e5c
Allow replacing projects
jtulach 89d3f90
Allow multiple calls into replaceProjects
jtulach db6c7d9
Describing intended implementation
jtulach 5a27f59
Moving comparator to its own class
jtulach b14f1e9
Can every problem be solved by another layer of indirection?
jtulach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
ide/projectui/src/org/netbeans/modules/project/ui/OpenProjectImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.netbeans.modules.project.ui; | ||
|
|
||
| import java.net.URL; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import org.netbeans.api.project.Project; | ||
| import org.openide.filesystems.FileObject; | ||
| import org.openide.util.Lookup; | ||
| import org.openide.windows.WindowManager; | ||
|
|
||
| final class OpenProjectImpl { | ||
| /** Main project */ | ||
| private Project mainProject; | ||
| /** List which holds the open projects */ | ||
| private List<Project> openProjects = List.of(); | ||
| private volatile OpenProjectOperation LOAD; | ||
|
|
||
| OpenProjectImpl() { | ||
|
|
||
| } | ||
|
|
||
| final List<Project> openProjects() { | ||
| return openProjects; | ||
| } | ||
|
|
||
| final void replaceProjectsImpl(OpenProjectsLoading.Callback callback, List<LazyProject> projects, URL mainProject, Lookup.Result<FileObject> selectedFiles) { | ||
| openProjects = new ArrayList<>(projects); | ||
| var urls = projects.stream().map(p -> p.url).toList(); | ||
| var load = new OpenProjectsLoading(callback, selectedFiles, urls, mainProject); | ||
| LOAD = load; | ||
| WindowManager.getDefault().invokeWhenUIReady(load); | ||
| } | ||
|
|
||
| boolean waitFinished(long timeout) { | ||
| return LOAD.waitFinished(timeout); | ||
| } | ||
|
|
||
| void preferredProject(Set<FileObject> singleton) { | ||
| LOAD.preferredProject(singleton); | ||
| } | ||
|
|
||
| boolean isDone() { | ||
| return LOAD.isDone(); | ||
| } | ||
|
|
||
| void enter() { | ||
| LOAD.enter(); | ||
| } | ||
|
|
||
| void exit() { | ||
| LOAD.exit(); | ||
| } | ||
|
|
||
| boolean closeBeforeOpen(Project[] someProjects) { | ||
| return LOAD.closeBeforeOpen(someProjects); | ||
| } | ||
|
|
||
| void updateGlobalState(List<Project> projects, Project mainProject) { | ||
| this.openProjects = projects; | ||
| this.mainProject = mainProject; | ||
| } | ||
|
|
||
| Project mainProject() { | ||
| return this.mainProject; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Replacement can permanently corrupt completion tracking.
exit()delegates to the current LOAD. However,close()increments the old loader before queuing close hooks, and replacement installs another loader before those hooks finish. Their completion decrements the new counter to -1, leavingisDone()false indefinitely. I reproduced this by holding the close queue during replacement and then draining it.