diff --git a/src/sql/workbench/api/common/extHostModelView.ts b/src/sql/workbench/api/common/extHostModelView.ts index 3008430ed4..ec3ec957e6 100644 --- a/src/sql/workbench/api/common/extHostModelView.ts +++ b/src/sql/workbench/api/common/extHostModelView.ts @@ -36,49 +36,49 @@ class ModelBuilderImpl implements azdata.ModelBuilder { navContainer(): azdata.ContainerBuilder { let id = this.getNextComponentId(); - let container: GenericContainerBuilder = new GenericContainerBuilder(this._proxy, this._handle, ModelComponentTypes.NavContainer, id); + let container: GenericContainerBuilder = new GenericContainerBuilder(this._proxy, this._handle, ModelComponentTypes.NavContainer, id, this.logService); this._componentBuilders.set(id, container); return container; } divContainer(): azdata.DivBuilder { let id = this.getNextComponentId(); - let container = new DivContainerBuilder(this._proxy, this._handle, ModelComponentTypes.DivContainer, id); + let container = new DivContainerBuilder(this._proxy, this._handle, ModelComponentTypes.DivContainer, id, this.logService); this._componentBuilders.set(id, container); return container; } flexContainer(): azdata.FlexBuilder { let id = this.getNextComponentId(); - let container: GenericContainerBuilder = new GenericContainerBuilder(this._proxy, this._handle, ModelComponentTypes.FlexContainer, id); + let container: GenericContainerBuilder = new GenericContainerBuilder(this._proxy, this._handle, ModelComponentTypes.FlexContainer, id, this.logService); this._componentBuilders.set(id, container); return container; } splitViewContainer(): azdata.SplitViewBuilder { let id = this.getNextComponentId(); - let container: GenericContainerBuilder = new GenericContainerBuilder(this._proxy, this._handle, ModelComponentTypes.SplitViewContainer, id); + let container: GenericContainerBuilder = new GenericContainerBuilder(this._proxy, this._handle, ModelComponentTypes.SplitViewContainer, id, this.logService); this._componentBuilders.set(id, container); return container; } formContainer(): azdata.FormBuilder { let id = this.getNextComponentId(); - let container = new FormContainerBuilder(this._proxy, this._handle, ModelComponentTypes.Form, id, this); + let container = new FormContainerBuilder(this._proxy, this._handle, ModelComponentTypes.Form, id, this, this.logService); this._componentBuilders.set(id, container); return container; } toolbarContainer(): azdata.ToolbarBuilder { let id = this.getNextComponentId(); - let container = new ToolbarContainerBuilder(this._proxy, this._handle, ModelComponentTypes.Toolbar, id); + let container = new ToolbarContainerBuilder(this._proxy, this._handle, ModelComponentTypes.Toolbar, id, this.logService); this._componentBuilders.set(id, container); return container; } groupContainer(): azdata.GroupBuilder { let id = this.getNextComponentId(); - let container = new GroupContainerBuilder(this._proxy, this._handle, ModelComponentTypes.Group, id); + let container = new GroupContainerBuilder(this._proxy, this._handle, ModelComponentTypes.Group, id, this.logService); this._componentBuilders.set(id, container); return container; } @@ -90,175 +90,175 @@ class ModelBuilderImpl implements azdata.ModelBuilder { this.cardDeprecationMessagePrinted = true; } let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new CardWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new CardWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } tree(): azdata.ComponentBuilder, azdata.TreeProperties> { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl, azdata.TreeProperties> = this.getComponentBuilder(new TreeComponentWrapper(this._extHostModelViewTree, this._proxy, this._handle, id, this._extension), id); + let builder: ComponentBuilderImpl, azdata.TreeProperties> = this.getComponentBuilder(new TreeComponentWrapper(this._extHostModelViewTree, this._proxy, this._handle, id, this._extension, this.logService), id); this._componentBuilders.set(id, builder); return builder; } inputBox(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new InputBoxWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new InputBoxWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } text(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new TextComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new TextComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } image(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new ImageComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new ImageComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } radioButton(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new RadioButtonWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new RadioButtonWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } checkBox(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new CheckBoxWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new CheckBoxWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } webView(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new WebViewWrapper(this._proxy, this._handle, id, this._extension.extensionLocation), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new WebViewWrapper(this._proxy, this._handle, id, this._extension.extensionLocation, this.logService), id); this._componentBuilders.set(id, builder); return builder; } editor(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new EditorWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new EditorWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } diffeditor(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new DiffEditorWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new DiffEditorWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } button(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new ButtonWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new ButtonWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } separator(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new SeparatorWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new SeparatorWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } dropDown(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new DropDownWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new DropDownWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } listBox(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new ListBoxWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new ListBoxWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } table(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new TableComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new TableComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } declarativeTable(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new DeclarativeTableWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new DeclarativeTableWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } dashboardWidget(widgetId: string): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder = this.getComponentBuilder(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWidget, id), id); + let builder = this.getComponentBuilder(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWidget, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } dashboardWebview(webviewId: string): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWebview, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new ComponentWrapper(this._proxy, this._handle, ModelComponentTypes.DashboardWebview, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } loadingComponent(): azdata.LoadingComponentBuilder { let id = this.getNextComponentId(); - let builder = new LoadingComponentBuilder(new LoadingComponentWrapper(this._proxy, this._handle, id)); + let builder = new LoadingComponentBuilder(new LoadingComponentWrapper(this._proxy, this._handle, id, this.logService)); this._componentBuilders.set(id, builder); return builder; } fileBrowserTree(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new FileBrowserTreeComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new FileBrowserTreeComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } hyperlink(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new HyperlinkComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new HyperlinkComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } radioCardGroup(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new RadioCardGroupComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new RadioCardGroupComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } listView(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new ListViewComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new ListViewComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; } tabbedPanel(): azdata.TabbedPanelComponentBuilder { let id = this.getNextComponentId(); - let builder = new TabbedPanelComponentBuilder(new TabbedPanelComponentWrapper(this._proxy, this._handle, id)); + let builder = new TabbedPanelComponentBuilder(new TabbedPanelComponentWrapper(this._proxy, this._handle, id, this.logService)); this._componentBuilders.set(id, builder); return builder; } propertiesContainer(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new PropertiesContainerComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new PropertiesContainerComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; @@ -266,7 +266,7 @@ class ModelBuilderImpl implements azdata.ModelBuilder { infoBox(): azdata.ComponentBuilder { let id = this.getNextComponentId(); - let builder: ComponentBuilderImpl = this.getComponentBuilder(new InfoBoxComponentWrapper(this._proxy, this._handle, id), id); + let builder: ComponentBuilderImpl = this.getComponentBuilder(new InfoBoxComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; @@ -274,7 +274,7 @@ class ModelBuilderImpl implements azdata.ModelBuilder { slider(): azdata.ComponentBuilder { const id = this.getNextComponentId(); - const builder: ComponentBuilderImpl = this.getComponentBuilder(new SliderComponentWrapper(this._proxy, this._handle, id), id); + const builder: ComponentBuilderImpl = this.getComponentBuilder(new SliderComponentWrapper(this._proxy, this._handle, id, this.logService), id); this._componentBuilders.set(id, builder); return builder; @@ -362,20 +362,20 @@ class ContainerBuilderImpl extends ContainerBuilderImpl { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) { - super(new ComponentWrapper(proxy, handle, type, id)); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, logService: ILogService) { + super(new ComponentWrapper(proxy, handle, type, id, logService)); } } class DivContainerBuilder extends ContainerBuilderImpl { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) { - super(new DivContainerWrapper(proxy, handle, type, id)); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, logService: ILogService) { + super(new DivContainerWrapper(proxy, handle, type, id, logService)); } } class FormContainerBuilder extends GenericContainerBuilder implements azdata.FormBuilder { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, private _builder: ModelBuilderImpl) { - super(proxy, handle, type, id); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, private _builder: ModelBuilderImpl, logService: ILogService) { + super(proxy, handle, type, id, logService); } withFormItems(components: (azdata.FormComponent | azdata.FormComponentGroup)[], itemLayout?: azdata.FormItemLayout): azdata.FormBuilder { @@ -492,8 +492,8 @@ class FormContainerBuilder extends GenericContainerBuilder { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) { - super(new GroupContainerComponentWrapper(proxy, handle, type, id)); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, logService: ILogService) { + super(new GroupContainerComponentWrapper(proxy, handle, type, id, logService)); } } @@ -595,7 +595,8 @@ class ComponentWrapper implements azdata.Component { constructor(protected readonly _proxy: MainThreadModelViewShape, protected readonly _handle: number, protected _type: ModelComponentTypes, - protected _id: string + protected _id: string, + protected _logService: ILogService ) { this.properties = {}; this.itemConfigs = []; @@ -708,6 +709,16 @@ class ComponentWrapper implements azdata.Component { } public addItems(items: Array, itemLayout?: any): void { + items = items.filter(item => { + if (this.itemConfigs.find(itemConfig => itemConfig.component.id === item.id)) { + this._logService.warn(`Trying to add duplicate component ${item.id} to container ${this.id}`); + return false; + } + return true; + }); + if (items.length === 0) { + return; + } const itemConfigs = items.map(item => { return { itemConfig: this.createAndAddItemConfig(item, itemLayout).toIItemConfig() @@ -739,6 +750,10 @@ class ComponentWrapper implements azdata.Component { } public addItem(item: azdata.Component, itemLayout?: any, index?: number): void { + if (this.itemConfigs.find(itemConfig => itemConfig.component.id === item.id)) { + this._logService.warn(`Trying to add duplicate component ${item.id} to container ${this.id}`); + return; + } const config = this.createAndAddItemConfig(item, itemLayout, index); this._proxy.$addToContainer(this._handle, this.id, [{ itemConfig: config.toIItemConfig(), index }]).then(undefined, (err) => this.handleError(err)); } @@ -864,8 +879,8 @@ class ComponentWrapper implements azdata.Component { class ComponentWithIconWrapper extends ComponentWrapper { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) { - super(proxy, handle, type, id); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, logService: ILogService) { + super(proxy, handle, type, id, logService); } public get iconPath(): azdata.IconPath { @@ -899,8 +914,8 @@ class ComponentWithIconWrapper extends ComponentWrapper { class CardWrapper extends ComponentWrapper implements azdata.CardComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Card, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Card, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); } @@ -968,8 +983,8 @@ class CardWrapper extends ComponentWrapper implements azdata.CardComponent { class InputBoxWrapper extends ComponentWrapper implements azdata.InputBoxComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.InputBox, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.InputBox, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); this._emitterMap.set(ComponentEventType.onEnterKeyPressed, new Emitter()); @@ -1072,8 +1087,8 @@ class InputBoxWrapper extends ComponentWrapper implements azdata.InputBoxCompone class CheckBoxWrapper extends ComponentWrapper implements azdata.CheckBoxComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.CheckBox, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.CheckBox, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); } @@ -1099,8 +1114,8 @@ class CheckBoxWrapper extends ComponentWrapper implements azdata.CheckBoxCompone } class WebViewWrapper extends ComponentWrapper implements azdata.WebViewComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string, private _extensionLocation: URI) { - super(proxy, handle, ModelComponentTypes.WebView, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, private _extensionLocation: URI, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.WebView, id, logService); this.properties = { 'extensionLocation': this._extensionLocation }; @@ -1135,8 +1150,8 @@ class WebViewWrapper extends ComponentWrapper implements azdata.WebViewComponent } class EditorWrapper extends ComponentWrapper implements azdata.EditorComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Editor, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Editor, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); this._emitterMap.set(ComponentEventType.onComponentCreated, new Emitter()); @@ -1188,8 +1203,8 @@ class EditorWrapper extends ComponentWrapper implements azdata.EditorComponent { } class DiffEditorWrapper extends ComponentWrapper implements azdata.DiffEditorComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.DiffEditor, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.DiffEditor, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); this._emitterMap.set(ComponentEventType.onComponentCreated, new Emitter()); @@ -1275,8 +1290,8 @@ class DiffEditorWrapper extends ComponentWrapper implements azdata.DiffEditorCom class RadioButtonWrapper extends ComponentWrapper implements azdata.RadioButtonComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.RadioButton, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.RadioButton, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); @@ -1322,8 +1337,8 @@ class RadioButtonWrapper extends ComponentWrapper implements azdata.RadioButtonC class TextComponentWrapper extends ComponentWrapper implements azdata.TextComponentProperties { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Text, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Text, id, logService); this.properties = {}; } @@ -1351,16 +1366,16 @@ class TextComponentWrapper extends ComponentWrapper implements azdata.TextCompon class ImageComponentWrapper extends ComponentWithIconWrapper implements azdata.ImageComponentProperties { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Image, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Image, id, logService); this.properties = {}; } } class TableComponentWrapper extends ComponentWrapper implements azdata.TableComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Table, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Table, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onSelectedRowChanged, new Emitter()); this._emitterMap.set(ComponentEventType.onCellAction, new Emitter()); @@ -1455,8 +1470,8 @@ class TableComponentWrapper extends ComponentWrapper implements azdata.TableComp class DropDownWrapper extends ComponentWrapper implements azdata.DropDownComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.DropDown, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.DropDown, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); } @@ -1517,8 +1532,8 @@ class DropDownWrapper extends ComponentWrapper implements azdata.DropDownCompone class DeclarativeTableWrapper extends ComponentWrapper implements azdata.DeclarativeTableComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.DeclarativeTable, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.DeclarativeTable, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); @@ -1530,7 +1545,9 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara } public set data(v: any[][]) { - this.setProperty('data', v); + this.clearItems().then(() => { + this.setProperty('data', v); + }); } public get dataValues(): azdata.DeclarativeTableCellValue[][] { @@ -1538,7 +1555,9 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara } public set dataValues(v: azdata.DeclarativeTableCellValue[][]) { - this.setProperty('dataValues', v); + this.clearItems().then(() => { + this.setProperty('dataValues', v); + }); } public get columns(): azdata.DeclarativeTableColumn[] { @@ -1600,11 +1619,13 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara properties.data = properties.data.map((row: any[]) => row.map(cell => { if (cell instanceof ComponentWrapper) { - // First ensure that we register the component using addItem - // such that it gets added to the ModelStore. We don't want to - // make the table component an actual container since that exposes - // a lot of functionality we don't need. - componentsToAdd.push(cell); + if (!this.itemConfigs.find(item => item.component.id === cell.id)) { + // First ensure that we register the component using addItem + // such that it gets added to the ModelStore. We don't want to + // make the table component an actual container since that exposes + // a lot of functionality we don't need. + componentsToAdd.push(cell); + } return cell.id; } return cell; @@ -1612,13 +1633,16 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara } else { if (properties.dataValues) { properties.dataValues = properties.dataValues.map((row: azdata.DeclarativeTableCellValue[]) => row.map(cell => { - if (cell.value instanceof ComponentWrapper) { - // First ensure that we register the component using addItem - // such that it gets added to the ModelStore. We don't want to - // make the table component an actual container since that exposes - // a lot of functionality we don't need. - componentsToAdd.push(cell.value); - return { value: cell.value.id, ariaLabel: cell.ariaLabel, style: cell.style }; + const cellValue = cell.value; + if (cellValue instanceof ComponentWrapper) { + if (!this.itemConfigs.find(item => item.component.id === cellValue.id)) { + // First ensure that we register the component using addItem + // such that it gets added to the ModelStore. We don't want to + // make the table component an actual container since that exposes + // a lot of functionality we don't need. + componentsToAdd.push(cellValue); + } + return { value: cellValue.id, ariaLabel: cell.ariaLabel, style: cell.style }; } return cell; })); @@ -1631,8 +1655,8 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara class ListBoxWrapper extends ComponentWrapper implements azdata.ListBoxComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.ListBox, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.ListBox, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onSelectedRowChanged, new Emitter()); } @@ -1659,8 +1683,8 @@ class ListBoxWrapper extends ComponentWrapper implements azdata.ListBoxComponent class ButtonWrapper extends ComponentWithIconWrapper implements azdata.ButtonComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Button, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Button, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); } @@ -1679,8 +1703,8 @@ class ButtonWrapper extends ComponentWithIconWrapper implements azdata.ButtonCom } class LoadingComponentWrapper extends ComponentWrapper implements azdata.LoadingComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.LoadingComponent, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.LoadingComponent, id, logService); this.properties = { loading: true }; @@ -1729,8 +1753,8 @@ class LoadingComponentWrapper extends ComponentWrapper implements azdata.Loading class FileBrowserTreeComponentWrapper extends ComponentWrapper implements azdata.FileBrowserTreeComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.FileBrowserTree, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.FileBrowserTree, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); } @@ -1750,14 +1774,14 @@ class FileBrowserTreeComponentWrapper extends ComponentWrapper implements azdata } class SeparatorWrapper extends ComponentWrapper implements azdata.SeparatorComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Separator, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Separator, id, logService); } } class DivContainerWrapper extends ComponentWrapper implements azdata.DivContainer { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) { - super(proxy, handle, type, id); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, logService: ILogService) { + super(proxy, handle, type, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); } @@ -1788,8 +1812,8 @@ class TreeComponentWrapper extends ComponentWrapper implements azdata.TreeCom constructor( private _extHostModelViewTree: ExtHostModelViewTreeViewsShape, - proxy: MainThreadModelViewShape, handle: number, id: string, private _extension: IExtensionDescription) { - super(proxy, handle, ModelComponentTypes.TreeComponent, id); + proxy: MainThreadModelViewShape, handle: number, id: string, private _extension: IExtensionDescription, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.TreeComponent, id, logService); this.properties = {}; } @@ -1808,8 +1832,8 @@ class TreeComponentWrapper extends ComponentWrapper implements azdata.TreeCom class HyperlinkComponentWrapper extends ComponentWrapper implements azdata.HyperlinkComponentProperties { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Hyperlink, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Hyperlink, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); } @@ -1835,8 +1859,8 @@ class HyperlinkComponentWrapper extends ComponentWrapper implements azdata.Hyper } class RadioCardGroupComponentWrapper extends ComponentWrapper implements azdata.RadioCardGroupComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.RadioCardGroup, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.RadioCardGroup, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); @@ -1910,8 +1934,8 @@ class RadioCardGroupComponentWrapper extends ComponentWrapper implements azdata. } class ListViewComponentWrapper extends ComponentWrapper implements azdata.ListViewComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.ListView, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.ListView, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidClick, new Emitter()); @@ -1947,8 +1971,8 @@ class ListViewComponentWrapper extends ComponentWrapper implements azdata.ListVi } class TabbedPanelComponentWrapper extends ComponentWrapper implements azdata.TabbedPanelComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.TabbedPanel, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.TabbedPanel, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); } @@ -1979,8 +2003,8 @@ class TabbedPanelComponentWrapper extends ComponentWrapper implements azdata.Tab } class PropertiesContainerComponentWrapper extends ComponentWrapper implements azdata.PropertiesContainerComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.PropertiesContainer, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.PropertiesContainer, id, logService); this.properties = {}; } @@ -2000,8 +2024,8 @@ class PropertiesContainerComponentWrapper extends ComponentWrapper implements az } class InfoBoxComponentWrapper extends ComponentWrapper implements azdata.InfoBoxComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.InfoBox, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.InfoBox, id, logService); this.properties = {}; } @@ -2031,8 +2055,8 @@ class InfoBoxComponentWrapper extends ComponentWrapper implements azdata.InfoBox } class SliderComponentWrapper extends ComponentWrapper implements azdata.SliderComponent { - constructor(proxy: MainThreadModelViewShape, handle: number, id: string) { - super(proxy, handle, ModelComponentTypes.Slider, id); + constructor(proxy: MainThreadModelViewShape, handle: number, id: string, logService: ILogService) { + super(proxy, handle, ModelComponentTypes.Slider, id, logService); this.properties = {}; this._emitterMap.set(ComponentEventType.onDidChange, new Emitter()); this._emitterMap.set(ComponentEventType.onInput, new Emitter()); @@ -2090,8 +2114,8 @@ class SliderComponentWrapper extends ComponentWrapper implements azdata.SliderCo } class GroupContainerComponentWrapper extends ComponentWrapper implements azdata.GroupContainer { - constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string) { - super(proxy, handle, type, id); + constructor(proxy: MainThreadModelViewShape, handle: number, type: ModelComponentTypes, id: string, logService: ILogService) { + super(proxy, handle, type, id, logService); this.properties = {}; } public get collapsed(): boolean {