Skip to content

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

Open
vogella wants to merge 2 commits into
eclipse-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 into
eclipse-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

   864 files  ± 0     864 suites  ±0   53m 52s ⏱️ + 1m 11s
 7 995 tests + 5   7 752 ✅ + 5  243 💤 ±0  0 ❌ ±0 
20 439 runs  +15  19 784 ✅ +15  655 💤 ±0  0 ❌ ±0 

Results for commit f67546f. ± Comparison against base commit ff1f1b7.

♻️ 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 2 times, most recently from 7252610 to 424a16a Compare April 18, 2026 19:27
@vogella vogella requested a review from Copilot April 20, 2026 14:01
@vogella vogella force-pushed the fix/issue-3790-open-close-mixed-selection branch from 424a16a to ea62040 Compare April 20, 2026 14:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ResourceMgmtActionProvider enablement unconditional in plugin.xml so 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.

Comment thread bundles/org.eclipse.ui.navigator.resources/plugin.xml
@vogella vogella force-pushed the fix/issue-3790-open-close-mixed-selection branch from ea62040 to 4d1b6f4 Compare June 1, 2026 09:43
@eclipse-platform-bot
Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF

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 patch
From f85f8c2b36ece57f1ff4040b028e41c7603e7383 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Mon, 1 Jun 2026 09:49:06 +0000
Subject: [PATCH] Version bump(s) for 4.41 stream


diff --git a/bundles/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF
index a26be904ac..eb4dacd798 100644
--- a/bundles/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-SymbolicName: org.eclipse.ui.navigator.resources; singleton:=true
-Bundle-Version: 3.10.100.qualifier
+Bundle-Version: 3.10.200.qualifier
 Bundle-Activator: org.eclipse.ui.internal.navigator.resources.plugin.WorkbenchNavigatorPlugin
 Bundle-Vendor: %Plugin.providerName
 Bundle-Localization: plugin
-- 
2.54.0

Further information are available in Common Build Issues - Missing version increments.

vogella and others added 2 commits June 1, 2026 15:30
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
@vogella vogella force-pushed the fix/issue-3790-open-close-mixed-selection branch from 8c2a2e9 to f67546f Compare June 1, 2026 13:30
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

3 participants