diff --git a/src/vs/editor/browser/standalone/simpleServices.ts b/src/vs/editor/browser/standalone/simpleServices.ts index 39a0207ea7a..c11c3813c5e 100644 --- a/src/vs/editor/browser/standalone/simpleServices.ts +++ b/src/vs/editor/browser/standalone/simpleServices.ts @@ -6,7 +6,6 @@ import {toErrorMessage} from 'vs/base/common/errors'; import {EventEmitter} from 'vs/base/common/eventEmitter'; -import {IDisposable} from 'vs/base/common/lifecycle'; import {Schemas} from 'vs/base/common/network'; import Severity from 'vs/base/common/severity'; import URI from 'vs/base/common/uri'; @@ -197,12 +196,6 @@ export class SimpleMessageService implements IMessageService { return window.confirm(messageText); } - - public setStatusMessage(message: string, autoDisposeAfter:number = -1): IDisposable { - return { - dispose: () => { /* Nothing to do here */ } - }; - } } export class SimpleEditorRequestService extends BaseRequestService { diff --git a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts index 74e1bd2203a..8247a997b7d 100644 --- a/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts +++ b/src/vs/platform/keybinding/browser/keybindingServiceImpl.ts @@ -18,6 +18,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat import {KeybindingResolver} from 'vs/platform/keybinding/common/keybindingResolver'; import {ICommandHandler, ICommandHandlerDescription, IKeybindingContextKey, IKeybindingItem, IKeybindingScopeLocation, IKeybindingService, SET_CONTEXT_COMMAND_ID} from 'vs/platform/keybinding/common/keybindingService'; import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; +import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IMessageService} from 'vs/platform/message/common/message'; import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; @@ -188,9 +189,10 @@ export abstract class KeybindingService extends AbstractKeybindingService implem private _firstTimeComputingResolver: boolean; private _currentChord: number; private _currentChordStatusMessage: IDisposable; + private _statusService: IStatusbarService; private _messageService: IMessageService; - constructor(configurationService: IConfigurationService, messageService: IMessageService) { + constructor(configurationService: IConfigurationService, messageService: IMessageService, statusService?: IStatusbarService) { super(0); this._lastContextId = 0; this._contexts = Object.create(null); @@ -201,6 +203,7 @@ export abstract class KeybindingService extends AbstractKeybindingService implem this._currentChordStatusMessage = null; this._configurationContext = new ConfigurationContext(configurationService); this._toDispose.push(this._configurationContext); + this._statusService = statusService; this._messageService = messageService; } @@ -303,18 +306,18 @@ export abstract class KeybindingService extends AbstractKeybindingService implem if (resolveResult && resolveResult.enterChord) { e.preventDefault(); this._currentChord = resolveResult.enterChord; - if (this._messageService) { + if (this._statusService) { let firstPartLabel = this.getLabelFor(new Keybinding(this._currentChord)); - this._currentChordStatusMessage = this._messageService.setStatusMessage(nls.localize('first.chord', "({0}) was pressed. Waiting for second key of chord...", firstPartLabel)); + this._currentChordStatusMessage = this._statusService.setStatusMessage(nls.localize('first.chord', "({0}) was pressed. Waiting for second key of chord...", firstPartLabel)); } return; } - if (this._messageService && this._currentChord) { + if (this._statusService && this._currentChord) { if (!resolveResult || !resolveResult.commandId) { let firstPartLabel = this.getLabelFor(new Keybinding(this._currentChord)); let chordPartLabel = this.getLabelFor(new Keybinding(e.asKeybinding())); - this._messageService.setStatusMessage(nls.localize('missing.chord', "The key combination ({0}, {1}) is not a command.", firstPartLabel, chordPartLabel), 10 * 1000 /* 10s */); + this._statusService.setStatusMessage(nls.localize('missing.chord', "The key combination ({0}, {1}) is not a command.", firstPartLabel, chordPartLabel), 10 * 1000 /* 10s */); e.preventDefault(); } } diff --git a/src/vs/platform/message/common/message.ts b/src/vs/platform/message/common/message.ts index fccbeefc07f..1fdb81b59d3 100644 --- a/src/vs/platform/message/common/message.ts +++ b/src/vs/platform/message/common/message.ts @@ -6,7 +6,6 @@ import nls = require('vs/nls'); import {TPromise} from 'vs/base/common/winjs.base'; -import {IDisposable} from 'vs/base/common/lifecycle'; import Severity from 'vs/base/common/severity'; import {createDecorator, ServiceIdentifier} from 'vs/platform/instantiation/common/instantiation'; import {Action} from 'vs/base/common/actions'; @@ -42,11 +41,6 @@ export interface IMessageService { show(sev: Severity, message: Error[]): () => void; show(sev: Severity, message: IMessageWithAction): () => void; - /** - * Prints something to the status bar area with optional auto dispose and delay. - */ - setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable; - /** * Hide any messages showing currently. */ diff --git a/src/vs/workbench/services/statusbar/common/statusbarService.ts b/src/vs/platform/statusbar/common/statusbar.ts similarity index 89% rename from src/vs/workbench/services/statusbar/common/statusbarService.ts rename to src/vs/platform/statusbar/common/statusbar.ts index 19b3447822b..b5a5ca51ac9 100644 --- a/src/vs/workbench/services/statusbar/common/statusbarService.ts +++ b/src/vs/platform/statusbar/common/statusbar.ts @@ -51,4 +51,9 @@ export interface IStatusbarService { * to remove the statusbar entry. */ addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority?: number): IDisposable; + + /** + * Prints something to the status bar area with optional auto dispose and delay. + */ + setStatusMessage(message: string, autoDisposeAfter?: number, delayBy?: number): IDisposable; } \ No newline at end of file diff --git a/src/vs/workbench/api/node/extHostStatusBar.ts b/src/vs/workbench/api/node/extHostStatusBar.ts index f9b359c0835..1c7bdf2571a 100644 --- a/src/vs/workbench/api/node/extHostStatusBar.ts +++ b/src/vs/workbench/api/node/extHostStatusBar.ts @@ -5,7 +5,7 @@ 'use strict'; import {Remotable, IThreadService} from 'vs/platform/thread/common/thread'; -import {IStatusbarService, StatusbarAlignment as MainThreadStatusBarAlignment} from 'vs/workbench/services/statusbar/common/statusbarService'; +import {IStatusbarService, StatusbarAlignment as MainThreadStatusBarAlignment} from 'vs/platform/statusbar/common/statusbar'; import {IDisposable} from 'vs/base/common/lifecycle'; import {StatusBarAlignment as ExtHostStatusBarAlignment, Disposable} from './extHostTypes'; import {StatusBarItem, StatusBarAlignment} from 'vscode'; diff --git a/src/vs/workbench/browser/parts/statusbar/statusbar.ts b/src/vs/workbench/browser/parts/statusbar/statusbar.ts index e09f60c106f..3a80eb21bca 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbar.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbar.ts @@ -7,7 +7,7 @@ import {Registry} from 'vs/platform/platform'; import {IDisposable} from 'vs/base/common/lifecycle'; /* tslint:disable:no-unused-variable */ -import statusbarService = require('vs/workbench/services/statusbar/common/statusbarService'); +import statusbarService = require('vs/platform/statusbar/common/statusbar'); /* tslint:enable:no-unused-variable */ import {SyncDescriptor0, createSyncDescriptor} from 'vs/platform/instantiation/common/descriptors'; import {IConstructorSignature0} from 'vs/platform/instantiation/common/instantiation'; diff --git a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts index c303ecb2e04..64fdedc32ea 100644 --- a/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts +++ b/src/vs/workbench/browser/parts/statusbar/statusbarPart.ts @@ -24,7 +24,7 @@ import {StatusbarAlignment, IStatusbarRegistry, Extensions, IStatusbarItem} from import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; import {IMessageService, Severity} from 'vs/platform/message/common/message'; -import {IStatusbarService, IStatusbarEntry} from 'vs/workbench/services/statusbar/common/statusbarService'; +import {IStatusbarService, IStatusbarEntry} from 'vs/platform/statusbar/common/statusbar'; export class StatusbarPart extends Part implements IStatusbarService { @@ -35,6 +35,7 @@ export class StatusbarPart extends Part implements IStatusbarService { private toDispose: IDisposable[]; private statusItemsContainer: Builder; + private statusMsgDispose: IDisposable; constructor( id: string, @@ -139,6 +140,44 @@ export class StatusbarPart extends Part implements IStatusbarService { return el; } + public setStatusMessage(message: string, autoDisposeAfter: number = -1, delayBy: number = 0): IDisposable { + if (this.statusMsgDispose) { + this.statusMsgDispose.dispose(); // dismiss any previous + } + + // Create new + let statusDispose: IDisposable; + let showHandle = setTimeout(() => { + statusDispose = this.addEntry({ text: message }, StatusbarAlignment.LEFT, Number.MIN_VALUE); + showHandle = null; + }, delayBy); + let hideHandle: number; + + // Dispose function takes care of timeouts and actual entry + const dispose = { + dispose: () => { + if (showHandle) { + clearTimeout(showHandle); + } + + if (hideHandle) { + clearTimeout(hideHandle); + } + + if (statusDispose) { + statusDispose.dispose(); + } + } + }; + this.statusMsgDispose = dispose; + + if (typeof autoDisposeAfter === 'number' && autoDisposeAfter > 0) { + hideHandle = setTimeout(() => dispose.dispose(), autoDisposeAfter); + } + + return dispose; + } + public dispose(): void { this.toDispose = dispose(this.toDispose); diff --git a/src/vs/workbench/browser/workbench.ts b/src/vs/workbench/browser/workbench.ts index 518e5f29d6c..116e84da39d 100644 --- a/src/vs/workbench/browser/workbench.ts +++ b/src/vs/workbench/browser/workbench.ts @@ -44,10 +44,14 @@ import {WorkbenchEditorService} from 'vs/workbench/services/editor/browser/edito import {Position, Parts, IPartService} from 'vs/workbench/services/part/common/partService'; import {IWorkspaceContextService as IWorkbenchWorkspaceContextService} from 'vs/workbench/services/workspace/common/contextService'; import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'; +import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService'; +import {WorkbenchKeybindingService} from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; import {IWorkspace, IConfiguration} from 'vs/platform/workspace/common/workspace'; import {IKeybindingService} from 'vs/platform/keybinding/common/keybindingService'; import {IActivityService} from 'vs/workbench/services/activity/common/activityService'; +import {IExtensionService} from 'vs/platform/extensions/common/extensions'; import {IViewletService} from 'vs/workbench/services/viewlet/common/viewletService'; +import {IConfigurationService} from 'vs/platform/configuration/common/configuration'; import {IPanelService} from 'vs/workbench/services/panel/common/panelService'; import {WorkbenchMessageService} from 'vs/workbench/services/message/browser/messageService'; import {IWorkbenchEditorService} from 'vs/workbench/services/editor/common/editorService'; @@ -61,7 +65,10 @@ import {IMessageService} from 'vs/platform/message/common/message'; import {ITelemetryService, Extenstions as TelemetryExtensions} from 'vs/platform/telemetry/common/telemetry'; import {IThreadService} from 'vs/platform/thread/common/thread'; import {MainThreadService} from 'vs/platform/thread/common/mainThreadService'; -import {IStatusbarService} from 'vs/workbench/services/statusbar/common/statusbarService'; +import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; +import {IActionsService} from 'vs/platform/actions/common/actions'; +import ActionsService from 'vs/platform/actions/common/actionsService'; +import {IContextMenuService} from 'vs/platform/contextview/browser/contextView'; interface WorkbenchParams { workspace?: IWorkspace; @@ -72,7 +79,7 @@ interface WorkbenchParams { export interface IWorkbenchCallbacks { onServicesCreated?: () => void; - onWorkbenchStarted?: () => void; + onWorkbenchStarted?: (customKeybindingsCount: number) => void; } /** @@ -94,6 +101,7 @@ export class Workbench implements IPartService { private workbenchCreated: boolean; private workbenchShutdown: boolean; private editorService: WorkbenchEditorService; + private keybindingService: IKeybindingService; private activitybarPart: ActivitybarPart; private sidebarPart: SidebarPart; private panelPart: PanelPart; @@ -111,17 +119,23 @@ export class Workbench implements IPartService { private panelHidden: boolean; private editorBackgroundDelayer: Delayer; - constructor(container: HTMLElement, workspace: IWorkspace, configuration: IConfiguration, options: IOptions, serviceCollection: ServiceCollection, + constructor( + container: HTMLElement, + workspace: IWorkspace, + configuration: IConfiguration, + options: IOptions, + serviceCollection: ServiceCollection, @IInstantiationService private instantiationService: IInstantiationService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService, + @IConfigurationService private configurationService: IConfigurationService, @IEventService private eventService: IEventService, @IWorkbenchWorkspaceContextService private contextService: IWorkbenchWorkspaceContextService, @IStorageService private storageService: IStorageService, @ITelemetryService private telemetryService: ITelemetryService, - @IKeybindingService private keybindingService: IKeybindingService, @ILifecycleService private lifecycleService: ILifecycleService, @IMessageService private messageService: IMessageService, - @IThreadService private threadService: IThreadService + @IThreadService private threadService: IThreadService, + @IExtensionService private extensionService: IExtensionService ) { // Validate params @@ -277,7 +291,7 @@ export class Workbench implements IPartService { this.creationPromiseComplete(true); if (this.callbacks && this.callbacks.onWorkbenchStarted) { - this.callbacks.onWorkbenchStarted(); + this.callbacks.onWorkbenchStarted(this.keybindingService.customKeybindingsCount()); } if (error) { @@ -305,6 +319,22 @@ export class Workbench implements IPartService { // Services we contribute serviceCollection.set(IPartService, this); + // Status bar + this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART); + this.toDispose.push(this.statusbarPart); + this.toShutdown.push(this.statusbarPart); + serviceCollection.set(IStatusbarService, this.statusbarPart); + + // Keybindings + this.keybindingService = new WorkbenchKeybindingService(this.configurationService, this.contextService, this.eventService, this.telemetryService, this.messageService, this.statusbarPart, this.extensionService, window); + serviceCollection.set(IKeybindingService, this.keybindingService); + + // Context Menu + serviceCollection.set(IContextMenuService, new ContextMenuService(this.messageService, this.telemetryService, this.keybindingService)); + + // Actions + serviceCollection.set(IActionsService, new ActionsService(this.extensionService, this.keybindingService)); + // Viewlet service (sidebar part) this.sidebarPart = this.instantiationService.createInstance(SidebarPart, Identifiers.SIDEBAR_PART); this.toDispose.push(this.sidebarPart); @@ -338,18 +368,8 @@ export class Workbench implements IPartService { this.quickOpen = this.instantiationService.createInstance(QuickOpenController); this.toDispose.push(this.quickOpen); this.toShutdown.push(this.quickOpen); - if (this.messageService instanceof WorkbenchMessageService) { - this.toDispose.push(this.quickOpen.onShow(() => (this.messageService).suspend())); // when quick open is open, don't show messages behind - this.toDispose.push(this.quickOpen.onHide(() => (this.messageService).resume())); // resume messages once quick open is closed again - } serviceCollection.set(IQuickOpenService, this.quickOpen); - // Status bar - this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART); - this.toDispose.push(this.statusbarPart); - this.toShutdown.push(this.statusbarPart); - serviceCollection.set(IStatusbarService, this.statusbarPart); - // History serviceCollection.set(IHistoryService, new HistoryService(this.eventService, this.editorService, this.contextService, this.quickOpen)); @@ -363,9 +383,6 @@ export class Workbench implements IPartService { if (this.threadService instanceof MainThreadService) { (this.threadService).setInstantiationService(this.instantiationService); } - if (this.messageService instanceof WorkbenchMessageService) { - (this.messageService).setWorkbenchServices(this.statusbarPart); - } (this.keybindingService).setInstantiationService(this.instantiationService); // Set the some services to registries that have been created eagerly @@ -611,6 +628,17 @@ export class Workbench implements IPartService { // Listen to editor changes this.toDispose.push(this.toDisposable(this.eventService.addListener(EventType.EDITOR_CLOSED, () => this.onEditorOpenedOrClosed()))); this.toDispose.push(this.toDisposable(this.eventService.addListener(EventType.EDITOR_OPENED, () => this.onEditorOpenedOrClosed()))); + + // Handle message service and quick open events + if (this.messageService instanceof WorkbenchMessageService) { + const messagesShowingContextKey = this.keybindingService.createKey('globalMessageVisible', false); + + this.toDispose.push((this.messageService).onMessagesShowing(() => messagesShowingContextKey.set(true))); + this.toDispose.push((this.messageService).onMessagesCleared(() => messagesShowingContextKey.reset())); + + this.toDispose.push(this.quickOpen.onShow(() => (this.messageService).suspend())); // when quick open is open, don't show messages behind + this.toDispose.push(this.quickOpen.onHide(() => (this.messageService).resume())); // resume messages once quick open is closed again + } } private onEditorOpenedOrClosed(): void { diff --git a/src/vs/workbench/electron-browser/shell.ts b/src/vs/workbench/electron-browser/shell.ts index 4035fd20e0a..f6d45a7834b 100644 --- a/src/vs/workbench/electron-browser/shell.ts +++ b/src/vs/workbench/electron-browser/shell.ts @@ -17,7 +17,6 @@ import aria = require('vs/base/browser/ui/aria/aria'); import {dispose, IDisposable} from 'vs/base/common/lifecycle'; import errors = require('vs/base/common/errors'); import {ContextViewService} from 'vs/platform/contextview/browser/contextViewService'; -import {ContextMenuService} from 'vs/workbench/services/contextview/electron-browser/contextmenuService'; import timer = require('vs/base/common/timer'); import {Workbench} from 'vs/workbench/browser/workbench'; import {Storage, inMemoryLocalStorageInstance} from 'vs/workbench/common/storage'; @@ -33,11 +32,8 @@ import {IConfigurationService} from 'vs/platform/configuration/common/configurat import {FileService} from 'vs/workbench/services/files/electron-browser/fileService'; import {SearchService} from 'vs/workbench/services/search/node/searchService'; import {LifecycleService} from 'vs/workbench/services/lifecycle/electron-browser/lifecycleService'; -import {WorkbenchKeybindingService} from 'vs/workbench/services/keybinding/electron-browser/keybindingService'; import {MainThreadService} from 'vs/workbench/services/thread/electron-browser/threadService'; import {MainProcessMarkerService} from 'vs/platform/markers/common/markerService'; -import {IActionsService} from 'vs/platform/actions/common/actions'; -import ActionsService from 'vs/platform/actions/common/actionsService'; import {IModelService} from 'vs/editor/common/services/modelService'; import {ModelServiceImpl} from 'vs/editor/common/services/modelServiceImpl'; import {CodeEditorServiceImpl} from 'vs/editor/browser/services/codeEditorServiceImpl'; @@ -50,10 +46,9 @@ import {IStorageService} from 'vs/platform/storage/common/storage'; import {ServiceCollection} from 'vs/platform/instantiation/common/serviceCollection'; import {InstantiationService} from 'vs/platform/instantiation/common/instantiationService'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; -import {IContextViewService, IContextMenuService} from 'vs/platform/contextview/browser/contextView'; +import {IContextViewService} from 'vs/platform/contextview/browser/contextView'; import {IEventService} from 'vs/platform/event/common/event'; import {IFileService} from 'vs/platform/files/common/files'; -import {IKeybindingService, IKeybindingContextKey} from 'vs/platform/keybinding/common/keybindingService'; import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {IMessageService, Severity} from 'vs/platform/message/common/message'; @@ -73,9 +68,7 @@ import {connect} from 'vs/base/parts/ipc/node/ipc.net'; import {IExtensionsChannel, ExtensionsChannelClient} from 'vs/workbench/parts/extensions/common/extensionsIpc'; import {IExtensionsService} from 'vs/workbench/parts/extensions/common/extensions'; import {ReloadWindowAction} from 'vs/workbench/electron-browser/actions'; - -// self registering service -import 'vs/platform/opener/electron-browser/opener.contribution'; +import 'vs/platform/opener/electron-browser/opener.contribution'; // self registering service /** * Services that we require for the Shell @@ -101,7 +94,6 @@ export class WorkbenchShell { private themeService: ThemeService; private contextService: IWorkspaceContextService; private telemetryService: ITelemetryService; - private keybindingService: WorkbenchKeybindingService; private container: HTMLElement; private toUnbind: IDisposable[]; @@ -116,8 +108,6 @@ export class WorkbenchShell { private options: IOptions; private workbench: Workbench; - private messagesShowingContextKey: IKeybindingContextKey; - constructor(container: HTMLElement, workspace: IWorkspace, services: ICoreServices, configuration: IConfiguration, options: IOptions) { this.container = container; @@ -153,8 +143,8 @@ export class WorkbenchShell { // Workbench this.workbench = instantiationService.createInstance(Workbench, workbenchContainer.getHTMLElement(), this.workspace, this.configuration, this.options, serviceCollection); this.workbench.startup({ - onWorkbenchStarted: () => { - this.onWorkbenchStarted(); + onWorkbenchStarted: (customKeybindingsCount) => { + this.onWorkbenchStarted(customKeybindingsCount); } }); @@ -176,7 +166,7 @@ export class WorkbenchShell { return workbenchContainer; } - private onWorkbenchStarted(): void { + private onWorkbenchStarted(customKeybindingsCount: number): void { // Log to telemetry service let windowSize = { @@ -191,7 +181,7 @@ export class WorkbenchShell { userAgent: navigator.userAgent, windowSize: windowSize, emptyWorkbench: !this.contextService.getWorkspace(), - customKeybindingsCount: this.keybindingService.customKeybindingsCount(), + customKeybindingsCount, theme: this.currentTheme, language: platform.language }); @@ -242,11 +232,6 @@ export class WorkbenchShell { let extensionService = new MainProcessExtensionService(this.contextService, this.threadService, this.messageService, this.telemetryService); - this.keybindingService = new WorkbenchKeybindingService(this.configurationService, this.contextService, this.eventService, this.telemetryService, this.messageService, extensionService, window); - this.messagesShowingContextKey = this.keybindingService.createKey('globalMessageVisible', false); - this.toUnbind.push(this.messageService.onMessagesShowing(() => this.messagesShowingContextKey.set(true))); - this.toUnbind.push(this.messageService.onMessagesCleared(() => this.messagesShowingContextKey.reset())); - this.contextViewService = new ContextViewService(this.container, this.telemetryService, this.messageService); let requestService = new RequestService( @@ -270,7 +255,6 @@ export class WorkbenchShell { serviceCollection.set(IRequestService, requestService); serviceCollection.set(IWorkspaceContextService, this.contextService); serviceCollection.set(IContextViewService, this.contextViewService); - serviceCollection.set(IContextMenuService, new ContextMenuService(this.messageService, this.telemetryService, this.keybindingService)); serviceCollection.set(IMessageService, this.messageService); serviceCollection.set(IStorageService, this.storageService); serviceCollection.set(ILifecycleService, lifecycleService); @@ -282,13 +266,11 @@ export class WorkbenchShell { serviceCollection.set(ISearchService, new SearchService(modelService, untitledEditorService, this.contextService, this.configurationService)); serviceCollection.set(IWindowService, this.windowService); serviceCollection.set(IConfigurationService, this.configurationService); - serviceCollection.set(IKeybindingService, this.keybindingService); serviceCollection.set(IMarkerService, markerService); serviceCollection.set(IModelService, modelService); serviceCollection.set(ICodeEditorService, new CodeEditorServiceImpl()); serviceCollection.set(IEditorWorkerService, editorWorkerService); serviceCollection.set(IThemeService, this.themeService); - serviceCollection.set(IActionsService, new ActionsService(extensionService, this.keybindingService)); serviceCollection.set(IExtensionsService, new ExtensionsChannelClient(this.initSharedProcessChannel(instantiationService, this.messageService))); return [instantiationService, serviceCollection]; diff --git a/src/vs/workbench/services/contextview/electron-browser/contextmenuService.ts b/src/vs/workbench/services/contextview/electron-browser/contextmenuService.ts index f50127166a6..6c4a4176f8a 100644 --- a/src/vs/workbench/services/contextview/electron-browser/contextmenuService.ts +++ b/src/vs/workbench/services/contextview/electron-browser/contextmenuService.ts @@ -22,14 +22,7 @@ export class ContextMenuService implements IContextMenuService { public serviceId = IContextMenuService; - private telemetryService: ITelemetryService; - private messageService: IMessageService; - private keybindingService: IKeybindingService; - - constructor(messageService: IMessageService, telemetryService: ITelemetryService, keybindingService: IKeybindingService) { - this.messageService = messageService; - this.telemetryService = telemetryService; - this.keybindingService = keybindingService; + constructor(private messageService: IMessageService, private telemetryService: ITelemetryService, private keybindingService: IKeybindingService) { } public showContextMenu(delegate: IContextMenuDelegate): void { @@ -77,7 +70,7 @@ export class ContextMenuService implements IContextMenuService { x = pos.x; y = pos.y; } - + let zoom = webFrame.getZoomFactor(); x *= zoom; y *= zoom; diff --git a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts index df5529d451b..fcf3448baec 100644 --- a/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts +++ b/src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts @@ -15,6 +15,7 @@ import {IExtensionService} from 'vs/platform/extensions/common/extensions'; import {IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry'; import {Extensions, IJSONContributionRegistry} from 'vs/platform/jsonschemas/common/jsonContributionRegistry'; import {KeybindingService} from 'vs/platform/keybinding/browser/keybindingServiceImpl'; +import {IStatusbarService} from 'vs/platform/statusbar/common/statusbar'; import {IOSupport} from 'vs/platform/keybinding/common/keybindingResolver'; import {IKeybindingItem, IUserFriendlyKeybinding} from 'vs/platform/keybinding/common/keybindingService'; import {ICommandRule, KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegistry'; @@ -35,7 +36,7 @@ interface ContributedKeyBinding { win?: string; } -function isContributedKeyBindingsArray(thing: ContributedKeyBinding|ContributedKeyBinding[]): thing is ContributedKeyBinding[] { +function isContributedKeyBindingsArray(thing: ContributedKeyBinding | ContributedKeyBinding[]): thing is ContributedKeyBinding[] { return Array.isArray(thing); } @@ -71,7 +72,7 @@ function isValidContributedKeyBinding(keyBinding: ContributedKeyBinding, rejects return true; } -let keybindingType:IJSONSchema = { +let keybindingType: IJSONSchema = { type: 'object', default: { command: '', key: '' }, properties: { @@ -122,8 +123,8 @@ export class WorkbenchKeybindingService extends KeybindingService { private _extensionService: IExtensionService; private _eventService: IEventService; - constructor(configurationService: IConfigurationService, contextService: IWorkspaceContextService, eventService: IEventService, telemetryService: ITelemetryService, messageService: IMessageService, extensionService: IExtensionService, domNode: HTMLElement) { - super(configurationService, messageService); + constructor(configurationService: IConfigurationService, contextService: IWorkspaceContextService, eventService: IEventService, telemetryService: ITelemetryService, messageService: IMessageService, statusBarService: IStatusbarService, extensionService: IExtensionService, domNode: HTMLElement) { + super(configurationService, messageService, statusBarService); this.contextService = contextService; this.eventService = eventService; this.telemetryService = telemetryService; @@ -183,11 +184,11 @@ export class WorkbenchKeybindingService extends KeybindingService { this.toDispose(); } - public getLabelFor(keybinding:Keybinding): string { + public getLabelFor(keybinding: Keybinding): string { return keybinding.toCustomLabel(getNativeLabelProvider()); } - public getHTMLLabelFor(keybinding:Keybinding): IHTMLContentElement[] { + public getHTMLLabelFor(keybinding: Keybinding): IHTMLContentElement[] { return keybinding.toCustomHTMLLabel(getNativeLabelProvider()); } @@ -195,7 +196,7 @@ export class WorkbenchKeybindingService extends KeybindingService { return keybinding.toCustomLabel(getNativeAriaLabelProvider()); } - public getElectronAcceleratorFor(keybinding:Keybinding): string { + public getElectronAcceleratorFor(keybinding: Keybinding): string { if (platform.isWindows) { // electron menus always do the correct rendering on Windows return super.getElectronAcceleratorFor(keybinding); @@ -212,7 +213,7 @@ export class WorkbenchKeybindingService extends KeybindingService { return super.getElectronAcceleratorFor(keybinding); } - private _handleKeybindingsExtensionPointUser(isBuiltin: boolean, keybindings:ContributedKeyBinding | ContributedKeyBinding[], collector:IExtensionMessageCollector): boolean { + private _handleKeybindingsExtensionPointUser(isBuiltin: boolean, keybindings: ContributedKeyBinding | ContributedKeyBinding[], collector: IExtensionMessageCollector): boolean { if (isContributedKeyBindingsArray(keybindings)) { let commandAdded = false; for (let i = 0, len = keybindings.length; i < len; i++) { @@ -224,7 +225,7 @@ export class WorkbenchKeybindingService extends KeybindingService { } } - private _handleKeybinding(isBuiltin: boolean, idx:number, keybindings:ContributedKeyBinding, collector:IExtensionMessageCollector): boolean { + private _handleKeybinding(isBuiltin: boolean, idx: number, keybindings: ContributedKeyBinding, collector: IExtensionMessageCollector): boolean { let rejects: string[] = []; let commandAdded = false; @@ -258,7 +259,7 @@ export class WorkbenchKeybindingService extends KeybindingService { return TPromise.as(null); } - private _asCommandRule(isBuiltin: boolean, idx:number, binding: ContributedKeyBinding): ICommandRule { + private _asCommandRule(isBuiltin: boolean, idx: number, binding: ContributedKeyBinding): ICommandRule { let {command, when, key, mac, linux, win} = binding; @@ -288,14 +289,14 @@ export class WorkbenchKeybindingService extends KeybindingService { } let schemaId = 'vscode://schemas/keybindings'; -let schema : IJSONSchema = { +let schema: IJSONSchema = { 'id': schemaId, 'type': 'array', 'title': nls.localize('keybindings.json.title', "Keybindings configuration"), 'items': { 'required': ['key'], 'type': 'object', - 'defaultSnippets': [ { 'body': { 'key': '{{_}}', 'command': '{{_}}', 'when': '{{_}}' } }], + 'defaultSnippets': [{ 'body': { 'key': '{{_}}', 'command': '{{_}}', 'when': '{{_}}' } }], 'properties': { 'key': { 'type': 'string', diff --git a/src/vs/workbench/services/message/browser/messageService.ts b/src/vs/workbench/services/message/browser/messageService.ts index 37faab197aa..cd46aff83a4 100644 --- a/src/vs/workbench/services/message/browser/messageService.ts +++ b/src/vs/workbench/services/message/browser/messageService.ts @@ -8,11 +8,9 @@ import errors = require('vs/base/common/errors'); import types = require('vs/base/common/types'); import {MessageList, Severity as BaseSeverity} from 'vs/base/browser/ui/messagelist/messageList'; import {Identifiers} from 'vs/workbench/common/constants'; -import {StatusbarAlignment} from 'vs/workbench/browser/parts/statusbar/statusbar'; import {IDisposable} from 'vs/base/common/lifecycle'; import {IMessageService, IMessageWithAction, IConfirmation, Severity} from 'vs/platform/message/common/message'; import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry'; -import {IStatusbarService} from 'vs/workbench/services/statusbar/common/statusbarService'; import Event from 'vs/base/common/event'; interface IBufferedMessage { @@ -27,13 +25,10 @@ export class WorkbenchMessageService implements IMessageService { private handler: MessageList; private disposeables: IDisposable[]; - private statusMsgDispose: IDisposable; private canShowMessages: boolean; private messageBuffer: IBufferedMessage[]; - private statusbarService: IStatusbarService; - constructor( private telemetryService: ITelemetryService ) { @@ -44,10 +39,6 @@ export class WorkbenchMessageService implements IMessageService { this.disposeables = []; } - public setWorkbenchServices(statusbarService: IStatusbarService): void { - this.statusbarService = statusbarService; - } - public get onMessagesShowing(): Event { return this.handler.onMessagesShowing; } @@ -132,48 +123,6 @@ export class WorkbenchMessageService implements IMessageService { return this.handler.showMessage(this.toBaseSeverity(sev), message); } - public setStatusMessage(message: string, autoDisposeAfter: number = -1, delayBy: number = 0): IDisposable { - if (this.statusbarService) { - if (this.statusMsgDispose) { - this.statusMsgDispose.dispose(); // dismiss any previous - } - - // Create new - let statusDispose: IDisposable; - let showHandle = setTimeout(() => { - statusDispose = this.statusbarService.addEntry({ text: message }, StatusbarAlignment.LEFT, Number.MIN_VALUE); - showHandle = null; - }, delayBy); - let hideHandle: number; - - // Dispose function takes care of timeouts and actual entry - const dispose = { - dispose: () => { - if (showHandle) { - clearTimeout(showHandle); - } - - if (hideHandle) { - clearTimeout(hideHandle); - } - - if (statusDispose) { - statusDispose.dispose(); - } - } - }; - this.statusMsgDispose = dispose; - - if (typeof autoDisposeAfter === 'number' && autoDisposeAfter > 0) { - hideHandle = setTimeout(() => dispose.dispose(), autoDisposeAfter); - } - - return dispose; - } - - return { dispose: () => { /* not yet ready */ } }; - } - public hideAll(): void { if (this.handler) { this.handler.hideMessages(); diff --git a/src/vs/workbench/test/browser/servicesTestUtils.ts b/src/vs/workbench/test/browser/servicesTestUtils.ts index ad24c55faca..8d1bfe4307d 100644 --- a/src/vs/workbench/test/browser/servicesTestUtils.ts +++ b/src/vs/workbench/test/browser/servicesTestUtils.ts @@ -119,12 +119,6 @@ export class TestMessageService implements IMessageService { public confirm(confirmation: IConfirmation): boolean { return false; } - - public setStatusMessage(message: string, autoDisposeAfter: number = -1): Lifecycle.IDisposable { - return { - dispose: () => { /* Nothing to do here */ } - }; - } } export class TestPartService implements PartService.IPartService {