mirror of
https://github.com/frosch95/SmartCSV.fx.Converter.git
synced 2026-04-11 13:48:22 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2af617d576 |
@@ -1,5 +1,5 @@
|
|||||||
group 'ninja.javafx'
|
group 'ninja.javafx'
|
||||||
version '1.0-SNAPSHOT'
|
version '1.1-SNAPSHOT'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.0.4'
|
ext.kotlin_version = '1.0.4'
|
||||||
@@ -15,7 +15,7 @@ buildscript {
|
|||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
|
|
||||||
mainClassName = 'ninja.javafx.smartcsv.fx.converter.ConverterKt'
|
mainClassName = 'ninja.javafx.smartcsv.fx.converter.ConverterFX'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -25,4 +25,5 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
compile 'com.beust:klaxon:0.24'
|
compile 'com.beust:klaxon:0.24'
|
||||||
|
compile 'no.tornado:tornadofx:1.5.6'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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