Properly save and restore dynamic tab state (#6185)

* WIP

* WIP 2

* WIP 3

* Rework state capture implementation

* Break loop after setting
This commit is contained in:
Karl Burtram
2019-06-27 16:14:28 -07:00
committed by GitHub
parent f5d647f05c
commit 4ef25ecf37
4 changed files with 57 additions and 9 deletions

View File

@@ -240,13 +240,20 @@ export class QueryResultsView extends Disposable {
}
// restore query model view tabs
this.dynamicModelViewTabs.forEach(tab => {
if (this._panelView.contains(tab)) {
this._panelView.removeTab(tab.identifier);
}
});
this.dynamicModelViewTabs = [];
this.input.state.visibleTabs.forEach(tabId => {
if (tabId.startsWith('querymodelview;')) {
// tab id format is 'tab type;title;model view id'
let parts = tabId.split(';');
if (parts.length === 3) {
let tab = this._register(new QueryModelViewTab(parts[1], this.instantiationService));
tab.view._componentId = parts[2];
tab.view.componentId = parts[2];
this.dynamicModelViewTabs.push(tab);
if (!this._panelView.contains(tab)) {
this._panelView.pushTab(tab, undefined, true);
@@ -275,12 +282,16 @@ export class QueryResultsView extends Disposable {
this.runnerDisposables = [];
[this.resultsTab, this.messagesTab, this.qpTab, this.topOperationsTab, this.chartTab].forEach(t => t.clear());
this.dynamicModelViewTabs.forEach(t => t.clear());
this.resultsTab.view.state = this.input.state.gridPanelState;
this.messagesTab.view.state = this.input.state.messagePanelState;
this.qpTab.view.state = this.input.state.queryPlanState;
this.topOperationsTab.view.state = this.input.state.topOperationsState;
this.chartTab.view.state = this.input.state.chartState;
this.dynamicModelViewTabs.forEach((dynamicTab: QueryModelViewTab) => {
dynamicTab.captureState(this.input.state.dynamicModelViewTabsState);
});
let info = this.queryModelService._getQueryInfo(input.uri);
if (info) {
@@ -306,6 +317,7 @@ export class QueryResultsView extends Disposable {
this.qpTab.clear();
this.topOperationsTab.clear();
this.chartTab.clear();
this.dynamicModelViewTabs.forEach(t => t.clear());
}
public get input(): QueryResultsInput {
@@ -388,12 +400,14 @@ export class QueryResultsView extends Disposable {
public registerQueryModelViewTab(title: string, componentId: string): void {
let tab = this._register(new QueryModelViewTab(title, this.instantiationService));
tab.view._componentId = componentId;
tab.view.componentId = componentId;
this.dynamicModelViewTabs.push(tab);
this.input.state.visibleTabs.add('querymodelview;' + title + ';' + componentId);
if (!this._panelView.contains(tab)) {
this._panelView.pushTab(tab, undefined, true);
}
tab.putState(this.input.state.dynamicModelViewTabsState);
}
}