From 630d46491648678b2e1c8dcd6ccc369866098893 Mon Sep 17 00:00:00 2001 From: Marvin Elsen Date: Thu, 3 Oct 2024 13:38:40 +0200 Subject: [PATCH] Polish words and character list --- .../kotlin/com/marvinelsen/willow/Model.kt | 3 ++ .../ui/controllers/DetailsController.kt | 47 +++++++++++++++---- src/main/resources/fxml/details.fxml | 25 ++++++++-- src/main/resources/i18n/willow.properties | 2 + src/main/resources/i18n/willow_de.properties | 2 + src/main/resources/i18n/willow_en.properties | 2 + .../resources/i18n/willow_zh_CN.properties | 2 + .../resources/i18n/willow_zh_TW.properties | 2 + 8 files changed, 73 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/com/marvinelsen/willow/Model.kt b/src/main/kotlin/com/marvinelsen/willow/Model.kt index 1823638..7748fba 100644 --- a/src/main/kotlin/com/marvinelsen/willow/Model.kt +++ b/src/main/kotlin/com/marvinelsen/willow/Model.kt @@ -35,6 +35,7 @@ class Model( val isSearching: ReadOnlyBooleanProperty = searchService.runningProperty() val isFindingWords: ReadOnlyBooleanProperty = findWordsService.runningProperty() + val isFindingCharacters: ReadOnlyBooleanProperty = findCharacterService.runningProperty() init { searchService.onSucceeded = EventHandler { @@ -65,6 +66,8 @@ class Model( } fun selectEntry(entry: DictionaryEntryFx) { + internalWordsContaining.setAll(emptyList()) + internalCharacters.setAll(emptyList()) internalSelectedEntry.value = entry } diff --git a/src/main/kotlin/com/marvinelsen/willow/ui/controllers/DetailsController.kt b/src/main/kotlin/com/marvinelsen/willow/ui/controllers/DetailsController.kt index a97c420..484b5e7 100644 --- a/src/main/kotlin/com/marvinelsen/willow/ui/controllers/DetailsController.kt +++ b/src/main/kotlin/com/marvinelsen/willow/ui/controllers/DetailsController.kt @@ -11,6 +11,7 @@ import javafx.beans.binding.Bindings import javafx.fxml.FXML import javafx.scene.control.Label import javafx.scene.control.ListView +import javafx.scene.control.ProgressIndicator import javafx.scene.control.TabPane import javafx.scene.input.ContextMenuEvent import javafx.scene.layout.FlowPane @@ -48,6 +49,18 @@ class DetailsController(private val model: Model, private val config: Config) { @FXML private lateinit var listViewCharacters: ListView + @FXML + private lateinit var progressIndicatorCharacters: ProgressIndicator + + @FXML + private lateinit var progressIndicatorWords: ProgressIndicator + + @FXML + private lateinit var labelNoCharactersFound: Label + + @FXML + private lateinit var labelNoWordsFound: Label + @FXML private fun initialize() { @@ -132,14 +145,26 @@ class DetailsController(private val model: Model, private val config: Config) { listViewWords.apply { cellFactory = DictionaryEntryCellFactory(resources, config) items = model.wordsContaining + + disableProperty().bind(Bindings.or(model.isFindingWords, Bindings.isEmpty(model.wordsContaining))) } + progressIndicatorWords.visibleProperty().bind(model.isFindingWords) + labelNoWordsFound + .visibleProperty() + .bind(Bindings.and(Bindings.isEmpty(model.wordsContaining), Bindings.not(model.isFindingWords))) } private fun initializeListViewCharacters() { listViewCharacters.apply { cellFactory = DictionaryEntryCellFactory(resources, config) items = model.characters + + disableProperty().bind(Bindings.or(model.isFindingCharacters, Bindings.isEmpty(model.characters))) } + progressIndicatorCharacters.visibleProperty().bind(model.isFindingCharacters) + labelNoCharactersFound + .visibleProperty() + .bind(Bindings.and(Bindings.isEmpty(model.characters), Bindings.not(model.isFindingCharacters))) } private fun initializeWebViewDefinition() { @@ -180,15 +205,21 @@ class DetailsController(private val model: Model, private val config: Config) { ) } - private fun lazyUpdateTabContent(selectedTabId: String?) = when (selectedTabId) { - "tabWords" -> { - model.findWords() - } + private fun lazyUpdateTabContent(selectedTabId: String?) { + when (selectedTabId) { + "tabWords" -> { + if (model.wordsContaining.isNotEmpty()) return - "tabCharacters" -> { - model.findCharacters() - } + model.findWords() + } - else -> {} + "tabCharacters" -> { + if (model.characters.isNotEmpty()) return + + model.findCharacters() + } + + else -> {} + } } } diff --git a/src/main/resources/fxml/details.fxml b/src/main/resources/fxml/details.fxml index 1e02969..ceab00e 100644 --- a/src/main/resources/fxml/details.fxml +++ b/src/main/resources/fxml/details.fxml @@ -2,8 +2,7 @@ - - + - + + + + + - + + + + + diff --git a/src/main/resources/i18n/willow.properties b/src/main/resources/i18n/willow.properties index 759a409..a38a7a1 100644 --- a/src/main/resources/i18n/willow.properties +++ b/src/main/resources/i18n/willow.properties @@ -18,3 +18,5 @@ menubar.help=_Help menubar.help.about=_About… list.no_entries_found=No matching entries found search.mode.phrase=Phrase +list.no_characters_found=No characters found +list.no_words_found=No words found diff --git a/src/main/resources/i18n/willow_de.properties b/src/main/resources/i18n/willow_de.properties index 744236a..4d2d28e 100644 --- a/src/main/resources/i18n/willow_de.properties +++ b/src/main/resources/i18n/willow_de.properties @@ -18,3 +18,5 @@ menubar.help=_Hilfe menubar.help.about=_Über… list.no_entries_found=No matching entries found search.mode.phrase=Phrase +list.no_characters_found=No characters found +list.no_words_found=No words found diff --git a/src/main/resources/i18n/willow_en.properties b/src/main/resources/i18n/willow_en.properties index 759a409..a38a7a1 100644 --- a/src/main/resources/i18n/willow_en.properties +++ b/src/main/resources/i18n/willow_en.properties @@ -18,3 +18,5 @@ menubar.help=_Help menubar.help.about=_About… list.no_entries_found=No matching entries found search.mode.phrase=Phrase +list.no_characters_found=No characters found +list.no_words_found=No words found diff --git a/src/main/resources/i18n/willow_zh_CN.properties b/src/main/resources/i18n/willow_zh_CN.properties index 1f9d84d..7b84147 100644 --- a/src/main/resources/i18n/willow_zh_CN.properties +++ b/src/main/resources/i18n/willow_zh_CN.properties @@ -18,3 +18,5 @@ menubar.help=_說明 menubar.help.about=_關於 Willow… list.no_entries_found=No matching entries found search.mode.phrase=Phrase +list.no_characters_found=No characters found +list.no_words_found=No words found diff --git a/src/main/resources/i18n/willow_zh_TW.properties b/src/main/resources/i18n/willow_zh_TW.properties index 1f9d84d..7b84147 100644 --- a/src/main/resources/i18n/willow_zh_TW.properties +++ b/src/main/resources/i18n/willow_zh_TW.properties @@ -18,3 +18,5 @@ menubar.help=_說明 menubar.help.about=_關於 Willow… list.no_entries_found=No matching entries found search.mode.phrase=Phrase +list.no_characters_found=No characters found +list.no_words_found=No words found