mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode e1d3dd53d17fb1529a002e4d6fb066db0a0bd385 (#6460)
* Merge from vscode e1d3dd53d17fb1529a002e4d6fb066db0a0bd385 * fix servers icon * fix tests
This commit is contained in:
@@ -27,14 +27,13 @@ import { IWindowService, MenuBarVisibility, getTitleBarStyle } from 'vs/platform
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IEditorService, IResourceEditor } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { Sizing, Direction, Grid } from 'vs/base/browser/ui/grid/grid';
|
||||
import { Sizing, Direction, Grid, SerializableGrid, ISerializableView, ISerializedGrid } from 'vs/base/browser/ui/grid/grid';
|
||||
import { WorkbenchLegacyLayout } from 'vs/workbench/browser/legacyLayout';
|
||||
import { IDimension } from 'vs/platform/layout/browser/layoutService';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar';
|
||||
import { IActivityBarService } from 'vs/workbench/services/activityBar/browser/activityBarService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IView } from 'vs/base/browser/ui/grid/gridview';
|
||||
|
||||
enum Settings {
|
||||
MENUBAR_VISIBLE = 'window.menuBarVisibility',
|
||||
@@ -57,6 +56,8 @@ enum Storage {
|
||||
|
||||
ZEN_MODE_ENABLED = 'workbench.zenmode.active',
|
||||
CENTERED_LAYOUT_ENABLED = 'workbench.centerededitorlayout.active',
|
||||
|
||||
GRID_LAYOUT = 'workbench.grid.layout'
|
||||
}
|
||||
|
||||
export abstract class Layout extends Disposable implements IWorkbenchLayoutService {
|
||||
@@ -89,16 +90,16 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
|
||||
private parts: Map<string, Part> = new Map<string, Part>();
|
||||
|
||||
private workbenchGrid: Grid | WorkbenchLegacyLayout;
|
||||
private workbenchGrid: SerializableGrid<ISerializableView> | WorkbenchLegacyLayout;
|
||||
|
||||
private disposed: boolean;
|
||||
|
||||
private titleBarPartView: IView;
|
||||
private activityBarPartView: IView;
|
||||
private sideBarPartView: IView;
|
||||
private panelPartView: IView;
|
||||
private editorPartView: IView;
|
||||
private statusBarPartView: IView;
|
||||
private titleBarPartView: ISerializableView;
|
||||
private activityBarPartView: ISerializableView;
|
||||
private sideBarPartView: ISerializableView;
|
||||
private panelPartView: ISerializableView;
|
||||
private editorPartView: ISerializableView;
|
||||
private statusBarPartView: ISerializableView;
|
||||
|
||||
private environmentService: IWorkbenchEnvironmentService;
|
||||
private configurationService: IConfigurationService;
|
||||
@@ -144,8 +145,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
hidden: false,
|
||||
sizeBeforeMaximize: 0,
|
||||
position: Position.BOTTOM,
|
||||
height: 350,
|
||||
width: 350,
|
||||
panelToRestore: undefined as string | undefined
|
||||
},
|
||||
|
||||
@@ -706,7 +705,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
|
||||
if (this.configurationService.getValue('workbench.useExperimentalGridLayout')) {
|
||||
|
||||
// Create view wrappers for all parts
|
||||
// View references for all parts
|
||||
this.titleBarPartView = titleBar;
|
||||
this.sideBarPartView = sideBar;
|
||||
this.activityBarPartView = activityBar;
|
||||
@@ -714,9 +713,63 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
this.panelPartView = panelPart;
|
||||
this.statusBarPartView = statusBar;
|
||||
|
||||
this.workbenchGrid = new Grid(this.editorPartView, { proportionalLayout: false });
|
||||
let workbenchGrid: SerializableGrid<ISerializableView> | undefined;
|
||||
|
||||
this.container.prepend(this.workbenchGrid.element);
|
||||
const savedGrid = this.storageService.get(Storage.GRID_LAYOUT, StorageScope.GLOBAL, undefined);
|
||||
if (savedGrid) {
|
||||
const parsedGrid: ISerializedGrid = JSON.parse(savedGrid);
|
||||
|
||||
const fromJSON = (serializedPart: { type: Parts } | null) => {
|
||||
if (serializedPart && serializedPart.type) {
|
||||
switch (serializedPart.type) {
|
||||
case Parts.ACTIVITYBAR_PART:
|
||||
return this.activityBarPartView;
|
||||
case Parts.TITLEBAR_PART:
|
||||
return this.titleBarPartView;
|
||||
case Parts.EDITOR_PART:
|
||||
return this.editorPartView;
|
||||
case Parts.PANEL_PART:
|
||||
return this.panelPartView;
|
||||
case Parts.SIDEBAR_PART:
|
||||
return this.sideBarPartView;
|
||||
case Parts.STATUSBAR_PART:
|
||||
return this.statusBarPartView;
|
||||
default:
|
||||
return this.editorPartView;
|
||||
}
|
||||
} else {
|
||||
return this.editorPartView;
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
workbenchGrid = SerializableGrid.deserialize(parsedGrid, { fromJSON }, { proportionalLayout: false });
|
||||
|
||||
// Set some layout state
|
||||
this.state.sideBar.position = Position.LEFT;
|
||||
for (let view of workbenchGrid.getNeighborViews(this.sideBarPartView, Direction.Right)) {
|
||||
if (view === this.activityBarPartView) {
|
||||
this.state.sideBar.position = Position.RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
this.state.panel.position = Position.BOTTOM;
|
||||
for (let view of workbenchGrid.getNeighborViews(this.panelPartView, Direction.Left)) {
|
||||
if (view === this.editorPartView) {
|
||||
this.state.panel.position = Position.RIGHT;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (!workbenchGrid) {
|
||||
workbenchGrid = new SerializableGrid(this.editorPartView, { proportionalLayout: false });
|
||||
}
|
||||
|
||||
this.container.prepend(workbenchGrid.element);
|
||||
this.workbenchGrid = workbenchGrid;
|
||||
|
||||
this._register((this.sideBarPartView as SidebarPart).onDidVisibilityChange((visible) => {
|
||||
this.setSideBarHidden(!visible, true);
|
||||
@@ -725,6 +778,17 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
this._register((this.panelPartView as PanelPart).onDidVisibilityChange((visible) => {
|
||||
this.setPanelHidden(!visible, true);
|
||||
}));
|
||||
|
||||
this._register(this.lifecycleService.onBeforeShutdown(beforeShutdownEvent => {
|
||||
beforeShutdownEvent.veto(new Promise((resolve) => {
|
||||
const grid = this.workbenchGrid as SerializableGrid<ISerializableView>;
|
||||
const serializedGrid = grid.serialize();
|
||||
|
||||
this.storageService.store(Storage.GRID_LAYOUT, JSON.stringify(serializedGrid), StorageScope.GLOBAL);
|
||||
|
||||
resolve();
|
||||
}));
|
||||
}));
|
||||
} else {
|
||||
this.workbenchGrid = instantiationService.createInstance(
|
||||
WorkbenchLegacyLayout,
|
||||
@@ -797,7 +861,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
}
|
||||
|
||||
if (!panelInGrid) {
|
||||
this.workbenchGrid.addView(this.panelPartView, this.getPanelDimension(this.state.panel.position) !== undefined ? this.getPanelDimension(this.state.panel.position) : Sizing.Split, this.editorPartView, this.state.panel.position === Position.BOTTOM ? Direction.Down : Direction.Right);
|
||||
this.workbenchGrid.addView(this.panelPartView, Sizing.Split, this.editorPartView, this.state.panel.position === Position.BOTTOM ? Direction.Down : Direction.Right);
|
||||
panelInGrid = true;
|
||||
}
|
||||
|
||||
@@ -852,10 +916,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
}
|
||||
}
|
||||
|
||||
private getPanelDimension(position: Position): number {
|
||||
return position === Position.BOTTOM ? this.state.panel.height : this.state.panel.width;
|
||||
}
|
||||
|
||||
isEditorLayoutCentered(): boolean {
|
||||
return this.state.editor.centered;
|
||||
}
|
||||
@@ -1148,12 +1208,9 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
|
||||
setPanelPosition(position: Position): void {
|
||||
const panelPart = this.getPart(Parts.PANEL_PART);
|
||||
const wasHidden = this.state.panel.hidden;
|
||||
|
||||
if (this.state.panel.hidden) {
|
||||
this.setPanelHidden(false, true /* Skip Layout */);
|
||||
} else {
|
||||
this.savePanelDimension();
|
||||
}
|
||||
|
||||
const newPositionValue = (position === Position.BOTTOM) ? 'bottom' : 'right';
|
||||
@@ -1179,10 +1236,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
|
||||
// Layout
|
||||
if (this.workbenchGrid instanceof Grid) {
|
||||
if (!wasHidden) {
|
||||
this.savePanelDimension();
|
||||
}
|
||||
|
||||
this.workbenchGrid.removeView(this.panelPartView);
|
||||
this.layout();
|
||||
} else {
|
||||
@@ -1192,18 +1245,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||
this._onPanelPositionChange.fire(positionToString(this.state.panel.position));
|
||||
}
|
||||
|
||||
private savePanelDimension(): void {
|
||||
if (!(this.workbenchGrid instanceof Grid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state.panel.position === Position.BOTTOM) {
|
||||
this.state.panel.height = this.workbenchGrid.getViewSize(this.panelPartView).height;
|
||||
} else {
|
||||
this.state.panel.width = this.workbenchGrid.getViewSize(this.panelPartView).width;
|
||||
}
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
super.dispose();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user