Skip to content

Commit

Permalink
remove obsolete starters, open readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinVaadin committed Apr 23, 2024
1 parent 2e9b90a commit e5216e4
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 64 deletions.
18 changes: 3 additions & 15 deletions src/main/kotlin/com/vaadin/plugin/module/SkeletonStarterPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@ class SkeletonStarterPanel {
StarterSupport.architectures.keys.first()
)

val root: DialogPanel? = panel {
val root: DialogPanel = panel {
buttonsGroup {
row("Framework") {
for (el in StarterSupport.frameworks.entries.filter { !it.key.contains("hilla") }) {
val r = radioButton(el.value, el.key).onChanged { refreshSupport() }
all["frameworks"]!![r.component] = el.key
}
}.topGap(TopGap.SMALL)
row("") {
for (el in StarterSupport.frameworks.entries.filter { it.key.contains("hilla") }) {
for (el in StarterSupport.frameworks.entries) {
val r = radioButton(el.value, el.key).onChanged { refreshSupport() }
all["frameworks"]!![r.component] = el.key
}
Expand All @@ -65,13 +59,7 @@ class SkeletonStarterPanel {
}.bind(model::buildTool)
buttonsGroup {
row("Architecture") {
for (el in StarterSupport.architectures.entries.filterIndexed { i, _ -> i <= 3 }) {
val r = radioButton(el.value, el.key).onChanged { refreshSupport() }
all["architectures"]!![r.component] = el.key
}
}.topGap(TopGap.SMALL)
row("") {
for (el in StarterSupport.architectures.entries.filterIndexed { i, _ -> i > 3 }) {
for (el in StarterSupport.architectures.entries) {
val r = radioButton(el.value, el.key).onChanged { refreshSupport() }
all["architectures"]!![r.component] = el.key
}
Expand Down
35 changes: 27 additions & 8 deletions src/main/kotlin/com/vaadin/plugin/module/VaadinModuleBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ package com.vaadin.plugin.module
import com.intellij.ide.util.projectWizard.ModuleBuilder
import com.intellij.ide.util.projectWizard.ModuleWizardStep
import com.intellij.ide.util.projectWizard.WizardContext
import com.intellij.notification.NotificationType
import com.intellij.openapi.Disposable
import com.intellij.openapi.module.ModifiableModuleModel
import com.intellij.openapi.module.Module
import com.intellij.openapi.fileEditor.OpenFileDescriptor
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
import com.intellij.openapi.module.ModuleType
import com.vaadin.plugin.starter.HasDownloadLink
import com.intellij.openapi.project.ProjectType
import com.intellij.openapi.roots.ModifiableRootModel
import com.intellij.openapi.startup.StartupManager
import com.intellij.openapi.vfs.VfsUtil
import com.vaadin.plugin.starter.DownloadableModel
import com.vaadin.plugin.utils.VaadinProjectUtil
import java.io.File

class VaadinModuleBuilder : ModuleBuilder() {

private var model: HasDownloadLink? = null
private var model: DownloadableModel? = null

override fun getBuilderId(): String {
return "vaadin"
Expand All @@ -26,13 +32,26 @@ class VaadinModuleBuilder : ModuleBuilder() {
return VaadinCustomOptionsStep(this)
}

fun setModel(model: HasDownloadLink) {
fun setModel(model: DownloadableModel) {
this.model = model
}

override fun createModule(moduleModel: ModifiableModuleModel): Module {
VaadinProjectUtil.downloadAndExtract(moduleModel.project, this.model!!.getDownloadLink(moduleModel.project))
return super.createModule(moduleModel)
override fun setupRootModel(modifiableRootModel: ModifiableRootModel) {
val project = modifiableRootModel.project
StartupManager.getInstance(project).runAfterOpened {
VaadinProjectUtil.downloadAndExtract(project, this.model!!.getDownloadLink(project)) {
VaadinProjectUtil.notify("Vaadin project created", NotificationType.INFORMATION, project)
VfsUtil.findFileByIoFile(File(project.basePath, "README.md"), true)?.let {
val descriptor = OpenFileDescriptor(project, it)
descriptor.setUsePreviewTab(true)
FileEditorManagerEx.getInstanceEx(project).openEditor(descriptor, true)
}
}
}
}

override fun getProjectType(): ProjectType? {
return this.model?.let { ProjectType.create(it.getProjectType()) }
}

}
6 changes: 3 additions & 3 deletions src/main/kotlin/com/vaadin/plugin/module/VaadinPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.intellij.ide.wizard.withVisualPadding
import com.intellij.openapi.ui.DialogPanel
import com.intellij.ui.dsl.builder.CollapsibleRow
import com.intellij.ui.dsl.builder.panel
import com.vaadin.plugin.starter.HasDownloadLink
import com.vaadin.plugin.starter.DownloadableModel

class VaadinPanel {

Expand Down Expand Up @@ -40,7 +40,7 @@ class VaadinPanel {
}

demoStarterGroup = collapsibleGroup("Demo Starters") {
row {}.cell(skeletonStarterPanel.root!!)
row {}.cell(skeletonStarterPanel.root)
}
separator()
row {
Expand All @@ -60,7 +60,7 @@ class VaadinPanel {
return dialogPanel!!
}

fun getModel(): HasDownloadLink {
fun getModel(): DownloadableModel {
return if (quickStarterGroup!!.expanded) quickStarterPanel.model else skeletonStarterPanel.model
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package com.vaadin.plugin.starter

import com.intellij.openapi.project.Project

interface HasDownloadLink {
interface DownloadableModel {

fun getDownloadLink(project: Project): String

fun getProjectType(): String

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class QuickStarterModel(
var exampleViews: Boolean,
var authentication: Boolean,
var version: String
) : BaseState(), HasDownloadLink {
) : BaseState(), DownloadableModel {

override fun getDownloadLink(project: Project): String {
var preset = ""
Expand All @@ -32,4 +32,8 @@ class QuickStarterModel(

return "https://start.vaadin.com/dl?preset=${preset}&projectName=${project.name}"
}

override fun getProjectType(): String {
return "maven"
}
}
6 changes: 5 additions & 1 deletion src/main/kotlin/com/vaadin/plugin/starter/StarterModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class StarterModel(
var language: String, // 17 / kotlin
var buildTool: String, // maven / gradle
var architecture: String // springboot / servlet / ...
) : HasDownloadLink {
) : DownloadableModel {

override fun getDownloadLink(project: Project): String {
var key: String
Expand All @@ -31,4 +31,8 @@ class StarterModel(
return link.replace("<version>", framework)
}

override fun getProjectType(): String {
return buildTool
}

}
36 changes: 3 additions & 33 deletions src/main/kotlin/com/vaadin/plugin/starter/StarterSupport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ class StarterSupport {
companion object {

val frameworks = linkedMapOf(
"24" to "Vaadin Flow 24",
"23" to "Vaadin Flow 23",
"14" to "Vaadin Flow 14",
"hilla-react" to "Hilla + React",
"hilla-lit" to "Hilla + Lit"
"24" to "Flow / Java",
"hilla-react" to "Hilla / React"
)

val languages = linkedMapOf(
Expand All @@ -21,9 +18,7 @@ class StarterSupport {
"springboot" to "Spring Boot",
"quarkus" to "Quarkus",
"jakartaee" to "Jakarta EE",
"servlet" to "Servlet",
"osgi" to "OSGI",
"karaf" to "Karaf"
"servlet" to "Servlet"
)

val buildTools = linkedMapOf(
Expand All @@ -33,18 +28,14 @@ class StarterSupport {

val downloadLinks = mapOf(
"hilla-react" to "https://github.com/vaadin/skeleton-starter-hilla-react/archive/master.zip",
"hilla-lit" to "https://github.com/vaadin/skeleton-starter-hilla-lit/archive/master.zip",
"hilla-react-gradle" to "https://github.com/vaadin/skeleton-starter-hilla-react-gradle/archive/master.zip",
"hilla-lit-gradle" to "https://github.com/vaadin/skeleton-starter-hilla-lit-gradle/archive/master.zip",
"kotlin" to "https://github.com/vaadin/skeleton-starter-kotlin-spring/archive/master.zip",
"gradle-servlet" to "https://github.com/vaadin/base-starter-gradle/archive/v<version>.zip",
"gradle-springboot" to "https://github.com/vaadin/base-starter-spring-gradle/archive/v<version>.zip",
"springboot" to "https://github.com/vaadin/skeleton-starter-flow-spring/archive/v<version>.zip",
"quarkus" to "https://github.com/vaadin/base-starter-flow-quarkus/archive/v<version>.zip",
"jakartaee" to "https://github.com/vaadin/skeleton-starter-flow-cdi/archive/v<version>.zip",
"servlet" to "https://github.com/vaadin/skeleton-starter-flow/archive/v<version>.zip",
"osgi" to "https://github.com/vaadin/base-starter-flow-osgi/archive/v<version>.zip",
"karaf" to "https://github.com/vaadin/vaadin-flow-karaf-example/archive/v<version>.zip"
)

private val supportMatrix = arrayOf(
Expand All @@ -55,34 +46,13 @@ class StarterSupport {
buildTools.keys,
17
),
StarterSupportMatrixElement(
"23",
setOf("17"),
architectures.keys,
buildTools.keys,
11
),
StarterSupportMatrixElement(
"14",
setOf("17"),
setOf("springboot", "jakartaee", "servlet", "osgi"),
buildTools.keys,
8
),
StarterSupportMatrixElement(
"hilla-react",
setOf("17"),
setOf("springboot"),
buildTools.keys,
17
),
StarterSupportMatrixElement(
"hilla-lit",
setOf("17"),
setOf("springboot"),
buildTools.keys,
17
)
)


Expand Down
17 changes: 15 additions & 2 deletions src/main/kotlin/com/vaadin/plugin/utils/VaadinProjectUtil.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.vaadin.plugin.utils

import com.intellij.notification.Notification
import com.intellij.notification.NotificationType
import com.intellij.notification.Notifications
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.util.download.DownloadableFileService
import com.intellij.util.io.ZipUtil
import java.io.File
Expand All @@ -18,7 +22,9 @@ class VaadinProjectUtil {

private val LOG: Logger = Logger.getInstance(VaadinProjectUtil::class.java)

fun downloadAndExtract(project: Project, url: String) {
private const val NOTIFICATION_GROUP = "Vaadin"

fun downloadAndExtract(project: Project, url: String, callback: () -> Unit) {
val filename = "project.zip"
LOG.info("Downloading $filename")
val basePath: String = project.basePath!!
Expand All @@ -29,7 +35,7 @@ class VaadinProjectUtil {
DownloadableFileService.getInstance().createDownloader(listOf(description), "Vaadin Starter Project")

WriteCommandAction.runWriteCommandAction(project, "Create Vaadin Project", "Vaadin", {
downloader.downloadWithBackgroundProgress(basePath, project).thenApply {
downloader.downloadWithBackgroundProgress(basePath, project).thenAccept {
LOG.info("Extracting $downloadedFile")
ZipUtil.extract(downloadedFile.toPath(), Path.of(basePath), null)
// move contents from single zip directory
Expand All @@ -40,6 +46,7 @@ class VaadinProjectUtil {
}
FileUtil.delete(downloadedFile)
LOG.info("$downloadedFile deleted")
VirtualFileManager.getInstance().asyncRefresh(callback)
}
})
}
Expand All @@ -62,6 +69,12 @@ class VaadinProjectUtil {
}
}

fun notify(content: String, type: NotificationType, project: Project?) {
Notifications.Bus.notify(
Notification(NOTIFICATION_GROUP, content, type), project
)
}

}

}

0 comments on commit e5216e4

Please sign in to comment.