Disable characters tab for entries that only contain a single character

This commit is contained in:
Marvin Elsen 2024-10-10 12:19:33 +02:00
parent cf07585361
commit 1c5b7d9bcc
Signed by: marvinelsen
GPG Key ID: 820672408CC318C2
2 changed files with 14 additions and 1 deletions

View File

@ -12,6 +12,7 @@ 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.ProgressIndicator
import javafx.scene.control.Tab
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
@ -43,6 +44,9 @@ class DetailsController(private val model: Model, private val config: Config) {
@FXML @FXML
private lateinit var tabPaneDetails: TabPane private lateinit var tabPaneDetails: TabPane
@FXML
private lateinit var tabCharacters: Tab
@FXML @FXML
private lateinit var webViewDefinition: WebView private lateinit var webViewDefinition: WebView
@ -152,6 +156,15 @@ class DetailsController(private val model: Model, private val config: Config) {
lazyUpdateTabContent(tabPaneDetails.selectionModel.selectedItem.id) lazyUpdateTabContent(tabPaneDetails.selectionModel.selectedItem.id)
} }
tabCharacters.disableProperty().bind(
Bindings.createBooleanBinding(
{
(model.selectedEntry.value?.traditionalProperty?.value?.length ?: 0) < 2
},
model.selectedEntry
)
)
} }
private fun initializeListViewWords() { private fun initializeListViewWords() {

View File

@ -35,7 +35,7 @@
<ProgressIndicator fx:id="progressIndicatorWords" visible="false"/> <ProgressIndicator fx:id="progressIndicatorWords" visible="false"/>
</StackPane> </StackPane>
</Tab> </Tab>
<Tab id="tabCharacters" closable="false" text="%tab.characters"> <Tab fx:id="tabCharacters" id="tabCharacters" closable="false" text="%tab.characters">
<StackPane> <StackPane>
<ListView fx:id="listViewCharacters"/> <ListView fx:id="listViewCharacters"/>
<Label fx:id="labelNoCharactersFound" text="%list.no_characters_found" textAlignment="CENTER" <Label fx:id="labelNoCharactersFound" text="%list.no_characters_found" textAlignment="CENTER"