Show Open/Close Project for mixed selections in Project Explorer#3866
Show Open/Close Project for mixed selections in Project Explorer#3866vogella wants to merge 2 commits into
Conversation
05018be to
e1e0229
Compare
7252610 to
424a16a
Compare
424a16a to
ea62040
Compare
There was a problem hiding this comment.
Pull request overview
This PR targets Project Explorer context-menu behavior so that Open/Close Project-related actions remain visible for mixed selections (e.g., when Ctrl+A includes working set headers or other non-resource elements), aligning with the behavior requested in issue #3790.
Changes:
- Made
ResourceMgmtActionProviderenablement unconditional inplugin.xmlso the provider is invoked even for mixed/non-resource selections. - Added navigator tests covering mixed selections (projects + files, projects + non-adaptable objects, multiple open projects with child resources).
- Updated project open/close actions’ selection checks to be based on “any selected project” (stream filter) instead of
selectionIsOfType(PROJECT).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/org.eclipse.ui.tests.navigator/src/org/eclipse/ui/tests/navigator/resources/ResourceMgmtActionProviderTests.java | Adds regression coverage for mixed selections and helper methods to build arbitrary selections. |
| bundles/org.eclipse.ui.navigator.resources/plugin.xml | Changes action provider enablement to always-on (<or/>) to avoid being filtered out by mixed selections. |
| bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java | Adjusts enablement and delta-check gating to detect projects in mixed selections. |
| bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java | Adjusts delta-check gating to detect projects in mixed selections. |
| bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseResourceAction.java | Adjusts enablement and delta-check gating to detect projects in mixed selections. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ea62040 to
4d1b6f4
Compare
|
This pull request changes some projects for the first time in this development cycle. An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patchFurther information are available in Common Build Issues - Missing version increments. |
Ctrl+A in an expanded Project Explorer produces a mixed selection: projects, child files/folders, and non-adaptable elements such as working set headers. Three problems combined to hide the Open/Close Project actions in that case: 1. The ResourceMgmtActionProvider enablement expression required ALL selected elements to adapt to IResource or IWorkingSet, so the provider was never activated for mixed selections. Fixed by replacing the expression with <or/> to always activate the provider, following the UndoRedoActionProvider pattern. fillContextMenu() only adds the actions when the selection contains a project. 2. CloseResourceAction and OpenResourceAction.updateSelection() called selectionIsOfType(PROJECT), which returns false whenever any non-IResource element (e.g. a working set header) is present, even if every resource element is a valid project. Fixed by filtering getSelectedResources() down to IProject instances instead. 3. CloseUnrelatedProjectsAction.resourceChanged() had the same selectionIsOfType guard. Fixed with a stream-based project check. The actions also override getActionResources() to keep only IProject instances, so the execution paths (run() and the scheduling rule in CloseResourceAction, hasOtherClosedProjects() in OpenResourceAction) no longer cast a non-project resource to IProject for a mixed selection. getSelectedResources() stays unfiltered so CloseUnrelatedProjectsAction still keeps a selected file's project related. Adds navigator tests covering mixed selections for both enablement and for reducing the selection to projects only before the action runs. Fixes eclipse-platform#3790
8c2a2e9 to
f67546f
Compare
The
ResourceMgmtActionProviderenablement expression required all selected elements to adapt toIResourceorIWorkingSet. This hid Open/Close Project actions when the selection contained non-resource elements (e.g., working set headers from Ctrl+A).Changed the enablement to always activate the provider (using
<or/>, the same pattern asUndoRedoActionProvider). The existingfillContextMenu()logic viaselectionToProjects()already filters to applicable projects and only shows relevant actions — no behavioral change for pure-project selections.Fixes #3790