Skip to content

Commit

Permalink
emptyView: use DragAndDropObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Jun 13, 2018
1 parent 12297b2 commit daaf84f
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/vs/workbench/parts/files/electron-browser/views/emptyView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { ResourcesDropHandler } from 'vs/workbench/browser/dnd';
import { ResourcesDropHandler, DragAndDropObserver } from 'vs/workbench/browser/dnd';
import { listDropBackground } from 'vs/platform/theme/common/colorRegistry';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';

Expand Down Expand Up @@ -74,17 +74,24 @@ export class EmptyView extends ViewletPanel {
});
}));

this.disposables.push(DOM.addDisposableListener(container, DOM.EventType.DROP, (e: DragEvent) => {
container.style.backgroundColor = this.themeService.getTheme().getColor(SIDE_BAR_BACKGROUND).toString();
const dropHandler = this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: true });
dropHandler.handleDrop(e, () => undefined, targetGroup => undefined);
}));
this.disposables.push(DOM.addDisposableListener(container, DOM.EventType.DRAG_LEAVE, () => {
container.style.backgroundColor = this.themeService.getTheme().getColor(SIDE_BAR_BACKGROUND).toString();
}));
this.disposables.push(DOM.addDisposableListener(container, DOM.EventType.DRAG_OVER, (e: DragEvent) => {
e.dataTransfer.dropEffect = 'copy';
container.style.backgroundColor = this.themeService.getTheme().getColor(listDropBackground).toString();
this.disposables.push(new DragAndDropObserver(container, {
onDrop: e => {
container.style.backgroundColor = this.themeService.getTheme().getColor(SIDE_BAR_BACKGROUND).toString();
const dropHandler = this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: true });
dropHandler.handleDrop(e, () => undefined, targetGroup => undefined);
},
onDragEnter: (e) => {
container.style.backgroundColor = this.themeService.getTheme().getColor(listDropBackground).toString();
},
onDragEnd: () => {
container.style.backgroundColor = this.themeService.getTheme().getColor(SIDE_BAR_BACKGROUND).toString();
},
onDragLeave: () => {
container.style.backgroundColor = this.themeService.getTheme().getColor(SIDE_BAR_BACKGROUND).toString();
},
onDragOver: e => {
e.dataTransfer.dropEffect = 'copy';
}
}));

this.setLabels();
Expand Down

0 comments on commit daaf84f

Please sign in to comment.