errorList.contribution.ts 2.4 KB
Newer Older
A
Alex Dima 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import nls = require('vs/nls');
I
isidor 已提交
7 8
import { Action } from 'vs/base/common/actions';
import { TPromise } from 'vs/base/common/winjs.base';
S
Sandeep Somavarapu 已提交
9
// import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
A
Alex Dima 已提交
10
import platform = require('vs/platform/platform');
S
Sandeep Somavarapu 已提交
11 12
// import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
// import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actionRegistry';
A
Alex Dima 已提交
13
import panel = require('vs/workbench/browser/panel');
I
isidor 已提交
14 15 16
import { ERROR_LIST_PANEL_ID } from 'vs/workbench/parts/errorList/browser/errorListConstants';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
A
Alex Dima 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

class ToggleErrorListAction extends Action {

	public static ID = 'workbench.action.errorList.toggle';
	public static LABEL = nls.localize('toggleErrorList', "Toggle Error List");

	constructor(id: string, label: string,
		@IPartService private partService: IPartService,
		@IPanelService private panelService: IPanelService
	) {
		super(id, label);
	}

	public run(event?: any): TPromise<any> {
		const panel = this.panelService.getActivePanel();
		if (panel && panel.getId() === ERROR_LIST_PANEL_ID) {
			this.partService.setPanelHidden(true);

			return TPromise.as(null);
		}

		return this.panelService.openPanel(ERROR_LIST_PANEL_ID, true);
	}
}

// register panel
(<panel.PanelRegistry>platform.Registry.as(panel.Extensions.Panels)).registerPanel(new panel.PanelDescriptor(
	'vs/workbench/parts/errorList/browser/errorList',
	'ErrorList',
	ERROR_LIST_PANEL_ID,
	nls.localize('errorListPanel', "Error List"),
	'errorList'
));


S
Sandeep Somavarapu 已提交
52 53 54 55 56 57 58
// let actionRegistry = <IWorkbenchActionRegistry>platform.Registry.as(ActionExtensions.WorkbenchActions);
// actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleErrorListAction, ToggleErrorListAction.ID, ToggleErrorListAction.LABEL, {
// 	primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A,
// 	linux: {
// 		primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_A
// 	}
// }), nls.localize('viewCategory', "View"));