mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 09:59:47 -05:00
* Checkpoint * Adding mock contents for tree * added open sqlproj dialog * reading files from directory * Added directory traversal * Adding tree sorting by folder vs file and label * Improved auto-unfolding of tree based on node type * replacing fs with fs.promise alias * PR feedback * added activation event for when workspace contains sqlproj files * Returning after displaying error * Fixing linter errors * Reworked tree * Fixing missing grandchildren * Correcting tree URI construction * Refactoring to isolate tree item responsibilities from data model responsibilities * project file parsing * constructing tree from project files rather than filesystem * Fixing double-initialization * Changing projectEntry to take enum for file type * Correct node type for project item * Parsing datasources.json * Child nodes for sql data source * Localizing strings * Checkpoint * Adding mock contents for tree * added open sqlproj dialog * reading files from directory * Added directory traversal * Adding tree sorting by folder vs file and label * Improved auto-unfolding of tree based on node type * replacing fs with fs.promise alias * PR feedback * added activation event for when workspace contains sqlproj files * Returning after displaying error * Fixing linter errors * Reworked tree * Fixing missing grandchildren * Correcting tree URI construction * Refactoring to isolate tree item responsibilities from data model responsibilities * project file parsing * constructing tree from project files rather than filesystem * Fixing double-initialization * Changing projectEntry to take enum for file type * Correct node type for project item * Parsing datasources.json * Child nodes for sql data source * Localizing strings * missed file in merge * changed extension method to helper * cleanup * Adding docstrings
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import * as vscode from 'vscode';
|
|
import * as constants from '../common/constants';
|
|
|
|
import { BaseProjectTreeItem, MessageTreeItem } from '../models/tree/baseTreeItem';
|
|
import { ProjectRootTreeItem } from '../models/tree/projectTreeItem';
|
|
import { Project } from '../models/project';
|
|
|
|
/**
|
|
* Tree view for database projects
|
|
*/
|
|
export class SqlDatabaseProjectTreeViewProvider implements vscode.TreeDataProvider<BaseProjectTreeItem> {
|
|
private _onDidChangeTreeData: vscode.EventEmitter<BaseProjectTreeItem | undefined> = new vscode.EventEmitter<BaseProjectTreeItem | undefined>();
|
|
readonly onDidChangeTreeData: vscode.Event<BaseProjectTreeItem | undefined> = this._onDidChangeTreeData.event;
|
|
|
|
private roots: BaseProjectTreeItem[] = [];
|
|
|
|
constructor() {
|
|
this.initialize();
|
|
}
|
|
|
|
private initialize() {
|
|
this.roots = [new MessageTreeItem(constants.noOpenProjectMessage)];
|
|
}
|
|
|
|
public getTreeItem(element: BaseProjectTreeItem): vscode.TreeItem {
|
|
return element.treeItem;
|
|
}
|
|
|
|
public getChildren(element?: BaseProjectTreeItem): BaseProjectTreeItem[] {
|
|
if (element === undefined) {
|
|
return this.roots;
|
|
}
|
|
|
|
return element.children;
|
|
}
|
|
|
|
public load(projects: Project[]) {
|
|
if (projects.length === 0) {
|
|
vscode.window.showErrorMessage(constants.noSqlProjFiles);
|
|
return;
|
|
}
|
|
|
|
let newRoots: BaseProjectTreeItem[] = [];
|
|
|
|
for (const proj of projects) {
|
|
newRoots.push(new ProjectRootTreeItem(proj));
|
|
}
|
|
|
|
this.roots = newRoots;
|
|
this._onDidChangeTreeData.fire();
|
|
}
|
|
}
|