diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4a3e48df83c6c..e937e0670952c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,9 +8,9 @@
## v1.38.0 - 05/25/2023
[Breaking Changes:](#breaking_changes_1.38.0)
-
-- [core] moved `ToolbarAwareTabBar.Styles` to `ScrollableTabBar.Styles` [12411](https://github.com/eclipse-theia/theia/pull/12411/)
-- [debug] Change the return type of (method) `DebugConfigurationManager.provideDynamicDebugConfigurations()` to
+- [workspace] Removed `WorkspaceFrontentContribution.createOpenWorkspaceOpenFileDialogProps(...)` and `WorkspaceFrontendContribution.preferences`
+- [core] Moved `ToolbarAwareTabBar.Styles` to `ScrollableTabBar.Styles` [12411](https://github.com/eclipse-theia/theia/pull/12411/)
+- [debug] Changed the return type of (method) `DebugConfigurationManager.provideDynamicDebugConfigurations()` to
`Promise>` [#12482](https://github.com/eclipse-theia/theia/pull/12482)
## v1.37.0 - 04/27/2023
diff --git a/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts b/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts
index 2c8d06921946b..12dab8403db04 100644
--- a/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts
+++ b/packages/filesystem/src/electron-browser/file-dialog/electron-file-dialog-service.ts
@@ -16,7 +16,6 @@
import { inject, injectable } from '@theia/core/shared/inversify';
import URI from '@theia/core/lib/common/uri';
-import { isOSX } from '@theia/core/lib/common/os';
import { MaybeArray } from '@theia/core/lib/common/types';
import { MessageService } from '@theia/core/lib/common/message-service';
import { FileStat } from '../../common/files';
@@ -101,14 +100,6 @@ export class ElectronFileDialogService extends DefaultFileDialogService {
}
protected toOpenDialogOptions(uri: URI, props: OpenFileDialogProps): OpenDialogOptions {
- if (!isOSX && props.canSelectFiles !== false && props.canSelectFolders === true) {
- console.warn(`Cannot have 'canSelectFiles' and 'canSelectFolders' at the same time. Fallback to 'folder' dialog. \nProps was: ${JSON.stringify(props)}.`);
-
- // Given that both props are set, fallback to using a `folder` dialog.
- props.canSelectFiles = false;
- props.canSelectFolders = true;
- }
-
const result: OpenDialogOptions = {
path: FileUri.fsPath(uri)
};
diff --git a/packages/workspace/src/browser/workspace-commands.ts b/packages/workspace/src/browser/workspace-commands.ts
index 0c679f665ca98..9020394fdab9a 100644
--- a/packages/workspace/src/browser/workspace-commands.ts
+++ b/packages/workspace/src/browser/workspace-commands.ts
@@ -74,9 +74,9 @@ export namespace WorkspaceCommands {
...Command.toDefaultLocalizedCommand({
id: 'workspace:openWorkspace',
category: CommonCommands.FILE_CATEGORY,
- label: 'Open Workspace...',
+ label: 'Open Workspace from File...',
}),
- dialogLabel: nls.localizeByDefault('Open Workspace')
+ dialogLabel: nls.localizeByDefault('Open Workspace from File')
};
export const OPEN_RECENT_WORKSPACE = Command.toLocalizedCommand({
id: 'workspace:openRecent',
diff --git a/packages/workspace/src/browser/workspace-frontend-contribution.spec.ts b/packages/workspace/src/browser/workspace-frontend-contribution.spec.ts
deleted file mode 100644
index 747d80f595fc6..0000000000000
--- a/packages/workspace/src/browser/workspace-frontend-contribution.spec.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-// *****************************************************************************
-// Copyright (C) 2018 TypeFox and others.
-//
-// This program and the accompanying materials are made available under the
-// terms of the Eclipse Public License v. 2.0 which is available at
-// http://www.eclipse.org/legal/epl-2.0.
-//
-// This Source Code may also be made available under the following Secondary
-// Licenses when the conditions for such availability set forth in the Eclipse
-// Public License v. 2.0 are satisfied: GNU General Public License, version 2
-// with the GNU Classpath Exception which is available at
-// https://www.gnu.org/software/classpath/license.html.
-//
-// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-// *****************************************************************************
-
-import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
-let disableJSDOM = enableJSDOM();
-
-import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider';
-FrontendApplicationConfigProvider.set({});
-
-import { expect } from 'chai';
-import { OS } from '@theia/core/lib/common/os';
-import { OpenFileDialogProps } from '@theia/filesystem/lib/browser/file-dialog';
-import { WorkspaceFrontendContribution } from './workspace-frontend-contribution';
-import { WorkspaceCommands } from './workspace-commands';
-
-disableJSDOM();
-
-describe('workspace-frontend-contribution', () => {
-
- describe('WorkspaceFrontendContribution', () => {
-
- const title = WorkspaceCommands.OPEN_WORKSPACE.dialogLabel;
- const filters = WorkspaceFrontendContribution.DEFAULT_FILE_FILTER;
-
- before(() => disableJSDOM = enableJSDOM());
- after(() => disableJSDOM());
-
- ([
- [OS.Type.Linux, 'browser', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
- [OS.Type.Linux, 'electron', true, { title, canSelectFiles: true, canSelectFolders: false, filters }],
- [OS.Type.Windows, 'browser', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
- [OS.Type.Windows, 'electron', true, { title, canSelectFiles: true, canSelectFolders: false, filters }],
- [OS.Type.OSX, 'browser', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
- [OS.Type.OSX, 'electron', true, { title, canSelectFiles: true, canSelectFolders: true, filters }],
- ] as [OS.Type, 'browser' | 'electron', boolean, OpenFileDialogProps][]).forEach(test => {
- const [type, environment, _, expected] = test;
- const electron = environment === 'electron' ? true : false;
- const os = (OS.Type as any)[type]; // eslint-disable-line @typescript-eslint/no-explicit-any
- const actual = WorkspaceFrontendContribution.createOpenWorkspaceOpenFileDialogProps({
- type,
- electron,
- });
- it(`createOpenWorkspaceOpenFileDialogProps - OS: ${os}, Environment: ${environment}`, () => {
- expect(actual).to.be.deep.equal(expected);
- });
- });
-
- });
-
-});
diff --git a/packages/workspace/src/browser/workspace-frontend-contribution.ts b/packages/workspace/src/browser/workspace-frontend-contribution.ts
index 47de27b034240..f3b266837f605 100644
--- a/packages/workspace/src/browser/workspace-frontend-contribution.ts
+++ b/packages/workspace/src/browser/workspace-frontend-contribution.ts
@@ -16,7 +16,7 @@
import { injectable, inject } from '@theia/core/shared/inversify';
import { CommandContribution, CommandRegistry, MenuContribution, MenuModelRegistry, MessageService, isWindows, MaybeArray } from '@theia/core/lib/common';
-import { isOSX, environment, OS } from '@theia/core';
+import { isOSX, environment } from '@theia/core';
import {
open, OpenerService, CommonMenus, KeybindingRegistry, KeybindingContribution,
FrontendApplicationContribution, SHELL_TABBAR_CONTEXT_COPY, OnWillStopAction, Navigatable, SaveableSource, Widget
@@ -27,7 +27,6 @@ import { WorkspaceService } from './workspace-service';
import { THEIA_EXT, VSCODE_EXT } from '../common';
import { WorkspaceCommands } from './workspace-commands';
import { QuickOpenWorkspace } from './quick-open-workspace';
-import { WorkspacePreferences } from './workspace-preferences';
import URI from '@theia/core/lib/common/uri';
import { FileService } from '@theia/filesystem/lib/browser/file-service';
import { EncodingRegistry } from '@theia/core/lib/browser/encoding-registry';
@@ -70,7 +69,6 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
@inject(QuickOpenWorkspace) protected readonly quickOpenWorkspace: QuickOpenWorkspace;
@inject(FileDialogService) protected readonly fileDialogService: FileDialogService;
- @inject(WorkspacePreferences) protected preferences: WorkspacePreferences;
@inject(ContextKeyService) protected readonly contextKeyService: ContextKeyService;
@inject(EncodingRegistry) protected readonly encodingRegistry: EncodingRegistry;
@inject(PreferenceConfigurations) protected readonly preferenceConfigurations: PreferenceConfigurations;
@@ -362,51 +360,26 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi
/**
* Opens a workspace after raising the `Open Workspace` dialog. Resolves to the URI of the recently opened workspace,
* if it was successful. Otherwise, resolves to `undefined`.
- *
- * **Caveat**: this behaves differently on different platforms
- * and `electron`/`browser` version has impact too. See [here](https://github.com/eclipse-theia/theia/pull/3202#issuecomment-430884195) for more details.
- *
- * Legend:
- * - Folders only: => `F`
- * - Workspace files only: => `W`
- * - Folders and workspace files: => `FW`
- *
- * -----
- *
- * |---------|-----------|-----------|------------|------------|
- * | | browser Y | browser N | electron Y | electron N |
- * |---------|-----------|-----------|------------|------------|
- * | Linux | FW | F | W | F |
- * | Windows | FW | F | W | F |
- * | OS X | FW | F | FW | FW |
- * |---------|-----------|-----------|------------|------------|
- *
*/
protected async doOpenWorkspace(): Promise {
- const props = await this.openWorkspaceOpenFileDialogProps();
+ const props = {
+ title: WorkspaceCommands.OPEN_WORKSPACE.dialogLabel,
+ canSelectFiles: true,
+ canSelectFolders: false,
+ filters: WorkspaceFrontendContribution.DEFAULT_FILE_FILTER
+ };
const [rootStat] = await this.workspaceService.roots;
- const workspaceFolderOrWorkspaceFileUri = await this.fileDialogService.showOpenDialog(props, rootStat);
- if (workspaceFolderOrWorkspaceFileUri &&
- this.getCurrentWorkspaceUri()?.toString() !== workspaceFolderOrWorkspaceFileUri.toString()) {
- const destinationFolder = await this.fileService.exists(workspaceFolderOrWorkspaceFileUri);
- if (destinationFolder) {
- this.workspaceService.open(workspaceFolderOrWorkspaceFileUri);
- return workspaceFolderOrWorkspaceFileUri;
+ const workspaceFileUri = await this.fileDialogService.showOpenDialog(props, rootStat);
+ if (workspaceFileUri &&
+ this.getCurrentWorkspaceUri()?.toString() !== workspaceFileUri.toString()) {
+ if (await this.fileService.exists(workspaceFileUri)) {
+ this.workspaceService.open(workspaceFileUri);
+ return workspaceFileUri;
}
}
return undefined;
}
- protected async openWorkspaceOpenFileDialogProps(): Promise {
- await this.preferences.ready;
- const type = OS.type();
- const electron = this.isElectron();
- return WorkspaceFrontendContribution.createOpenWorkspaceOpenFileDialogProps({
- type,
- electron,
- });
- }
-
protected async closeWorkspace(): Promise {
await this.workspaceService.close();
}
@@ -519,40 +492,4 @@ export namespace WorkspaceFrontendContribution {
'Theia Workspace (*.theia-workspace)': [THEIA_EXT],
'VS Code Workspace (*.code-workspace)': [VSCODE_EXT]
};
-
- /**
- * Returns with an `OpenFileDialogProps` for opening the `Open Workspace` dialog.
- */
- export function createOpenWorkspaceOpenFileDialogProps(options: Readonly<{ type: OS.Type, electron: boolean }>): OpenFileDialogProps {
- const { electron, type } = options;
- const title = WorkspaceCommands.OPEN_WORKSPACE.dialogLabel;
- // If browser
- if (!electron) {
- return {
- title,
- canSelectFiles: true,
- canSelectFolders: true,
- filters: DEFAULT_FILE_FILTER
- };
- }
-
- // If electron
- if (OS.Type.OSX === type) {
- // `Finder` can select folders and files at the same time. We allow folders and workspace files.
- return {
- title,
- canSelectFiles: true,
- canSelectFolders: true,
- filters: DEFAULT_FILE_FILTER
- };
- }
-
- return {
- title,
- canSelectFiles: true,
- canSelectFolders: false,
- filters: DEFAULT_FILE_FILTER
- };
- }
-
}