Skip to content

Show Open/Close Project for mixed selections in Project Explorer#3866

Open
vogella wants to merge 2 commits intoeclipse-platform:masterfrom
vogella:fix/issue-3790-open-close-mixed-selection
Open

Show Open/Close Project for mixed selections in Project Explorer#3866
vogella wants to merge 2 commits intoeclipse-platform:masterfrom
vogella:fix/issue-3790-open-close-mixed-selection

Conversation

@vogella
Copy link
Copy Markdown
Contributor

@vogella vogella commented Apr 5, 2026

The ResourceMgmtActionProvider enablement expression required all selected elements to adapt to IResource or IWorkingSet. 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 as UndoRedoActionProvider). The existing fillContextMenu() logic via selectionToProjects() already filters to applicable projects and only shows relevant actions — no behavioral change for pure-project selections.

Fixes #3790

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

Test Results

   840 files   -    12     840 suites   - 12   40m 42s ⏱️ - 13m 38s
 7 232 tests  -   667   6 991 ✅  -   665  241 💤  -  2  0 ❌ ±0 
18 414 runs   - 1 785  17 787 ✅  - 1 757  627 💤  - 28  0 ❌ ±0 

Results for commit 424a16a. ± Comparison against base commit 9b991c8.

This pull request removes 670 and adds 3 tests. Note that renamed tests count towards both.
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testBoundaries
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testBug156426
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testBug377417
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testCloseMatches
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testCloseMatches1
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testIncompleteMatch
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testIncompleteMatch1
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testNesting
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testPartitioned
org.eclipse.jface.text.tests.DefaultPairMatcherTest ‑ testSimpleMatchDifferentMatchers
…
org.eclipse.ui.tests.navigator.resources.ResourceMgmtActionProviderTests ‑ testFillContextMenu_fileAndOpenProjectSelection_closeProjectEnabled
org.eclipse.ui.tests.navigator.resources.ResourceMgmtActionProviderTests ‑ testFillContextMenu_mixedSelectionOpenProjectAndNonAdaptableElement
org.eclipse.ui.tests.navigator.resources.ResourceMgmtActionProviderTests ‑ testFillContextMenu_twoOpenProjectsWithChildResourcesSelection

♻️ This comment has been updated with latest results.

@vogella vogella force-pushed the fix/issue-3790-open-close-mixed-selection branch 4 times, most recently from 05018be to e1e0229 Compare April 13, 2026 18:49
@vogella vogella marked this pull request as ready for review April 15, 2026 23:09
@vogella vogella force-pushed the fix/issue-3790-open-close-mixed-selection branch from 05972e9 to 7252610 Compare April 17, 2026 03:35
vogella added 2 commits April 18, 2026 21:27
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.

2. CloseResourceAction and OpenResourceAction.updateSelection() called
   selectionIsOfType(PROJECT), which returns false whenever any
   non-IResource element (e.g. a working set header) is present in the
   selection, even if every resource element is a valid open/closed
   project. Fixed by checking getSelectedResources() directly.

3. CloseUnrelatedProjectsAction.resourceChanged() had the same
   selectionIsOfType guard, preventing the action from reacting to
   project state changes for mixed selections. Fixed analogously.

ResourceMgmtActionProvider now overrides getSelectedResources() on the
open/close action instances to filter the selection down to IProject
elements only, so that files and folders selected alongside projects
(expanded Ctrl+A) do not disable the actions.

Fixes eclipse-platform#3790
Move the project-filtering logic from anonymous getSelectedResources()
overrides in ResourceMgmtActionProvider into the action classes
themselves (OpenResourceAction, CloseResourceAction,
CloseUnrelatedProjectsAction). This fixes the API analysis build
failure caused by illegally subclassing these action classes.

The updateSelection() methods now filter getSelectedResources() to
IProject instances, so mixed selections (e.g. Ctrl+A) correctly
enable/disable Open/Close Project actions. The resourceChanged()
methods also use stream-based project checks instead of
selectionIsOfType() to react properly to project state changes
during mixed selections.
@vogella vogella force-pushed the fix/issue-3790-open-close-mixed-selection branch from 7252610 to 424a16a Compare April 18, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Open/Close Project visibility in Project Explorer for mixed selections

1 participant