Skip to content

Commit

Permalink
#1131 | Show bundled What's New tab with fallback to GitHub page
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored May 15, 2024
1 parent 59042bf commit a05cc68
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@

/ccv2

jflex-*.jar
jflex-*.jar

resources/CHANGELOG.md
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Other
- Migrated to `IntelliJ Platform Gradle Plugin 2.beta2` [#1124](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1124)
- Show once `CHANGELOG.md` in a new `What's New` tab once per version [#1125](https://github.com/epam/sap-commerce-intellij-idea-plugin/issues/1125)
- Show bundled `What's New` tab with fallback to GitHub page [#1131](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1131)
- Updated gradle wrapper to 8.7 [#1126](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/1126)

## [2024.1.2]
Expand Down
11 changes: 11 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ val ccv2OpenApiTasks = ccv2OpenApiSpecs.mapIndexed { index, (taskName, schema, p
if (index > 0) {
val previousTaskName = ccv2OpenApiSpecs[index - 1].first
dependsOn(previousTaskName)
} else {
dependsOn("copyChangelog")
}
}
}
Expand Down Expand Up @@ -182,6 +184,15 @@ intellijPlatform {
}

tasks {
val copyChangelog by registering(Copy::class) {
from("CHANGELOG.md")
into("resources")
}

patchPluginXml {
dependsOn(copyChangelog)
}

val jvmArguments = mutableListOf<String>().apply {
add(properties("intellij.jvm.args").get())

Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# ./gradlew wrapper --gradle-version 8.7
gradle.version=8.7

org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false
#org.jetbrains.intellij.platform.buildFeature.useBinaryReleases=false

# This is required because after upgrading to Gradle 5.1.1 the daemon runs out of memory during compilation with the
# default value of 512m
Expand Down Expand Up @@ -51,7 +51,8 @@ intellij.plugin.version=2024.1.3
intellij.plugin.since.build=241.14494.240
intellij.plugin.until.build=241.*

intellij.version=241.15989.150
#intellij.version=241.15989.150
intellij.version=2024.1.1

# Plugin Verifier integration -> https://github.com/JetBrains/intellij-plugin-verifier
# https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,17 @@ import com.intellij.ide.util.RunOnceUtil
import com.intellij.idea.plugin.hybris.settings.components.ProjectSettingsComponent
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.extensions.PluginId
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.TextEditorWithPreview
import com.intellij.openapi.fileEditor.impl.HTMLEditorProvider
import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
import com.intellij.openapi.util.io.StreamUtil
import com.intellij.testFramework.LightVirtualFile
import com.intellij.ui.jcef.JBCefApp
import java.io.IOException
import java.nio.charset.StandardCharsets

class WhatsNewStartupActivity : ProjectActivity {

Expand All @@ -38,11 +45,30 @@ class WhatsNewStartupActivity : ProjectActivity {
val version = pluginDescriptor.version

RunOnceUtil.runOnceForProject(project, "sapCX_showWhatsNew_$version") {
val request = HTMLEditorProvider.Request.url("https://github.com/epam/sap-commerce-intellij-idea-plugin/blob/main/CHANGELOG.md#$version")
try {
val content = this.javaClass.getResourceAsStream("/CHANGELOG.md").use { html ->
html
?.let { String(StreamUtil.readBytes(it), StandardCharsets.UTF_8) }
} ?: return@runOnceForProject

invokeLater {
HTMLEditorProvider.openEditor(project, "See What's New", request)
val lvf = LightVirtualFile("What's New in SAP Commerce Developers Toolset - ${version}").also {
it.putUserData(TextEditorWithPreview.DEFAULT_LAYOUT_FOR_FILE, TextEditorWithPreview.Layout.SHOW_PREVIEW)
it.setContent(null, content, true)
it.fileType = FileTypeManagerEx.getInstance().getFileTypeByExtension("md")
it.isWritable = false
}

invokeLater {
FileEditorManager.getInstance(project).openFile(lvf, true, true)
}
} catch (e: IOException) {
val request = HTMLEditorProvider.Request.url("https://github.com/epam/sap-commerce-intellij-idea-plugin/blob/main/CHANGELOG.md#$version")

invokeLater {
HTMLEditorProvider.openEditor(project, "What's New in SAP Commerce Developers Toolset - ${version}", request)
}
}
}
}

}

0 comments on commit a05cc68

Please sign in to comment.