Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display welcome page on install #128

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"onCommand:quarkusTools.addExtension",
"onCommand:quarkusTools.debugQuarkusProject",
"onCommand:quarkusTools.welcome",
"onLanguage:quarkus-properties"
"onLanguage:quarkus-properties",
"*"
],
"main": "./dist/extension",
"extensionDependencies": [
Expand Down Expand Up @@ -113,7 +114,7 @@
},
"quarkus.tools.alwaysShowWelcomePage": {
"type": "boolean",
"default": true,
"default": false,
"description": "Determines whether to show the welcome page on extension startup."
},
"quarkus.tools.starter.api": {
Expand Down
4 changes: 2 additions & 2 deletions src/QuarkusConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export namespace QuarkusConfig {
}

export function getAlwaysShowWelcomePage(): boolean {
return workspace.getConfiguration().get<boolean>(ALWAYS_SHOW_WELCOME_PAGE, true);
return workspace.getConfiguration().get<boolean>(ALWAYS_SHOW_WELCOME_PAGE, false);
}

export function getTerminateProcessOnDebugExit(): TerminateProcessConfig {
Expand Down Expand Up @@ -107,4 +107,4 @@ export enum TerminateProcessConfig {
Ask = "Ask",
Terminate = "Always terminate",
DontTerminate = "Never terminate"
}
}
34 changes: 27 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import * as requirements from './languageServer/requirements';
import * as fs from 'fs';

import { QUARKUS_PROJECT_REQUEST, JDTLS_PROJECT_INFO_COMMAND, QUARKUS_PROPERTY_DEFINITION_REQUEST, JDTLS_PROPERTY_DEFINITION_COMMAND } from './definitions/wizardConstants';

Expand Down Expand Up @@ -43,8 +44,8 @@ interface QuarkusPropertiesChangeEvent {
}

interface QuarkusPropertyDefinitionParams {
uri: string;
propertySource: string;
uri: string;
propertySource: string;
}

export function activate(context: ExtensionContext) {
Expand All @@ -56,12 +57,12 @@ export function activate(context: ExtensionContext) {
connectToLS().then(() => {
const quarkusPojectInfoRequest = new RequestType<QuarkusProjectInfoParams, any, void, void>(QUARKUS_PROJECT_REQUEST);
languageClient.onRequest(quarkusPojectInfoRequest, async (params: QuarkusProjectInfoParams) =>
<any> await commands.executeCommand("java.execute.workspaceCommand", JDTLS_PROJECT_INFO_COMMAND, params)
<any>await commands.executeCommand("java.execute.workspaceCommand", JDTLS_PROJECT_INFO_COMMAND, params)
);

const quarkusPropertyDefinitionRequest = new RequestType<QuarkusPropertyDefinitionParams, any, void, void>(QUARKUS_PROPERTY_DEFINITION_REQUEST);
const quarkusPropertyDefinitionRequest = new RequestType<QuarkusPropertyDefinitionParams, any, void, void>(QUARKUS_PROPERTY_DEFINITION_REQUEST);
languageClient.onRequest(quarkusPropertyDefinitionRequest, async (params: QuarkusPropertyDefinitionParams) =>
<any> await commands.executeCommand("java.execute.workspaceCommand", JDTLS_PROPERTY_DEFINITION_COMMAND, params)
<any>await commands.executeCommand("java.execute.workspaceCommand", JDTLS_PROPERTY_DEFINITION_COMMAND, params)
);

/**
Expand All @@ -88,9 +89,15 @@ export function deactivate() {
}

function displayWelcomePageIfNeeded(context: ExtensionContext): void {
if (QuarkusConfig.getAlwaysShowWelcomePage()) {
const welcomePageDisplayed: boolean|undefined = context.globalState.get('welcomePageDisplayed');
if (!welcomePageDisplayed || QuarkusConfig.getAlwaysShowWelcomePage()) {
WelcomeWebview.createOrShow(context);
}

if (!welcomePageDisplayed) {
context.globalState.update('welcomePageDisplayed', true);
removeStartupActivationEvent(context);
}
}

function registerVSCodeCommands(context: ExtensionContext) {
Expand Down Expand Up @@ -174,8 +181,21 @@ function connectToLS() {
quarkus = defaultValue;
} else {
const x = JSON.stringify(configQuarkus); // configQuarkus is not a JSON type
quarkus = { quarkus : JSON.parse(x)};
quarkus = { quarkus: JSON.parse(x) };
}
return quarkus;
}
}

function removeStartupActivationEvent(context: ExtensionContext) {
const extensionPackage = JSON.parse((fs.readFileSync(context.asAbsolutePath('./package.json'))).toString());
if (extensionPackage && extensionPackage.activationEvents) {
let i: number = extensionPackage.activationEvents.length;
while (i--) {
if (extensionPackage.activationEvents[i] === "*") {
extensionPackage.activationEvents.splice(i, 1);
}
}
fs.writeFileSync(context.asAbsolutePath('./package.json'), JSON.stringify(extensionPackage, null, 2));
}
}