Add css styles options to all components (#2454)

* add css styling in all components

* formatting

* formatting

* small typo

* small typo

* use builder to add style instead
This commit is contained in:
Abbie Petchtes
2018-09-07 09:08:29 -07:00
committed by Kevin Cunnane
parent 287811f4ab
commit 10f05e75ce
25 changed files with 124 additions and 66 deletions

View File

@@ -193,7 +193,6 @@ export class ConnectionWidget {
}, },
ariaLabel: userNameOption.displayName ariaLabel: userNameOption.displayName
}); });
// Password // Password
let passwordOption = this._optionsMaps[ConnectionOptionSpecialType.password]; let passwordOption = this._optionsMaps[ConnectionOptionSpecialType.password];
let passwordBuilder = DialogHelper.appendRow(this._tableContainer, passwordOption.displayName, 'connection-label', 'connection-input'); let passwordBuilder = DialogHelper.appendRow(this._tableContainer, passwordOption.displayName, 'connection-label', 'connection-input');

View File

@@ -42,9 +42,10 @@ export default class ButtonComponent extends ComponentWithIconBase implements IC
@ViewChild('fileInput', { read: ElementRef }) private _fileInputContainer: ElementRef; @ViewChild('fileInput', { read: ElementRef }) private _fileInputContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {
@@ -63,7 +64,7 @@ export default class ButtonComponent extends ComponentWithIconBase implements IC
if (this._fileInputContainer) { if (this._fileInputContainer) {
const self = this; const self = this;
this._fileInputContainer.nativeElement.onchange = () => { this._fileInputContainer.nativeElement.onchange = () => {
let file = self._fileInputContainer.nativeElement.files[0]; let file = self._fileInputContainer.nativeElement.files[0];
let reader = new FileReader(); let reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
let text = (<FileReader>e.target).result; let text = (<FileReader>e.target).result;
@@ -153,7 +154,7 @@ export default class ButtonComponent extends ComponentWithIconBase implements IC
this.setPropertyFromUI<sqlops.ButtonProperties, string>(this.setFileContentProperties, newValue); this.setPropertyFromUI<sqlops.ButtonProperties, string>(this.setFileContentProperties, newValue);
} }
private setFileContentProperties(properties: sqlops.ButtonProperties, fileContent: string) : void { private setFileContentProperties(properties: sqlops.ButtonProperties, fileContent: string): void {
properties.fileContent = fileContent; properties.fileContent = fileContent;
} }

View File

@@ -4,7 +4,8 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import 'vs/css!./card'; import 'vs/css!./card';
import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver, import {
Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver,
ViewChild, ViewChildren, ElementRef, Injector, OnDestroy, QueryList, ViewChild, ViewChildren, ElementRef, Injector, OnDestroy, QueryList,
} from '@angular/core'; } from '@angular/core';
@@ -28,11 +29,11 @@ export default class CardComponent extends ComponentWithIconBase implements ICom
private backgroundColor: string; private backgroundColor: string;
constructor(@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, constructor( @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {
@@ -70,7 +71,7 @@ export default class CardComponent extends ComponentWithIconBase implements ICom
public getClass(): string { public getClass(): string {
return (this.selectable && this.selected || this._hasFocus) ? 'model-card selected' : return (this.selectable && this.selected || this._hasFocus) ? 'model-card selected' :
'model-card unselected'; 'model-card unselected';
} }
public onCardHoverChanged(event: any) { public onCardHoverChanged(event: any) {
@@ -81,7 +82,7 @@ export default class CardComponent extends ComponentWithIconBase implements ICom
} }
/// IComponent implementation /// IComponent implementation
public setLayout (layout: any): void { public setLayout(layout: any): void {
// TODO allow configuring the look and feel // TODO allow configuring the look and feel
this.layout(); this.layout();
} }
@@ -141,7 +142,7 @@ export default class CardComponent extends ComponentWithIconBase implements ICom
public get statusColor(): string { public get statusColor(): string {
let status = this.getPropertyOrDefault<CardProperties, StatusIndicator>((props) => props.status, StatusIndicator.None); let status = this.getPropertyOrDefault<CardProperties, StatusIndicator>((props) => props.status, StatusIndicator.None);
switch(status) { switch (status) {
case StatusIndicator.Ok: case StatusIndicator.Ok:
return 'green'; return 'green';
case StatusIndicator.Warning: case StatusIndicator.Warning:

View File

@@ -29,8 +29,9 @@ export default class CheckBoxComponent extends ComponentBase implements ICompone
@ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef; @ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -19,6 +19,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { ModelComponentWrapper } from 'sql/parts/modelComponents/modelComponentWrapper.component'; import { ModelComponentWrapper } from 'sql/parts/modelComponents/modelComponentWrapper.component';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import { Builder } from 'vs/base/browser/builder';
import { IdGenerator } from 'vs/base/common/idGenerator'; import { IdGenerator } from 'vs/base/common/idGenerator';
import { createCSSRule, removeCSSRulesContainingSelector } from 'vs/base/browser/dom'; import { createCSSRule, removeCSSRulesContainingSelector } from 'vs/base/browser/dom';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
@@ -35,8 +36,11 @@ export abstract class ComponentBase extends Disposable implements IComponent, On
private _valid: boolean = true; private _valid: boolean = true;
protected _validations: (() => boolean | Thenable<boolean>)[] = []; protected _validations: (() => boolean | Thenable<boolean>)[] = [];
private _eventQueue: IComponentEventArgs[] = []; private _eventQueue: IComponentEventArgs[] = [];
private _CSSStyles: { [key: string]: string } = {};
constructor( constructor(
protected _changeRef: ChangeDetectorRef) { protected _changeRef: ChangeDetectorRef,
protected _el: ElementRef) {
super(); super();
} }
@@ -80,11 +84,20 @@ export abstract class ComponentBase extends Disposable implements IComponent, On
public refreshDataProvider(item: any): void { public refreshDataProvider(item: any): void {
} }
public updateStyles() {
let element = new Builder(this._el.nativeElement);
this._CSSStyles = this.CSSStyles;
element.style(this._CSSStyles);
}
public setProperties(properties: { [key: string]: any; }): void { public setProperties(properties: { [key: string]: any; }): void {
if (!properties) { if (!properties) {
this.properties = {}; this.properties = {};
} }
this.properties = properties; this.properties = properties;
if (this.CSSStyles !== this._CSSStyles) {
this.updateStyles();
}
this.layout(); this.layout();
this.validate(); this.validate();
} }
@@ -140,11 +153,19 @@ export abstract class ComponentBase extends Disposable implements IComponent, On
} }
public get position(): string { public get position(): string {
return this.getPropertyOrDefault<sqlops.EditorProperties, string>((props) => props.position, ''); return this.getPropertyOrDefault<sqlops.ComponentProperties, string>((props) => props.position, '');
} }
public set position(newValue: string) { public set position(newValue: string) {
this.setPropertyFromUI<sqlops.EditorProperties, string>((properties, position) => { properties.position = position; }, newValue); this.setPropertyFromUI<sqlops.ComponentProperties, string>((properties, position) => { properties.position = position; }, newValue);
}
public get CSSStyles(): { [key: string]: string } {
return this.getPropertyOrDefault<sqlops.ComponentProperties, { [key: string]: string }>((props) => props.CSSStyles, {});
}
public set CSSStyles(newValue: { [key: string]: string }) {
this.setPropertyFromUI<sqlops.ComponentProperties, { [key: string]: string }>((properties, CSSStyles) => { properties.CSSStyles = CSSStyles; }, newValue);
} }
public convertSizeToNumber(size: number | string): number { public convertSizeToNumber(size: number | string): number {
@@ -223,9 +244,10 @@ export abstract class ContainerBase<T> extends ComponentBase {
@ViewChildren(ModelComponentWrapper) protected _componentWrappers: QueryList<ModelComponentWrapper>; @ViewChildren(ModelComponentWrapper) protected _componentWrappers: QueryList<ModelComponentWrapper>;
constructor( constructor(
_changeRef: ChangeDetectorRef _changeRef: ChangeDetectorRef,
_el: ElementRef
) { ) {
super(_changeRef); super(_changeRef, _el);
this.items = []; this.items = [];
this._validations.push(() => this.items.every(item => { this._validations.push(() => this.items.every(item => {
return this.modelStore.getComponent(item.descriptor.id).valid; return this.modelStore.getComponent(item.descriptor.id).valid;
@@ -239,7 +261,7 @@ export abstract class ContainerBase<T> extends ComponentBase {
} }
if (index !== undefined && index !== null && index >= 0 && index < this.items.length) { if (index !== undefined && index !== null && index >= 0 && index < this.items.length) {
this.items.splice(index, 0, new ItemDescriptor(componentDescriptor, config)); this.items.splice(index, 0, new ItemDescriptor(componentDescriptor, config));
} else if(!index) { } else if (!index) {
this.items.push(new ItemDescriptor(componentDescriptor, config)); this.items.push(new ItemDescriptor(componentDescriptor, config));
} else { } else {
throw new Error(nls.localize('invalidIndex', 'The index is invalid.')); throw new Error(nls.localize('invalidIndex', 'The index is invalid.'));

View File

@@ -27,8 +27,9 @@ export abstract class ComponentWithIconBase extends ComponentBase {
protected _iconClass: string; protected _iconClass: string;
protected _iconPath: IUserFriendlyIcon; protected _iconPath: IUserFriendlyIcon;
constructor( constructor(
changeRef: ChangeDetectorRef) { changeRef: ChangeDetectorRef,
super(changeRef); el: ElementRef, ) {
super(changeRef, el);
} }
/// IComponent implementation /// IComponent implementation

View File

@@ -64,9 +64,10 @@ export default class DeclarativeTableComponent extends ComponentBase implements
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService @Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {
@@ -134,7 +135,7 @@ export default class DeclarativeTableComponent extends ComponentBase implements
private onCellDataChanged(newValue: any, row: number, cell: number): void { private onCellDataChanged(newValue: any, row: number, cell: number): void {
this.data[row][cell] = newValue; this.data[row][cell] = newValue;
this.data = this.data; this.data = this.data;
let newCellData : sqlops.TableCell = { let newCellData: sqlops.TableCell = {
row: row, row: row,
column: cell, column: cell,
value: newValue value: newValue

View File

@@ -41,9 +41,10 @@ export default class DropDownComponent extends ComponentBase implements ICompone
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService @Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -41,12 +41,12 @@ export default class EditorComponent extends ComponentBase implements IComponent
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(IInstantiationService) private _instantiationService: IInstantiationService, @Inject(IInstantiationService) private _instantiationService: IInstantiationService,
@Inject(IModelService) private _modelService: IModelService, @Inject(IModelService) private _modelService: IModelService,
@Inject(IModeService) private _modeService: IModeService @Inject(IModeService) private _modeService: IModeService
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {
@@ -107,7 +107,7 @@ export default class EditorComponent extends ComponentBase implements IComponent
this._editor.layout(new DOM.Dimension( this._editor.layout(new DOM.Dimension(
width && width > 0 ? width : DOM.getContentWidth(this._el.nativeElement), width && width > 0 ? width : DOM.getContentWidth(this._el.nativeElement),
height && height > 0 ? height : DOM.getContentHeight(this._el.nativeElement))); height && height > 0 ? height : DOM.getContentHeight(this._el.nativeElement)));
let element = <HTMLElement> this._el.nativeElement; let element = <HTMLElement>this._el.nativeElement;
element.style.position = this.position; element.style.position = this.position;
} }
@@ -129,7 +129,6 @@ export default class EditorComponent extends ComponentBase implements IComponent
} }
/// IComponent implementation /// IComponent implementation
public setLayout(layout: any): void { public setLayout(layout: any): void {
// TODO allow configuring the look and feel // TODO allow configuring the look and feel
this.layout(); this.layout();

View File

@@ -27,15 +27,16 @@ export default class FileBrowserTreeComponent extends ComponentBase implements I
@Input() modelStore: IModelStore; @Input() modelStore: IModelStore;
private _treeView: FileBrowserTreeView; private _treeView: FileBrowserTreeView;
private _viewModel: FileBrowserViewModel; private _viewModel: FileBrowserViewModel;
private _fileFilters: [{label: string, filters: string[]}] = [ private _fileFilters: [{ label: string, filters: string[] }] = [
{ label: 'All Files', filters: ['*'] } { label: 'All Files', filters: ['*'] }
]; ];
@ViewChild('fileBrowserTree', { read: ElementRef }) private _treeContainer: ElementRef; @ViewChild('fileBrowserTree', { read: ElementRef }) private _treeContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IInstantiationService) private _instantiationService: IInstantiationService) { @Inject(IInstantiationService) private _instantiationService: IInstantiationService,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -45,8 +45,11 @@ export default class FlexContainer extends ContainerBase<FlexItemLayout> impleme
private _width: string; private _width: string;
private _position: string; private _position: string;
constructor(@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { constructor(
super(changeRef); @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) el: ElementRef
) {
super(changeRef, el);
this._flexFlow = ''; // default this._flexFlow = ''; // default
this._justifyContent = ''; // default this._justifyContent = ''; // default
} }

View File

@@ -106,8 +106,9 @@ export default class FormContainer extends ContainerBase<FormItemLayout> impleme
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -45,8 +45,9 @@ export default class GroupContainer extends ContainerBase<GroupLayout> implement
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -42,9 +42,10 @@ export default class InputBoxComponent extends ComponentBase implements ICompone
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService @Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -37,9 +37,10 @@ export default class ListBoxComponent extends ComponentBase implements IComponen
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService, @Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(IClipboardService) private clipboardService: IClipboardService @Inject(IClipboardService) private clipboardService: IClipboardService,
@Inject(forwardRef(() => ElementRef)) el: ElementRef,
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -35,8 +35,9 @@ export default class LoadingComponent extends ComponentBase implements IComponen
@ViewChild('childElement', { read: ElementRef }) private _childElement: ElementRef; @ViewChild('childElement', { read: ElementRef }) private _childElement: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
this._validations.push(() => { this._validations.push(() => {
if (!this._component) { if (!this._component) {
return true; return true;

View File

@@ -33,8 +33,9 @@ export default class RadioButtonComponent extends ComponentBase implements IComp
@ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef; @ViewChild('input', { read: ElementRef }) private _inputContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -35,8 +35,9 @@ export default class TableComponent extends ComponentBase implements IComponent,
@ViewChild('table', { read: ElementRef }) private _inputContainer: ElementRef; @ViewChild('table', { read: ElementRef }) private _inputContainer: ElementRef;
constructor( constructor(
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService) { @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -6,7 +6,7 @@
import 'vs/css!./radioButton'; import 'vs/css!./radioButton';
import { import {
Component, Input, Inject, ChangeDetectorRef, forwardRef, Component, Input, Inject, ChangeDetectorRef, forwardRef,
OnDestroy, AfterViewInit OnDestroy, AfterViewInit, ElementRef
} from '@angular/core'; } from '@angular/core';
import * as sqlops from 'sqlops'; import * as sqlops from 'sqlops';
@@ -26,8 +26,9 @@ export default class TextComponent extends ComponentBase implements IComponent,
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {

View File

@@ -52,8 +52,9 @@ export default class ToolbarContainer extends ContainerBase<ToolbarItemConfig> i
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef) { @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef) {
super(changeRef, el);
this._orientation = Orientation.Horizontal; this._orientation = Orientation.Horizontal;
} }

View File

@@ -55,8 +55,10 @@ export default class TreeComponent extends ComponentBase implements IComponent,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService,
@Inject(IContextViewService) private contextViewService: IContextViewService, @Inject(IContextViewService) private contextViewService: IContextViewService,
@Inject(IInstantiationService) private _instantiationService: IInstantiationService) { @Inject(IInstantiationService) private _instantiationService: IInstantiationService,
super(changeRef); @Inject(forwardRef(() => ElementRef)) el: ElementRef
) {
super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {
@@ -112,7 +114,7 @@ export default class TreeComponent extends ComponentBase implements IComponent,
this._tree.domFocus(); this._tree.domFocus();
this._register(this._tree); this._register(this._tree);
this._register(attachListStyler(this._tree, this.themeService)); this._register(attachListStyler(this._tree, this.themeService));
this._register(this._tree.onDidChangeSelection( e => { this._register(this._tree.onDidChangeSelection(e => {
this._dataProvider.onNodeSelected(e.selection); this._dataProvider.onNodeSelected(e.selection);
})); }));
this._tree.refresh(); this._tree.refresh();

View File

@@ -53,7 +53,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
constructor( constructor(
@Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface, @Inject(forwardRef(() => CommonServiceInterface)) private _commonService: CommonServiceInterface,
@Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ChangeDetectorRef)) changeRef: ChangeDetectorRef,
@Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(forwardRef(() => ElementRef)) el: ElementRef,
@Inject(IPartService) private partService: IPartService, @Inject(IPartService) private partService: IPartService,
@Inject(IThemeService) private themeService: IThemeService, @Inject(IThemeService) private themeService: IThemeService,
@Inject(IEnvironmentService) private environmentService: IEnvironmentService, @Inject(IEnvironmentService) private environmentService: IEnvironmentService,
@@ -63,7 +63,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
@Inject(IInstantiationService) private instantiationService: IInstantiationService, @Inject(IInstantiationService) private instantiationService: IInstantiationService,
@Inject(IContextKeyService) contextKeyService: IContextKeyService @Inject(IContextKeyService) contextKeyService: IContextKeyService
) { ) {
super(changeRef); super(changeRef, el);
} }
ngOnInit(): void { ngOnInit(): void {
@@ -139,7 +139,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
/// IComponent implementation /// IComponent implementation
public layout(): void { public layout(): void {
let element = <HTMLElement> this._el.nativeElement; let element = <HTMLElement>this._el.nativeElement;
element.style.position = this.position; element.style.position = this.position;
this._webview.layout(); this._webview.layout();
} }

View File

@@ -147,6 +147,15 @@ declare module 'sqlops' {
*/ */
updateProperties(properties: { [key: string]: any }): Thenable<void>; updateProperties(properties: { [key: string]: any }): Thenable<void>;
/**
* Sends an updated property of the component to the UI
*
* @returns {Thenable<void>} Thenable that completes once the update
* has been applied in the UI
* @memberof Component
*/
updateProperty(key: string, value: any): Thenable<void>;
enabled: boolean; enabled: boolean;
/** /**
* Event fired to notify that the component's validity has changed * Event fired to notify that the component's validity has changed
@@ -312,7 +321,7 @@ declare module 'sqlops' {
/** /**
* Matches the CSS style key and its available values. * Matches the CSS style key and its available values.
*/ */
CSSStyles?: { [key: string]: string } CSSStyles?: { [key: string]: string };
} }
export interface FormItemLayout { export interface FormItemLayout {
@@ -427,6 +436,10 @@ declare module 'sqlops' {
* Without this the component will fail to correctly size itself * Without this the component will fail to correctly size itself
*/ */
position?: string; position?: string;
/**
* Matches the CSS style key and its available values.
*/
CSSStyles?: { [key: string]: string };
} }
export interface ComponentWithIcon { export interface ComponentWithIcon {

View File

@@ -340,7 +340,7 @@ class FormContainerBuilder extends ContainerBuilderImpl<sqlops.FormContainer, sq
itemConfig.config.isInGroup = true; itemConfig.config.isInGroup = true;
this._component.insertItem(component.component as ComponentWrapper, componentIndex, itemConfig.config); this._component.insertItem(component.component as ComponentWrapper, componentIndex, itemConfig.config);
if (componentIndex) { if (componentIndex) {
componentIndex ++; componentIndex++;
} }
this.addComponentActions(component, layout); this.addComponentActions(component, layout);
}); });
@@ -560,6 +560,10 @@ class ComponentWrapper implements sqlops.Component {
return this.notifyPropertyChanged(); return this.notifyPropertyChanged();
} }
public updateProperty(key: string, value: any): Thenable<void> {
return this.setProperty(key, value);
}
protected notifyPropertyChanged(): Thenable<void> { protected notifyPropertyChanged(): Thenable<void> {
return this._proxy.$setProperties(this._handle, this._id, this.properties); return this._proxy.$setProperties(this._handle, this._id, this.properties);
} }

View File

@@ -16,7 +16,7 @@ class TestComponent extends ComponentBase {
public descriptor: IComponentDescriptor; public descriptor: IComponentDescriptor;
constructor(public modelStore: IModelStore, id: string) { constructor(public modelStore: IModelStore, id: string) {
super(undefined); super(undefined, undefined);
this.descriptor = modelStore.createComponentDescriptor('TestComponent', id); this.descriptor = modelStore.createComponentDescriptor('TestComponent', id);
this.baseInit(); this.baseInit();
} }
@@ -33,7 +33,7 @@ class TestContainer extends ContainerBase<TestComponent> {
public descriptor: IComponentDescriptor; public descriptor: IComponentDescriptor;
constructor(public modelStore: IModelStore, id: string) { constructor(public modelStore: IModelStore, id: string) {
super(undefined); super(undefined, undefined);
this.descriptor = modelStore.createComponentDescriptor('TestContainer', id); this.descriptor = modelStore.createComponentDescriptor('TestContainer', id);
this._changeRef = { this._changeRef = {
detectChanges: () => undefined detectChanges: () => undefined