提交 7a5b24d3 编写于 作者: B Benjamin Pasero

first cut commands for up/down/left/right (for #11517)

上级 e56ea2f4
......@@ -74,6 +74,10 @@ export class PagedList<T> {
this.list = new List(container, delegate, pagedRenderers, options);
}
get widget(): List<number> {
return this.list;
}
get onFocusChange(): Event<IFocusChangeEvent<T>> {
return mapEvent(this.list.onFocusChange, ({ elements, indexes }) => ({ elements: elements.map(e => this._model.get(e)), indexes }));
}
......
......@@ -122,8 +122,7 @@ class FocusTrait<T> extends Trait<T> {
}
}
class Controller<T> implements IDisposable {
class KeyboardController<T> implements IDisposable {
private disposables: IDisposable[];
constructor(
......@@ -131,9 +130,6 @@ class Controller<T> implements IDisposable {
private view: ListView<T>
) {
this.disposables = [];
this.disposables.push(view.addListener('mousedown', e => this.onMouseDown(e)));
this.disposables.push(view.addListener('click', e => this.onPointer(e)));
this.disposables.push(view.addListener(TouchEventType.Tap, e => this.onPointer(e)));
const onKeyDown = chain(domEvent(view.domNode, 'keydown'))
.map(e => new StandardKeyboardEvent(e));
......@@ -145,19 +141,6 @@ class Controller<T> implements IDisposable {
onKeyDown.filter(e => e.keyCode === KeyCode.PageDown).on(this.onPageDownArrow, this, this.disposables);
}
private onMouseDown(e: IListMouseEvent<T>) {
e.preventDefault();
e.stopPropagation();
}
private onPointer(e: IListMouseEvent<T>) {
e.preventDefault();
e.stopPropagation();
this.view.domNode.focus();
this.list.setFocus([e.index]);
this.list.setSelection([e.index]);
}
private onEnter(e: StandardKeyboardEvent): void {
e.preventDefault();
e.stopPropagation();
......@@ -201,11 +184,47 @@ class Controller<T> implements IDisposable {
}
}
class MouseController<T> implements IDisposable {
private disposables: IDisposable[];
constructor(
private list: List<T>,
private view: ListView<T>
) {
this.disposables = [];
this.disposables.push(view.addListener('mousedown', e => this.onMouseDown(e)));
this.disposables.push(view.addListener('click', e => this.onPointer(e)));
this.disposables.push(view.addListener(TouchEventType.Tap, e => this.onPointer(e)));
}
private onMouseDown(e: IListMouseEvent<T>) {
e.preventDefault();
e.stopPropagation();
}
private onPointer(e: IListMouseEvent<T>) {
e.preventDefault();
e.stopPropagation();
this.view.domNode.focus();
this.list.setFocus([e.index]);
this.list.setSelection([e.index]);
}
dispose() {
this.disposables = dispose(this.disposables);
}
}
export interface IListOptions extends IListViewOptions {
ariaLabel?: string;
mouseSupport?: boolean;
keyboardSupport?: boolean;
}
const DefaultOptions: IListOptions = {};
const DefaultOptions: IListOptions = {
keyboardSupport: true,
mouseSupport: true
};
export class List<T> implements IDisposable {
......@@ -216,7 +235,8 @@ export class List<T> implements IDisposable {
private selection: Trait<T>;
private eventBufferer: EventBufferer;
private view: ListView<T>;
private controller: Controller<T>;
private mouseController: MouseController<T>;
private keyboardController: KeyboardController<T>;
private disposables: IDisposable[];
@memoize
......@@ -262,13 +282,22 @@ export class List<T> implements IDisposable {
this.view = new ListView(container, delegate, renderers, options);
this.view.domNode.setAttribute('role', 'tree');
this.view.domNode.tabIndex = 0;
this.controller = new Controller(this, this.view);
this._onDOMFocus = domEvent(this.view.domNode, 'focus');
this._onDOMBlur = domEvent(this.view.domNode, 'blur');
this._onDispose = new Emitter<void>();
this.disposables = [this.focus, this.selection, this.view, this.controller, this._onDispose];
this.disposables = [this.focus, this.selection, this.view, this._onDispose];
if (typeof options.keyboardSupport !== 'boolean' || options.keyboardSupport) {
this.keyboardController = new KeyboardController(this, this.view);
this.disposables.push(this.keyboardController);
}
if (typeof options.mouseSupport !== 'boolean' || options.mouseSupport) {
this.mouseController = new MouseController(this, this.view);
this.disposables.push(this.mouseController);
}
this.onFocusChange(this._onFocusChange, this, this.disposables);
......
......@@ -647,6 +647,7 @@ export interface ITreeOptions {
useShadows?: boolean;
paddingOnRow?: boolean;
ariaLabel?: string;
keyboardSupport?: boolean;
}
export interface ITreeContext extends ITreeConfiguration {
......
......@@ -93,6 +93,7 @@ export enum ClickBehavior {
export interface IControllerOptions {
clickBehavior?: ClickBehavior;
keyboardSupport?: boolean;
}
interface IKeybindingDispatcherItem {
......@@ -134,20 +135,24 @@ export class DefaultController implements _.IController {
private options: IControllerOptions;
constructor(options: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_UP }) {
constructor(options: IControllerOptions = { clickBehavior: ClickBehavior.ON_MOUSE_UP, keyboardSupport: true }) {
this.options = options;
this.downKeyBindingDispatcher = new KeybindingDispatcher();
if (typeof options.keyboardSupport !== 'boolean' || options.keyboardSupport) {
this.downKeyBindingDispatcher.set(KeyCode.UpArrow, (t, e) => this.onUp(t, e));
this.downKeyBindingDispatcher.set(KeyCode.DownArrow, (t, e) => this.onDown(t, e));
this.downKeyBindingDispatcher.set(KeyCode.LeftArrow, (t, e) => this.onLeft(t, e));
this.downKeyBindingDispatcher.set(KeyCode.RightArrow, (t, e) => this.onRight(t, e));
if (platform.isMacintosh) {
this.downKeyBindingDispatcher.set(KeyMod.CtrlCmd | KeyCode.UpArrow, (t, e) => this.onLeft(t, e));
}
}
// TODO@Ben adopt more keybindings as configurable commands
this.downKeyBindingDispatcher.set(KeyCode.Space, (t, e) => this.onSpace(t, e));
this.downKeyBindingDispatcher.set(KeyCode.UpArrow, (t, e) => this.onUp(t, e));
this.downKeyBindingDispatcher.set(KeyCode.PageUp, (t, e) => this.onPageUp(t, e));
this.downKeyBindingDispatcher.set(KeyCode.DownArrow, (t, e) => this.onDown(t, e));
this.downKeyBindingDispatcher.set(KeyCode.PageDown, (t, e) => this.onPageDown(t, e));
this.downKeyBindingDispatcher.set(KeyCode.LeftArrow, (t, e) => this.onLeft(t, e));
if (platform.isMacintosh) {
this.downKeyBindingDispatcher.set(KeyMod.CtrlCmd | KeyCode.UpArrow, (t, e) => this.onLeft(t, e));
}
this.downKeyBindingDispatcher.set(KeyCode.RightArrow, (t, e) => this.onRight(t, e));
this.downKeyBindingDispatcher.set(KeyCode.Escape, (t, e) => this.onEscape(t, e));
this.downKeyBindingDispatcher.set(KeyCode.Home, (t, e) => this.onHome(t, e));
this.downKeyBindingDispatcher.set(KeyCode.End, (t, e) => this.onEnd(t, e));
......
......@@ -39,7 +39,7 @@ export class TreeContext implements _.ITreeContext {
this.dataSource = configuration.dataSource;
this.renderer = configuration.renderer || new TreeDefaults.LegacyRenderer();
this.controller = configuration.controller || new TreeDefaults.DefaultController();
this.controller = configuration.controller || new TreeDefaults.DefaultController({ clickBehavior: TreeDefaults.ClickBehavior.ON_MOUSE_UP, keyboardSupport: typeof options.keyboardSupport !== 'boolean' || options.keyboardSupport });
this.dnd = configuration.dnd || new TreeDefaults.DefaultDragAndDrop();
this.filter = configuration.filter || new TreeDefaults.DefaultFilter();
this.sorter = configuration.sorter || null;
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { ITree } from 'vs/base/parts/tree/browser/tree';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { IContextKeyService, IContextKey, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
export const IListService = createDecorator<IListService>('listService');
export interface IListService {
_serviceBrand: any;
register(tree: ITree): IDisposable;
register(list: List<any>): IDisposable;
getFocused(): ITree | List<any>;
}
export const ListFocusContext = new RawContextKey<boolean>('listFocus', false);
export class ListService implements IListService {
public _serviceBrand: any;
private focusedTreeOrList: ITree | List<any>;
private listFocusContext: IContextKey<boolean>;
constructor(
@IContextKeyService contextKeyService: IContextKeyService
) {
this.listFocusContext = ListFocusContext.bindTo(contextKeyService);
}
public register(tree: ITree): IDisposable;
public register(list: List<any>): IDisposable;
public register(widget: ITree | List<any>): IDisposable {
// Check for currently being focused
if (widget.isDOMFocused()) {
this.onListDOMFocus(widget);
}
const toDispose = [
widget.onDOMFocus(() => this.onListDOMFocus(widget)),
widget.onDOMBlur(() => this.onListDOMBlur(widget))
];
return {
dispose: () => dispose(toDispose)
};
}
private onListDOMFocus(list: ITree | List<any>): void {
setTimeout(() => {
this.focusedTreeOrList = list;
this.listFocusContext.set(true);
}, 0 /* helps to track focus correctly when focus moves between 2 lists */);
}
private onListDOMBlur(list: ITree | List<any>): void {
this.focusedTreeOrList = void 0;
this.listFocusContext.set(false);
}
public getFocused(): ITree | List<any> {
return this.focusedTreeOrList;
}
}
\ No newline at end of file
......@@ -22,12 +22,10 @@ import { IConfigurationEditingService, ConfigurationTarget } from 'vs/workbench/
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IExtensionManagementService, LocalExtensionType, ILocalExtension } from 'vs/platform/extensionManagement/common/extensionManagement';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import paths = require('vs/base/common/paths');
import { isMacintosh, isLinux } from 'vs/base/common/platform';
import { IQuickOpenService, IFilePickOpenEntry, ISeparator } from 'vs/platform/quickOpen/common/quickOpen';
import { KeyMod } from 'vs/base/common/keyCodes';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import * as browser from 'vs/base/browser/browser';
import { IIntegrityService } from 'vs/platform/integrity/common/integrity';
import { IEntryRunContext } from 'vs/base/parts/quickopen/common/quickOpen';
......@@ -896,28 +894,4 @@ export class OpenIntroductoryVideosUrlAction extends Action {
window.open(OpenIntroductoryVideosUrlAction.URL);
return null;
}
}
// --- commands
CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string]) {
const editorService = accessor.get(IWorkbenchEditorService);
let [leftResource, rightResource, label, description] = args;
if (!label) {
label = nls.localize('diffLeftRightLabel', "{0} ⟷ {1}", leftResource.toString(true), rightResource.toString(true));
}
return editorService.openEditor({ leftResource, rightResource, label, description }).then(() => {
return void 0;
});
});
CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, number]) {
const editorService = accessor.get(IWorkbenchEditorService);
const [resource, column] = args;
return editorService.openEditor({ resource }, column).then(() => {
return void 0;
});
});
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import nls = require('vs/nls');
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { NoEditorsVisibleContext, InZenModeContext } from 'vs/workbench/electron-browser/workbench';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IListService, ListFocusContext } from 'vs/platform/list/browser/listService';
import { List } from 'vs/base/browser/ui/list/listWidget';
import errors = require('vs/base/common/errors');
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import URI from 'vs/base/common/uri';
// --- List Commands
export function registerCommands(): void {
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.down',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ListFocusContext,
primary: KeyCode.DownArrow,
mac: {
primary: KeyCode.DownArrow,
secondary: [KeyMod.WinCtrl | KeyCode.KEY_N]
},
handler: (accessor, arg2) => {
const listService = accessor.get(IListService);
const focused = listService.getFocused();
const count = typeof arg2 === 'number' ? arg2 : 1;
// List
if (focused instanceof List) {
const list = focused;
list.focusNext(count);
list.reveal(list.getFocus()[0]);
}
// Tree
else if (focused) {
const tree = focused;
tree.focusNext(count, { origin: 'keyboard' });
tree.reveal(tree.getFocus()).done(null, errors.onUnexpectedError);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.up',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ListFocusContext,
primary: KeyCode.UpArrow,
mac: {
primary: KeyCode.UpArrow,
secondary: [KeyMod.WinCtrl | KeyCode.KEY_P]
},
handler: (accessor, arg2) => {
const listService = accessor.get(IListService);
const focused = listService.getFocused();
const count = typeof arg2 === 'number' ? arg2 : 1;
// List
if (focused instanceof List) {
const list = focused;
list.focusPrevious(count);
list.reveal(list.getFocus()[0]);
}
// Tree
else if (focused) {
const tree = focused;
tree.focusPrevious(count, { origin: 'keyboard' });
tree.reveal(tree.getFocus()).done(null, errors.onUnexpectedError);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.left',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ListFocusContext,
primary: KeyCode.LeftArrow,
mac: {
primary: KeyCode.LeftArrow,
secondary: [KeyMod.CtrlCmd | KeyCode.UpArrow]
},
handler: (accessor) => {
const listService = accessor.get(IListService);
const focused = listService.getFocused();
// Tree only
if (!(focused instanceof List)) {
const tree = focused;
const focus = tree.getFocus();
tree.collapse(focus).then(didCollapse => {
if (focus && !didCollapse) {
tree.focusParent({ origin: 'keyboard' });
return tree.reveal(tree.getFocus());
}
return void 0;
}).done(null, errors.onUnexpectedError);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'list.right',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: ListFocusContext,
primary: KeyCode.RightArrow,
handler: (accessor) => {
const listService = accessor.get(IListService);
const focused = listService.getFocused();
// Tree only
if (!(focused instanceof List)) {
const tree = focused;
const focus = tree.getFocus();
tree.expand(focus).then(didExpand => {
if (focus && !didExpand) {
tree.focusFirstChild({ origin: 'keyboard' });
return tree.reveal(tree.getFocus());
}
return void 0;
}).done(null, errors.onUnexpectedError);
}
}
});
// --- commands
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.closeWindow', // close the window when the last editor is closed by reusing the same keybinding
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: NoEditorsVisibleContext,
primary: KeyMod.CtrlCmd | KeyCode.KEY_W,
handler: accessor => {
const windowService = accessor.get(IWindowIPCService);
windowService.getWindow().close();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.exitZenMode',
weight: CommonEditorRegistry.commandWeight(-1000),
handler(accessor: ServicesAccessor, configurationOrName: any) {
const partService = accessor.get(IPartService);
partService.toggleZenMode();
},
when: InZenModeContext,
primary: KeyChord(KeyCode.Escape, KeyCode.Escape)
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.quit',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
handler(accessor: ServicesAccessor) {
const windowsService = accessor.get(IWindowsService);
windowsService.quit();
},
when: void 0,
primary: KeyMod.CtrlCmd | KeyCode.KEY_Q,
win: { primary: void 0 }
});
CommandsRegistry.registerCommand('_workbench.diff', function (accessor: ServicesAccessor, args: [URI, URI, string, string]) {
const editorService = accessor.get(IWorkbenchEditorService);
let [leftResource, rightResource, label, description] = args;
if (!label) {
label = nls.localize('diffLeftRightLabel', "{0} ⟷ {1}", leftResource.toString(true), rightResource.toString(true));
}
return editorService.openEditor({ leftResource, rightResource, label, description }).then(() => {
return void 0;
});
});
CommandsRegistry.registerCommand('_workbench.open', function (accessor: ServicesAccessor, args: [URI, number]) {
const editorService = accessor.get(IWorkbenchEditorService);
const [resource, column] = args;
return editorService.openEditor({ resource }, column).then(() => {
return void 0;
});
});
}
\ No newline at end of file
......@@ -13,18 +13,13 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actionRegistry';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindings } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService';
import { CloseEditorAction, KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, ReportIssueAction, ReportPerformanceIssueAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseFolderAction, CloseWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction } from 'vs/workbench/electron-browser/actions';
import { MessagesVisibleContext, NoEditorsVisibleContext, InZenModeContext } from 'vs/workbench/electron-browser/workbench';
import { MessagesVisibleContext } from 'vs/workbench/electron-browser/workbench';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { registerCommands } from 'vs/workbench/electron-browser/commands';
const closeEditorOrWindowKeybindings: IKeybindings = { primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } };
// Contribute Commands
registerCommands();
// Contribute Global Actions
const viewCategory = nls.localize('view', "View");
......@@ -66,47 +61,12 @@ workbenchActionsRegistry.registerWorkbenchAction(
}), 'View: Reset Zoom', viewCategory
);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseMessagesAction, CloseMessagesAction.ID, CloseMessagesAction.LABEL, { primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape] }, MessagesVisibleContext), 'Close Notification Messages');
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, closeEditorOrWindowKeybindings), 'View: Close Editor', viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(CloseEditorAction, CloseEditorAction.ID, CloseEditorAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_W, win: { primary: KeyMod.CtrlCmd | KeyCode.F4, secondary: [KeyMod.CtrlCmd | KeyCode.KEY_W] } }), 'View: Close Editor', viewCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleFullScreenAction, ToggleFullScreenAction.ID, ToggleFullScreenAction.LABEL, { primary: KeyCode.F11, mac: { primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.KEY_F } }), 'View: Toggle Full Screen', viewCategory);
if (isWindows || isLinux) {
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMenuBarAction, ToggleMenuBarAction.ID, ToggleMenuBarAction.LABEL), 'View: Toggle Menu Bar', viewCategory);
}
// close the window when the last editor is closed by reusing the same keybinding
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.closeWindow',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
when: NoEditorsVisibleContext,
primary: closeEditorOrWindowKeybindings.primary,
handler: accessor => {
const windowService = accessor.get(IWindowIPCService);
windowService.getWindow().close();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.exitZenMode',
weight: CommonEditorRegistry.commandWeight(-1000),
handler(accessor: ServicesAccessor, configurationOrName: any) {
const partService = accessor.get(IPartService);
partService.toggleZenMode();
},
when: InZenModeContext,
primary: KeyChord(KeyCode.Escape, KeyCode.Escape)
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'workbench.action.quit',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(),
handler(accessor: ServicesAccessor) {
const windowsService = accessor.get(IWindowsService);
windowsService.quit();
},
when: void 0,
primary: KeyMod.CtrlCmd | KeyCode.KEY_Q,
win: { primary: void 0 }
});
// Configuration: Workbench
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
......
......@@ -58,6 +58,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ViewletService } from 'vs/workbench/services/viewlet/browser/viewletService';
import { FileService } from 'vs/workbench/services/files/electron-browser/fileService';
import { IFileService } from 'vs/platform/files/common/files';
import { IListService, ListService } from 'vs/platform/list/browser/listService';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/node/configurationResolverService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
......@@ -451,6 +452,9 @@ export class Workbench implements IPartService {
this.keybindingService = this.instantiationService.createInstance(WorkbenchKeybindingService, window);
serviceCollection.set(IKeybindingService, this.keybindingService);
// List
serviceCollection.set(IListService, this.instantiationService.createInstance(ListService));
// Context Menu
serviceCollection.set(IContextMenuService, new SyncDescriptor(ContextMenuService));
......
......@@ -40,6 +40,7 @@ import { ExtensionsInput } from 'vs/workbench/parts/extensions/common/extensions
import { Query } from '../common/extensionQuery';
import { OpenGlobalSettingsAction } from 'vs/workbench/parts/preferences/browser/preferencesActions';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IListService } from 'vs/platform/list/browser/listService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { IMessageService, CloseAction } from 'vs/platform/message/common/message';
......@@ -74,6 +75,7 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
@IInstantiationService private instantiationService: IInstantiationService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorInputService: IEditorGroupService,
@IListService private listService: IListService,
@IExtensionsWorkbenchService private extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionTipsService private tipsService: IExtensionTipsService,
@IMessageService private messageService: IMessageService,
......@@ -105,9 +107,12 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
const delegate = new Delegate();
const renderer = this.instantiationService.createInstance(Renderer);
this.list = new PagedList(this.extensionsBox, delegate, [renderer], {
ariaLabel: localize('extensions', "Extensions")
ariaLabel: localize('extensions', "Extensions"),
keyboardSupport: false
});
this.disposables.push(this.listService.register(this.list.widget));
const onKeyDown = chain(domEvent(this.searchBox, 'keydown'))
.filter(() => this.list.length > 0)
.map(e => new StandardKeyboardEvent(e));
......
......@@ -28,6 +28,7 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer
import * as DOM from 'vs/base/browser/dom';
import { CollapseAction, CollapsibleViewletView } from 'vs/workbench/browser/viewlet';
import { FileStat } from 'vs/workbench/parts/files/common/explorerViewModel';
import { IListService } from 'vs/platform/list/browser/listService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
......@@ -80,6 +81,7 @@ export class ExplorerView extends CollapsibleViewletView {
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IProgressService private progressService: IProgressService,
@IListService private listService: IListService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IFileService private fileService: IFileService,
@IPartService private partService: IPartService,
......@@ -347,11 +349,15 @@ export class ExplorerView extends CollapsibleViewletView {
autoExpandSingleChildren: true,
ariaLabel: nls.localize('treeAriaLabel', "Files Explorer"),
twistiePixels: 12,
showTwistie: false
showTwistie: false,
keyboardSupport: false
});
this.toDispose.push(lifecycle.toDisposable(() => renderer.dispose()));
// Register to list service
this.toDispose.push(this.listService.register(this.explorerViewer));
// Update Viewer based on File Change Events
this.toDispose.push(this.fileService.onAfterOperation(e => this.onFileOperation(e)));
this.toDispose.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
......
......@@ -386,7 +386,7 @@ export class FileController extends DefaultController {
@IContextKeyService contextKeyService: IContextKeyService,
@IKeybindingService private keybindingService: IKeybindingService
) {
super({ clickBehavior: ClickBehavior.ON_MOUSE_UP /* do not change to not break DND */ });
super({ clickBehavior: ClickBehavior.ON_MOUSE_UP /* do not change to not break DND */, keyboardSupport: false /* handled via IListService */ });
this.contributedContextMenu = menuService.createMenu(MenuId.ExplorerContext, contextKeyService);
......
......@@ -28,6 +28,7 @@ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/un
import { CloseAllEditorsAction } from 'vs/workbench/browser/parts/editor/editorActions';
import { ToggleEditorLayoutAction } from 'vs/workbench/browser/actions/toggleEditorLayout';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IListService } from 'vs/platform/list/browser/listService';
const $ = dom.$;
......@@ -58,6 +59,7 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
@IEditorGroupService editorGroupService: IEditorGroupService,
@IConfigurationService private configurationService: IConfigurationService,
@IKeybindingService keybindingService: IKeybindingService,
@IListService private listService: IListService,
@IUntitledEditorService private untitledEditorService: IUntitledEditorService,
@IContextKeyService contextKeyService: IContextKeyService,
@IViewletService private viewletService: IViewletService
......@@ -115,9 +117,13 @@ export class OpenEditorsView extends AdaptiveCollapsibleViewletView {
indentPixels: 0,
twistiePixels: 22,
ariaLabel: nls.localize({ key: 'treeAriaLabel', comment: ['Open is an adjective'] }, "Open Editors: List of Active Files"),
showTwistie: false
showTwistie: false,
keyboardSupport: false
});
// Register to list service
this.toDispose.push(this.listService.register(this.tree));
// Update open editors focus context
const viewerFocusTracker = dom.trackFocus(this.tree.getHTMLElement());
viewerFocusTracker.addFocusListener(() => {
......
......@@ -173,7 +173,7 @@ export class Controller extends treedefaults.DefaultController {
@ITelemetryService private telemetryService: ITelemetryService,
@IKeybindingService private keybindingService: IKeybindingService
) {
super({ clickBehavior: treedefaults.ClickBehavior.ON_MOUSE_DOWN });
super({ clickBehavior: treedefaults.ClickBehavior.ON_MOUSE_DOWN, keyboardSupport: false });
}
public onClick(tree: ITree, element: any, event: IMouseEvent): boolean {
......
......@@ -24,6 +24,7 @@ import { IContextViewService, IContextMenuService } from 'vs/platform/contextvie
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IMessageService } from 'vs/platform/message/common/message';
import { IListService } from 'vs/platform/list/browser/listService';
import { IMenuService } from 'vs/platform/actions/common/actions';
import { IAction, IActionItem } from 'vs/base/common/actions';
import { createActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
......@@ -156,6 +157,7 @@ export class SCMViewlet extends Viewlet {
@IContextKeyService private contextKeyService: IContextKeyService,
@IKeybindingService private keybindingService: IKeybindingService,
@IMessageService private messageService: IMessageService,
@IListService private listService: IListService,
@IContextMenuService private contextMenuService: IContextMenuService,
@IThemeService private themeService: IThemeService,
@IMenuService private menuService: IMenuService,
......@@ -199,8 +201,10 @@ export class SCMViewlet extends Viewlet {
this.list = new List(this.listContainer, delegate, [
new ResourceGroupRenderer(this.menus, actionItemProvider),
this.instantiationService.createInstance(ResourceRenderer, this.menus, actionItemProvider)
]);
this.instantiationService.createInstance(ResourceRenderer, this.menus, actionItemProvider),
], { keyboardSupport: false });
this.disposables.push(this.listService.register(this.list));
chain(this.list.onSelectionChange)
.map(e => e.elements[0])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册