Skip to content

DirectoryProjectProvider with GenericProject impl and DirectoryGroup replacement - #9737

Draft
mbien wants to merge 28 commits into
apache:masterfrom
mbien:dir-project-group
Draft

mbien wants to merge 28 commits into
apache:masterfrom
mbien:dir-project-group

Conversation

@mbien

@mbien mbien commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

This PR builds on top of #9736 and contains SPI and API for directory projects in the first two commits and several features/actions which were either migrated or added to use that new API

Only commits prefixed with [2] are meant for this PR

API:

  • DirectoryProjectProvider SPI added with GpDirectoryProjectProvider as reference impl

  • Single method interface defines a single createProject(FileObject dir) method and is located in ide/projectuiapi

  • ProjectManager has now a new API method findOrCreateDirProject()

  • e156ee6 Add DirectoryProjectProvider SPI

  • 84bf4bd Add ProjectManager.findOrCreateDirProject

Refactors the directory-based project group action to use the new generic project type as base, combined with the pre-existing SubprojectsGroup. (see #9738 for generated design doc)

-> Relationship is now reversed. Functionality moved into the Lookup instead of hardcoded logic within a specialized Group impl. (could be potentially swapped out if needed)

Migration path was added to restore groups (old user config) of kind directory as generic project based SubprojectsGroup.

Right click menu action integration + Open Project dialog integration

  • 287467c Open as Generic Project action
  • 0e1d853 Add Open Directory as Project checkbox

Assisted-by: qwen3.8-27b + granite4.2:8b

screenshots

Open as Generic Project (active on all folders which aren't projects yet)
image

Open Project dialog:
image

@mbien mbien added Editor ci:all-tests [ci] enable all tests ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Oct 21, 2026
@neilcsmith-net

neilcsmith-net commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Thanks. Generally going in the right direction in my opinion. Initial comments after quick glance through -

  • DirectoryProjectProvider should probably be an SPI in projectapi in https://github.com/apache/netbeans/tree/master/ide/projectapi/src/org/netbeans/spi/project The docs should be more general, and not special case groups - there are other potential use cases (at least one in the fallback PR).
  • The SPI method might be better named something like findOrCreateProject to convey what it does? On the other hand, depends what the API side does ....
  • General usage of the SPI should be via the project API, possibly ProjectManager::findOrCreateProject adjacent to ProjectManager::findProject ? Groups should use this via the API.
  • The API should use lookup all, first wins, to support 0, 1 or multiple DirectoryProjectProvider implementations.
  • Directory groups should probably not fail if no provider is available - one hiding mechanism is disabling / excluding the generic project module. The feature should not break if that is done.

@mbien mbien removed the ci:all-tests [ci] enable all tests label Oct 29, 2026
@mbien
mbien force-pushed the dir-project-group branch from 5fb379f to f545faf Compare October 29, 2026 15:11
@mbien

mbien commented Oct 29, 2026 •

Copy link
Copy Markdown
Member Author

changes:

  • rebase
  • API in ProjectManager.findOrCreateDirProject() - still thinking how to make the method less powerful since it does too much atm -> might not be its final form
  • refactored everything to use that API, moved the open-folder-as-project action to its destination (next to its inverse action open-project-of-folder; we have also the option to merge both)
  • regenerated Directory groups → Generic Project ("dirproject") #9738

i think that would be the first 4 points of #9737 (comment). Forgot about 5, next sync maybe.

remember that only the commits marked with [2] are for this PR since it contains another pr. Githup lets you select commits with the all-commits button in the files-changed tab.

@neilcsmith-net

neilcsmith-net commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Thanks for taking on board the comments. This is looking exciting! Will take a deeper dive into the code and test some things as soon as I can.

API in ProjectManager.findOrCreateDirProject() - still thinking how to make the method less powerful since it does too much atm -> might not be its final form

I'm still trying to understand your concern here (following on from conversation elsewhere). My initial view looking at the updated code, in particular the action, is that is might actually handle one more thing - clearing the non-project cache when required. That feels like an implementation detail that a consumer of this method shouldn't need to consider. If it's actually needed?!

Comment on lines +158 to +168
Project existing = findProject(projectDirectory);
if (existing != null) {
return existing;
}
for (DirectoryProjectProvider provider : Lookup.getDefault().lookupAll(DirectoryProjectProvider.class)) {
Project project = provider.createProject(projectDirectory);
if (project != null) {
return project;
}
}
return null;

@mbien mbien Oct 29, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assuming we keep this this way: we could probably move this whole section into a default method in impl which is a constant of type ProjectManagerImplementaiton (yes its an interface despite its name)

since there can be never enough abstraction layers between the client and the impl. This would be layer 3 I believe.

@mbien
mbien force-pushed the dir-project-group branch from f545faf to 0e1d853 Compare November 27, 2026 18:39
@mbien

mbien commented Nov 27, 2026

Copy link
Copy Markdown
Member Author

rebased and restructured this PR so that all changes follow the API commit, updated description and added screenshots.

mbien and others added 10 commits November 27, 2026 20:01
Consulted when a directory is about to become a group in the
projects view, before falling back to the stock group; an
implementation may promote it to a project of its own type,
per-user and non-intrusively.
Returns the project existing in a directory, or asks the registered
DirectoryProjectProvider instances to create one; null if no
provider claims the directory.
GenericProject.promoteToProject() promotes a directory per-user and
non-intrusively (no marker file in the directory); the new group is
shown as the subprojects group of the promoted project.
On load, a legacy directory group is turned into a subprojects group,
resolving its directory to a project (promoting it if needed);
DirectoryGroup and its edit panel are removed.
New "Open Directory as Project" checkbox in the project chooser,
persisted like the sibling options and off by default. While it is
checked, OK/Enter accepts a non-project directory and promotes it
via ProjectManager.findOrCreateDirProject() (a per-user promotion
that writes no marker file into the directory). The checkbox is
disabled while the selection contains projects only, so Enter keeps
its drill-in behaviour for arbitrary folders.

Co-authored-by: Jaroslav Tulach <[email protected]>
@mbien
mbien force-pushed the dir-project-group branch from 0e1d853 to 5e3f29c Compare November 27, 2026 21:07
}
Project p = null;
try {
p = ProjectManager.getDefault().findProject(child);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neilcsmith-net

Copy link
Copy Markdown
Member

Generally looking good, thanks! Minor concern with the new checkbox and action in the platform. Can we automatically hide these if no directory project provider is registered? Or, as action can already be hidden, maybe we just need a way to brand which checkboxes can show in the Open Project dialog?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants