mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
@@ -15,19 +14,25 @@ import { Composite, CompositeDescriptor, CompositeRegistry } from 'vs/workbench/
|
||||
import { IConstructorSignature0 } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ToggleSidebarVisibilityAction } from 'vs/workbench/browser/actions/toggleSidebarVisibility';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IPartService } from 'vs/workbench/services/part/common/partService';
|
||||
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ToggleSidebarPositionAction } from 'vs/workbench/browser/actions/toggleSidebarPosition';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';
|
||||
|
||||
export abstract class Viewlet extends Composite implements IViewlet {
|
||||
|
||||
constructor(id: string,
|
||||
protected configurationService: IConfigurationService,
|
||||
private partService: IPartService,
|
||||
telemetryService: ITelemetryService,
|
||||
themeService: IThemeService
|
||||
themeService: IThemeService,
|
||||
storageService: IStorageService
|
||||
) {
|
||||
super(id, telemetryService, themeService);
|
||||
super(id, telemetryService, themeService, storageService);
|
||||
}
|
||||
|
||||
getOptimalWidth(): number {
|
||||
@@ -35,12 +40,14 @@ export abstract class Viewlet extends Composite implements IViewlet {
|
||||
}
|
||||
|
||||
getContextMenuActions(): IAction[] {
|
||||
return [<IAction>{
|
||||
id: ToggleSidebarVisibilityAction.ID,
|
||||
label: nls.localize('compositePart.hideSideBarLabel', "Hide Side Bar"),
|
||||
enabled: true,
|
||||
run: () => this.partService.setSideBarHidden(true)
|
||||
}];
|
||||
const toggleSidebarPositionAction = new ToggleSidebarPositionAction(ToggleSidebarPositionAction.ID, ToggleSidebarPositionAction.getLabel(this.partService), this.partService, this.configurationService);
|
||||
return [toggleSidebarPositionAction,
|
||||
<IAction>{
|
||||
id: ToggleSidebarVisibilityAction.ID,
|
||||
label: nls.localize('compositePart.hideSideBarLabel', "Hide Side Bar"),
|
||||
enabled: true,
|
||||
run: () => this.partService.setSideBarHidden(true)
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,9 +118,9 @@ export class ViewletRegistry extends CompositeRegistry<Viewlet> {
|
||||
Registry.add(Extensions.Viewlets, new ViewletRegistry());
|
||||
|
||||
/**
|
||||
* A reusable action to toggle a viewlet with a specific id.
|
||||
* A reusable action to show a viewlet with a specific id.
|
||||
*/
|
||||
export class ToggleViewletAction extends Action {
|
||||
export class ShowViewletAction extends Action {
|
||||
private viewletId: string;
|
||||
|
||||
constructor(
|
||||
@@ -121,7 +128,8 @@ export class ToggleViewletAction extends Action {
|
||||
name: string,
|
||||
viewletId: string,
|
||||
@IViewletService protected viewletService: IViewletService,
|
||||
@IEditorGroupsService private editorGroupService: IEditorGroupsService
|
||||
@IEditorGroupsService private editorGroupService: IEditorGroupsService,
|
||||
@IPartService private partService: IPartService
|
||||
) {
|
||||
super(id, name);
|
||||
|
||||
@@ -129,7 +137,7 @@ export class ToggleViewletAction extends Action {
|
||||
this.enabled = !!this.viewletService && !!this.editorGroupService;
|
||||
}
|
||||
|
||||
run(): TPromise<any> {
|
||||
run(): Thenable<any> {
|
||||
|
||||
// Pass focus to viewlet if not open or focused
|
||||
if (this.otherViewletShowing() || !this.sidebarHasFocus()) {
|
||||
@@ -139,7 +147,7 @@ export class ToggleViewletAction extends Action {
|
||||
// Otherwise pass focus to editor group
|
||||
this.editorGroupService.activeGroup.focus();
|
||||
|
||||
return TPromise.as(true);
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
private otherViewletShowing(): boolean {
|
||||
@@ -152,7 +160,7 @@ export class ToggleViewletAction extends Action {
|
||||
const activeViewlet = this.viewletService.getActiveViewlet();
|
||||
const activeElement = document.activeElement;
|
||||
|
||||
return activeViewlet && activeElement && DOM.isAncestor(activeElement, (<Viewlet>activeViewlet).getContainer());
|
||||
return activeViewlet && activeElement && DOM.isAncestor(activeElement, this.partService.getContainer(Parts.SIDEBAR_PART));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +170,7 @@ export class CollapseAction extends Action {
|
||||
constructor(viewer: ITree, enabled: boolean, clazz: string) {
|
||||
super('workbench.action.collapse', nls.localize('collapse', "Collapse All"), clazz, enabled, (context: any) => {
|
||||
if (viewer.getHighlight()) {
|
||||
return TPromise.as(null); // Global action disabled if user is in edit mode from another action
|
||||
return Promise.resolve(null); // Global action disabled if user is in edit mode from another action
|
||||
}
|
||||
|
||||
viewer.collapseAll();
|
||||
@@ -171,7 +179,17 @@ export class CollapseAction extends Action {
|
||||
viewer.domFocus();
|
||||
viewer.focusFirst();
|
||||
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Collapse All action for the new tree
|
||||
export class CollapseAction2 extends Action {
|
||||
constructor(tree: AsyncDataTree<any>, enabled: boolean, clazz: string) {
|
||||
super('workbench.action.collapse', nls.localize('collapse', "Collapse All"), clazz, enabled, () => {
|
||||
tree.collapseAll();
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user