Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ronove
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kaj Koivunen
Ronove
Commits
8e257800
Commit
8e257800
authored
2 years ago
by
Kaj Koivunen
Browse files
Options
Downloads
Patches
Plain Diff
asetusvalikko
parent
00d7f0c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/kotlin/SettingsView.kt
+83
-0
83 additions, 0 deletions
src/main/kotlin/SettingsView.kt
with
83 additions
and
0 deletions
src/main/kotlin/SettingsView.kt
0 → 100644
+
83
−
0
View file @
8e257800
package
guru.kake.ronove
import
javafx.scene.control.*
import
javafx.scene.paint.Color
import
tornadofx.*
class
SettingsView
:
View
(
"Settings"
)
{
private
lateinit
var
deeplKey
:
PasswordField
private
lateinit
var
deeplStatus
:
Label
private
lateinit
var
deeplRadio
:
RadioButton
private
lateinit
var
googleKey
:
PasswordField
private
lateinit
var
googleStatus
:
Label
private
lateinit
var
googleRadio
:
RadioButton
private
lateinit
var
applyButton
:
Button
private
val
toggleGroup
=
ToggleGroup
()
private
var
deeplService
:
TranslationService
?
=
null
private
var
googleService
:
TranslationService
?
=
null
override
val
root
=
form
{
deeplRadio
=
radiobutton
(
"DeepL"
,
toggleGroup
)
{
action
{
updateButton
()
}
}
fieldset
()
{
field
(
"API key"
)
{
deeplKey
=
passwordfield
()
}
button
(
"Save & test"
)
{
action
{
try
{
deeplService
=
DeepLTranslator
(
deeplKey
.
text
)
deeplStatus
.
text
=
"API initialized succesfully!"
deeplStatus
.
textFill
=
Color
.
GREEN
}
catch
(
e
:
TranslationServiceException
)
{
deeplStatus
.
text
=
e
.
message
deeplStatus
.
textFill
=
Color
.
RED
}
finally
{
updateButton
()
}
}
}
deeplStatus
=
label
()
}
googleRadio
=
radiobutton
(
"Google Translate"
,
toggleGroup
)
{
action
{
updateButton
()
}
}
fieldset
()
{
field
(
"API key"
)
{
googleKey
=
passwordfield
()
}
button
(
"Save & test"
)
{
}
googleStatus
=
label
()
}
hbox
{
applyButton
=
button
(
"Apply"
)
{
isDefaultButton
=
true
isDisable
=
true
action
{
when
(
toggleGroup
.
selectedToggle
)
{
googleRadio
->
TranslationBackend
.
service
=
googleService
deeplRadio
->
TranslationBackend
.
service
=
deeplService
else
->
assert
(
false
)
}
}
}
button
(
"Cancel"
)
{
isCancelButton
=
true
action
{
close
()
}
}
}
}
private
fun
updateButton
()
{
applyButton
.
isDisable
=
when
(
toggleGroup
.
selectedToggle
)
{
googleRadio
->
googleService
==
null
deeplRadio
->
deeplService
==
null
else
->
true
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment