From 9246d3ba48e4b36f5bad78e1461053ccd03620e2 Mon Sep 17 00:00:00 2001 From: Thad House Date: Tue, 17 Jul 2018 12:49:13 -0700 Subject: [PATCH] Show WPILib help whenever a new project is created. Only happens when a new project is created or a project is opened for the first time on a specific system --- vscode-wpilib/src/cppprovider/apiprovider.ts | 2 +- vscode-wpilib/src/extension.ts | 15 +++++++++++++++ .../src/{cppprovider => }/persistentState.ts | 2 +- vscode-wpilib/src/webviews/help.ts | 8 ++++++-- 4 files changed, 23 insertions(+), 4 deletions(-) rename vscode-wpilib/src/{cppprovider => }/persistentState.ts (97%) diff --git a/vscode-wpilib/src/cppprovider/apiprovider.ts b/vscode-wpilib/src/cppprovider/apiprovider.ts index 8043a942..4377b020 100644 --- a/vscode-wpilib/src/cppprovider/apiprovider.ts +++ b/vscode-wpilib/src/cppprovider/apiprovider.ts @@ -4,10 +4,10 @@ import * as jsonc from 'jsonc-parser'; import * as path from 'path'; import * as vscode from 'vscode'; import { CppToolsApi, CustomConfigurationProvider, SourceFileConfigurationItem } from 'vscode-cpptools'; +import { PersistentFolderState } from '../persistentState'; import { IExecuteAPI, IExternalAPI, IPreferences } from '../shared/externalapi'; import { gradleRun, promisifyReadFile } from '../utilities'; import { IToolChain } from './jsonformats'; -import { PersistentFolderState } from './persistentState'; const isWindows = (process.platform === 'win32'); diff --git a/vscode-wpilib/src/extension.ts b/vscode-wpilib/src/extension.ts index 66d62771..de0dd447 100644 --- a/vscode-wpilib/src/extension.ts +++ b/vscode-wpilib/src/extension.ts @@ -9,6 +9,7 @@ import { DeployDebugAPI } from './deploydebugapi'; import { ExampleTemplateAPI } from './exampletemplateapi'; import { ExecuteAPI } from './executor'; import { activateJava } from './java/java'; +import { PersistentFolderState } from './persistentState'; import { PreferencesAPI } from './preferencesapi'; import { IExternalAPI } from './shared/externalapi'; import { ToolAPI } from './toolapi'; @@ -93,6 +94,20 @@ export async function activate(context: vscode.ExtensionContext) { context.subscriptions.push(await ProjectCreator.Create(externalApi.getExampleTemplateAPI())); + const wp = vscode.workspace.workspaceFolders; + if (wp) { + for (const w of wp) { + if (externalApi.getPreferencesAPI().getPreferences(w).getIsWPILibProject()) { + const persistentState = new PersistentFolderState('wpilib.newProjectHelp', false, w.uri.fsPath); + if (persistentState.Value === false) { + persistentState.Value = true; + help.displayHelp(); + break; + } + } + } + } + // Use the console to output diagnostic information (console.log) and errors (console.error) // This line of code will only be executed once when your extension is activated console.log('Congratulations, your extension "vscode-wpilib" is now active!'); diff --git a/vscode-wpilib/src/cppprovider/persistentState.ts b/vscode-wpilib/src/persistentState.ts similarity index 97% rename from vscode-wpilib/src/cppprovider/persistentState.ts rename to vscode-wpilib/src/persistentState.ts index 373a7039..66e42532 100644 --- a/vscode-wpilib/src/cppprovider/persistentState.ts +++ b/vscode-wpilib/src/persistentState.ts @@ -6,7 +6,7 @@ import * as path from 'path'; import * as vscode from 'vscode'; -import { extensionContext } from '../utilities'; +import { extensionContext } from './utilities'; class PersistentStateBase { private key: string; diff --git a/vscode-wpilib/src/webviews/help.ts b/vscode-wpilib/src/webviews/help.ts index 89ef13e3..d67e27b1 100644 --- a/vscode-wpilib/src/webviews/help.ts +++ b/vscode-wpilib/src/webviews/help.ts @@ -24,11 +24,15 @@ export class Help extends WebViewBase { this.statusBar.command = 'wpilibcore.help'; this.disposables.push(this.statusBar); - this.disposables.push(vscode.commands.registerCommand('wpilibcore.help', async () => { - this.displayWebView(vscode.ViewColumn.Active); + this.disposables.push(vscode.commands.registerCommand('wpilibcore.help', () => { + this.displayHelp(); })); } + public displayHelp() { + this.displayWebView(vscode.ViewColumn.Active); + } + private async asyncInitialize() { await this.loadWebpage(path.join(extensionContext.extensionPath, 'resources', 'webviews', 'help.html'));