mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-08 01:28:26 -05:00
* Fixes #1856 Object Explorer needs Icons field for nodes separate from type/subtype - Adds in the concept of a themeable icon path which matches VSCode's implementation. This should help support theme-based overrides in the future
This commit is contained in:
@@ -95,3 +95,7 @@ export class NodeType {
|
||||
public static ColumnMasterKey = 'ColumnMasterKey';
|
||||
public static ColumnEncryptionKey = 'ColumnEncryptionKey';
|
||||
}
|
||||
|
||||
export interface SqlThemeIcon {
|
||||
readonly id: string;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
'use strict';
|
||||
|
||||
import { NodeType } from 'sql/parts/objectExplorer/common/nodeType';
|
||||
import { TreeNode, TreeItemCollapsibleState, ObjectExplorerCallbacks } from 'sql/parts/objectExplorer/common/treeNode';
|
||||
import { TreeNode, TreeItemCollapsibleState } from 'sql/parts/objectExplorer/common/treeNode';
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
@@ -20,7 +20,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { warn, error } from 'sql/base/common/log';
|
||||
import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView';
|
||||
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export const SERVICE_ID = 'ObjectExplorerService';
|
||||
|
||||
@@ -402,7 +401,7 @@ export class ObjectExplorerService implements IObjectExplorerService {
|
||||
}
|
||||
|
||||
return new TreeNode(nodeInfo.nodeType, nodeInfo.label, isLeaf, nodeInfo.nodePath,
|
||||
nodeInfo.nodeSubType, nodeInfo.nodeStatus, parent, nodeInfo.metadata, {
|
||||
nodeInfo.nodeSubType, nodeInfo.nodeStatus, parent, nodeInfo.metadata, nodeInfo.iconType, {
|
||||
getChildren: treeNode => this.getChildren(treeNode),
|
||||
isExpanded: treeNode => this.isExpanded(treeNode),
|
||||
setNodeExpandedState: (treeNode, expandedState) => this.setNodeExpandedState(treeNode, expandedState),
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
'use strict';
|
||||
|
||||
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
|
||||
import { NodeType } from 'sql/parts/objectExplorer/common/nodeType';
|
||||
import { NodeType, SqlThemeIcon } from 'sql/parts/objectExplorer/common/nodeType';
|
||||
import * as sqlops from 'sqlops';
|
||||
|
||||
import * as UUID from 'vs/base/common/uuid';
|
||||
@@ -83,6 +83,23 @@ export class TreeNode {
|
||||
|
||||
public metadata: sqlops.ObjectMetadata;
|
||||
|
||||
public iconType: string | SqlThemeIcon;
|
||||
|
||||
constructor(nodeTypeId: string, label: string, isAlwaysLeaf: boolean, nodePath: string,
|
||||
nodeSubType: string, nodeStatus: string, parent: TreeNode, metadata: sqlops.ObjectMetadata,
|
||||
iconType: string | SqlThemeIcon,
|
||||
private _objectExplorerCallbacks: ObjectExplorerCallbacks) {
|
||||
this.nodeTypeId = nodeTypeId;
|
||||
this.label = label;
|
||||
this.isAlwaysLeaf = isAlwaysLeaf;
|
||||
this.nodePath = nodePath;
|
||||
this.parent = parent;
|
||||
this.metadata = metadata;
|
||||
this.iconType = iconType;
|
||||
this.id = UUID.generateUuid();
|
||||
this.nodeSubType = nodeSubType;
|
||||
this.nodeStatus = nodeStatus;
|
||||
}
|
||||
public getConnectionProfile(): ConnectionProfile {
|
||||
var currentNode: TreeNode = this;
|
||||
while (!currentNode.connection && currentNode.parent) {
|
||||
@@ -149,18 +166,4 @@ export class TreeNode {
|
||||
public setSelected(selected: boolean, clearOtherSelections?: boolean): Thenable<void> {
|
||||
return this._objectExplorerCallbacks.setNodeSelected(this, selected, clearOtherSelections);
|
||||
}
|
||||
|
||||
constructor(nodeTypeId: string, label: string, isAlwaysLeaf: boolean, nodePath: string,
|
||||
nodeSubType: string, nodeStatus: string, parent: TreeNode, metadata: sqlops.ObjectMetadata,
|
||||
private _objectExplorerCallbacks: ObjectExplorerCallbacks) {
|
||||
this.nodeTypeId = nodeTypeId;
|
||||
this.label = label;
|
||||
this.isAlwaysLeaf = isAlwaysLeaf;
|
||||
this.nodePath = nodePath;
|
||||
this.parent = parent;
|
||||
this.metadata = metadata;
|
||||
this.id = UUID.generateUuid();
|
||||
this.nodeSubType = nodeSubType;
|
||||
this.nodeStatus = nodeStatus;
|
||||
}
|
||||
}
|
||||
@@ -105,38 +105,45 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
*/
|
||||
public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
|
||||
if (templateId === ServerTreeRenderer.CONNECTION_TEMPLATE_ID) {
|
||||
this.renderConnection(tree, element, templateData);
|
||||
this.renderConnection(element, templateData);
|
||||
} else if (templateId === ServerTreeRenderer.CONNECTION_GROUP_TEMPLATE_ID) {
|
||||
this.renderConnectionProfileGroup(tree, element, templateData);
|
||||
this.renderConnectionProfileGroup(element, templateData);
|
||||
} else {
|
||||
this.renderObjectExplorer(tree, element, templateData);
|
||||
this.renderObjectExplorer(element, templateData);
|
||||
}
|
||||
}
|
||||
|
||||
private renderObjectExplorer(tree: ITree, treeNode: TreeNode, templateData: IObjectExplorerTemplateData): void {
|
||||
var iconName = treeNode.nodeTypeId;
|
||||
if (treeNode.nodeStatus) {
|
||||
iconName = treeNode.nodeTypeId + '_' + treeNode.nodeStatus;
|
||||
}
|
||||
if (treeNode.nodeSubType) {
|
||||
iconName = treeNode.nodeTypeId + '_' + treeNode.nodeSubType;
|
||||
private renderObjectExplorer(treeNode: TreeNode, templateData: IObjectExplorerTemplateData): void {
|
||||
// Use an explicitly defined iconType first. If not defined, fall back to using nodeType and
|
||||
// other compount indicators instead.
|
||||
let iconName: string = undefined;
|
||||
if (treeNode.iconType) {
|
||||
iconName = (typeof treeNode.iconType === 'string') ? treeNode.iconType : treeNode.iconType.id;
|
||||
} else {
|
||||
iconName = treeNode.nodeTypeId;
|
||||
if (treeNode.nodeStatus) {
|
||||
iconName = treeNode.nodeTypeId + '_' + treeNode.nodeStatus;
|
||||
}
|
||||
if (treeNode.nodeSubType) {
|
||||
iconName = treeNode.nodeTypeId + '_' + treeNode.nodeSubType;
|
||||
}
|
||||
}
|
||||
|
||||
let tokens: string[] = [];
|
||||
for (var index = 1; index < templateData.icon.classList.length; index++) {
|
||||
for (let index = 1; index < templateData.icon.classList.length; index++) {
|
||||
tokens.push(templateData.icon.classList.item(index));
|
||||
}
|
||||
templateData.icon.classList.remove(...tokens);
|
||||
templateData.icon.classList.add('icon');
|
||||
let iconLoweCaseName = iconName.toLocaleLowerCase();
|
||||
templateData.icon.classList.add(iconLoweCaseName);
|
||||
let iconLowerCaseName = iconName.toLocaleLowerCase();
|
||||
templateData.icon.classList.add(iconLowerCaseName);
|
||||
|
||||
templateData.label.textContent = treeNode.label;
|
||||
templateData.root.title = treeNode.label;
|
||||
}
|
||||
|
||||
|
||||
private renderConnection(tree: ITree, connection: ConnectionProfile, templateData: IConnectionTemplateData): void {
|
||||
private renderConnection(connection: ConnectionProfile, templateData: IConnectionTemplateData): void {
|
||||
if (!this._isCompact) {
|
||||
if (this._connectionManagementService.isConnected(undefined, connection)) {
|
||||
templateData.icon.classList.remove('disconnected');
|
||||
@@ -157,9 +164,9 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
templateData.connectionProfile = connection;
|
||||
}
|
||||
|
||||
private renderConnectionProfileGroup(tree: ITree, connectionProfileGroup: ConnectionProfileGroup, templateData: IConnectionProfileGroupTemplateData): void {
|
||||
private renderConnectionProfileGroup(connectionProfileGroup: ConnectionProfileGroup, templateData: IConnectionProfileGroupTemplateData): void {
|
||||
|
||||
var rowElement = this.findParentElement(templateData.root, 'monaco-tree-row');
|
||||
let rowElement = this.findParentElement(templateData.root, 'monaco-tree-row');
|
||||
if (rowElement) {
|
||||
if (connectionProfileGroup.color) {
|
||||
rowElement.style.background = connectionProfileGroup.color;
|
||||
@@ -179,7 +186,7 @@ export class ServerTreeRenderer implements IRenderer {
|
||||
* Returns the first parent which contains the className
|
||||
*/
|
||||
private findParentElement(container: HTMLElement, className: string): HTMLElement {
|
||||
var currentElement = container;
|
||||
let currentElement = container;
|
||||
while (currentElement) {
|
||||
if (currentElement.className.includes(className)) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user