Skip to content

Commit

Permalink
Add graalvm and application plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonScholz committed Nov 1, 2023
1 parent 8047f95 commit 7d44d6b
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 19 deletions.
9 changes: 8 additions & 1 deletion kotlin-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import io.gitlab.arturbosch.detekt.Detekt

plugins {
kotlin("jvm")
application

id("io.gitlab.arturbosch.detekt")
id("org.jlleitschuh.gradle.ktlint")

id("org.graalvm.buildtools.native") version "0.9.28"
}

repositories {
Expand All @@ -17,7 +20,11 @@ dependencies {
implementation("com.miglayout:miglayout-swing:11.2")
implementation("org.eclipse.platform:org.eclipse.core.databinding:1.13.100")
// Just for comparison with JFace implementation
//implementation("org.eclipse.platform:org.eclipse.jface.databinding:1.15.100")
// implementation("org.eclipse.platform:org.eclipse.jface.databinding:1.15.100")
}

application {
mainClass = "io.github.simonscholz.MainKt"
}

detekt {
Expand Down
10 changes: 5 additions & 5 deletions kotlin-app/src/main/kotlin/io/github/simonscholz/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import io.github.simonscholz.qrcode.QrCodeFactory
import io.github.simonscholz.ui.ImageUI
import io.github.simonscholz.ui.MainUI
import io.github.simonscholz.ui.PropertiesUI
import org.eclipse.core.databinding.DataBindingContext
import java.awt.Component
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent
import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO
import org.eclipse.core.databinding.DataBindingContext
import javax.swing.JFrame
import javax.swing.JOptionPane
import javax.swing.SwingUtilities
Expand All @@ -35,7 +35,7 @@ fun main() {

val (imagePanel, setImage) = ImageUI.createImagePanel()
val (propertiesPanel, applyOnChange) = PropertiesUI.createPropertiesUI(qrCodeConfigViewModel, dataBindingContext) {
if(qrCodeConfigViewModel.qrCodeContent.value.isNotBlank()) {
if (qrCodeConfigViewModel.qrCodeContent.value.isNotBlank()) {
val qrCodeImage = renderImage(qrCodeConfigViewModel, frame)
setImage(qrCodeImage)
}
Expand All @@ -49,8 +49,8 @@ fun main() {

dataBindingContext.bindings.forEach {
it.model.addChangeListener {
if(applyOnChange()) {
if(qrCodeConfigViewModel.qrCodeContent.value.isNotBlank()) {
if (applyOnChange()) {
if (qrCodeConfigViewModel.qrCodeContent.value.isNotBlank()) {
val qrCodeImage = renderImage(qrCodeConfigViewModel, frame)
setImage(qrCodeImage)
}
Expand All @@ -72,7 +72,7 @@ private fun renderImage(qrCodeConfigViewModel: QrCodeConfigViewModel, component:
relativeSize = qrCodeConfigViewModel.relativeBorderSize.value,
relativeBorderRound = qrCodeConfigViewModel.borderRadius.value,
)
if(qrCodeConfigViewModel.logo.value.isNotBlank() && File(qrCodeConfigViewModel.logo.value).exists()) {
if (qrCodeConfigViewModel.logo.value.isNotBlank() && File(qrCodeConfigViewModel.logo.value).exists()) {
runCatching {
ImageIO.read(File(qrCodeConfigViewModel.logo.value)).let {
builder.qrLogoConfig(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package io.github.simonscholz.extension
import io.github.simonscholz.observables.BackgroundColorObservable
import io.github.simonscholz.observables.DocumentObservable
import io.github.simonscholz.observables.JSpinnerIntObservable
import org.eclipse.core.databinding.observable.value.IObservableValue
import java.awt.Color
import java.awt.Component
import org.eclipse.core.databinding.observable.value.IObservableValue
import javax.swing.JSpinner
import javax.swing.text.JTextComponent

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.simonscholz.observables

import java.awt.Color
import java.awt.Component
import org.eclipse.core.databinding.observable.Diffs
import org.eclipse.core.databinding.observable.value.AbstractObservableValue
import java.awt.Color
import java.awt.Component

class BackgroundColorObservable(
private val component: Component,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.simonscholz.observables

import org.eclipse.core.databinding.observable.Diffs
import org.eclipse.core.databinding.observable.value.AbstractObservableValue
import javax.swing.event.DocumentEvent
import javax.swing.event.DocumentListener
import javax.swing.text.Document
import javax.swing.text.JTextComponent
import org.eclipse.core.databinding.observable.Diffs
import org.eclipse.core.databinding.observable.value.AbstractObservableValue

class DocumentObservable(private val document: Document) : AbstractObservableValue<String>() {
private var documentValue = document.getText(0, document.length)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.github.simonscholz.observables

import javax.swing.SwingUtilities
import org.eclipse.core.databinding.observable.Realm
import javax.swing.SwingUtilities

class SwingRealm: Realm() {
class SwingRealm : Realm() {

init {
setDefault(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import io.github.simonscholz.extension.toIntObservable
import io.github.simonscholz.extension.toObservable
import io.github.simonscholz.model.QrCodeConfigViewModel
import io.github.simonscholz.ui.properties.BorderPropertiesUI
import net.miginfocom.swing.MigLayout
import org.eclipse.core.databinding.DataBindingContext
import org.eclipse.core.databinding.observable.value.IObservableValue
import java.awt.Color
import java.io.File
import javax.swing.JButton
Expand All @@ -18,10 +21,6 @@ import javax.swing.JTextArea
import javax.swing.JTextField
import javax.swing.SpinnerNumberModel
import javax.swing.filechooser.FileNameExtensionFilter
import net.miginfocom.swing.MigLayout
import org.eclipse.core.databinding.DataBindingContext
import org.eclipse.core.databinding.observable.value.IObservableValue


object PropertiesUI {

Expand Down Expand Up @@ -80,7 +79,7 @@ object PropertiesUI {
return Pair(propertiesPanel, applyOnChange::isSelected)
}

private fun createColorPickerFormItem(propertiesPanel: JPanel, labelText: String, model : IObservableValue<Color>, dataBindingContext: DataBindingContext) {
private fun createColorPickerFormItem(propertiesPanel: JPanel, labelText: String, model: IObservableValue<Color>, dataBindingContext: DataBindingContext) {
propertiesPanel.add(JLabel(labelText))
val colorPicker = JButton("Choose Color").apply {
isFocusPainted = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.github.simonscholz.extension.toBackgroundColorObservable
import io.github.simonscholz.extension.toObservable
import io.github.simonscholz.model.QrCodeConfigViewModel
import net.miginfocom.swing.MigLayout
import org.eclipse.core.databinding.DataBindingContext
import java.awt.Color
import javax.swing.BorderFactory
import javax.swing.JButton
Expand All @@ -12,7 +13,6 @@ import javax.swing.JLabel
import javax.swing.JPanel
import javax.swing.JTextField
import javax.swing.border.TitledBorder
import org.eclipse.core.databinding.DataBindingContext

object BorderPropertiesUI {
fun createBorderPropertiesUI(dataBindingContext: DataBindingContext, qrCodeConfigViewModel: QrCodeConfigViewModel): JPanel {
Expand Down

0 comments on commit 7d44d6b

Please sign in to comment.