mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 09:35:40 -05:00
remove special case (#16779)
This commit is contained in:
@@ -26,8 +26,7 @@ import {
|
||||
} from 'sql/platform/connection/common/connectionManagement';
|
||||
import { QueryEditor } from 'sql/workbench/contrib/query/browser/queryEditor';
|
||||
import { IQueryModelService } from 'sql/workbench/services/query/common/queryModel';
|
||||
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
|
||||
import { attachEditableDropdownStyler, attachSelectBoxStyler } from 'sql/platform/theme/common/styler';
|
||||
import { attachEditableDropdownStyler } from 'sql/platform/theme/common/styler';
|
||||
import { Dropdown } from 'sql/base/parts/editableDropdown/browser/dropdown';
|
||||
import { Task } from 'sql/workbench/services/tasks/browser/tasksRegistry';
|
||||
import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerService';
|
||||
@@ -578,8 +577,6 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
private _isConnected: boolean;
|
||||
private _databaseListDropdown: HTMLElement;
|
||||
private _dropdown: Dropdown;
|
||||
private _databaseSelectBox: SelectBox;
|
||||
private _isInAccessibilityMode: boolean;
|
||||
private readonly _selectDatabaseString: string = nls.localize("selectDatabase", "Select Database");
|
||||
|
||||
// CONSTRUCTOR /////////////////////////////////////////////////////////
|
||||
@@ -588,30 +585,17 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
@IContextViewService contextViewProvider: IContextViewService,
|
||||
@IConnectionManagementService private readonly connectionManagementService: IConnectionManagementService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@ILogService private readonly logService: ILogService
|
||||
) {
|
||||
super();
|
||||
this._databaseListDropdown = $('.databaseListDropdown');
|
||||
this._isInAccessibilityMode = this.configurationService.getValue('editor.accessibilitySupport') === 'on';
|
||||
|
||||
if (this._isInAccessibilityMode) {
|
||||
this._databaseSelectBox = new SelectBox([this._selectDatabaseString], this._selectDatabaseString, contextViewProvider, undefined, { ariaLabel: this._selectDatabaseString });
|
||||
this._databaseSelectBox.render(this._databaseListDropdown);
|
||||
this._databaseSelectBox.onDidSelect(e => { this.databaseSelected(e.selected); });
|
||||
this._databaseSelectBox.disable();
|
||||
|
||||
} else {
|
||||
this._dropdown = new Dropdown(this._databaseListDropdown, contextViewProvider, {
|
||||
strictSelection: true,
|
||||
placeholder: this._selectDatabaseString,
|
||||
ariaLabel: this._selectDatabaseString
|
||||
});
|
||||
this._register(this._dropdown.onValueChange(s => this.databaseSelected(s)));
|
||||
this._register(this._dropdown.onFocus(() => this.onDropdownFocus()));
|
||||
}
|
||||
|
||||
// Register event handlers
|
||||
this._dropdown = new Dropdown(this._databaseListDropdown, contextViewProvider, {
|
||||
strictSelection: true,
|
||||
placeholder: this._selectDatabaseString,
|
||||
ariaLabel: this._selectDatabaseString
|
||||
});
|
||||
this._register(this._dropdown.onValueChange(s => this.databaseSelected(s)));
|
||||
this._register(this._dropdown.onFocus(() => this.onDropdownFocus()));
|
||||
this._register(this.connectionManagementService.onConnectionChanged(params => this.onConnectionChanged(params)));
|
||||
}
|
||||
|
||||
@@ -621,12 +605,7 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
}
|
||||
|
||||
public style(styles) {
|
||||
if (this._isInAccessibilityMode) {
|
||||
this._databaseSelectBox.style(styles);
|
||||
}
|
||||
else {
|
||||
this._dropdown.style(styles);
|
||||
}
|
||||
this._dropdown.style(styles);
|
||||
}
|
||||
|
||||
public setActionContext(context: any): void {
|
||||
@@ -637,27 +616,15 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
if (this._isInAccessibilityMode) {
|
||||
this._databaseSelectBox.focus();
|
||||
} else {
|
||||
this._dropdown.focus();
|
||||
}
|
||||
this._dropdown.focus();
|
||||
}
|
||||
|
||||
public blur(): void {
|
||||
if (this._isInAccessibilityMode) {
|
||||
this._databaseSelectBox.blur();
|
||||
} else {
|
||||
this._dropdown.blur();
|
||||
}
|
||||
this._dropdown.blur();
|
||||
}
|
||||
|
||||
public attachStyler(themeService: IThemeService): IDisposable {
|
||||
if (this._isInAccessibilityMode) {
|
||||
return attachSelectBoxStyler(this, themeService);
|
||||
} else {
|
||||
return attachEditableDropdownStyler(this, themeService);
|
||||
}
|
||||
return attachEditableDropdownStyler(this, themeService);
|
||||
}
|
||||
|
||||
// EVENT HANDLERS FROM EDITOR //////////////////////////////////////////
|
||||
@@ -670,13 +637,8 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
this._isConnected = false;
|
||||
this._currentDatabaseName = undefined;
|
||||
|
||||
if (this._isInAccessibilityMode) {
|
||||
this._databaseSelectBox.disable();
|
||||
this._databaseSelectBox.setOptions([this._selectDatabaseString]);
|
||||
} else {
|
||||
this._dropdown.enabled = false;
|
||||
this._dropdown.value = '';
|
||||
}
|
||||
this._dropdown.enabled = false;
|
||||
this._dropdown.value = '';
|
||||
}
|
||||
|
||||
// PRIVATE HELPERS /////////////////////////////////////////////////////
|
||||
@@ -768,11 +730,7 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
}
|
||||
|
||||
private resetDatabaseName() {
|
||||
if (this._isInAccessibilityMode) {
|
||||
this._databaseSelectBox.selectWithOptionName(this.getCurrentDatabaseName());
|
||||
} else {
|
||||
this._dropdown.value = this.getCurrentDatabaseName();
|
||||
}
|
||||
this._dropdown.value = this.getCurrentDatabaseName();
|
||||
}
|
||||
|
||||
private onConnectionChanged(connParams: IConnectionParams): void {
|
||||
@@ -825,24 +783,15 @@ export class ListDatabasesActionItem extends Disposable implements IActionViewIt
|
||||
private updateConnection(databaseName: string): void {
|
||||
this._isConnected = true;
|
||||
this._currentDatabaseName = databaseName;
|
||||
|
||||
if (this._isInAccessibilityMode) {
|
||||
this.getDatabaseNames()
|
||||
.then(databaseNames => {
|
||||
this._databaseSelectBox.setOptions(databaseNames);
|
||||
this._databaseSelectBox.selectWithOptionName(databaseName);
|
||||
}).catch(onUnexpectedError);
|
||||
} else {
|
||||
// Set the value immediately to the initial database so the user can see that, and then
|
||||
// populate the list with just that value to avoid displaying an error while we load
|
||||
// the full list of databases
|
||||
this._dropdown.value = databaseName;
|
||||
this._dropdown.values = [databaseName];
|
||||
this._dropdown.enabled = true;
|
||||
this.getDatabaseNames().then(databaseNames => {
|
||||
this._dropdown.values = databaseNames;
|
||||
}).catch(onUnexpectedError);
|
||||
}
|
||||
// Set the value immediately to the initial database so the user can see that, and then
|
||||
// populate the list with just that value to avoid displaying an error while we load
|
||||
// the full list of databases
|
||||
this._dropdown.value = databaseName;
|
||||
this._dropdown.values = [databaseName];
|
||||
this._dropdown.enabled = true;
|
||||
this.getDatabaseNames().then(databaseNames => {
|
||||
this._dropdown.values = databaseNames;
|
||||
}).catch(onUnexpectedError);
|
||||
}
|
||||
|
||||
// TESTING PROPERTIES //////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user