Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explorer multiple selection #41461

Merged
merged 16 commits into from
Jan 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/vs/base/browser/dnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export const DataTransfers = {
*/
URL: 'URL',

/**
* Application specific resource transfer type when multiple resources are being dragged.
*/
URLS: 'URLS',

/**
* Browser specific transfer type to download.
*/
Expand All @@ -58,4 +63,4 @@ export const DataTransfers = {
* Typicaly transfer type for copy/paste transfers.
*/
TEXT: 'text/plain'
};
};
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
private eventBufferer = new EventBufferer();
private view: ListView<T>;
private spliceable: ISpliceable<T>;
private disposables: IDisposable[];
protected disposables: IDisposable[];
private styleElement: HTMLStyleElement;

@memoize get onFocusChange(): Event<IListEvent<T>> {
Expand Down
22 changes: 15 additions & 7 deletions src/vs/platform/list/browser/listService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class ListService implements IListService {
const RawWorkbenchListFocusContextKey = new RawContextKey<boolean>('listFocus', true);
export const WorkbenchListSupportsMultiSelectContextKey = new RawContextKey<boolean>('listSupportsMultiselect', true);
export const WorkbenchListFocusContextKey = ContextKeyExpr.and(RawWorkbenchListFocusContextKey, ContextKeyExpr.not(InputFocusedContextKey));
export const WorkbenchListDoubleSelection = new RawContextKey<boolean>('listDoubleSelection', false);

export type Widget = List<any> | PagedList<any> | ITree;

Expand All @@ -91,7 +92,7 @@ function createScopedContextKeyService(contextKeyService: IContextKeyService, wi
export class WorkbenchList<T> extends List<T> {

readonly contextKeyService: IContextKeyService;
private disposable: IDisposable;
private listDoubleSelection: IContextKey<boolean>;

constructor(
container: HTMLElement,
Expand All @@ -103,17 +104,18 @@ export class WorkbenchList<T> extends List<T> {
@IThemeService themeService: IThemeService
) {
super(container, delegate, renderers, options);
this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(contextKeyService);
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);

this.disposable = combinedDisposable([
this.disposables.push(combinedDisposable([
this.contextKeyService,
(listService as ListService).register(this),
attachListStyler(this, themeService)
]);
}

dispose(): void {
this.disposable.dispose();
]));
this.disposables.push(this.onSelectionChange(() => {
const selection = this.getSelection();
this.listDoubleSelection.set(selection && selection.length === 2);
}));
}
}

Expand Down Expand Up @@ -150,6 +152,7 @@ export class WorkbenchTree extends Tree {

readonly contextKeyService: IContextKeyService;
private disposables: IDisposable[] = [];
private listDoubleSelection: IContextKey<boolean>;

constructor(
container: HTMLElement,
Expand All @@ -161,13 +164,18 @@ export class WorkbenchTree extends Tree {
) {
super(container, configuration, options);

this.listDoubleSelection = WorkbenchListDoubleSelection.bindTo(contextKeyService);
this.contextKeyService = createScopedContextKeyService(contextKeyService, this);

this.disposables.push(
this.contextKeyService,
(listService as ListService).register(this),
attachListStyler(this, themeService)
);
this.disposables.push(this.onDidChangeSelection(() => {
const selection = this.getSelection();
this.listDoubleSelection.set(selection && selection.length === 2);
}));
}

dispose(): void {
Expand Down
20 changes: 20 additions & 0 deletions src/vs/platform/message/common/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
'use strict';

import nls = require('vs/nls');
import uri from 'vs/base/common/uri';
import paths = require('vs/base/common/paths');
import { TPromise } from 'vs/base/common/winjs.base';
import Severity from 'vs/base/common/severity';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
Expand Down Expand Up @@ -35,6 +37,24 @@ export const CancelAction = new Action('cancel.message', nls.localize('cancel',

export const IMessageService = createDecorator<IMessageService>('messageService');

const MAX_CONFIRM_FILES = 10;
export function getConfirmMessage(start: string, resourcesToConfirm: uri[]): string {
const message = [start];
message.push('');
message.push(...resourcesToConfirm.slice(0, MAX_CONFIRM_FILES).map(r => paths.basename(r.fsPath)));

if (resourcesToConfirm.length > MAX_CONFIRM_FILES) {
if (resourcesToConfirm.length - MAX_CONFIRM_FILES === 1) {
message.push(nls.localize('moreFile', "...1 additional file not shown"));
} else {
message.push(nls.localize('moreFiles', "...{0} additional files not shown", resourcesToConfirm.length - MAX_CONFIRM_FILES));
}
}

message.push('');
return message.join('\n');
}

export interface IConfirmationResult {
confirmed: boolean;
checkboxChecked?: boolean;
Expand Down
20 changes: 13 additions & 7 deletions src/vs/workbench/browser/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,19 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): (IDragge

// Data Transfer: URL
else {
const rawURLData = e.dataTransfer.getData(DataTransfers.URL);
if (rawURLData) {
try {
resources.push({ resource: URI.parse(rawURLData), isExternal: false });
} catch (error) {
// Invalid URI
try {
const rawURLsData = e.dataTransfer.getData(DataTransfers.URLS);
if (rawURLsData) {
const uriStrArray: string[] = JSON.parse(rawURLsData);
resources.push(...uriStrArray.map(uriStr => ({ resource: URI.parse(uriStr), isExternal: false })));
} else {
const rawURLData = e.dataTransfer.getData(DataTransfers.URL);
if (rawURLData) {
resources.push({ resource: URI.parse(rawURLData), isExternal: false });
}
}
} catch (error) {
// Invalid URI
}
}
}
Expand All @@ -268,4 +274,4 @@ export function extractResources(e: DragEvent, externalOnly?: boolean): (IDragge
}

return resources;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTI
import { SyncActionDescriptor, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { openWindowCommand, REVEAL_IN_OS_COMMAND_ID, COPY_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, OPEN_TO_SIDE_COMMAND_ID, REVERT_FILE_COMMAND_ID, SAVE_FILE_COMMAND_ID, SAVE_FILE_LABEL, SAVE_FILE_AS_COMMAND_ID, SAVE_FILE_AS_LABEL, SAVE_ALL_IN_GROUP_COMMAND_ID, OpenEditorsGroupContext, COMPARE_WITH_SAVED_COMMAND_ID, COMPARE_RESOURCE_COMMAND_ID, SELECT_FOR_COMPARE_COMMAND_ID, ResourceSelectedForCompareContext, REVEAL_IN_OS_LABEL, DirtyEditorContext } from 'vs/workbench/parts/files/electron-browser/fileCommands';
import { openWindowCommand, REVEAL_IN_OS_COMMAND_ID, COPY_PATH_COMMAND_ID, REVEAL_IN_EXPLORER_COMMAND_ID, OPEN_TO_SIDE_COMMAND_ID, REVERT_FILE_COMMAND_ID, SAVE_FILE_COMMAND_ID, SAVE_FILE_LABEL, SAVE_FILE_AS_COMMAND_ID, SAVE_FILE_AS_LABEL, SAVE_ALL_IN_GROUP_COMMAND_ID, OpenEditorsGroupContext, COMPARE_WITH_SAVED_COMMAND_ID, COMPARE_RESOURCE_COMMAND_ID, SELECT_FOR_COMPARE_COMMAND_ID, ResourceSelectedForCompareContext, REVEAL_IN_OS_LABEL, DirtyEditorContext, COMPARE_SELECTED_COMMAND_ID } from 'vs/workbench/parts/files/electron-browser/fileCommands';
import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
Expand All @@ -22,6 +22,7 @@ import { CLOSE_UNMODIFIED_EDITORS_COMMAND_ID, CLOSE_EDITORS_IN_GROUP_COMMAND_ID,
import { OPEN_FOLDER_SETTINGS_COMMAND, OPEN_FOLDER_SETTINGS_LABEL } from 'vs/workbench/parts/preferences/browser/preferencesActions';
import { AutoSaveContext } from 'vs/workbench/services/textfile/common/textfiles';
import { ResourceContextKey } from 'vs/workbench/common/resources';
import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService';


// Contribute Global Actions
Expand Down Expand Up @@ -341,14 +342,24 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group: '3_compare',
order: 20,
command: compareResourceCommand,
when: ContextKeyExpr.and(ExplorerFolderContext.toNegated(), ResourceContextKey.IsFile, ResourceSelectedForCompareContext)
when: ContextKeyExpr.and(ExplorerFolderContext.toNegated(), ResourceContextKey.IsFile, ResourceSelectedForCompareContext, WorkbenchListDoubleSelection.toNegated())
});

MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group: '3_compare',
order: 30,
command: selectForCompareCommand,
when: ContextKeyExpr.and(ExplorerFolderContext.toNegated(), ResourceContextKey.IsFile)
when: ContextKeyExpr.and(ExplorerFolderContext.toNegated(), ResourceContextKey.IsFile, WorkbenchListDoubleSelection.toNegated())
});

MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group: '3_compare',
order: 30,
command: {
id: COMPARE_SELECTED_COMMAND_ID,
title: nls.localize('compareSelected', "Compare Selected")
},
when: ContextKeyExpr.and(ExplorerFolderContext.toNegated(), ResourceContextKey.IsFile, WorkbenchListDoubleSelection)
});

MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
Expand Down
Loading