scm.contribution.ts 4.0 KB
Newer Older
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

J
Joao Moreno 已提交
8
import { localize } from 'vs/nls';
9
import { Registry } from 'vs/platform/registry/common/platform';
10
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
J
Joao Moreno 已提交
11
import { DirtyDiffWorkbenchController } from './dirtydiffDecorator';
J
Joao Moreno 已提交
12
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ToggleViewletAction } from 'vs/workbench/browser/viewlet';
J
Joao Moreno 已提交
13
import { VIEWLET_ID } from 'vs/workbench/parts/scm/common/scm';
B
Benjamin Pasero 已提交
14
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionExtensions } from 'vs/workbench/common/actions';
J
Joao Moreno 已提交
15 16 17
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
J
Joao Moreno 已提交
18
import { StatusUpdater, StatusBarController } from './scmActivity';
19
import { SCMViewlet } from 'vs/workbench/parts/scm/electron-browser/scmViewlet';
20
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
21
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
B
Benjamin Pasero 已提交
22
import { INextEditorGroupsService } from 'vs/workbench/services/group/common/nextEditorGroupsService';
23

J
Joao Moreno 已提交
24
class OpenSCMViewletAction extends ToggleViewletAction {
25

26
	static readonly ID = VIEWLET_ID;
J
Joao Moreno 已提交
27
	static LABEL = localize('toggleGitViewlet', "Show Git");
J
Joao Moreno 已提交
28

B
Benjamin Pasero 已提交
29 30
	constructor(id: string, label: string, @IViewletService viewletService: IViewletService, @INextEditorGroupsService editorGroupService: INextEditorGroupsService) {
		super(id, label, VIEWLET_ID, viewletService, editorGroupService);
J
Joao Moreno 已提交
31 32 33
	}
}

34
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
35
	.registerWorkbenchContribution(DirtyDiffWorkbenchController, LifecyclePhase.Running);
36

J
Joao Moreno 已提交
37
const viewletDescriptor = new ViewletDescriptor(
38
	SCMViewlet,
J
Joao Moreno 已提交
39
	VIEWLET_ID,
J
Joao Moreno 已提交
40
	localize('source control', "Source Control"),
J
Joao Moreno 已提交
41
	'scm',
42
	2
J
Joao Moreno 已提交
43 44 45 46 47
);

Registry.as<ViewletRegistry>(ViewletExtensions.Viewlets)
	.registerViewlet(viewletDescriptor);

48
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
49
	.registerWorkbenchContribution(StatusUpdater, LifecyclePhase.Running);
J
Joao Moreno 已提交
50

51
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
52
	.registerWorkbenchContribution(StatusBarController, LifecyclePhase.Running);
J
Joao Moreno 已提交
53

J
Joao Moreno 已提交
54 55
// Register Action to Open Viewlet
Registry.as<IWorkbenchActionRegistry>(WorkbenchActionExtensions.WorkbenchActions).registerWorkbenchAction(
J
Joao Moreno 已提交
56
	new SyncActionDescriptor(OpenSCMViewletAction, VIEWLET_ID, localize('toggleSCMViewlet', "Show SCM"), {
J
Joao Moreno 已提交
57 58 59 60 61 62
		primary: null,
		win: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G },
		linux: { primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_G },
		mac: { primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.KEY_G }
	}),
	'View: Show SCM',
J
Joao Moreno 已提交
63
	localize('view', "View")
J
Joao Moreno 已提交
64
);
65

66
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration).registerConfiguration({
67
	id: 'scm',
68
	order: 5,
J
Joao Moreno 已提交
69
	title: localize('scmConfigurationTitle', "SCM"),
70 71
	type: 'object',
	properties: {
J
Joao Moreno 已提交
72
		'scm.alwaysShowProviders': {
73
			type: 'boolean',
J
Joao Moreno 已提交
74
			description: localize('alwaysShowProviders', "Whether to always show the Source Control Provider section."),
75
			default: false
76
		},
J
Joao Moreno 已提交
77 78 79 80
		'scm.diffDecorations': {
			type: 'string',
			enum: ['all', 'gutter', 'overview', 'none'],
			default: 'all',
J
Joao Moreno 已提交
81
			description: localize('diffDecorations', "Controls diff decorations in the editor.")
82
		},
J
Joao Moreno 已提交
83
		'scm.diffDecorationsGutterWidth': {
84 85 86 87
			type: 'number',
			enum: [1, 2, 3, 4, 5],
			default: 3,
			description: localize('diffGutterWidth', "Controls the width(px) of diff decorations in gutter (added & modified).")
88 89
		}
	}
90
});