Merge from vscode 7653d836944892f83ce9e1f95c1204bafa1aec31

This commit is contained in:
ADS Merger
2020-05-08 03:58:34 +00:00
parent dac1970c43
commit fa62ec1f34
209 changed files with 5131 additions and 2480 deletions

View File

@@ -14,7 +14,7 @@ import { IAction, Action } from 'vs/base/common/actions';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IViewlet } from 'vs/workbench/common/viewlet';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { append, $, addClass, toggleClass, Dimension } from 'vs/base/browser/dom';
import { append, $, addClass, toggleClass, Dimension, hide, show } from 'vs/base/browser/dom';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
@@ -57,6 +57,9 @@ import { ILabelService } from 'vs/platform/label/common/label';
import { MementoObject } from 'vs/workbench/common/memento';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { DragAndDropObserver } from 'vs/workbench/browser/dnd';
import { URI } from 'vs/base/common/uri';
import { SIDE_BAR_DRAG_AND_DROP_BACKGROUND } from 'vs/workbench/common/theme';
const NonEmptyWorkspaceContext = new RawContextKey<boolean>('nonEmptyWorkspace', false);
const DefaultViewsContext = new RawContextKey<boolean>('defaultExtensionViews', true);
@@ -400,8 +403,12 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
addClass(parent, 'extensions-viewlet');
this.root = parent;
const header = append(this.root, $('.header'));
const overlay = append(this.root, $('.overlay'));
const overlayBackgroundColor = this.getColor(SIDE_BAR_DRAG_AND_DROP_BACKGROUND) ?? '';
overlay.style.backgroundColor = overlayBackgroundColor;
hide(overlay);
const header = append(this.root, $('.header'));
const placeholder = localize('searchExtensions', "Search Extensions in Marketplace");
const searchValue = this.searchViewletState['query.value'] ? this.searchViewletState['query.value'] : '';
@@ -435,6 +442,49 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
}
}));
// Register DragAndDrop support
this._register(new DragAndDropObserver(this.root, {
onDragEnd: (e: DragEvent) => undefined,
onDragEnter: (e: DragEvent) => {
if (this.isSupportedDragElement(e)) {
show(overlay);
}
},
onDragLeave: (e: DragEvent) => {
if (this.isSupportedDragElement(e)) {
hide(overlay);
}
},
onDragOver: (e: DragEvent) => {
if (e.dataTransfer) {
e.dataTransfer.dropEffect = this.isSupportedDragElement(e) ? 'copy' : 'none';
}
},
onDrop: async (e: DragEvent) => {
if (this.isSupportedDragElement(e)) {
hide(overlay);
if (e.dataTransfer && e.dataTransfer.files.length > 0) {
let vsixPaths: URI[] = [];
for (let index = 0; index < e.dataTransfer.files.length; index++) {
const path = e.dataTransfer.files.item(index)!.path;
if (path.indexOf('.vsix') !== -1) {
vsixPaths.push(URI.parse(path));
}
}
try {
// Attempt to install the extension(s)
await this.instantiationService.createInstance(InstallVSIXAction, InstallVSIXAction.ID, InstallVSIXAction.LABEL).run(vsixPaths);
}
catch (err) {
this.notificationService.error(err);
}
}
}
},
}));
super.create(append(this.root, $('.extensions')));
}
@@ -622,6 +672,15 @@ export class ExtensionsViewPaneContainer extends ViewPaneContainer implements IE
this.notificationService.error(err);
}
private isSupportedDragElement(e: DragEvent): boolean {
if (e.dataTransfer) {
const typesLowerCase = e.dataTransfer.types.map(t => t.toLocaleLowerCase());
return typesLowerCase.indexOf('files') !== -1;
}
return false;
}
}
export class StatusUpdater extends Disposable implements IWorkbenchContribution {