Skip to content

Commit

Permalink
Show WPILib help whenever a new project is created.
Browse files Browse the repository at this point in the history
Only happens when a new project is created or a project is opened for the first time on a specific system
  • Loading branch information
ThadHouse committed Jul 17, 2018
1 parent 0867361 commit 9246d3b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion vscode-wpilib/src/cppprovider/apiprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
15 changes: 15 additions & 0 deletions vscode-wpilib/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import * as path from 'path';
import * as vscode from 'vscode';
import { extensionContext } from '../utilities';
import { extensionContext } from './utilities';

class PersistentStateBase<T> {
private key: string;
Expand Down
8 changes: 6 additions & 2 deletions vscode-wpilib/src/webviews/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down

0 comments on commit 9246d3b

Please sign in to comment.