diff --git a/src/sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution.ts b/src/sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution.ts index be58acff53..ad594249e6 100644 --- a/src/sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution.ts +++ b/src/sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution.ts @@ -5,11 +5,13 @@ import { IConfigurationRegistry, Extensions, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry'; import { Registry } from 'vs/platform/registry/common/platform'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; +import { localize } from 'vs/nls'; const configurationRegistry = Registry.as(Extensions.Configuration); export const SERVER_GROUP_CONFIG = 'serverGroup'; export const SERVER_GROUP_COLORS_CONFIG = 'colors'; +export const SERVER_GROUP_AUTOEXPAND_CONFIG = 'autoExpand'; const serverGroupConfig: IConfigurationNode = { id: 'Server Groups', @@ -18,6 +20,7 @@ const serverGroupConfig: IConfigurationNode = { [SERVER_GROUP_CONFIG + '.' + SERVER_GROUP_COLORS_CONFIG]: { type: 'array', items: 'string', + 'description': localize('serverGroup.colors', 'Server Group color palette used in the Object Explorer viewlet.'), default: [ '#A1634D', '#7F0000', @@ -28,7 +31,12 @@ const serverGroupConfig: IConfigurationNode = { '#6A6599', '#515151' ] - } + }, + [SERVER_GROUP_CONFIG + '.' + SERVER_GROUP_AUTOEXPAND_CONFIG]: { + 'type': 'boolean', + 'description': localize('serverGroup.autoExpand', 'Auto-expand Server Groups in the Object Explorer viewlet.'), + 'default': 'true' + }, } }; diff --git a/src/sql/parts/objectExplorer/viewlet/serverTreeController.ts b/src/sql/parts/objectExplorer/viewlet/serverTreeController.ts index 82797aa3f7..4ea1db04ab 100644 --- a/src/sql/parts/objectExplorer/viewlet/serverTreeController.ts +++ b/src/sql/parts/objectExplorer/viewlet/serverTreeController.ts @@ -17,6 +17,7 @@ import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile import { ServerTreeActionProvider } from 'sql/parts/objectExplorer/viewlet/serverTreeActionProvider'; import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions'; import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode'; +import { OpenMode } from 'vs/base/parts/tree/browser/treeDefaults'; /** * Extends the tree controller to handle clicks on the tree elements @@ -29,7 +30,10 @@ export class ServerTreeController extends treedefaults.DefaultController { @ITelemetryService private telemetryService: ITelemetryService, @IKeybindingService private keybindingService: IKeybindingService ) { - super({ clickBehavior: treedefaults.ClickBehavior.ON_MOUSE_DOWN }); + super({ + clickBehavior: treedefaults.ClickBehavior.ON_MOUSE_DOWN, + openMode: OpenMode.SINGLE_CLICK + }); } public onClick(tree: ITree, element: any, event: IMouseEvent): boolean { diff --git a/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts b/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts index a6f2d36e23..0b1391997b 100644 --- a/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts +++ b/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts @@ -29,6 +29,8 @@ import { Button } from 'sql/base/browser/ui/button/button'; import { attachButtonStyler } from 'sql/common/theme/styler'; import Event, { Emitter } from 'vs/base/common/event'; import { TreeNode, TreeItemCollapsibleState } from 'sql/parts/objectExplorer/common/treeNode'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { SERVER_GROUP_CONFIG, SERVER_GROUP_AUTOEXPAND_CONFIG } from 'sql/parts/objectExplorer/serverGroupDialog/serverGroup.contribution'; const $ = builder.$; @@ -52,6 +54,7 @@ export class ServerTreeView { @IThemeService private _themeService: IThemeService, @IErrorMessageService private _errorMessageService: IErrorMessageService, @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, + @IConfigurationService private _configurationService: IConfigurationService ) { this._activeConnectionsFilterAction = this._instantiationService.createInstance( ActiveConnectionsFilterAction, @@ -109,12 +112,10 @@ export class ServerTreeView { // Refresh Tree when these events are emitted this._toDispose.push(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => { self.handleAddConnectionProfile(newProfile); - }) - ); + })); this._toDispose.push(this._connectionManagementService.onDeleteConnectionProfile(() => { self.refreshTree(); - }) - ); + })); this._toDispose.push(this._connectionManagementService.onDisconnect((connectionParams) => { if (self.isObjectExplorerConnectionUri(connectionParams.connectionUri)) { self.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile); @@ -124,7 +125,7 @@ export class ServerTreeView { if (this._objectExplorerService && this._objectExplorerService.onUpdateObjectExplorerNodes) { this._toDispose.push(this._objectExplorerService.onUpdateObjectExplorerNodes(args => { if (args.errorMessage) { - this.showError(args.errorMessage); + self.showError(args.errorMessage); } if (args.connection) { self.onObjectExplorerSessionCreated(args.connection); @@ -133,9 +134,15 @@ export class ServerTreeView { } return new Promise((resolve, reject) => { self.refreshTree(); - let root = this._tree.getInput(); + let root = self._tree.getInput(); + + let expandGroups: boolean = self._configurationService.getValue(SERVER_GROUP_CONFIG)[SERVER_GROUP_AUTOEXPAND_CONFIG]; + if (expandGroups) { + self._tree.expandAll(ConnectionProfileGroup.getSubgroups(root)); + } + if (root && !root.hasValidConnections) { - this._treeSelectionHandler.onTreeActionStateChange(true); + self._treeSelectionHandler.onTreeActionStateChange(true); resolve(); } else { resolve(); diff --git a/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts b/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts index b4a0f00650..dc34f6213a 100644 --- a/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts +++ b/src/sqltest/parts/registeredServer/viewlet/serverTreeView.test.ts @@ -24,7 +24,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => { let instantiationService = new TestInstantiationService(); let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}); mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []); - serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined); + serverTreeView = new ServerTreeView(mockConnectionManagementService.object, instantiationService, undefined, undefined, undefined, undefined, undefined); let tree = { clearSelection() { }, getSelection() { },