-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement data.table.notebook.examples quick pick display and example…
… notebook loading (#75)
- Loading branch information
1 parent
5c75e39
commit 5006b66
Showing
3 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { | ||
ExtensionContext, | ||
Disposable, | ||
QuickPickItem, | ||
ViewColumn, | ||
Uri, | ||
commands, | ||
window, | ||
workspace | ||
} | ||
from 'vscode'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import * as config from './config'; | ||
import * as constants from './constants'; | ||
|
||
let _context: ExtensionContext; | ||
|
||
export function registerCommands(context: ExtensionContext) { | ||
_context = context; | ||
registerCommand(constants.NotebookExamplesCommand, createNotebookExamplesCommand); | ||
} | ||
|
||
function registerCommand(commandName: string, callback: (...args: any[]) => any, thisArg?: any): Disposable { | ||
const command: Disposable = commands.registerCommand(commandName, callback); | ||
_context.subscriptions.push(command); | ||
return command; | ||
} | ||
|
||
/** | ||
* Displays buil-in Data Table Notebook Examples Quick Pick list. | ||
*/ | ||
async function createNotebookExamplesCommand(): Promise<void> { | ||
const notebookQuickPickItems: Array<QuickPickItem> = []; | ||
config.notebookExamples.forEach(notebook => notebookQuickPickItems.push({ | ||
label: `$(notebook) ${notebook.name}`, | ||
description: notebook.description, | ||
detail: notebook.file | ||
})); | ||
const selectedNotebook: QuickPickItem | undefined = | ||
await window.showQuickPick(notebookQuickPickItems, {canPickMany: false}); | ||
if (selectedNotebook) { | ||
const notebookUrl: string | undefined = selectedNotebook.detail; | ||
const extensionPath: string = _context.asAbsolutePath('./'); | ||
if (notebookUrl) { | ||
const notebookUri: Uri = Uri.file(path.join(extensionPath, notebookUrl)); | ||
// open data table example notebook | ||
commands.executeCommand(constants.VSCodeOpenCommand, notebookUri); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters