-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
multi-root workspace support, minimal patch
What is a workspace / workspace folder? It is a folder on the file system that serves as a container for: - workspace configuration: in sub-folder ".theia" - preferences, in ".theia/settings.json" - root folders list, in ".theia/roots.json" - optionally content in the form of other files/folders For backward compatibility and simplicity, a workspace folder that contains no explicit root folder list configuration will use its own folder as the single root. This permits using any folder as a workspace. If subsequently an additional root folder is added to such a workspace, then both the newly added folder and the original implicit root are added to the root folders list configuration. Either can later be removed. If all roots are removed form the configuration, the workspace falls-back to using its own folder as implicit root. This PR is the minimal patch for #1660 What's included in this PR: - a workspace's root folders list can be modified using the navigator context menu "add/remove folder" items to add or remove a folder - preference 'workspace.supportMultiRootWorkspace', with default value false, can be used to control if the context menu entries, used to modify the list of root folders, are shown or not. Since this is a new feature that is not supported by most Theia extensions yet, it probably makes sense to hide the UI by default for now - previously the "current root" was a static value, obtained by each extension that needs it, at the startup of a Theia client. To change it (e.g. to switch workspace), a restart of the client was required. For this feature we did not want to have to restart the client each time the list of root folders is updated, so we introduced a new "onWorkspaceRootChanged" event. Extensions that need to know when the list of root folders is modified can react to this event, e.g. to update their widgets. It's still necessary to reload the Theia frontend when switching workspace in a given tab or when closing a workspace. - the root folder list comprised of 1 to many folders can be displayed from the file navigator widget. - the root folders will be scanned for git repositories that the user can select, stage and commit files into. What's not included: - users should have the choice of naming the workspace and choosing where to store the config file - preference extension should be able to handle the settings from multiple projects - search-in-workspace and file-search extension should be able to perform the search across all folders in the workspace, and / or provide filtering mechanism to reduce the amount of information being displayed - output and problems widgets should display data from all root folders, and / or provide filtering mechanism to reduce the amount of information being displayed - task extension should be able to run tasks defined under all root folders - users should be able to open the terminal from any root folder in the workspace Signed-off-by: elaihau <liang.huang@ericsson.com>
- Loading branch information
elaihau
committed
Aug 7, 2018
1 parent
10aaf1f
commit d4896cf
Showing
38 changed files
with
730 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2018 Ericsson 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 { injectable, inject } from 'inversify'; | ||
import { FileSystem, FileStat } from '../common'; | ||
import { FileStatNode, DirNode } from './file-tree'; | ||
import { FileDialogFactory, FileDialogProps } from './file-dialog'; | ||
import URI from '@theia/core/lib/common/uri'; | ||
import { LabelProvider } from '@theia/core/lib/browser'; | ||
|
||
@injectable() | ||
export class FileDialogService { | ||
@inject(FileSystem) protected readonly fileSystem: FileSystem; | ||
@inject(FileDialogFactory) protected readonly fileDialogFactory: FileDialogFactory; | ||
@inject(LabelProvider) protected readonly labelProvider: LabelProvider; | ||
|
||
async show(props: FileDialogProps, folder?: FileStat): Promise<FileStatNode | undefined> { | ||
const title = props && props.title ? props.title : 'Open'; | ||
const folderToOpen = folder || await this.fileSystem.getCurrentUserHome(); | ||
if (folderToOpen) { | ||
const rootUri = new URI(folderToOpen.uri).parent; | ||
const name = this.labelProvider.getName(rootUri); | ||
const [rootStat, label] = await Promise.all([ | ||
this.fileSystem.getFileStat(rootUri.toString()), | ||
this.labelProvider.getIcon(folderToOpen) | ||
]); | ||
if (rootStat) { | ||
const rootNode = DirNode.createRoot(rootStat, name, label); | ||
const dialog = this.fileDialogFactory({ title }); | ||
dialog.model.navigateTo(rootNode); | ||
const nodes = await dialog.open(); | ||
return Array.isArray(nodes) ? nodes[0] : nodes; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.