Add doAction API call for ModelView (#10345)

* Add doAction API call for ModelView

* cleanup
This commit is contained in:
Charles Gagnon
2020-05-12 10:47:20 -07:00
committed by GitHub
parent ff848b5903
commit 3fa0deed71
13 changed files with 70 additions and 8 deletions

View File

@@ -104,6 +104,10 @@ export class MainThreadModelView extends Disposable implements MainThreadModelVi
return new Promise(resolve => this.execModelViewAction(handle, (modelView) => resolve(modelView.focus(componentId))));
}
$doAction(handle: number, componentId: string, action: string, ...args: any[]): Thenable<void> {
return new Promise(resolve => this.execModelViewAction(handle, (modelView) => resolve(modelView.doAction(componentId, action, ...args))));
}
private runCustomValidations(handle: number, componentId: string): Thenable<boolean> {
return this._proxy.$runCustomValidations(handle, componentId);
}

View File

@@ -15,7 +15,7 @@ import * as vscode from 'vscode';
import * as azdata from 'azdata';
import { SqlMainContext, ExtHostModelViewShape, MainThreadModelViewShape, ExtHostModelViewTreeViewsShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { IItemConfig, ModelComponentTypes, IComponentShape, IComponentEventArgs, ComponentEventType, ColumnSizingMode } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IItemConfig, ModelComponentTypes, IComponentShape, IComponentEventArgs, ComponentEventType, ColumnSizingMode, ModelViewAction } from 'sql/workbench/api/common/sqlExtHostTypes';
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { firstIndex } from 'vs/base/common/arrays';
import { ILogService } from 'vs/platform/log/common/log';
@@ -818,6 +818,10 @@ class ComponentWrapper implements azdata.Component {
public focus() {
return this._proxy.$focus(this._handle, this._id);
}
public doAction(action: ModelViewAction, ...args: any[]): Thenable<void> {
return this._proxy.$doAction(this._handle, this._id, action, ...args);
}
}
class ComponentWithIconWrapper extends ComponentWrapper {
@@ -1755,7 +1759,7 @@ class TabbedPanelComponentWrapper extends ComponentWrapper implements azdata.Tab
const itemConfigs = createFromTabs(tabs);
// Go through all of the tabs and either update their layout if they already exist
// or add them if they don't.
// We do not currently support reordering or removing tabs.
// We do not currently support reordering or removing tabs.
itemConfigs.forEach(newItemConfig => {
const existingTab = this.itemConfigs.find(itemConfig => newItemConfig.config.id === itemConfig.config.id);
if (existingTab) {
@@ -1766,6 +1770,10 @@ class TabbedPanelComponentWrapper extends ComponentWrapper implements azdata.Tab
});
}
public selectTab(id: string): void {
this.doAction(ModelViewAction.SelectTab, id);
}
public get onTabChanged(): vscode.Event<string> {
let emitter = this._emitterMap.get(ComponentEventType.onDidChange);
return emitter && emitter.event;

View File

@@ -526,6 +526,10 @@ class ModelViewDashboardImpl implements azdata.window.ModelViewDashboard {
});
return tabs;
}
selectTab(id: string): void {
this._tabbedPanel.selectTab(id);
}
}
export class ExtHostModelViewDialog implements ExtHostModelViewDialogShape {

View File

@@ -739,6 +739,7 @@ export interface MainThreadModelViewShape extends IDisposable {
$setDataProvider(handle: number, componentId: string): Thenable<void>;
$refreshDataProvider(handle: number, componentId: string, item?: any): Thenable<void>;
$focus(handle: number, componentId: string): Thenable<void>;
$doAction(handle: number, componentId: string, action: string, ...args: any[]): Thenable<void>;
}
export interface ExtHostObjectExplorerShape {

View File

@@ -179,6 +179,10 @@ export enum ModelComponentTypes {
PropertiesContainer
}
export enum ModelViewAction {
SelectTab = 'selectTab'
}
export enum ColumnSizingMode {
ForceFit = 0, // all columns will be sized to fit in viewable space, no horiz scroll bar
AutoFit = 1, // columns will be ForceFit up to a certain number; currently 3. At 4 or more the behavior will switch to NO force fit