New Features #1

Open
marvinelsen wants to merge 76 commits from develop into main
8 changed files with 73 additions and 12 deletions
Showing only changes of commit 630d464916 - Show all commits

View File

@ -35,6 +35,7 @@ class Model(
val isSearching: ReadOnlyBooleanProperty = searchService.runningProperty() val isSearching: ReadOnlyBooleanProperty = searchService.runningProperty()
val isFindingWords: ReadOnlyBooleanProperty = findWordsService.runningProperty() val isFindingWords: ReadOnlyBooleanProperty = findWordsService.runningProperty()
val isFindingCharacters: ReadOnlyBooleanProperty = findCharacterService.runningProperty()
init { init {
searchService.onSucceeded = EventHandler { searchService.onSucceeded = EventHandler {
@ -65,6 +66,8 @@ class Model(
} }
fun selectEntry(entry: DictionaryEntryFx) { fun selectEntry(entry: DictionaryEntryFx) {
internalWordsContaining.setAll(emptyList())
internalCharacters.setAll(emptyList())
internalSelectedEntry.value = entry internalSelectedEntry.value = entry
} }

View File

@ -11,6 +11,7 @@ import javafx.beans.binding.Bindings
import javafx.fxml.FXML import javafx.fxml.FXML
import javafx.scene.control.Label import javafx.scene.control.Label
import javafx.scene.control.ListView import javafx.scene.control.ListView
import javafx.scene.control.ProgressIndicator
import javafx.scene.control.TabPane import javafx.scene.control.TabPane
import javafx.scene.input.ContextMenuEvent import javafx.scene.input.ContextMenuEvent
import javafx.scene.layout.FlowPane import javafx.scene.layout.FlowPane
@ -48,6 +49,18 @@ class DetailsController(private val model: Model, private val config: Config) {
@FXML @FXML
private lateinit var listViewCharacters: ListView<DictionaryEntryFx> private lateinit var listViewCharacters: ListView<DictionaryEntryFx>
@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 @FXML
private fun initialize() { private fun initialize() {
@ -132,14 +145,26 @@ class DetailsController(private val model: Model, private val config: Config) {
listViewWords.apply { listViewWords.apply {
cellFactory = DictionaryEntryCellFactory(resources, config) cellFactory = DictionaryEntryCellFactory(resources, config)
items = model.wordsContaining 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() { private fun initializeListViewCharacters() {
listViewCharacters.apply { listViewCharacters.apply {
cellFactory = DictionaryEntryCellFactory(resources, config) cellFactory = DictionaryEntryCellFactory(resources, config)
items = model.characters 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() { private fun initializeWebViewDefinition() {
@ -180,15 +205,21 @@ class DetailsController(private val model: Model, private val config: Config) {
) )
} }
private fun lazyUpdateTabContent(selectedTabId: String?) = when (selectedTabId) { private fun lazyUpdateTabContent(selectedTabId: String?) {
"tabWords" -> { when (selectedTabId) {
model.findWords() "tabWords" -> {
} if (model.wordsContaining.isNotEmpty()) return
"tabCharacters" -> { model.findWords()
model.findCharacters() }
}
else -> {} "tabCharacters" -> {
if (model.characters.isNotEmpty()) return
model.findCharacters()
}
else -> {}
}
} }
} }

View File

@ -2,8 +2,7 @@
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.FlowPane?> <?import javafx.scene.layout.*?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.web.WebView?> <?import javafx.scene.web.WebView?>
<VBox xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1" <VBox xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="com.marvinelsen.willow.ui.controllers.DetailsController" fx:controller="com.marvinelsen.willow.ui.controllers.DetailsController"
@ -29,10 +28,28 @@
<ListView fx:id="listViewSentences"/> <ListView fx:id="listViewSentences"/>
</Tab> </Tab>
<Tab id="tabWords" closable="false" text="%tab.words"> <Tab id="tabWords" closable="false" text="%tab.words">
<ListView fx:id="listViewWords"/> <StackPane>
<ListView fx:id="listViewWords"/>
<Label fx:id="labelNoWordsFound" text="%list.no_words_found" textAlignment="CENTER"
visible="false" wrapText="true">
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
</padding>
</Label>
<ProgressIndicator fx:id="progressIndicatorWords" visible="false"/>
</StackPane>
</Tab> </Tab>
<Tab id="tabCharacters" closable="false" text="%tab.characters"> <Tab id="tabCharacters" closable="false" text="%tab.characters">
<ListView fx:id="listViewCharacters"/> <StackPane>
<ListView fx:id="listViewCharacters"/>
<Label fx:id="labelNoCharactersFound" text="%list.no_characters_found" textAlignment="CENTER"
visible="false" wrapText="true">
<padding>
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
</padding>
</Label>
<ProgressIndicator fx:id="progressIndicatorCharacters" visible="false"/>
</StackPane>
</Tab> </Tab>
</TabPane> </TabPane>
</VBox> </VBox>

View File

@ -18,3 +18,5 @@ menubar.help=_Help
menubar.help.about=_About… menubar.help.about=_About…
list.no_entries_found=No matching entries found list.no_entries_found=No matching entries found
search.mode.phrase=Phrase search.mode.phrase=Phrase
list.no_characters_found=No characters found
list.no_words_found=No words found

View File

@ -18,3 +18,5 @@ menubar.help=_Hilfe
menubar.help.about=_Über… menubar.help.about=_Über…
list.no_entries_found=No matching entries found list.no_entries_found=No matching entries found
search.mode.phrase=Phrase search.mode.phrase=Phrase
list.no_characters_found=No characters found
list.no_words_found=No words found

View File

@ -18,3 +18,5 @@ menubar.help=_Help
menubar.help.about=_About… menubar.help.about=_About…
list.no_entries_found=No matching entries found list.no_entries_found=No matching entries found
search.mode.phrase=Phrase search.mode.phrase=Phrase
list.no_characters_found=No characters found
list.no_words_found=No words found

View File

@ -18,3 +18,5 @@ menubar.help=_說明
menubar.help.about=_關於 Willow… menubar.help.about=_關於 Willow…
list.no_entries_found=No matching entries found list.no_entries_found=No matching entries found
search.mode.phrase=Phrase search.mode.phrase=Phrase
list.no_characters_found=No characters found
list.no_words_found=No words found

View File

@ -18,3 +18,5 @@ menubar.help=_說明
menubar.help.about=_關於 Willow… menubar.help.about=_關於 Willow…
list.no_entries_found=No matching entries found list.no_entries_found=No matching entries found
search.mode.phrase=Phrase search.mode.phrase=Phrase
list.no_characters_found=No characters found
list.no_words_found=No words found