Skip to content

Commit

Permalink
Java/JavaFX 11 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kubovy committed Mar 30, 2020
1 parent aec295d commit a68d9c4
Show file tree
Hide file tree
Showing 33 changed files with 99 additions and 546 deletions.
28 changes: 0 additions & 28 deletions alert-manager/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
plugins {
id 'org.jetbrains.kotlin.jvm'// version '1.3.11'
}

group 'com.poterion.monitor'
version '1.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}

dependencies {
api project(':api')
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ class AlertManagerService(override val controller: ControllerInterface, config:
} else {
LOGGER.warn("${call?.request()?.method()} ${call?.request()?.url()}:" +
" ${response?.code()} ${response?.message()}")
error = response?.let { "Code: ${it.code()} ${it.message() ?: ""}" } ?: "Service error"
error = response?.let { "Code: ${it.code()} ${it.message()}" } ?: "Service error"
updater(getStatusItems("Service error", Status.SERVICE_ERROR,
response?.let { "Code: ${it.code()} ${it.message() ?: ""}" }))
response?.let { "Code: ${it.code()} ${it.message()}" }))
}
} catch (e: IOException) {
LOGGER.error(e.message)
Expand Down
32 changes: 4 additions & 28 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
plugins {
id 'org.jetbrains.kotlin.jvm'// version '1.3.11'
}

group 'com.poterion.monitor'
version '1.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}

dependencies {
compile project(':data')
compile project(':javafx-utils')
compile project(':kotlin-utils')
api project(':serial-communication')
// JavaFX
compileOnly 'org.openjfx:javafx-controls:11'
compileOnly 'org.openjfx:javafx-graphics:11'
compileOnly 'org.openjfx:javafx-fxml:11'
// Jackson
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.10.1'
implementation 'com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.1'
Expand Down
35 changes: 35 additions & 0 deletions api/src/main/java/com/poterion/monitor/api/Converters.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/******************************************************************************
* Copyright (c) 2020 Jan Kubovy <[email protected]> *
* *
* This program is free software: you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the Free *
* Software Foundation, version 3. *
* *
* This program is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
* for more details. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program. If not, see <https://www.gnu.org/licenses/>. *
******************************************************************************/
package com.poterion.monitor.api

import com.poterion.communication.serial.payload.RgbColor
import javafx.scene.paint.Color
import kotlin.math.roundToInt

/**
* Converts [RgbColor] to [Color].
* @author Jan Kubovy [[email protected]]
*/
fun RgbColor.toColor() = Color.rgb(red, green, blue)

/**
* Converts a [Color] to [RgbColor].
* @author Jan Kubovy [[email protected]]
*/
fun Color.toRGBColor(): RgbColor = listOf(red, green, blue)
.map { (it * 255.0).roundToInt() }
.let { (red, green, blue) -> RgbColor(red, green, blue) }

49 changes: 27 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
id 'org.jetbrains.kotlin.jvm' version '1.3.71'
id 'de.undercouch.download' version '4.0.0'
id 'idea'
}

group 'com.poterion.monitor'
version project.hasProperty('version') && project.version != "unspecified" ? project.version : '1.0-SNAPSHOT'
allprojects {
group 'com.poterion.monitor'
version project.hasProperty('version') && project.version != "unspecified" ? project.version : '1.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
apply plugin: 'org.jetbrains.kotlin.jvm'

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
tasks.withType(JavaCompile.class) {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}

tasks.withType(KotlinCompile.class) {
kotlinOptions {
freeCompilerArgs = [ "-Xjsr305=strict" ]
jvmTarget = "11"
}
}

repositories {
mavenCentral()
jcenter()
google()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://www.dcm4che.org/maven2/' }
}
}

task writePropertyFile(group: 'build') {
Expand All @@ -43,15 +57,6 @@ task assembleFatJar(type: Jar, group: 'build', dependsOn: [assemble]) {
with jar
}

repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}

dependencies {
// Common
api project(':api')
Expand All @@ -72,7 +77,7 @@ dependencies {
compile project(':notifications')
compile project(':system-tray')
// Kotlin
compile 'org.jetbrains.kotlin:kotlin-reflect:1.3.61'
compile 'org.jetbrains.kotlin:kotlin-reflect:1.3.71'
// Commons
compile 'commons-cli:commons-cli:1.4'
// Logging
Expand Down
28 changes: 0 additions & 28 deletions control/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
plugins {
id 'org.jetbrains.kotlin.jvm'// version '1.3.11'
}

group 'com.poterion.monitor'
version '1.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}

dependencies {
api project(':api')
}
32 changes: 3 additions & 29 deletions data/build.gradle
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
plugins {
id 'org.jetbrains.kotlin.jvm'// version '1.3.11'
}

group 'com.poterion.monitor'
version '1.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}

dependencies {
compile project(':javafx-utils')
// Kotlin
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.61'
implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.71'
// JavaFX
compileOnly 'org.openjfx:javafx-base:11'
// Jackson
compile 'com.fasterxml.jackson.core:jackson-annotations:2.10.1'
compile 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
Expand Down
30 changes: 1 addition & 29 deletions deployment-case/build.gradle
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
plugins {
id 'org.jetbrains.kotlin.jvm'// version '1.3.11'
}

group 'com.poterion.monitor'
version '1.0-SNAPSHOT'

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}

repositories {
mavenCentral()
jcenter()
google()
maven {
url 'https://www.dcm4che.org/maven2/'
}
}

dependencies {
api project(':serial-communication')
api project(':api')
// Jinja
implementation 'com.hubspot.jinjava:jinjava:2.5.2'
// Testing
testImplementation 'junit:junit:4.13'
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.3.61"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:1.3.71"
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ConfigWindowTabDevices {
override fun updateItem(item: Type?, empty: Boolean) {
super.updateItem(item, empty)
@Suppress("UNCHECKED_CAST")
text = transformer(tableRow.item as? Entry, item)
text = transformer(tableRow.item, item)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@
******************************************************************************/
package com.poterion.monitor.notifiers.deploymentcase.ui

import com.poterion.communication.serial.toColor
import com.poterion.communication.serial.toHex
import com.poterion.monitor.notifiers.deploymentcase.control.findInStateMachine
import com.poterion.monitor.notifiers.deploymentcase.data.Action
import com.poterion.monitor.notifiers.deploymentcase.data.DeploymentCaseConfig
import com.poterion.monitor.notifiers.deploymentcase.data.LightPattern
import com.poterion.monitor.notifiers.deploymentcase.data.SharedUiData
import com.poterion.monitor.notifiers.deploymentcase.data.Variable
import com.poterion.monitor.notifiers.deploymentcase.data.VariableType
import com.poterion.monitor.notifiers.deploymentcase.data.*
import com.poterion.monitor.notifiers.deploymentcase.getDisplayString
import com.poterion.utils.javafx.autoFitTable
import com.poterion.utils.javafx.toColor
import com.poterion.utils.javafx.toHex
import com.poterion.utils.javafx.toObservableList
import com.poterion.utils.kotlin.noop
import javafx.beans.InvalidationListener
Expand All @@ -35,18 +30,7 @@ import javafx.collections.ListChangeListener
import javafx.fxml.FXML
import javafx.fxml.FXMLLoader
import javafx.scene.Parent
import javafx.scene.control.Alert
import javafx.scene.control.Button
import javafx.scene.control.ButtonType
import javafx.scene.control.CheckBox
import javafx.scene.control.ColorPicker
import javafx.scene.control.ComboBox
import javafx.scene.control.Label
import javafx.scene.control.Slider
import javafx.scene.control.TableCell
import javafx.scene.control.TableColumn
import javafx.scene.control.TableView
import javafx.scene.control.TextField
import javafx.scene.control.*
import javafx.scene.control.cell.PropertyValueFactory
import javafx.scene.input.KeyCode
import javafx.scene.input.KeyEvent
Expand Down Expand Up @@ -203,7 +187,7 @@ class ConfigWindowTabVariables {
override fun startEdit() {
super.startEdit()
val entry = tableView.items[index]
if (!isEmpty && !isReadOnly(tableRow.item as? Variable)) {
if (!isEmpty && !isReadOnly(tableRow.item)) {
text = null
graphic = when (entry.type) {
VariableType.BOOLEAN -> createCheckBox()
Expand Down Expand Up @@ -422,7 +406,7 @@ class ConfigWindowTabVariables {
override fun startEdit() {
super.startEdit()
@Suppress("UNCHECKED_CAST")
if (!isEmpty && !isReadOnly(tableRow.item as? Entry)) {
if (!isEmpty && !isReadOnly(tableRow.item)) {
text = null
graphic = createComboBox()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun <Entry> TableColumn<Entry, String>.initEditableText(propertyName: String,

override fun startEdit() {
super.startEdit()
if (!isEmpty && !isReadOnly(tableRow?.item as? Entry)) {
if (!isEmpty && !isReadOnly(tableRow?.item)) {
text = null
graphic = createTextField()
textField?.selectAll()
Expand All @@ -69,7 +69,7 @@ fun <Entry> TableColumn<Entry, String>.initEditableText(propertyName: String,
} else {
text = item
graphic = null
style = styler(tableRow?.item as? Entry)
style = styler(tableRow?.item)
}
}

Expand Down
Loading

0 comments on commit a68d9c4

Please sign in to comment.