mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-06 01:25:38 -05:00
52 lines
2.3 KiB
TypeScript
52 lines
2.3 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 path from 'path';
|
|
import { WorkspaceTreeDataProvider } from './common/workspaceTreeDataProvider';
|
|
import { WorkspaceService } from './services/workspaceService';
|
|
import { SelectProjectFileActionName } from './common/constants';
|
|
import { WorkspaceTreeItem } from './common/interfaces';
|
|
|
|
export function activate(context: vscode.ExtensionContext): void {
|
|
const workspaceService = new WorkspaceService();
|
|
const workspaceTreeDataProvider = new WorkspaceTreeDataProvider(workspaceService);
|
|
context.subscriptions.push(vscode.window.registerTreeDataProvider('dataworkspace.views.main', workspaceTreeDataProvider));
|
|
context.subscriptions.push(vscode.commands.registerCommand('projects.addProject', async () => {
|
|
// To Sakshi - You can replace the implementation with your complete dialog implementation
|
|
// but all the code here should be reusable by you
|
|
if (vscode.workspace.workspaceFile) {
|
|
const filter: { [name: string]: string[] } = {};
|
|
const projectTypes = await workspaceService.getAllProjectTypes();
|
|
projectTypes.forEach(type => {
|
|
filter[type.displayName] = projectTypes.map(projectType => projectType.projectFileExtension);
|
|
});
|
|
let fileUris = await vscode.window.showOpenDialog({
|
|
canSelectFiles: true,
|
|
canSelectFolders: false,
|
|
canSelectMany: false,
|
|
defaultUri: vscode.Uri.file(path.dirname(vscode.workspace.workspaceFile.path)),
|
|
openLabel: SelectProjectFileActionName,
|
|
filters: filter
|
|
});
|
|
if (!fileUris || fileUris.length === 0) {
|
|
return;
|
|
}
|
|
await workspaceService.addProjectsToWorkspace(fileUris);
|
|
}
|
|
}));
|
|
|
|
context.subscriptions.push(vscode.commands.registerCommand('dataworkspace.refresh', () => {
|
|
workspaceTreeDataProvider.refresh();
|
|
}));
|
|
|
|
context.subscriptions.push(vscode.commands.registerCommand('projects.removeProject', async (treeItem: WorkspaceTreeItem) => {
|
|
await workspaceService.removeProject(vscode.Uri.file(treeItem.element.project.projectFilePath));
|
|
}));
|
|
}
|
|
|
|
export function deactivate(): void {
|
|
}
|