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 { Registry } from 'vs/platform/registry/common/platform';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import { localize } from 'vs/nls';
const configurationRegistry = Registry.as<IConfigurationRegistry>(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]: <IJSONSchema>{
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'
},
}
};

View File

@@ -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 {

View File

@@ -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<void>((resolve, reject) => {
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) {
this._treeSelectionHandler.onTreeActionStateChange(true);
self._treeSelectionHandler.onTreeActionStateChange(true);
resolve();
} else {
resolve();