Add workspace import support to Eclipse launcher window - #3995
Conversation
5d4e732 to
56de0b8
Compare
|
What about storing the workspaces in user scope scoped by product / application instead of storing them in configuration scope. This way the workspaces for a product would always be the same which I think is the most common use case. |
Test Results 858 files ± 0 858 suites ±0 56m 51s ⏱️ + 18m 47s For more details on these failures, see this check. Results for commit 35e577a. ± Comparison against base commit 889d5d5. ♻️ This comment has been updated with latest results. |
|
Interesting idea, but can we please made this feature optional, so the "Import..." is not shown at all (we extend We have Eclipse based application deployed with rpm, so by default installation is read only and all settings are stored on (typically mounted) user home and for a specific application version the path would be something like Not only that this path is by default hidden, it is also application version specific, different application versions are installed in parallel and should not share the workspaces used. "Import..." would casue more troubles in this scenario, so we would want to disable this completely to avoid user errors.
In our case it would be important to have that "per product / per version" or give a chance to see that the workspace is for a different product version. Ideally Eclise could automatically detect Eclipse workspaces from "compatible" workspaces. "Compatible" is the key, and it should be possible, similar to |
56de0b8 to
979ee98
Compare
Thanks for the feedback, i am exploring this path. If it can be done in user mode, made it optional. |
979ee98 to
cbeb03c
Compare
cbeb03c to
29c6d94
Compare
|
See https://github.com/eclipse-platform/eclipse.platform.ui/pull/3875/changes how to use user scope to save the recent workspaces together with a product / application prefix. The example is used for the theme but it should be easy to apply the same approach to the workspaces. |
Thanks aton, i was about to ask for some help in this context. Let me check on that. |
|
Why are there 3 commits? |
@merks : Thanks for your interest. |
| if (Platform.getInstanceLocation().isSet()) { | ||
| store.setValue(RECENT_WORKSPACES, sb.toString()); | ||
| } | ||
| // else { |
There was a problem hiding this comment.
I guess you will clean this up.
There was a problem hiding this comment.
Will need to investigate on this if configuration scope needs any check here or else can be removed.
| protected Control createDialogArea(Composite parent) { | ||
| Composite container = (Composite) super.createDialogArea(parent); | ||
| container.setLayout(new GridLayout(1, false)); | ||
| // FIX ORDER |
There was a problem hiding this comment.
Sorry that was a debug message while coding, removed now.
29c6d94 to
a0e1cf5
Compare
|
I assume if you switch to save and load the recent workspaces from User Scope no import is needed. |
May be, let me check. Still trying to figure out. |
|
It's quite a bit of extra logic for what to me seems a narrow use case. I think Lar's question kind of hints at the fact that one might share them across all products of the same type. That being said, given I have 50 installations and I never want to share workspaces across them, so I don't actually like that so much. But maybe I'm special. Then again, one can always find workspace without an import dialog too, so I'm a bit ambivalent over all... |
|
I feel UserScope + Product ID is best generic solution like updated in #3878. Please let me know if we can go with this. |
Sounds good to me. |
|
How is RECENT_WORKSPACES value maintained with multiple products are using this? Is there some kind of locking to prevent overwriting the values stored from other instances. Is this value ordered and how do multiple instance working with a single such list impact the order across the instances? |
5ce4b33 to
4ece49d
Compare
Good question. The proposal is to store RECENT_WORKSPACES in UserScope scoped by product/application ID, so each product maintains its own ordered MRU list. I am not currently proposing any additional locking. This would follow the same Eclipse preferences infrastructure already used by other UserScope preferences (e.g., the recently added themeid preference), which also relies on the standard preference APIs without custom synchronization. Since RECENT_WORKSPACES is a UI-driven convenience feature that is updated infrequently, any concurrent updates would only affect the recent-workspace history itself and not workspace data. |
|
The theme is changed infrequently and the product-scoped theme is intended to make that even more infrequent. But the workspace location preference is used by every IDE when it starts. I literally have dozens of installations of the Eclipse IDE for Committers and often have 10 or more different installations of that product open at once. I really don't need and would not like them all to share one unified list because each is augmented with additional tools and are intended to work on specific git repositories. But assuming I'm "special" and that others would want this (and I won't question why), I would still like a clear understanding of how this actually works. Each IDE when it starts moves its workspace to the front? When is that preference saved? When is it loaded and reloaded? When I switch workspaces in an IDE, do I see workspaces from other installations? I really do wonder what problem we are solving and I'm particularly concerned whether in doing so we create a new and different problem that we didn't have before. Sorry for being a little negative on the topic... |
|
Yes, it would be great to outline the solution, Ed's questions are all valid. |
There was a problem hiding this comment.
Pull request overview
This PR adds “workspace import” capabilities to the Eclipse launcher’s Choose Workspace flow, enabling users to discover and import recent workspaces from a previous Eclipse/application installation via a new import UI.
Changes:
- Adds a new
WorkspaceImportDialogfor browsing an installation path, filtering, and selecting workspaces to import. - Extends
ChooseWorkspaceDialogto always show the “Recent Workspaces” section and to launch the import flow (including deduplication/merge behavior). - Introduces new NLS keys for the import UI and related messages.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkspaceImportDialog.java |
New dialog to browse a previous installation, filter, select all/none, and import detected workspaces. |
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java |
Adds Import button and import/merge logic; refreshes Recent Workspaces UI after changes. |
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/messages.properties |
Adds user-facing strings for the import button and the new import dialog. |
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java |
Declares new NLS fields corresponding to the added message keys. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Final list | ||
| List<String> result = new ArrayList<>(merged); | ||
| // Persist | ||
| launchData.setRecentWorkspaces(result.toArray(new String[0])); | ||
| saveRecentWorkspacesToPreferences(result); | ||
| refreshRecentWorkspacesComposite(); | ||
|
|
||
| MessageDialog.openInformation(getShell(), "Workspaces Updated", //$NON-NLS-1$ | ||
| "Imported " + selected.size() + " workspace(s)."); //$NON-NLS-1$ //$NON-NLS-2$ |
There was a problem hiding this comment.
Thanks for pointing this out - updated in the latest commit.
saveRecentWorkspacesToPreferences wrote through a separate preference store, which could diverge from what the launcher reads from ConfigurationScope on restart. I've removed that method entirely and now persist via launchData.writePersistedData(), the same path the rest of the launcher uses.
Also externalized the confirmation dialog's message.
| String recentWorkspacesValue = props.getProperty("RECENT_WORKSPACES"); //$NON-NLS-1$ | ||
| if (recentWorkspacesValue == null || recentWorkspacesValue.isEmpty()) { | ||
| return workspaces; | ||
| } | ||
|
|
||
| for (String path : recentWorkspacesValue.split("\\n")) { //$NON-NLS-1$ | ||
| String trimmedPath = path.trim(); | ||
| if (!trimmedPath.isEmpty() && new File(trimmedPath).exists()) { |
There was a problem hiding this comment.
Thanks for updating the split delimiter - using "\n" here is correct. Also, reusing the RECENT_WORKSPACES constant instead of the hardcoded string is a good change, keeping this in sync with the key definition used elsewhere (e.g. ChooseWorkspaceData).
One thing I'd restore though: the trim() / empty-check / File.exists() validation that was in the loop before should stay - without it, a leading/trailing/doubled newline in the stored value produces empty-string entries that gets added as "workspaces" with no filtering, and stale entries pointing at deleted/moved workspace paths get offered as importable - which contradicts the PR's own goal of handling empty/invalid workspaces.
| } catch (Exception e) { | ||
| e.printStackTrace(); | ||
| } |
There was a problem hiding this comment.
Sorry, missed the point: we should not use workbench which might not be running yet, but static IDEWorkbenchPlugin should be OK.
| // Handle clear button click | ||
| filter.addListener(SWT.DefaultSelection, e -> { | ||
| filter.setText(EMPTY); | ||
| }); |
There was a problem hiding this comment.
yes, updated. Tested it.
| } catch (IOException e) { | ||
| e.printStackTrace(); | ||
| } |
| // else { | ||
| // MessageDialog.openInformation(getShell(), "saveRecentWorkspacesToPreferences", //$NON-NLS-1$ | ||
| // "Instance location not set yet. Skipping preference save."); //$NON-NLS-1$ | ||
| // } |
4ece49d to
48fb3d1
Compare
48fb3d1 to
aa939d6
Compare
loggers(DO NOT DELETE)
aa939d6 to
8159349
Compare
any workspaces or has already imported workspaces, add javadoc, update removeWorkspaceFromLauncher(). Updated as per review comment updates.
8159349 to
35e577a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (4)
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java:568
File.exists()also accepts regular files, so a stale preference whose former workspace directory has been replaced by a file is offered as a valid workspace and can be persisted for launch. Require the imported path to be a directory.
for (String path : recentWorkspacesValue.split("\n")) { //$NON-NLS-1$
String trimmedPath = path.trim();
if (!trimmedPath.isEmpty() && new File(trimmedPath).exists()) {
workspaces.add(trimmedPath);
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkspaceImportDialog.java:325
getCheckedElements()only returns checkedTableItems that remain visible after filtering, so pressing OK while a filter is active silently drops every checked workspace hidden by that filter. Build the result from the tracked check-state set intersected with the viewer's full input instead.
selected.clear();
Object[] checked = viewer.getCheckedElements();
for (Object o : checked) {
selected.add((String) o);
}
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java:517
- Only the Recent Workspaces links are refreshed here; the workspace combo was populated before the import and remains stale. Consequently imported paths are absent from its dropdown, and using “Remove from launcher selection” on a newly imported link passes an item that is not in the combo to
Combo.remove(String). Repopulate the combo fromgetRecentWorkspaces()while preserving its current text before refreshing the links.
launchData.setRecentWorkspaces(result.toArray(new String[0]));
launchData.writePersistedData();
refreshRecentWorkspacesComposite();
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java:451
- Duplicate detection uses exact string equality even though this class defines duplicates as normalized paths in
filterDuplicatedPaths. For example, an existing/tmp/ws/and detected/tmp/wspass this check, and the laterLinkedHashSetalso persists both spellings. Use one normalized path key for both filtering and merging so the advertised duplicate prevention applies to equivalent paths.
This issue also appears on line 565 of the same file.
for (String ws : detected) {
if (!existing.contains(ws)) {
filtered.add(ws);
This PR introduces workspace capability in the Choose Workspace dialog.
Users can now import recent workspaces from a previous Eclipse installation directly from the launcher UI.
Features added:
Additional improvements:
This change enhances workspace migration usability and improves the overall launcher experience for users moving between Eclipse installations.
Before this pr :

After this pr :
Import...is the newly added button ->Import..., you can browse previous eclipse installation path and browse recently used workspaces in it and import them like this - the desired ones ->Import...again like this ->How to test this new feature :
step 1 - pick this jar ->
org.eclipse.ui.ide_3.23.200.v20260818-0711.zip
extract this zip file to get a jar, place this jar in the fresh eclipse installation at
..\eclipse\pluginsfolder.step 2 - Open this file "..\eclipse\configuration\org.eclipse.equinox.simpleconfigurator\bundles.info", search for "org.eclipse.ui.ide," line and replace the whole line with
org.eclipse.ui.ide,3.23.200.v20260818-0711,plugins/org.eclipse.ui.ide_3.23.200.v20260818-0711.jar,4,falseNote : Once done with testing, please revert back to get the original eclipse installation state before you proceed.
I am not sure if this can be tested in a different way easily, but i have tested this way on windows platform.