contextMenuService.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. var __param = (this && this.__param) || function (paramIndex, decorator) {
  12. return function (target, key) { decorator(target, key, paramIndex); }
  13. };
  14. import { ModifierKeyEmitter } from '../../../base/browser/dom.js';
  15. import { Emitter } from '../../../base/common/event.js';
  16. import { Disposable } from '../../../base/common/lifecycle.js';
  17. import { IKeybindingService } from '../../keybinding/common/keybinding.js';
  18. import { INotificationService } from '../../notification/common/notification.js';
  19. import { ITelemetryService } from '../../telemetry/common/telemetry.js';
  20. import { IThemeService } from '../../theme/common/themeService.js';
  21. import { ContextMenuHandler } from './contextMenuHandler.js';
  22. import { IContextViewService } from './contextView.js';
  23. let ContextMenuService = class ContextMenuService extends Disposable {
  24. constructor(telemetryService, notificationService, contextViewService, keybindingService, themeService) {
  25. super();
  26. this._onDidShowContextMenu = new Emitter();
  27. this._onDidHideContextMenu = new Emitter();
  28. this.contextMenuHandler = new ContextMenuHandler(contextViewService, telemetryService, notificationService, keybindingService, themeService);
  29. }
  30. configure(options) {
  31. this.contextMenuHandler.configure(options);
  32. }
  33. // ContextMenu
  34. showContextMenu(delegate) {
  35. this.contextMenuHandler.showContextMenu(Object.assign(Object.assign({}, delegate), { onHide: (didCancel) => {
  36. if (delegate.onHide) {
  37. delegate.onHide(didCancel);
  38. }
  39. this._onDidHideContextMenu.fire();
  40. } }));
  41. ModifierKeyEmitter.getInstance().resetKeyStatus();
  42. this._onDidShowContextMenu.fire();
  43. }
  44. };
  45. ContextMenuService = __decorate([
  46. __param(0, ITelemetryService),
  47. __param(1, INotificationService),
  48. __param(2, IContextViewService),
  49. __param(3, IKeybindingService),
  50. __param(4, IThemeService)
  51. ], ContextMenuService);
  52. export { ContextMenuService };