/******************************************************************************** * Copyright (C) 2017 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 '../../src/browser/style/index.css'; import 'font-awesome/css/font-awesome.min.css'; import 'file-icons-js/css/style.css'; import { ContainerModule, interfaces } from 'inversify'; import { KeybindingContext, KeybindingContribution, KeybindingRegistry } from './keybinding'; import { bindContributionProvider } from '@gedit/utils'; import { ApplicationShell, ApplicationShellLayoutMigration, ApplicationShellLayoutMigrationError, ApplicationShellOptions, DockPanelRenderer, DockPanelRendererFactory, ShellLayoutRestorer, SidePanelHandler, SidePanelHandlerFactory, SplitPositionHandler, TabBarRenderer, TabBarRendererFactory, TabBarToolbar, TabBarToolbarContribution, TabBarToolbarFactory, TabBarToolbarRegistry, ViewContainer, ViewContainerIdentifier, WidgetFactory, WidgetManager } from './shell'; import { StatusBar, StatusBarImpl } from './status-bar'; import { ApplicationShellMouseTracker } from './shell/application-shell-mouse-tracker'; import { FrontendApplicationContribution } from '@gedit/application-common/lib/browser'; import { DialogOverlayService } from './dialogs'; import { ProgressLocationService, DispatchingProgressClient, ProgressStatusBarItem, ProgressBar } from './progress'; import { TabBarDecorator, TabBarDecoratorService } from './shell'; import { ContextMenuContext, ContextMenuRenderer } from './menu'; import { ProgressBarFactory, ProgressBarOptions } from './progress'; import { CommandContribution } from '@gedit/command'; import { IconThemeService } from '@gedit/theme'; import { ProgressClient, ProgressService } from '@gedit/connection'; import '../../src/browser/style/materialcolors.css'; // require('../../src/browser/style/materialcolors.css').use(); /** * 绑定布局容器 * @param bind */ function bindShellPanel(bind: interfaces.Bind): void { bind(ApplicationShellOptions).toConstantValue({}); bind(ApplicationShell).toSelf().inSingletonScope(); bind(SidePanelHandlerFactory).toAutoFactory(SidePanelHandler); bind(SidePanelHandler).toSelf(); bind(SplitPositionHandler).toSelf().inSingletonScope(); bindContributionProvider(bind, TabBarToolbarContribution); bind(TabBarToolbarRegistry).toSelf().inSingletonScope(); bind(FrontendApplicationContribution).toService(TabBarToolbarRegistry); bind(TabBarToolbarFactory).toFactory(context => () => { const container = context.container.createChild(); container.bind(TabBarToolbar).toSelf().inSingletonScope(); return container.get(TabBarToolbar); }); bind(DockPanelRendererFactory).toFactory(context => () => { const {container} = context; const tabBarToolbarRegistry = container.get(TabBarToolbarRegistry); const tabBarRendererFactory: () => TabBarRenderer = container.get(TabBarRendererFactory); const tabBarToolbarFactory: () => TabBarToolbar = container.get(TabBarToolbarFactory); return new DockPanelRenderer(tabBarRendererFactory, tabBarToolbarRegistry, tabBarToolbarFactory); }); bind(DockPanelRenderer).toSelf(); bind(TabBarRendererFactory).toFactory(context => () => { const contextMenuRenderer = context.container.get(ContextMenuRenderer); const decoratorService = context.container.get(TabBarDecoratorService); const iconThemeService = context.container.get(IconThemeService); return new TabBarRenderer(contextMenuRenderer, decoratorService, iconThemeService); }); bindContributionProvider(bind, TabBarDecorator); bind(TabBarDecoratorService).toSelf().inSingletonScope(); bindContributionProvider(bind, ApplicationShellLayoutMigration); bind(ApplicationShellLayoutMigration).toConstantValue({ layoutVersion: 2.0, onWillInflateLayout({layoutVersion}): void { throw ApplicationShellLayoutMigrationError.create( `It is not possible to migrate layout of version ${layoutVersion} to version ${this.layoutVersion}.` ); } }); bindContributionProvider(bind, WidgetFactory); bind(WidgetManager).toSelf().inSingletonScope(); bind(ShellLayoutRestorer).toSelf().inSingletonScope(); bind(CommandContribution).toService(ShellLayoutRestorer); bind(ApplicationShellMouseTracker).toSelf().inSingletonScope(); bind(FrontendApplicationContribution).toService(ApplicationShellMouseTracker); } export default new ContainerModule((bind, unbind, isBound, rebind) => { bindShellPanel(bind); bind(KeybindingRegistry).toSelf().inSingletonScope(); bindContributionProvider(bind, KeybindingContext); bindContributionProvider(bind, KeybindingContribution); bind(StatusBarImpl).toSelf().inSingletonScope(); bind(StatusBar).toService(StatusBarImpl); bind(ViewContainer.Factory).toFactory(context => (options: ViewContainerIdentifier) => { const container = context.container.createChild(); container.bind(ViewContainerIdentifier).toConstantValue(options); container.bind(ViewContainer).toSelf().inSingletonScope(); return container.get(ViewContainer); }); bind(DialogOverlayService).toSelf().inSingletonScope(); bind(FrontendApplicationContribution).toService(DialogOverlayService); bind(DispatchingProgressClient).toSelf().inSingletonScope(); bind(ProgressLocationService).toSelf().inSingletonScope(); bind(ProgressStatusBarItem).toSelf().inSingletonScope(); bind(ProgressClient).toService(DispatchingProgressClient); bind(ProgressService).toSelf().inSingletonScope(); bind(ProgressBarFactory).toFactory(context => (options: ProgressBarOptions) => { const childContainer = context.container.createChild(); childContainer.bind(ProgressBarOptions).toConstantValue(options); childContainer.bind(ProgressBar).toSelf().inSingletonScope(); return childContainer.get(ProgressBar); }); bind(ContextMenuContext).toSelf().inSingletonScope(); });