import { Logger } from "./bll/utils/logger" ; import { TYPES } from "./bll/utils/constants" ; import { inject , injectable } from "inversify" ; import { CommandHolder } from "./commandholder" ; import { Settings } from "./bll/entities/settings" ; import { Output } from "./view/output" ; import { TeamCityStatusBarItem } from "./view/teamcitystatusbaritem" ; import { CredentialsStore } from "./bll/credentialsstore/credentialsstore" ; import { Disposable } from "vscode" ; import { WorkspaceProxy } from "./bll/moduleproxies/workspace-proxy" ; import { IProviderManager } from "./view/iprovidermanager" ; import { WebLinkListener } from "./dal/weblinklistener" ; import { NewNotificationWatcher } from "./bll/notifications/NewNotificationWatcher" ; import { Context } from "./view/Context" ; import { Worker } from "./bll/mychanges/Worker" ; import { ExpandableItem } from "./bll/entities/presentable/expandableitem" ; import { TimePeriodItem } from "./bll/entities/presentable/timeperioditem" ; import { CheckInInfoItem } from "./bll/entities/presentable/checkininfoitem" ; import { BuildConfigItem } from "./bll/entities/presentable/buildconfigitem" ; import { LeaveSelectableItem } from "./bll/entities/presentable/leaveselectableitem" ; import { ProjectItem } from "./bll/entities/presentable/projectitem" ; import { CvsResourceItem } from "./bll/entities/cvsresources/cvsresourceitem" ; @ injectable ( ) export class ExtensionManager { private credentialsStore : CredentialsStore ; private readonly _commandHolder : CommandHolder ; private readonly _disposables : Disposable [ ] = [ ] ; private readonly providerManager : IProviderManager ; constructor ( @ inject ( TYPES . Settings ) settings , @ inject ( TYPES . CredentialsStore ) credentialsStore , @ inject ( TYPES . CommandHolder ) commandHolder , @ inject ( TYPES . NotificationWatcher ) notificationWatcher , @ inject ( TYPES . Output ) output , @ inject ( TYPES . ProviderManager ) providerManager , @ inject ( TYPES . TeamCityStatusBarItem ) statusBarItem , @ inject ( TYPES . WorkspaceProxy ) workspaceProxy , @ inject ( TYPES . WebLinkListener ) webLinkListener , @ inject ( TYPES . Context ) myContext , @ inject ( TYPES . MyChangesWorker ) worker ) { this . credentialsStore = credentialsStore ; this . _commandHolder = commandHolder ; this . _disposables . push ( notificationWatcher ) ; this . _disposables . push ( worker ) ; this . _disposables . push ( output ) ; this . _disposables . push ( statusBarItem ) ; this . _disposables . push ( providerManager ) ; this . _disposables . push ( webLinkListener ) ; this . _disposables . push ( myContext ) ; this . providerManager = providerManager ; if ( workspaceProxy . workspaceFolders && workspaceProxy . workspaceFolders . length !== 0 ) { const defaultWorkspace = workspaceProxy . workspaceFolders [ 0 ] ; this . initLogger ( settings . loggingLevel , defaultWorkspace . uri . fsPath ) ; } this . trySignInWithPersistentStorage ( ) ; worker . work ( ) ; } public smartUpdateProvider ( treeItem ) { if ( treeItem instanceof TimePeriodItem ) { this . providerManager . showChangesProvider ( ) ; } else if ( treeItem instanceof CheckInInfoItem || treeItem instanceof CvsResourceItem ) { this . providerManager . showResourceProvider ( ) ; } else if ( treeItem instanceof ProjectItem || treeItem instanceof BuildConfigItem ) { this . providerManager . showBuildProvider ( ) ; } } public dispose ( ) { this . _disposables . forEach ( ( disposable ) => disposable . dispose ( ) ) ; } public get commandHolder ( ) : CommandHolder { return this . _commandHolder ; } private initLogger ( loggingLevel , rootPath ) { if ( loggingLevel === undefined ) { return ; } Logger . SetLoggingLevel ( loggingLevel ) ; if ( rootPath !== undefined ) { Logger . LogPath = rootPath ; Logger . logInfo ( `Logger path: ${ rootPath }` ) ; Logger . logInfo ( `Logging level: ${ loggingLevel }` ) ; } else { Logger . logWarning ( `Folder not opened!` ) ; } } private trySignInWithPersistentStorage ( ) { this . commandHolder . signIn ( true ) ; } }