-
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.
preferences for multi-root workspace
With changes in 543b119, URIs of root folders in a multi-root workspace are stored in a file with the extension of "theia-workspace", while the workspace preferences are in the ".theia/settings.json" under the first root. In this pull request, workspace preferences are stored - in the workspace file under the "settings" property, if a workspace file exists, or - in the ".theia/settings.json" if the workspace data is not saved in a workspace file. Also, this change supports - having 4 levels of preferences (from highest priority to the lowest): FolderPreference, WorkspacePreference, UserPreference, and DefaultPreference is added, with - an updated preference editor that supports viewing & editing the FolderPreferences, WorkspacePreferences, and UserPreferneces. This is the 3rd patch of #1660. Signed-off-by: elaihau <liang.huang@ericsson.com>
- Loading branch information
elaihau
committed
Oct 22, 2018
1 parent
c2939ab
commit 53c75c5
Showing
44 changed files
with
1,388 additions
and
445 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
56 changes: 56 additions & 0 deletions
56
packages/core/src/browser/preferences/default-preference-provider.ts
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,56 @@ | ||
/******************************************************************************** | ||
* 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 { inject, injectable, named, interfaces } from 'inversify'; | ||
import { ContributionProvider } from '../../common'; | ||
import { PreferenceProvider } from './preference-provider'; | ||
import { PreferenceScope } from './preference-service'; | ||
import { PreferenceContribution } from './preference-contribution'; | ||
|
||
export function bindDefaultPreferenceProvider(bind: interfaces.Bind): void { | ||
bind(PreferenceProvider).to(DefaultPrefrenceProvider).inSingletonScope().whenTargetNamed(PreferenceScope.Default); | ||
} | ||
|
||
@injectable() | ||
export class DefaultPrefrenceProvider extends PreferenceProvider { | ||
|
||
protected readonly preferences: { [name: string]: any } = {}; | ||
|
||
constructor( | ||
@inject(ContributionProvider) @named(PreferenceContribution) | ||
protected readonly preferenceContributions: ContributionProvider<PreferenceContribution> | ||
) { | ||
super(); | ||
this.preferenceContributions.getContributions().forEach(contrib => { | ||
for (const prefName of Object.keys(contrib.schema.properties)) { | ||
this.preferences[prefName] = contrib.schema.properties[prefName].default; | ||
} | ||
}); | ||
this._ready.resolve(); | ||
} | ||
|
||
getPreferences(): { [name: string]: any } { | ||
return this.preferences; | ||
} | ||
|
||
async setPreference(): Promise<void> { | ||
throw new Error('Unsupported'); | ||
} | ||
|
||
canProvide(preferenceName: string, resourceUri?: string): number { | ||
return 0; | ||
} | ||
} |
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.