UNPKG

2.44 kBPlain TextView Raw
1// *****************************************************************************
2// Copyright (C) 2019 TypeFox and others.
3//
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License v. 2.0 which is available at
6// http://www.eclipse.org/legal/epl-2.0.
7//
8// This Source Code may also be made available under the following Secondary
9// Licenses when the conditions for such availability set forth in the Eclipse
10// Public License v. 2.0 are satisfied: GNU General Public License, version 2
11// with the GNU Classpath Exception which is available at
12// https://www.gnu.org/software/classpath/license.html.
13//
14// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15// *****************************************************************************
16
17import { injectable, inject, named } from 'inversify';
18import { FrontendApplicationContribution } from './frontend-application';
19import { ContributionProvider } from '../common/contribution-provider';
20import { IconThemeService, IconTheme } from './icon-theme-service';
21import { MaybePromise } from '../common/types';
22import { Disposable } from '../common/disposable';
23
24export const IconThemeContribution = Symbol('IconThemeContribution');
25export interface IconThemeContribution {
26 registerIconThemes(iconThemes: IconThemeService): MaybePromise<void>;
27}
28
29@injectable()
30export class IconThemeApplicationContribution implements FrontendApplicationContribution {
31
32 @inject(IconThemeService)
33 protected readonly iconThemes: IconThemeService;
34
35 @inject(ContributionProvider) @named(IconThemeContribution)
36 protected readonly iconThemeContributions: ContributionProvider<IconThemeContribution>;
37
38 async onStart(): Promise<void> {
39 for (const contribution of this.iconThemeContributions.getContributions()) {
40 await contribution.registerIconThemes(this.iconThemes);
41 }
42 }
43
44}
45
46@injectable()
47export class DefaultFileIconThemeContribution implements IconTheme, IconThemeContribution {
48
49 readonly id = 'theia-file-icons';
50 readonly label = 'File Icons (Theia)';
51 readonly hasFileIcons = true;
52 readonly hasFolderIcons = true;
53
54 registerIconThemes(iconThemes: IconThemeService): MaybePromise<void> {
55 iconThemes.register(this);
56 }
57
58 /* rely on behaviour before for backward-compatibility */
59 activate(): Disposable {
60 return Disposable.NULL;
61 }
62
63}