Fix detekt issues
All checks were successful
Pull Request / build (pull_request) Successful in 3m37s
All checks were successful
Pull Request / build (pull_request) Successful in 3m37s
This commit is contained in:
parent
62c57d1e85
commit
7add73fe28
@ -3,10 +3,10 @@ package com.marvinelsen.willow
|
|||||||
import com.marvinelsen.willow.config.Config
|
import com.marvinelsen.willow.config.Config
|
||||||
import com.marvinelsen.willow.domain.SqliteDictionary
|
import com.marvinelsen.willow.domain.SqliteDictionary
|
||||||
import com.marvinelsen.willow.ui.controllers.DetailsController
|
import com.marvinelsen.willow.ui.controllers.DetailsController
|
||||||
import com.marvinelsen.willow.ui.controllers.SearchResultsController
|
|
||||||
import com.marvinelsen.willow.ui.controllers.MainController
|
import com.marvinelsen.willow.ui.controllers.MainController
|
||||||
import com.marvinelsen.willow.ui.controllers.MenuController
|
import com.marvinelsen.willow.ui.controllers.MenuController
|
||||||
import com.marvinelsen.willow.ui.controllers.SearchController
|
import com.marvinelsen.willow.ui.controllers.SearchController
|
||||||
|
import com.marvinelsen.willow.ui.controllers.SearchResultsController
|
||||||
import com.marvinelsen.willow.ui.util.FindWordsService
|
import com.marvinelsen.willow.ui.util.FindWordsService
|
||||||
import com.marvinelsen.willow.ui.util.SearchService
|
import com.marvinelsen.willow.ui.util.SearchService
|
||||||
import javafx.application.Application
|
import javafx.application.Application
|
||||||
|
@ -6,7 +6,6 @@ import javafx.beans.property.StringProperty
|
|||||||
import javafx.collections.FXCollections
|
import javafx.collections.FXCollections
|
||||||
import javafx.collections.ObservableList
|
import javafx.collections.ObservableList
|
||||||
|
|
||||||
// TODO: Consider removing this class completely if no property is ever used directly
|
|
||||||
data class DictionaryEntryFx(
|
data class DictionaryEntryFx(
|
||||||
val traditionalProperty: StringProperty,
|
val traditionalProperty: StringProperty,
|
||||||
val simplifiedProperty: StringProperty,
|
val simplifiedProperty: StringProperty,
|
||||||
|
@ -46,54 +46,14 @@ class DetailsController(private val model: Model, private val config: Config) {
|
|||||||
@FXML
|
@FXML
|
||||||
@Suppress("UnusedPrivateMember")
|
@Suppress("UnusedPrivateMember")
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
labelHeadword.textProperty().bind(
|
initializeLabelHeadword()
|
||||||
Bindings.createStringBinding(
|
initializeTabPaneDetails()
|
||||||
{
|
initializeListViewWords()
|
||||||
when (config.script.value!!) {
|
initializeWebViewDefinition()
|
||||||
Script.SIMPLIFIED -> model.selectedEntry.value?.simplifiedProperty?.value
|
|
||||||
Script.TRADITIONAL -> model.selectedEntry.value?.traditionalProperty?.value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
config.script,
|
|
||||||
model.selectedEntry
|
|
||||||
)
|
|
||||||
)
|
|
||||||
labelHeadword
|
|
||||||
.styleProperty()
|
|
||||||
.bind(
|
|
||||||
Bindings.concat(
|
|
||||||
"-fx-font-size: ",
|
|
||||||
config.detailHeadwordFontSize.asString(),
|
|
||||||
"px;"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
tabPaneDetails.disableProperty().bind(Bindings.isNull(model.selectedEntry))
|
model.selectedEntry.addListener { _, _, newEntry ->
|
||||||
|
if (newEntry == null) return@addListener
|
||||||
|
|
||||||
listViewWords.cellFactory = DictionaryEntryCellFactory(resources, config)
|
|
||||||
listViewWords.items = model.wordsContaining
|
|
||||||
tabPaneDetails.selectionModel.selectedItemProperty().addListener { _, _, selectedTab ->
|
|
||||||
if (model.selectedEntry.value == null) return@addListener
|
|
||||||
|
|
||||||
when (selectedTab.id) {
|
|
||||||
"tabWords" -> {
|
|
||||||
model.findWords()
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
webViewDefinition.apply {
|
|
||||||
isContextMenuEnabled = false
|
|
||||||
engine.userStyleSheetLocation =
|
|
||||||
this::class.java.getResource("/css/definitions.css")!!.toExternalForm()
|
|
||||||
}
|
|
||||||
|
|
||||||
model.selectedEntry.addListener { _, _, newValue ->
|
|
||||||
if (newValue == null) {
|
|
||||||
return@addListener
|
|
||||||
}
|
|
||||||
when (tabPaneDetails.selectionModel.selectedItem.id) {
|
when (tabPaneDetails.selectionModel.selectedItem.id) {
|
||||||
"tabWords" -> {
|
"tabWords" -> {
|
||||||
model.findWords()
|
model.findWords()
|
||||||
@ -101,22 +61,71 @@ class DetailsController(private val model: Model, private val config: Config) {
|
|||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
webViewDefinition.engine.loadContent(
|
webViewDefinition.engine.loadContent(newEntry.createCedictDefinitionHtml())
|
||||||
createHTML().html {
|
}
|
||||||
body {
|
}
|
||||||
h1 {
|
|
||||||
+"CC-CEDICT"
|
private fun initializeWebViewDefinition() {
|
||||||
}
|
webViewDefinition.apply {
|
||||||
ol {
|
engine.userStyleSheetLocation = this::class.java.getResource("/css/definitions.css")!!.toExternalForm()
|
||||||
for (definition in newValue.definitions) {
|
}
|
||||||
li {
|
}
|
||||||
+definition.joinToString(separator = "; ")
|
|
||||||
}
|
private fun initializeListViewWords() {
|
||||||
}
|
listViewWords.apply {
|
||||||
|
cellFactory = DictionaryEntryCellFactory(resources, config)
|
||||||
|
items = model.wordsContaining
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeTabPaneDetails() {
|
||||||
|
tabPaneDetails.apply {
|
||||||
|
disableProperty().bind(Bindings.isNull(model.selectedEntry))
|
||||||
|
|
||||||
|
selectionModel.selectedItemProperty().addListener { _, _, selectedTab ->
|
||||||
|
if (model.selectedEntry.value == null) return@addListener
|
||||||
|
|
||||||
|
when (selectedTab.id) {
|
||||||
|
"tabWords" -> {
|
||||||
|
model.findWords()
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeLabelHeadword() {
|
||||||
|
labelHeadword.apply {
|
||||||
|
textProperty().bind(
|
||||||
|
Bindings.createStringBinding(
|
||||||
|
{
|
||||||
|
when (config.script.value!!) {
|
||||||
|
Script.SIMPLIFIED -> model.selectedEntry.value?.simplifiedProperty?.value
|
||||||
|
Script.TRADITIONAL -> model.selectedEntry.value?.traditionalProperty?.value
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
config.script,
|
||||||
|
model.selectedEntry
|
||||||
|
)
|
||||||
|
)
|
||||||
|
styleProperty().bind(Bindings.concat("-fx-font-size: ", config.detailHeadwordFontSize.asString(), "px;"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun DictionaryEntryFx.createCedictDefinitionHtml() = createHTML().html {
|
||||||
|
body {
|
||||||
|
h1 {
|
||||||
|
+"CC-CEDICT"
|
||||||
|
}
|
||||||
|
ol {
|
||||||
|
for (definition in this@createCedictDefinitionHtml.definitions) {
|
||||||
|
li {
|
||||||
|
+definition.joinToString(separator = "; ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,6 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
|
|||||||
CHANGES, NO_CHANGES
|
CHANGES, NO_CHANGES
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
|
||||||
private lateinit var comboBoxPronunciationDetails: ComboBox<Pronunciation>
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var comboBoxLocale: ComboBox<Locale>
|
private lateinit var comboBoxLocale: ComboBox<Locale>
|
||||||
|
|
||||||
@ -79,7 +76,6 @@ class PreferencesDialog(owner: Window?, config: Config) : Dialog<PreferencesDial
|
|||||||
val root: DialogPane = loader.load()
|
val root: DialogPane = loader.load()
|
||||||
|
|
||||||
dialogPane = root
|
dialogPane = root
|
||||||
// TODO: Use resource bundle string
|
|
||||||
title = "Settings"
|
title = "Settings"
|
||||||
isResizable = true
|
isResizable = true
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user