mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 01:25:38 -05:00
Strict null scripting (#12126)
* strict null scripting * fix compile * fix tests * fix icon
This commit is contained in:
@@ -31,7 +31,7 @@ export class ConnectionViewletPanel extends ViewPane {
|
||||
|
||||
public static readonly ID = 'dataExplorer.servers';
|
||||
|
||||
private _root: HTMLElement;
|
||||
private _root?: HTMLElement;
|
||||
private _serverTreeView: ServerTreeView;
|
||||
private _addServerAction: IAction;
|
||||
private _addServerGroupAction: IAction;
|
||||
@@ -89,7 +89,7 @@ export class ConnectionViewletPanel extends ViewPane {
|
||||
|
||||
layoutBody(size: number): void {
|
||||
this._serverTreeView.layout(size);
|
||||
DOM.toggleClass(this._root, 'narrow', this._root.clientWidth < 300);
|
||||
DOM.toggleClass(this._root!, 'narrow', this._root!.clientWidth < 300);
|
||||
}
|
||||
|
||||
show(): void {
|
||||
|
||||
@@ -87,9 +87,9 @@ export class DataExplorerViewlet extends Viewlet {
|
||||
}
|
||||
|
||||
export class DataExplorerViewPaneContainer extends ViewPaneContainer {
|
||||
private root: HTMLElement;
|
||||
private root?: HTMLElement;
|
||||
|
||||
private dataSourcesBox: HTMLElement;
|
||||
private dataSourcesBox?: HTMLElement;
|
||||
|
||||
constructor(
|
||||
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
|
||||
@@ -125,7 +125,7 @@ export class DataExplorerViewPaneContainer extends ViewPaneContainer {
|
||||
}
|
||||
|
||||
layout(dimension: Dimension): void {
|
||||
toggleClass(this.root, 'narrow', dimension.width <= 300);
|
||||
toggleClass(this.root!, 'narrow', dimension.width <= 300);
|
||||
super.layout(new Dimension(dimension.width, dimension.height));
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ export class DataExplorerViewPaneContainer extends ViewPaneContainer {
|
||||
|
||||
getSecondaryActions(): IAction[] {
|
||||
let menu = this.menuService.createMenu(MenuId.DataExplorerAction, this.contextKeyService);
|
||||
let actions = [];
|
||||
let actions: IAction[] = [];
|
||||
menu.getActions({}).forEach(group => {
|
||||
if (group[0] === 'secondary') {
|
||||
actions.push(...group[1]);
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { attachListStyler } from 'vs/platform/theme/common/styler';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { ISelectionEvent, ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
@@ -29,31 +29,30 @@ import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
|
||||
import { Button } from 'sql/base/browser/ui/button/button';
|
||||
import { attachButtonStyler } from 'sql/platform/theme/common/styler';
|
||||
import { TreeNode, TreeItemCollapsibleState } from 'sql/workbench/services/objectExplorer/common/treeNode';
|
||||
import { SERVER_GROUP_AUTOEXPAND_CONFIG } from 'sql/workbench/contrib/objectExplorer/common/serverGroup.contribution';
|
||||
import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService';
|
||||
import { ServerTreeActionProvider } from 'sql/workbench/services/objectExplorer/browser/serverTreeActionProvider';
|
||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||
import { isHidden } from 'sql/base/browser/dom';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { startsWith } from 'vs/base/common/strings';
|
||||
import { SERVER_GROUP_CONFIG } from 'sql/workbench/services/serverGroup/common/interfaces';
|
||||
import { horizontalScrollingKey } from 'vs/platform/list/browser/listService';
|
||||
import { ITreeContextMenuEvent } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ITreeContextMenuEvent, ITreeEvent } from 'vs/base/browser/ui/tree/tree';
|
||||
import { ObjectExplorerActionsContext } from 'sql/workbench/services/objectExplorer/browser/objectExplorerActions';
|
||||
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { AsyncServerTree, ServerTreeElement } from 'sql/workbench/services/objectExplorer/browser/asyncServerTree';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
|
||||
/**
|
||||
* ServerTreeview implements the dynamic tree view.
|
||||
*/
|
||||
export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
|
||||
public messages: HTMLElement;
|
||||
private _buttonSection: HTMLElement;
|
||||
public messages?: HTMLElement;
|
||||
private _buttonSection?: HTMLElement;
|
||||
private _treeSelectionHandler: TreeSelectionHandler;
|
||||
private _activeConnectionsFilterAction: ActiveConnectionsFilterAction;
|
||||
private _tree: ITree | AsyncServerTree;
|
||||
private _tree?: ITree | AsyncServerTree;
|
||||
private _onSelectionOrFocusChange: Emitter<void>;
|
||||
private _actionProvider: ServerTreeActionProvider;
|
||||
|
||||
@@ -81,7 +80,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
// Refresh the tree input now that the capabilities are registered so that we can
|
||||
// get the full ConnectionProfiles with the server info updated properly
|
||||
const treeInput = TreeUpdateUtils.getTreeInput(this._connectionManagementService);
|
||||
const treeInput = TreeUpdateUtils.getTreeInput(this._connectionManagementService)!;
|
||||
await this._tree.setInput(treeInput);
|
||||
this._treeSelectionHandler.onTreeActionStateChange(false);
|
||||
} else {
|
||||
@@ -113,7 +112,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
}
|
||||
|
||||
public get tree(): ITree | AsyncServerTree {
|
||||
return this._tree;
|
||||
return this._tree!;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,14 +158,14 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
|
||||
const horizontalScrollEnabled: boolean = this._configurationService.getValue(horizontalScrollingKey) || false;
|
||||
this._tree = this._register(TreeCreationUtils.createServersTree(container, this._instantiationService, this._configurationService, horizontalScrollEnabled));
|
||||
this._register(this._tree.onDidChangeSelection((event) => this.onSelected(event)));
|
||||
this._register(this._tree.onDidChangeSelection((event: ISelectionEvent | ITreeEvent<ServerTreeElement>) => this.onSelected(event)));
|
||||
this._register(this._tree.onDidBlur(() => this._onSelectionOrFocusChange.fire()));
|
||||
this._register(this._tree.onDidChangeFocus(() => this._onSelectionOrFocusChange.fire()));
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
this._register(this._tree.onContextMenu(e => this.onContextMenu(e)));
|
||||
this._register(this._tree.onMouseDblClick(e => {
|
||||
// Open dashboard on double click for server and database nodes
|
||||
let connectionProfile: ConnectionProfile;
|
||||
let connectionProfile: ConnectionProfile | undefined;
|
||||
if (e.element instanceof ConnectionProfile) {
|
||||
connectionProfile = e.element;
|
||||
} else if (e.element instanceof TreeNode) {
|
||||
@@ -212,16 +211,16 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
await this.refreshTree();
|
||||
const root = <ConnectionProfileGroup>this._tree.getInput();
|
||||
const root = <ConnectionProfileGroup>this._tree!.getInput();
|
||||
|
||||
const expandGroups: boolean = this._configurationService.getValue(SERVER_GROUP_CONFIG)[SERVER_GROUP_AUTOEXPAND_CONFIG];
|
||||
const expandGroups = this._configurationService.getValue<{ autoExpand: boolean }>(SERVER_GROUP_CONFIG).autoExpand;
|
||||
if (expandGroups) {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
await Promise.all(ConnectionProfileGroup.getSubgroups(root).map(subgroup => {
|
||||
return this._tree.expand(subgroup);
|
||||
return this._tree!.expand(subgroup);
|
||||
}));
|
||||
} else {
|
||||
await this._tree.expandAll(ConnectionProfileGroup.getSubgroups(root));
|
||||
await this._tree!.expandAll(ConnectionProfileGroup.getSubgroups(root));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -238,7 +237,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
public isObjectExplorerConnectionUri(uri: string): boolean {
|
||||
let isBackupRestoreUri: boolean = uri.indexOf(ConnectionUtils.ConnectionUriBackupIdAttributeName) >= 0 ||
|
||||
uri.indexOf(ConnectionUtils.ConnectionUriRestoreIdAttributeName) >= 0;
|
||||
return uri && startsWith(uri, ConnectionUtils.uriPrefixes.default) && !isBackupRestoreUri;
|
||||
return !!uri && uri.startsWith(ConnectionUtils.uriPrefixes.default) && !isBackupRestoreUri;
|
||||
}
|
||||
|
||||
private async handleAddConnectionProfile(newProfile?: IConnectionProfile): Promise<void> {
|
||||
@@ -277,16 +276,16 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
}
|
||||
}
|
||||
|
||||
const currentSelections = this._tree.getSelection();
|
||||
const currentSelections = this._tree!.getSelection();
|
||||
const currentSelectedElement = currentSelections && currentSelections.length >= 1 ? currentSelections[0] : undefined;
|
||||
const newProfileIsSelected = currentSelectedElement && newProfile ? currentSelectedElement.id === newProfile.id : false;
|
||||
if (newProfile && currentSelectedElement && !newProfileIsSelected) {
|
||||
this._tree.clearSelection();
|
||||
this._tree!.clearSelection();
|
||||
}
|
||||
await this.refreshTree();
|
||||
if (newProfile && !newProfileIsSelected) {
|
||||
await this._tree.reveal(newProfile);
|
||||
this._tree.select(newProfile);
|
||||
await this._tree!.reveal(newProfile);
|
||||
this._tree!.select(newProfile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,11 +303,11 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
*/
|
||||
private getConnectionInTreeInput(connectionId: string): ConnectionProfile | undefined {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
const root = this._tree.getInput();
|
||||
const root = this._tree.getInput()!;
|
||||
const connections = ConnectionProfileGroup.getConnectionsInGroup(root);
|
||||
return connections.find(conn => conn.id === connectionId);
|
||||
} else {
|
||||
const root = TreeUpdateUtils.getTreeInput(this._connectionManagementService);
|
||||
const root = TreeUpdateUtils.getTreeInput(this._connectionManagementService)!;
|
||||
const connections = ConnectionProfileGroup.getConnectionsInGroup(root);
|
||||
const results = connections.filter(con => {
|
||||
if (connectionId === con.id) {
|
||||
@@ -330,16 +329,16 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
this._tree.rerender(element);
|
||||
} else {
|
||||
await this._tree.refresh(element);
|
||||
await this._tree!.refresh(element);
|
||||
}
|
||||
await this._tree.expand(element);
|
||||
await this._tree.reveal(element, 0.5);
|
||||
await this._tree!.expand(element);
|
||||
await this._tree!.reveal(element, 0.5);
|
||||
this._treeSelectionHandler.onTreeActionStateChange(false);
|
||||
}
|
||||
}
|
||||
|
||||
public addObjectExplorerNodeAndRefreshTree(connection: IConnectionProfile): void {
|
||||
hide(this.messages);
|
||||
hide(this.messages!);
|
||||
if (!this._objectExplorerService.getObjectExplorerNode(connection)) {
|
||||
this._objectExplorerService.updateObjectExplorerNodes(connection).catch(e => errors.onUnexpectedError(e));
|
||||
}
|
||||
@@ -356,35 +355,35 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
this._tree.collapse(conn);
|
||||
await this.refreshTree();
|
||||
} else {
|
||||
await this._tree.collapse(conn);
|
||||
return this._tree.refresh(conn);
|
||||
await this._tree!.collapse(conn);
|
||||
return this._tree!.refresh(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async refreshTree(): Promise<void> {
|
||||
hide(this.messages);
|
||||
hide(this.messages!);
|
||||
this.clearOtherActions();
|
||||
return TreeUpdateUtils.registeredServerUpdate(this._tree, this._connectionManagementService);
|
||||
return TreeUpdateUtils.registeredServerUpdate(this._tree!, this._connectionManagementService);
|
||||
}
|
||||
|
||||
public async refreshElement(element: ServerTreeElement): Promise<void> {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
return this._tree.updateChildren(element);
|
||||
} else {
|
||||
return this._tree.refresh(element);
|
||||
return this._tree!.refresh(element);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter connections based on view (recent/active)
|
||||
*/
|
||||
private filterConnections(treeInput: ConnectionProfileGroup[], view: string): ConnectionProfileGroup[] {
|
||||
private filterConnections(treeInput: ConnectionProfileGroup[] | undefined, view: string): ConnectionProfileGroup[] | undefined {
|
||||
if (!treeInput || treeInput.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
const result = treeInput.map(group => {
|
||||
const result = coalesce(treeInput.map(group => {
|
||||
// Keep active/recent connections and remove the rest
|
||||
if (group.connections) {
|
||||
group.connections = group.connections.filter(con => {
|
||||
@@ -408,7 +407,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
return group;
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -416,35 +415,35 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
* Set tree elements based on the view (recent/active)
|
||||
*/
|
||||
public showFilteredTree(view: string): void {
|
||||
hide(this.messages);
|
||||
hide(this.messages!);
|
||||
// Clear other action views if user switched between two views
|
||||
this.clearOtherActions(view);
|
||||
const root = TreeUpdateUtils.getTreeInput(this._connectionManagementService);
|
||||
let treeInput: ConnectionProfileGroup = null;
|
||||
let treeInput: ConnectionProfileGroup | undefined = undefined;
|
||||
if (root) {
|
||||
// Filter results based on view
|
||||
const filteredResults = this.filterConnections([root], view);
|
||||
if (!filteredResults || !filteredResults[0]) {
|
||||
show(this.messages);
|
||||
this.messages.focus();
|
||||
show(this.messages!);
|
||||
this.messages!.focus();
|
||||
} else {
|
||||
treeInput = filteredResults[0];
|
||||
}
|
||||
this._tree.setInput(treeInput).then(async () => {
|
||||
if (isHidden(this.messages)) {
|
||||
this._tree.getFocus();
|
||||
this._tree!.setInput(treeInput!).then(async () => {
|
||||
if (isHidden(this.messages!)) {
|
||||
this._tree!.getFocus();
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
await Promise.all(ConnectionProfileGroup.getSubgroups(treeInput).map(subgroup => {
|
||||
this._tree.expand(subgroup);
|
||||
await Promise.all(ConnectionProfileGroup.getSubgroups(treeInput!).map(subgroup => {
|
||||
this._tree!.expand(subgroup);
|
||||
}));
|
||||
} else {
|
||||
await this._tree.expandAll(ConnectionProfileGroup.getSubgroups(treeInput));
|
||||
await this._tree!.expandAll(ConnectionProfileGroup.getSubgroups(treeInput!));
|
||||
}
|
||||
} else {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
this._tree.setFocus([]);
|
||||
} else {
|
||||
this._tree.clearFocus();
|
||||
this._tree!.clearFocus();
|
||||
}
|
||||
}
|
||||
}, errors.onUnexpectedError);
|
||||
@@ -460,33 +459,33 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (!searchString) {
|
||||
return;
|
||||
}
|
||||
hide(this.messages);
|
||||
hide(this.messages!);
|
||||
// Clear other actions if user searched during other views
|
||||
this.clearOtherActions();
|
||||
// Filter connections based on search
|
||||
const filteredResults = this.searchConnections(searchString);
|
||||
if (!filteredResults || filteredResults.length === 0) {
|
||||
show(this.messages);
|
||||
this.messages.focus();
|
||||
show(this.messages!);
|
||||
this.messages!.focus();
|
||||
}
|
||||
// Add all connections to tree root and set tree input
|
||||
const treeInput = new ConnectionProfileGroup('searchroot', undefined, 'searchroot', undefined, undefined);
|
||||
treeInput.addConnections(filteredResults);
|
||||
this._tree.setInput(treeInput).then(async () => {
|
||||
if (isHidden(this.messages)) {
|
||||
this._tree.getFocus();
|
||||
this._tree!.setInput(treeInput).then(async () => {
|
||||
if (isHidden(this.messages!)) {
|
||||
this._tree!.getFocus();
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
await Promise.all(ConnectionProfileGroup.getSubgroups(treeInput).map(subgroup => {
|
||||
this._tree.expand(subgroup);
|
||||
this._tree!.expand(subgroup);
|
||||
}));
|
||||
} else {
|
||||
await this._tree.expandAll(ConnectionProfileGroup.getSubgroups(treeInput));
|
||||
await this._tree!.expandAll(ConnectionProfileGroup.getSubgroups(treeInput));
|
||||
}
|
||||
} else {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
this._tree.setFocus([]);
|
||||
} else {
|
||||
this._tree.clearFocus();
|
||||
this._tree!.clearFocus();
|
||||
}
|
||||
}
|
||||
}, errors.onUnexpectedError);
|
||||
@@ -497,7 +496,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
*/
|
||||
private searchConnections(searchString: string): ConnectionProfile[] {
|
||||
|
||||
const root = TreeUpdateUtils.getTreeInput(this._connectionManagementService);
|
||||
const root = TreeUpdateUtils.getTreeInput(this._connectionManagementService)!;
|
||||
const connections = ConnectionProfileGroup.getConnectionsInGroup(root);
|
||||
const results = connections.filter(con => {
|
||||
if (searchString && (searchString.length > 0)) {
|
||||
@@ -542,7 +541,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
}
|
||||
|
||||
private onSelected(event: any): void {
|
||||
this._treeSelectionHandler.onTreeSelect(event, this._tree, this._connectionManagementService, this._objectExplorerService, () => this._onSelectionOrFocusChange.fire());
|
||||
this._treeSelectionHandler.onTreeSelect(event, this._tree!, this._connectionManagementService, this._objectExplorerService, () => this._onSelectionOrFocusChange.fire());
|
||||
this._onSelectionOrFocusChange.fire();
|
||||
}
|
||||
|
||||
@@ -550,21 +549,21 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
* set the layout of the view
|
||||
*/
|
||||
public layout(height: number): void {
|
||||
this._tree.layout(height);
|
||||
this._tree!.layout(height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of selected nodes in the tree
|
||||
*/
|
||||
public getSelection(): any[] {
|
||||
return this._tree.getSelection();
|
||||
return this._tree!.getSelection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the tree view currently has focus
|
||||
*/
|
||||
public isFocused(): boolean {
|
||||
return this._tree.getHTMLElement() === document.activeElement;
|
||||
return this._tree!.getHTMLElement() === document.activeElement;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -572,9 +571,9 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
*/
|
||||
public async setExpandedState(element: ServerTreeElement, expandedState?: TreeItemCollapsibleState): Promise<void> {
|
||||
if (expandedState === TreeItemCollapsibleState.Collapsed) {
|
||||
return this._tree.collapse(element);
|
||||
return this._tree!.collapse(element);
|
||||
} else if (expandedState === TreeItemCollapsibleState.Expanded) {
|
||||
return this._tree.expand(element);
|
||||
return this._tree!.expand(element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,7 +581,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
* Reveal the given element in the tree
|
||||
*/
|
||||
public async reveal(element: ServerTreeElement): Promise<void> {
|
||||
return this._tree.reveal(element);
|
||||
return this._tree!.reveal(element);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -593,7 +592,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
this._tree.setSelection([]);
|
||||
} else {
|
||||
this._tree.clearSelection();
|
||||
this._tree!.clearSelection();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -602,14 +601,14 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
this._tree.setSelection(this._tree.getSelection().concat(element));
|
||||
this._tree.reveal(element);
|
||||
} else {
|
||||
this._tree.select(element);
|
||||
return this._tree.reveal(element);
|
||||
this._tree!.select(element);
|
||||
return this._tree!.reveal(element);
|
||||
}
|
||||
} else {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
this._tree.setSelection(this._tree.getSelection().filter(item => item !== element));
|
||||
} else {
|
||||
this._tree.deselect(element);
|
||||
this._tree!.deselect(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -621,7 +620,7 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
if (this._tree instanceof AsyncServerTree) {
|
||||
return !this._tree.getNode(element).collapsed;
|
||||
} else {
|
||||
return this._tree.isExpanded(element);
|
||||
return this._tree!.isExpanded(element);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -630,42 +629,45 @@ export class ServerTreeView extends Disposable implements IServerTreeView {
|
||||
* Return actions in the context menu
|
||||
*/
|
||||
private onContextMenu(e: ITreeContextMenuEvent<ServerTreeElement>): boolean {
|
||||
e.browserEvent.preventDefault();
|
||||
e.browserEvent.stopPropagation();
|
||||
this._tree.setSelection([e.element]);
|
||||
if (e.element) {
|
||||
e.browserEvent.preventDefault();
|
||||
e.browserEvent.stopPropagation();
|
||||
this._tree!.setSelection([e.element]);
|
||||
|
||||
let actionContext: any;
|
||||
if (e.element instanceof TreeNode) {
|
||||
let context = new ObjectExplorerActionsContext();
|
||||
context.nodeInfo = e.element.toNodeInfo();
|
||||
// Note: getting DB name before, but intentionally not using treeUpdateUtils.getConnectionProfile as it replaces
|
||||
// the connection ID with a new one. This breaks a number of internal tasks
|
||||
context.connectionProfile = e.element.getConnectionProfile().toIConnectionProfile();
|
||||
context.connectionProfile.databaseName = e.element.getDatabaseName();
|
||||
actionContext = context;
|
||||
} else if (e.element instanceof ConnectionProfile) {
|
||||
let context = new ObjectExplorerActionsContext();
|
||||
context.connectionProfile = e.element.toIConnectionProfile();
|
||||
context.isConnectionNode = true;
|
||||
actionContext = context;
|
||||
} else {
|
||||
// TODO: because the connection group is used as a context object and isn't serializable,
|
||||
// the Group-level context menu is not currently extensible
|
||||
actionContext = e.element;
|
||||
let actionContext: any;
|
||||
if (e.element instanceof TreeNode) {
|
||||
let context = new ObjectExplorerActionsContext();
|
||||
context.nodeInfo = e.element.toNodeInfo();
|
||||
// Note: getting DB name before, but intentionally not using treeUpdateUtils.getConnectionProfile as it replaces
|
||||
// the connection ID with a new one. This breaks a number of internal tasks
|
||||
context.connectionProfile = e.element.getConnectionProfile()!.toIConnectionProfile();
|
||||
context.connectionProfile.databaseName = e.element.getDatabaseName();
|
||||
actionContext = context;
|
||||
} else if (e.element instanceof ConnectionProfile) {
|
||||
let context = new ObjectExplorerActionsContext();
|
||||
context.connectionProfile = e.element.toIConnectionProfile();
|
||||
context.isConnectionNode = true;
|
||||
actionContext = context;
|
||||
} else {
|
||||
// TODO: because the connection group is used as a context object and isn't serializable,
|
||||
// the Group-level context menu is not currently extensible
|
||||
actionContext = e.element;
|
||||
}
|
||||
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => e.anchor,
|
||||
getActions: () => this._actionProvider.getActions(this._tree!, e.element!),
|
||||
getKeyBinding: (action) => this._keybindingService.lookupKeybinding(action.id),
|
||||
onHide: (wasCancelled?: boolean) => {
|
||||
if (wasCancelled) {
|
||||
this._tree!.domFocus();
|
||||
}
|
||||
},
|
||||
getActionsContext: () => (actionContext)
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
this._contextMenuService.showContextMenu({
|
||||
getAnchor: () => e.anchor,
|
||||
getActions: () => this._actionProvider.getActions(this._tree, e.element),
|
||||
getKeyBinding: (action) => this._keybindingService.lookupKeybinding(action.id),
|
||||
onHide: (wasCancelled?: boolean) => {
|
||||
if (wasCancelled) {
|
||||
this._tree.domFocus();
|
||||
}
|
||||
},
|
||||
getActionsContext: () => (actionContext)
|
||||
});
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,130 +40,148 @@ export const EDIT_DATA_COMMAND_ID = 'dataExplorer.scriptAsEdit';
|
||||
// Script as Create
|
||||
CommandsRegistry.registerCommand({
|
||||
id: SCRIPT_AS_CREATE_COMMAND_ID,
|
||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||
};
|
||||
const scriptCreateAction = new ScriptCreateAction(ScriptCreateAction.ID, ScriptCreateAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptCreateAction.run(baseContext));
|
||||
handler: async (accessor, args: TreeViewItemHandleArg): Promise<boolean | undefined> => {
|
||||
if (args.$treeItem?.payload) {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem)!.metadata
|
||||
};
|
||||
const scriptCreateAction = new ScriptCreateAction(ScriptCreateAction.ID, ScriptCreateAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptCreateAction.run(baseContext));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Script as Delete
|
||||
CommandsRegistry.registerCommand({
|
||||
id: SCRIPT_AS_DELETE_COMMAND_ID,
|
||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||
};
|
||||
const scriptDeleteAction = new ScriptDeleteAction(ScriptDeleteAction.ID, ScriptDeleteAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptDeleteAction.run(baseContext));
|
||||
handler: async (accessor, args: TreeViewItemHandleArg): Promise<boolean | undefined> => {
|
||||
if (args.$treeItem?.payload) {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem)!.metadata
|
||||
};
|
||||
const scriptDeleteAction = new ScriptDeleteAction(ScriptDeleteAction.ID, ScriptDeleteAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptDeleteAction.run(baseContext));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Script as Select
|
||||
CommandsRegistry.registerCommand({
|
||||
id: SCRIPT_AS_SELECT_COMMAND_ID,
|
||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||
};
|
||||
const scriptSelectAction = new ScriptSelectAction(ScriptSelectAction.ID, ScriptSelectAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptSelectAction.run(baseContext));
|
||||
handler: async (accessor, args: TreeViewItemHandleArg): Promise<boolean | undefined> => {
|
||||
if (args.$treeItem?.payload) {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem)!.metadata
|
||||
};
|
||||
const scriptSelectAction = new ScriptSelectAction(ScriptSelectAction.ID, ScriptSelectAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptSelectAction.run(baseContext));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Script as Execute
|
||||
CommandsRegistry.registerCommand({
|
||||
id: SCRIPT_AS_EXECUTE_COMMAND_ID,
|
||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||
};
|
||||
const scriptExecuteAction = new ScriptExecuteAction(ScriptExecuteAction.ID, ScriptExecuteAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptExecuteAction.run(baseContext));
|
||||
handler: async (accessor, args: TreeViewItemHandleArg): Promise<boolean | undefined> => {
|
||||
if (args.$treeItem?.payload) {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem)!.metadata
|
||||
};
|
||||
const scriptExecuteAction = new ScriptExecuteAction(ScriptExecuteAction.ID, ScriptExecuteAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptExecuteAction.run(baseContext));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Script as Alter
|
||||
CommandsRegistry.registerCommand({
|
||||
id: SCRIPT_AS_ALTER_COMMAND_ID,
|
||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||
};
|
||||
const scriptAlterAction = new ScriptAlterAction(ScriptAlterAction.ID, ScriptAlterAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptAlterAction.run(baseContext));
|
||||
handler: async (accessor, args: TreeViewItemHandleArg): Promise<boolean | undefined> => {
|
||||
if (args.$treeItem?.payload) {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const errorMessageService = accessor.get(IErrorMessageService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem)!.metadata
|
||||
};
|
||||
const scriptAlterAction = new ScriptAlterAction(ScriptAlterAction.ID, ScriptAlterAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService, errorMessageService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => scriptAlterAction.run(baseContext));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// Edit Data
|
||||
CommandsRegistry.registerCommand({
|
||||
id: EDIT_DATA_COMMAND_ID,
|
||||
handler: async (accessor, args: TreeViewItemHandleArg) => {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem).metadata
|
||||
};
|
||||
const editDataAction = new EditDataAction(EditDataAction.ID, EditDataAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => editDataAction.run(baseContext));
|
||||
handler: async (accessor, args: TreeViewItemHandleArg): Promise<boolean | undefined> => {
|
||||
if (args.$treeItem?.payload) {
|
||||
const capabilitiesService = accessor.get(ICapabilitiesService);
|
||||
const oeShimService = accessor.get(IOEShimService);
|
||||
const queryEditorService = accessor.get(IQueryEditorService);
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const scriptingService = accessor.get(IScriptingService);
|
||||
const progressService = accessor.get(IProgressService);
|
||||
const profile = new ConnectionProfile(capabilitiesService, args.$treeItem.payload);
|
||||
const baseContext: BaseActionContext = {
|
||||
profile: profile,
|
||||
object: oeShimService.getNodeInfoForTreeItem(args.$treeItem)!.metadata
|
||||
};
|
||||
const editDataAction = new EditDataAction(EditDataAction.ID, EditDataAction.LABEL,
|
||||
queryEditorService, connectionManagementService, scriptingService);
|
||||
return progressService.withProgress({ location: VIEWLET_ID }, () => editDataAction.run(baseContext));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
//#endregion
|
||||
@@ -186,9 +204,9 @@ CommandsRegistry.registerCommand({
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||
const selectionHandler = instantiationService.createInstance(TreeSelectionHandler);
|
||||
const node = await getTreeNode(args, objectExplorerService);
|
||||
const node = (await getTreeNode(args, objectExplorerService))!;
|
||||
selectionHandler.onTreeActionStateChange(true);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node)!;
|
||||
let ownerUri = connectionManagementService.getConnectionUri(connectionProfile);
|
||||
ownerUri = connectionManagementService.getFormattedUri(ownerUri, connectionProfile);
|
||||
let metadata = node.metadata;
|
||||
@@ -207,7 +225,7 @@ CommandsRegistry.registerCommand({
|
||||
const instantiationService = accessor.get(IInstantiationService);
|
||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||
const selectionHandler = instantiationService.createInstance(TreeSelectionHandler);
|
||||
const node = await getTreeNode(args, objectExplorerService);
|
||||
const node = (await getTreeNode(args, objectExplorerService))!;
|
||||
selectionHandler.onTreeActionStateChange(true);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node);
|
||||
let metadata = node.metadata;
|
||||
@@ -227,9 +245,9 @@ CommandsRegistry.registerCommand({
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||
const selectionHandler = instantiationService.createInstance(TreeSelectionHandler);
|
||||
const node = await getTreeNode(args, objectExplorerService);
|
||||
const node = (await getTreeNode(args, objectExplorerService))!;
|
||||
selectionHandler.onTreeActionStateChange(true);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node)!;
|
||||
let metadata = node.metadata;
|
||||
let ownerUri = connectionManagementService.getConnectionUri(connectionProfile);
|
||||
ownerUri = connectionManagementService.getFormattedUri(ownerUri, connectionProfile);
|
||||
@@ -249,9 +267,9 @@ CommandsRegistry.registerCommand({
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||
const selectionHandler = instantiationService.createInstance(TreeSelectionHandler);
|
||||
const node = await getTreeNode(args, objectExplorerService);
|
||||
const node = (await getTreeNode(args, objectExplorerService))!;
|
||||
selectionHandler.onTreeActionStateChange(true);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node)!;
|
||||
let metadata = node.metadata;
|
||||
let ownerUri = connectionManagementService.getConnectionUri(connectionProfile);
|
||||
ownerUri = connectionManagementService.getFormattedUri(ownerUri, connectionProfile);
|
||||
@@ -271,9 +289,9 @@ CommandsRegistry.registerCommand({
|
||||
const connectionManagementService = accessor.get(IConnectionManagementService);
|
||||
const objectExplorerService = accessor.get(IObjectExplorerService);
|
||||
const selectionHandler = instantiationService.createInstance(TreeSelectionHandler);
|
||||
const node = await getTreeNode(args, objectExplorerService);
|
||||
const node = (await getTreeNode(args, objectExplorerService))!;
|
||||
selectionHandler.onTreeActionStateChange(true);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node);
|
||||
let connectionProfile = TreeUpdateUtils.getConnectionProfile(node)!;
|
||||
let metadata = node.metadata;
|
||||
let ownerUri = connectionManagementService.getConnectionUri(connectionProfile);
|
||||
ownerUri = connectionManagementService.getFormattedUri(ownerUri, connectionProfile);
|
||||
@@ -297,8 +315,8 @@ CommandsRegistry.registerCommand({
|
||||
//set objectExplorerTreeNode for context menu clicks
|
||||
const node = await getTreeNode(args, objectExplorerService);
|
||||
selectionHandler.onTreeActionStateChange(true);
|
||||
const connectionProfile = TreeUpdateUtils.getConnectionProfile(<TreeNode>node);
|
||||
const metadata = node.metadata;
|
||||
const connectionProfile = TreeUpdateUtils.getConnectionProfile(<TreeNode>node)!;
|
||||
const metadata = node!.metadata;
|
||||
let ownerUri = connectionManagementService.getConnectionUri(connectionProfile);
|
||||
ownerUri = connectionManagementService.getFormattedUri(ownerUri, connectionProfile);
|
||||
|
||||
@@ -320,9 +338,9 @@ export async function handleOeRefreshCommand(accessor: ServicesAccessor, args: O
|
||||
const logService = accessor.get(ILogService);
|
||||
const notificationService = accessor.get(INotificationService);
|
||||
const treeNode = await getTreeNode(args, objectExplorerService);
|
||||
const tree = objectExplorerService.getServerTreeView().tree;
|
||||
const tree = objectExplorerService.getServerTreeView()!.tree;
|
||||
try {
|
||||
await objectExplorerService.refreshTreeNode(treeNode.getSession(), treeNode);
|
||||
await objectExplorerService.refreshTreeNode(treeNode!.getSession()!, treeNode!);
|
||||
if (tree instanceof AsyncServerTree) {
|
||||
await tree.updateChildren(treeNode);
|
||||
} else {
|
||||
@@ -330,7 +348,7 @@ export async function handleOeRefreshCommand(accessor: ServicesAccessor, args: O
|
||||
}
|
||||
} catch (err) {
|
||||
// Display message to the user but also log the entire error to the console for the stack trace
|
||||
notificationService.error(localize('refreshError', "An error occurred refreshing node '{0}': {1}", args.nodeInfo.label, getErrorMessage(err)));
|
||||
notificationService.error(localize('refreshError', "An error occurred refreshing node '{0}': {1}", args.nodeInfo?.label, getErrorMessage(err)));
|
||||
logService.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType'
|
||||
import { ServerTreeView } from 'sql/workbench/contrib/objectExplorer/browser/serverTreeView';
|
||||
import { createObjectExplorerServiceMock } from 'sql/workbench/services/objectExplorer/test/browser/testObjectExplorerService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ITree } from 'vs/base/parts/tree/browser/tree';
|
||||
import { TestTree } from 'sql/workbench/test/treeMock';
|
||||
import { TestConnectionManagementService } from 'sql/platform/connection/test/common/testConnectionManagementService';
|
||||
|
||||
@@ -56,7 +55,7 @@ const oeActionArgs: ObjectExplorerActionsContext = { connectionProfile: connecti
|
||||
|
||||
let instantiationService: IInstantiationService;
|
||||
let logServiceMock: TypeMoq.Mock<ILogService>;
|
||||
let treeMock: TypeMoq.Mock<ITree>;
|
||||
let treeMock: TypeMoq.Mock<TestTree>;
|
||||
|
||||
suite('Scripting Actions', () => {
|
||||
|
||||
@@ -68,7 +67,7 @@ suite('Scripting Actions', () => {
|
||||
const serverTreeViewMock = TypeMoq.Mock.ofType(ServerTreeView, TypeMoq.MockBehavior.Loose, connectionManagementServiceMock.object, instantiationService, undefined, undefined, undefined, undefined, capabilitiesService);
|
||||
treeMock = TypeMoq.Mock.ofType(TestTree);
|
||||
serverTreeViewMock.setup(x => x.tree).returns(() => treeMock.object);
|
||||
collection.set(IObjectExplorerService, createObjectExplorerServiceMock({ serverTreeView: serverTreeViewMock.object, treeNode: treeNode }).object);
|
||||
collection.set(IObjectExplorerService, createObjectExplorerServiceMock({ serverTreeView: serverTreeViewMock.object, treeNode: treeNode }));
|
||||
logServiceMock = TypeMoq.Mock.ofInstance(new NullLogService());
|
||||
collection.set(ILogService, logServiceMock.object);
|
||||
collection.set(INotificationService, new TestNotificationService());
|
||||
|
||||
Reference in New Issue
Block a user