mirror of
https://github.com/frosch95/SmartCSV.fx.Converter.git
synced 2026-04-11 13:48:22 +02:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 265e3f7f70 | |||
| a386abe617 | |||
| 2af617d576 |
23
build.gradle
23
build.gradle
@@ -1,8 +1,5 @@
|
||||
group 'ninja.javafx'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.0.4'
|
||||
ext.kotlin_version = '1.3.72'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -12,17 +9,27 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = 'ninja.javafx.smartcsv.fx.converter.ConverterKt'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
|
||||
id 'application'
|
||||
id 'org.openjfx.javafxplugin' version '0.0.8'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
javafx {
|
||||
modules = [ 'javafx.controls', 'javafx.fxml' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
compile 'com.beust:klaxon:0.24'
|
||||
compile 'no.tornado:tornadofx:1.5.6'
|
||||
}
|
||||
|
||||
group 'ninja.javafx'
|
||||
version '1.1-SNAPSHOT'
|
||||
mainClassName = 'ninja.javafx.smartcsv.fx.converter.ConverterFX'
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.13-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
|
||||
|
||||
@@ -85,11 +85,9 @@ class Converter(val name: String) {
|
||||
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun constraint(column : JsonObject, key : String, value: Any?) {
|
||||
if (value == null) return
|
||||
val constraints = column["constraints"] as JsonObject? ?: JsonObject(HashMap<String, Any>())
|
||||
column["constraints"] = constraints
|
||||
val constraints = column.getOrPut("constraints") { JsonObject(mutableMapOf()) } as JsonObject
|
||||
constraints[key] = value
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
Copyright (c) 2016 javafx.ninja <info@javafx.ninja>
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
package ninja.javafx.smartcsv.fx.converter
|
||||
|
||||
import javafx.geometry.Insets
|
||||
import javafx.scene.control.Label
|
||||
import javafx.scene.layout.GridPane
|
||||
import javafx.scene.layout.Priority
|
||||
import javafx.stage.FileChooser
|
||||
import tornadofx.*
|
||||
|
||||
class ConverterFX : App() {
|
||||
override val primaryView = FileInputView::class
|
||||
|
||||
|
||||
}
|
||||
|
||||
class FileInput {
|
||||
var name by property<String>()
|
||||
fun nameProperty() = getProperty(FileInput::name)
|
||||
}
|
||||
|
||||
class FileInputView : View("SmartCSV.fx Converter") {
|
||||
override val root = GridPane()
|
||||
private val fileinput = FileInput()
|
||||
private val fileChooser = FileChooser()
|
||||
private val state = Label()
|
||||
|
||||
val controller: FileInputController by inject()
|
||||
|
||||
|
||||
init {
|
||||
primaryStage.width = 600.0
|
||||
primaryStage.height = 120.0
|
||||
|
||||
fileChooser.title = "Open old config file"
|
||||
fileChooser.extensionFilters.addAll(FileChooser.ExtensionFilter("JSON Files", "*.json"))
|
||||
|
||||
with(root) {
|
||||
|
||||
padding = Insets(8.0, 8.0, 8.0, 8.0)
|
||||
|
||||
root.vgap = 8.0
|
||||
root.hgap = 8.0
|
||||
|
||||
textfield() {
|
||||
isEditable = false
|
||||
isDisable = false
|
||||
isMouseTransparent = true
|
||||
isFocusTraversable = false
|
||||
useMaxWidth = true
|
||||
bind(fileinput.nameProperty())
|
||||
gridpaneConstraints {
|
||||
columnRowIndex(0, 0)
|
||||
hGrow = Priority.ALWAYS
|
||||
}
|
||||
}
|
||||
|
||||
button("Select File") {
|
||||
gridpaneConstraints {
|
||||
columnRowIndex(1, 0)
|
||||
}
|
||||
setOnAction {
|
||||
state.text = null
|
||||
val selectedFile = fileChooser.showOpenDialog(primaryStage)
|
||||
if (selectedFile != null) {
|
||||
fileinput.name = selectedFile.absolutePath
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this += state
|
||||
state.gridpaneConstraints {
|
||||
columnRowIndex(0, 1)
|
||||
}
|
||||
|
||||
|
||||
button("Convert") {
|
||||
gridpaneConstraints {
|
||||
columnRowIndex(1, 1)
|
||||
}
|
||||
setOnAction {
|
||||
controller.convert(fileinput.name)
|
||||
state.text = "converted ${fileinput.name}"
|
||||
fileinput.name = null
|
||||
}
|
||||
disableProperty().bind(fileinput.nameProperty().isNull)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FileInputController : Controller() {
|
||||
|
||||
fun convert(inputValue: String) {
|
||||
Converter(inputValue).convert()
|
||||
println("Converted $inputValue!")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user