Fix OE single click and expand groups by default (#1096)

This commit is contained in:
Karl Burtram
2018-04-06 15:15:41 -07:00
committed by GitHub
parent 3990719054
commit 2182658301
4 changed files with 29 additions and 10 deletions

View File

@@ -5,11 +5,13 @@
import { IConfigurationRegistry, Extensions, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry'; import { IConfigurationRegistry, Extensions, IConfigurationNode } from 'vs/platform/configuration/common/configurationRegistry';
import { Registry } from 'vs/platform/registry/common/platform'; import { Registry } from 'vs/platform/registry/common/platform';
import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { localize } from 'vs/nls';
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration); const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
export const SERVER_GROUP_CONFIG = 'serverGroup'; export const SERVER_GROUP_CONFIG = 'serverGroup';
export const SERVER_GROUP_COLORS_CONFIG = 'colors'; export const SERVER_GROUP_COLORS_CONFIG = 'colors';
export const SERVER_GROUP_AUTOEXPAND_CONFIG = 'autoExpand';
const serverGroupConfig: IConfigurationNode = { const serverGroupConfig: IConfigurationNode = {
id: 'Server Groups', id: 'Server Groups',
@@ -18,6 +20,7 @@ const serverGroupConfig: IConfigurationNode = {
[SERVER_GROUP_CONFIG + '.' + SERVER_GROUP_COLORS_CONFIG]: <IJSONSchema>{ [SERVER_GROUP_CONFIG + '.' + SERVER_GROUP_COLORS_CONFIG]: <IJSONSchema>{
type: 'array', type: 'array',
items: 'string', items: 'string',
'description': localize('serverGroup.colors', 'Server Group color palette used in the Object Explorer viewlet.'),
default: [ default: [
'#A1634D', '#A1634D',
'#7F0000', '#7F0000',
@@ -28,7 +31,12 @@ const serverGroupConfig: IConfigurationNode = {
'#6A6599', '#6A6599',
'#515151' '#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'
},
} }
}; };

View File

@@ -17,6 +17,7 @@ import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile
import { ServerTreeActionProvider } from 'sql/parts/objectExplorer/viewlet/serverTreeActionProvider'; import { ServerTreeActionProvider } from 'sql/parts/objectExplorer/viewlet/serverTreeActionProvider';
import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions'; import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions';
import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode'; 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 * 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, @ITelemetryService private telemetryService: ITelemetryService,
@IKeybindingService private keybindingService: IKeybindingService @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 { public onClick(tree: ITree, element: any, event: IMouseEvent): boolean {

View File

@@ -29,6 +29,8 @@ import { Button } from 'sql/base/browser/ui/button/button';
import { attachButtonStyler } from 'sql/common/theme/styler'; import { attachButtonStyler } from 'sql/common/theme/styler';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { TreeNode, TreeItemCollapsibleState } from 'sql/parts/objectExplorer/common/treeNode'; 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.$; const $ = builder.$;
@@ -52,6 +54,7 @@ export class ServerTreeView {
@IThemeService private _themeService: IThemeService, @IThemeService private _themeService: IThemeService,
@IErrorMessageService private _errorMessageService: IErrorMessageService, @IErrorMessageService private _errorMessageService: IErrorMessageService,
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService, @ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
@IConfigurationService private _configurationService: IConfigurationService
) { ) {
this._activeConnectionsFilterAction = this._instantiationService.createInstance( this._activeConnectionsFilterAction = this._instantiationService.createInstance(
ActiveConnectionsFilterAction, ActiveConnectionsFilterAction,
@@ -109,12 +112,10 @@ export class ServerTreeView {
// Refresh Tree when these events are emitted // Refresh Tree when these events are emitted
this._toDispose.push(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => { this._toDispose.push(this._connectionManagementService.onAddConnectionProfile((newProfile: IConnectionProfile) => {
self.handleAddConnectionProfile(newProfile); self.handleAddConnectionProfile(newProfile);
}) }));
);
this._toDispose.push(this._connectionManagementService.onDeleteConnectionProfile(() => { this._toDispose.push(this._connectionManagementService.onDeleteConnectionProfile(() => {
self.refreshTree(); self.refreshTree();
}) }));
);
this._toDispose.push(this._connectionManagementService.onDisconnect((connectionParams) => { this._toDispose.push(this._connectionManagementService.onDisconnect((connectionParams) => {
if (self.isObjectExplorerConnectionUri(connectionParams.connectionUri)) { if (self.isObjectExplorerConnectionUri(connectionParams.connectionUri)) {
self.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile); self.deleteObjectExplorerNodeAndRefreshTree(connectionParams.connectionProfile);
@@ -124,7 +125,7 @@ export class ServerTreeView {
if (this._objectExplorerService && this._objectExplorerService.onUpdateObjectExplorerNodes) { if (this._objectExplorerService && this._objectExplorerService.onUpdateObjectExplorerNodes) {
this._toDispose.push(this._objectExplorerService.onUpdateObjectExplorerNodes(args => { this._toDispose.push(this._objectExplorerService.onUpdateObjectExplorerNodes(args => {
if (args.errorMessage) { if (args.errorMessage) {
this.showError(args.errorMessage); self.showError(args.errorMessage);
} }
if (args.connection) { if (args.connection) {
self.onObjectExplorerSessionCreated(args.connection); self.onObjectExplorerSessionCreated(args.connection);
@@ -133,9 +134,15 @@ export class ServerTreeView {
} }
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
self.refreshTree(); self.refreshTree();
let root = <ConnectionProfileGroup>this._tree.getInput(); let root = <ConnectionProfileGroup>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) { if (root && !root.hasValidConnections) {
this._treeSelectionHandler.onTreeActionStateChange(true); self._treeSelectionHandler.onTreeActionStateChange(true);
resolve(); resolve();
} else { } else {
resolve(); resolve();

View File

@@ -24,7 +24,7 @@ suite('ServerTreeView onAddConnectionProfile handler tests', () => {
let instantiationService = new TestInstantiationService(); let instantiationService = new TestInstantiationService();
let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {}); let mockConnectionManagementService = TypeMoq.Mock.ofType(ConnectionManagementService, TypeMoq.MockBehavior.Strict, {}, {});
mockConnectionManagementService.setup(x => x.getConnectionGroups()).returns(x => []); 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 = <Tree>{ let tree = <Tree>{
clearSelection() { }, clearSelection() { },
getSelection() { }, getSelection() { },