Compare commits
89 Commits
Author | SHA1 | Date | |
---|---|---|---|
52acfeb5da | |||
1077735b98 | |||
892058c47e | |||
f5126e2d9e | |||
79182f165c | |||
8976165b27 | |||
baa4b9bd1a | |||
64ecdd84aa | |||
b8194f3ca6 | |||
cfff342a3a | |||
a92a57bffe | |||
959a5c2680 | |||
a1a7567bd0 | |||
1b5c32c320 | |||
e028bed311 | |||
6f59af3cde | |||
4b84ec5a82 | |||
039cb7e0a8 | |||
c427af15b6 | |||
40222f67ed | |||
a4e5b9145f | |||
168d1634a2 | |||
50017f45c4 | |||
dbc482bee4 | |||
8db4c3879f | |||
ea1973a3cf | |||
af3a291536 | |||
eebf3864a9 | |||
33402c0fcb | |||
898a5d3cc5 | |||
1c5b7d9bcc | |||
cf07585361 | |||
86aa108e52 | |||
2fcdda5ae3 | |||
f344c8df23 | |||
eb3beb0dfe | |||
7dab46364e | |||
3cf4e0f600 | |||
2c11a3563f | |||
c7bd51408a | |||
06fb624a38 | |||
48359c0601 | |||
07cf27863b | |||
b939f23b9f | |||
9baa66bde9 | |||
15b2138f77 | |||
6ebdf4051c | |||
ee989b8997 | |||
d48c1b2bf2 | |||
d473eafe35 | |||
46af4db9f1 | |||
630d464916 | |||
f6f2cfac5c | |||
8ada0a5510 | |||
12eb98d5b1 | |||
d9b7b82c60 | |||
cb52240eea | |||
3939021285 | |||
1ab6ef453a | |||
7add73fe28 | |||
62c57d1e85 | |||
387e10dd50 | |||
6f5b8427e0 | |||
c9c794604b | |||
039efe8b6c | |||
8c5ac438c2 | |||
cb5eb95b04 | |||
6446c2d9c8 | |||
bc9d09c39f | |||
6003bc678e | |||
fee7cbf260 | |||
02257b7e6b | |||
9ac6f51743 | |||
cc1da1f7b5 | |||
8350cb3b3d | |||
efde0dcdb4 | |||
9508412427 | |||
49fe0f65bd | |||
231b4eb0fe | |||
cdcfd92f60 | |||
30f88c9e3e | |||
a88b4d409d | |||
cfaff6c6b9 | |||
ac182c10c0 | |||
47d53d4df8 | |||
573515217e | |||
239d0d7da2 | |||
a65c1db941 | |||
3a159fba76 |
@ -2,7 +2,9 @@ plugins {
|
|||||||
alias(libs.plugins.kotlin.jvm)
|
alias(libs.plugins.kotlin.jvm)
|
||||||
alias(libs.plugins.kotlin.serialization)
|
alias(libs.plugins.kotlin.serialization)
|
||||||
alias(libs.plugins.detekt)
|
alias(libs.plugins.detekt)
|
||||||
|
alias(libs.plugins.shadow)
|
||||||
alias(libs.plugins.jfx)
|
alias(libs.plugins.jfx)
|
||||||
|
java
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.marvinelsen"
|
group = "com.marvinelsen"
|
||||||
@ -20,13 +22,19 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
detektPlugins(libs.detekt.formatting)
|
detektPlugins(libs.detekt.formatting)
|
||||||
|
|
||||||
implementation(libs.chinese.transliteration)
|
|
||||||
implementation(libs.cedict.parser)
|
|
||||||
|
|
||||||
implementation(libs.sqlite.jdbc)
|
implementation(libs.sqlite.jdbc)
|
||||||
|
|
||||||
implementation(libs.kotlinx.serialization.json)
|
implementation(libs.kotlinx.serialization.json)
|
||||||
implementation(libs.kotlinx.html.jvm)
|
implementation(libs.kotlinx.html.jvm)
|
||||||
|
implementation(libs.kotlinx.coroutines.core)
|
||||||
|
implementation(libs.kotlinx.coroutines.javafx)
|
||||||
|
|
||||||
|
implementation(libs.segment)
|
||||||
|
|
||||||
|
implementation(libs.ikonli.javafx)
|
||||||
|
implementation(libs.ikonli.material2)
|
||||||
|
|
||||||
|
implementation(libs.slf4j.nop)
|
||||||
|
|
||||||
testImplementation(libs.kotest.core)
|
testImplementation(libs.kotest.core)
|
||||||
testImplementation(libs.kotest.assertions)
|
testImplementation(libs.kotest.assertions)
|
||||||
@ -43,6 +51,7 @@ kotlin {
|
|||||||
javafx {
|
javafx {
|
||||||
version = libs.versions.javafx.get()
|
version = libs.versions.javafx.get()
|
||||||
modules("javafx.base", "javafx.graphics", "javafx.controls", "javafx.fxml", "javafx.web")
|
modules("javafx.base", "javafx.graphics", "javafx.controls", "javafx.fxml", "javafx.web")
|
||||||
|
// setPlatform("mac")
|
||||||
}
|
}
|
||||||
|
|
||||||
detekt {
|
detekt {
|
||||||
@ -50,3 +59,10 @@ detekt {
|
|||||||
allRules = false
|
allRules = false
|
||||||
autoCorrect = true
|
autoCorrect = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
manifest {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
attributes["Main-Class"] = "com.marvinelsen.willow.MainKt"
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +1,25 @@
|
|||||||
[versions]
|
[versions]
|
||||||
kotlin = "2.0.20"
|
kotlin = "2.0.20"
|
||||||
detekt = "1.23.7"
|
detekt = "1.23.7"
|
||||||
|
shadow = "8.3.5"
|
||||||
jfx-plugin = "0.1.0"
|
jfx-plugin = "0.1.0"
|
||||||
javafx = "22.0.1"
|
javafx = "23"
|
||||||
|
|
||||||
kotest = "5.9.1"
|
kotest = "5.9.1"
|
||||||
|
|
||||||
cedict-parser = "1.0.1"
|
|
||||||
chinese-transliteration = "1.0.1"
|
|
||||||
|
|
||||||
sqlite-jdbc = "3.46.0.1"
|
sqlite-jdbc = "3.46.0.1"
|
||||||
|
|
||||||
kotlinx-serialization-json = "1.7.1"
|
kotlinx-serialization-json = "1.7.1"
|
||||||
kotlinx-html-jvm = "0.11.0"
|
kotlinx-html-jvm = "0.11.0"
|
||||||
|
kotlinx-coroutines = "1.9.0"
|
||||||
|
|
||||||
|
segment = "0.3.1"
|
||||||
|
|
||||||
|
ikonli-javafx = "12.3.1"
|
||||||
|
|
||||||
|
slf4j = "2.0.16"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
chinese-transliteration = { module = "com.marvinelsen:chinese-transliteration", version.ref = "chinese-transliteration" }
|
|
||||||
cedict-parser = { module = "com.marvinelsen:cedict-parser", version.ref = "cedict-parser" }
|
|
||||||
|
|
||||||
# Kotest
|
# Kotest
|
||||||
# See: https://kotest.io
|
# See: https://kotest.io
|
||||||
kotest-core = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
|
kotest-core = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
|
||||||
@ -27,6 +29,14 @@ sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite-jdbc" }
|
|||||||
|
|
||||||
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }
|
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization-json" }
|
||||||
kotlinx-html-jvm = { module = "org.jetbrains.kotlinx:kotlinx-html-jvm", version.ref = "kotlinx-html-jvm" }
|
kotlinx-html-jvm = { module = "org.jetbrains.kotlinx:kotlinx-html-jvm", version.ref = "kotlinx-html-jvm" }
|
||||||
|
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
|
||||||
|
kotlinx-coroutines-javafx = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-javafx", version.ref = "kotlinx-coroutines" }
|
||||||
|
|
||||||
|
segment = { module = "com.github.houbb:segment", version.ref = "segment" }
|
||||||
|
slf4j-nop = { module = "org.slf4j:slf4j-nop", version.ref = "slf4j" }
|
||||||
|
|
||||||
|
ikonli-javafx = { module = "org.kordamp.ikonli:ikonli-javafx", version.ref = "ikonli-javafx" }
|
||||||
|
ikonli-material2 = { group = "org.kordamp.ikonli", name = "ikonli-material2-pack", version.ref = "ikonli-javafx" }
|
||||||
|
|
||||||
# Detekt
|
# Detekt
|
||||||
# See: https://detekt.dev
|
# See: https://detekt.dev
|
||||||
@ -42,4 +52,8 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
|
|||||||
# See: https://detekt.dev
|
# See: https://detekt.dev
|
||||||
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
|
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
|
||||||
|
|
||||||
|
# Gradle Shadow
|
||||||
|
# See: https://gradleup.com/shadow/
|
||||||
|
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
||||||
|
|
||||||
jfx = { id = "org.openjfx.javafxplugin", version.ref = "jfx-plugin" }
|
jfx = { id = "org.openjfx.javafxplugin", version.ref = "jfx-plugin" }
|
||||||
|
5
src/main/kotlin/com/marvinelsen/willow/Main.kt
Normal file
5
src/main/kotlin/com/marvinelsen/willow/Main.kt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.marvinelsen.willow
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
actualMain(args)
|
||||||
|
}
|
@ -1,62 +1,169 @@
|
|||||||
package com.marvinelsen.willow
|
package com.marvinelsen.willow
|
||||||
|
|
||||||
import com.marvinelsen.willow.domain.SearchMode
|
import com.marvinelsen.willow.domain.SearchMode
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
import com.marvinelsen.willow.domain.SqliteDictionary
|
||||||
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.domain.entities.Sentence
|
||||||
|
import com.marvinelsen.willow.ui.undo.Command
|
||||||
|
import com.marvinelsen.willow.ui.undo.UndoManager
|
||||||
import com.marvinelsen.willow.ui.util.ClipboardHelper
|
import com.marvinelsen.willow.ui.util.ClipboardHelper
|
||||||
import com.marvinelsen.willow.ui.util.FindWordsService
|
import javafx.beans.property.BooleanProperty
|
||||||
import com.marvinelsen.willow.ui.util.SearchService
|
|
||||||
import javafx.beans.property.ObjectProperty
|
import javafx.beans.property.ObjectProperty
|
||||||
import javafx.beans.property.ReadOnlyBooleanProperty
|
import javafx.beans.property.ReadOnlyBooleanProperty
|
||||||
import javafx.beans.property.ReadOnlyObjectProperty
|
import javafx.beans.property.ReadOnlyObjectProperty
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty
|
||||||
import javafx.beans.property.SimpleObjectProperty
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
import javafx.collections.FXCollections
|
import javafx.collections.FXCollections
|
||||||
import javafx.collections.ObservableList
|
import javafx.collections.ObservableList
|
||||||
import javafx.event.EventHandler
|
import kotlinx.coroutines.MainScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
class Model(private val searchService: SearchService, private val findWordsService: FindWordsService) {
|
@Suppress("TooManyFunctions")
|
||||||
private val internalSelectedEntry: ObjectProperty<DictionaryEntryFx> = SimpleObjectProperty()
|
class Model(
|
||||||
private val internalSearchResults: ObservableList<DictionaryEntryFx> = FXCollections.observableArrayList()
|
private val dictionary: SqliteDictionary,
|
||||||
private val internalWordsContaining: ObservableList<DictionaryEntryFx> = FXCollections.observableArrayList()
|
private val undoManager: UndoManager,
|
||||||
|
) {
|
||||||
|
private val internalSelectedEntry: ObjectProperty<DictionaryEntry> = SimpleObjectProperty()
|
||||||
|
private val internalSearchResults: ObservableList<DictionaryEntry> = FXCollections.observableArrayList()
|
||||||
|
private val internalWordsBeginning: ObservableList<DictionaryEntry> = FXCollections.observableArrayList()
|
||||||
|
private val internalWordsContaining: ObservableList<DictionaryEntry> = FXCollections.observableArrayList()
|
||||||
|
private val internalCharacters: ObservableList<DictionaryEntry> = FXCollections.observableArrayList()
|
||||||
|
private val internalSentences: ObservableList<Sentence> = FXCollections.observableArrayList()
|
||||||
|
|
||||||
val selectedEntry: ReadOnlyObjectProperty<DictionaryEntryFx> = internalSelectedEntry
|
private val internalIsSearching: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalIsFindingWordsBeginning: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalIsFindingWordsContaining: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalIsFindingCharacters: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalIsFindingSentences: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
|
||||||
val searchResults: ObservableList<DictionaryEntryFx> =
|
private val internalFinishedFindingWordsBeginning: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalFinishedFindingWordsContaining: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalFinishedFindingCharacters: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
private val internalFinishedFindingSentences: BooleanProperty = SimpleBooleanProperty(false)
|
||||||
|
|
||||||
|
val canUndo: ReadOnlyBooleanProperty = undoManager.canUndoProperty
|
||||||
|
val canRedo: ReadOnlyBooleanProperty = undoManager.canRedoProperty
|
||||||
|
|
||||||
|
val selectedEntry: ReadOnlyObjectProperty<DictionaryEntry> = internalSelectedEntry
|
||||||
|
|
||||||
|
val searchResults: ObservableList<DictionaryEntry> =
|
||||||
FXCollections.unmodifiableObservableList(internalSearchResults)
|
FXCollections.unmodifiableObservableList(internalSearchResults)
|
||||||
val wordsContaining: ObservableList<DictionaryEntryFx> =
|
val wordsBeginning: ObservableList<DictionaryEntry> =
|
||||||
|
FXCollections.unmodifiableObservableList(internalWordsBeginning)
|
||||||
|
val wordsContaining: ObservableList<DictionaryEntry> =
|
||||||
FXCollections.unmodifiableObservableList(internalWordsContaining)
|
FXCollections.unmodifiableObservableList(internalWordsContaining)
|
||||||
|
val characters: ObservableList<DictionaryEntry> =
|
||||||
|
FXCollections.unmodifiableObservableList(internalCharacters)
|
||||||
|
val sentences: ObservableList<Sentence> =
|
||||||
|
FXCollections.unmodifiableObservableList(internalSentences)
|
||||||
|
|
||||||
val isSearching: ReadOnlyBooleanProperty = searchService.runningProperty()
|
val isSearching: ReadOnlyBooleanProperty = internalIsSearching
|
||||||
val isFindingWords: ReadOnlyBooleanProperty = findWordsService.runningProperty()
|
val isFindingWordsBeginning: ReadOnlyBooleanProperty = internalIsFindingWordsBeginning
|
||||||
|
val isFindingWordsContaining: ReadOnlyBooleanProperty = internalIsFindingWordsContaining
|
||||||
|
val isFindingCharacters: ReadOnlyBooleanProperty = internalIsFindingCharacters
|
||||||
|
val isFindingSentences: ReadOnlyBooleanProperty = internalIsFindingSentences
|
||||||
|
|
||||||
init {
|
val finishedFindingWordsBeginning: ReadOnlyBooleanProperty = internalFinishedFindingWordsBeginning
|
||||||
searchService.onSucceeded = EventHandler {
|
val finishedFindingWordsContaining: ReadOnlyBooleanProperty = internalFinishedFindingWordsContaining
|
||||||
internalSearchResults.setAll(searchService.value)
|
val finishedFindingCharacters: ReadOnlyBooleanProperty = internalFinishedFindingCharacters
|
||||||
}
|
val finishedFindingSentences: ReadOnlyBooleanProperty = internalFinishedFindingSentences
|
||||||
findWordsService.onSucceeded = EventHandler {
|
|
||||||
internalWordsContaining.setAll(findWordsService.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun search(query: String, searchMode: SearchMode) {
|
private val coroutineScope = MainScope()
|
||||||
searchService.searchQuery = query
|
|
||||||
searchService.searchMode = searchMode
|
|
||||||
searchService.restart()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findWords() {
|
|
||||||
findWordsService.entry = internalSelectedEntry.value
|
|
||||||
findWordsService.restart()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun selectEntry(entry: DictionaryEntryFx) {
|
|
||||||
internalSelectedEntry.value = entry
|
|
||||||
}
|
|
||||||
|
|
||||||
fun copyHeadwordOfSelectedEntry() {
|
fun copyHeadwordOfSelectedEntry() {
|
||||||
ClipboardHelper.copyHeadword(internalSelectedEntry.get())
|
ClipboardHelper.copyString(internalSelectedEntry.value.traditional)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun copyPronunciationOfSelectedEntry() {
|
fun copyPronunciationOfSelectedEntry() {
|
||||||
ClipboardHelper.copyPronunciation(internalSelectedEntry.get())
|
ClipboardHelper.copyString(internalSelectedEntry.value.pinyinWithToneMarks)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun undoSelection() {
|
||||||
|
undoManager.undo()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun redoSelection() {
|
||||||
|
undoManager.redo()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun search(query: String, searchMode: SearchMode) {
|
||||||
|
coroutineScope.launch {
|
||||||
|
internalIsSearching.value = true
|
||||||
|
internalSearchResults.setAll(dictionary.search(query, searchMode))
|
||||||
|
internalIsSearching.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findWordsBeginning() {
|
||||||
|
coroutineScope.launch {
|
||||||
|
internalIsFindingWordsBeginning.value = true
|
||||||
|
internalWordsBeginning.setAll(
|
||||||
|
dictionary
|
||||||
|
.findWordsBeginningWith(internalSelectedEntry.value)
|
||||||
|
)
|
||||||
|
internalIsFindingWordsBeginning.value = false
|
||||||
|
internalFinishedFindingWordsBeginning.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findWordsContaining() {
|
||||||
|
coroutineScope.launch {
|
||||||
|
internalIsFindingWordsContaining.value = true
|
||||||
|
internalWordsContaining.setAll(
|
||||||
|
dictionary
|
||||||
|
.findWordsContaining(internalSelectedEntry.value)
|
||||||
|
)
|
||||||
|
internalIsFindingWordsContaining.value = false
|
||||||
|
internalFinishedFindingWordsContaining.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findCharacters() {
|
||||||
|
coroutineScope.launch {
|
||||||
|
internalIsFindingCharacters.value = true
|
||||||
|
internalCharacters.setAll(
|
||||||
|
dictionary
|
||||||
|
.findCharactersOf(internalSelectedEntry.value)
|
||||||
|
)
|
||||||
|
internalIsFindingCharacters.value = false
|
||||||
|
internalFinishedFindingCharacters.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findSentences() {
|
||||||
|
coroutineScope.launch {
|
||||||
|
internalIsFindingSentences.value = true
|
||||||
|
internalSentences.setAll(
|
||||||
|
dictionary
|
||||||
|
.findExampleSentencesFor(internalSelectedEntry.value)
|
||||||
|
)
|
||||||
|
internalIsFindingSentences.value = false
|
||||||
|
internalFinishedFindingSentences.value = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun selectEntry(entry: DictionaryEntry) {
|
||||||
|
undoManager.execute(object : Command {
|
||||||
|
private val previouslySelectedEntry = internalSelectedEntry.value
|
||||||
|
|
||||||
|
override fun execute() {
|
||||||
|
select(entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun undo() {
|
||||||
|
if (previouslySelectedEntry == null) return
|
||||||
|
|
||||||
|
select(previouslySelectedEntry)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun select(entry: DictionaryEntry) {
|
||||||
|
internalFinishedFindingCharacters.value = false
|
||||||
|
internalFinishedFindingWordsBeginning.value = false
|
||||||
|
internalFinishedFindingWordsContaining.value = false
|
||||||
|
internalFinishedFindingSentences.value = false
|
||||||
|
|
||||||
|
internalSelectedEntry.value = entry
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
package com.marvinelsen.willow
|
package com.marvinelsen.willow
|
||||||
|
|
||||||
|
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.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.util.FindWordsService
|
import com.marvinelsen.willow.ui.controllers.SearchResultsController
|
||||||
import com.marvinelsen.willow.ui.util.SearchService
|
import com.marvinelsen.willow.ui.undo.UndoManager
|
||||||
import javafx.application.Application
|
import javafx.application.Application
|
||||||
|
import javafx.application.HostServices
|
||||||
import javafx.fxml.FXMLLoader
|
import javafx.fxml.FXMLLoader
|
||||||
import javafx.scene.Scene
|
import javafx.scene.Scene
|
||||||
|
import javafx.scene.image.Image
|
||||||
import javafx.scene.layout.BorderPane
|
import javafx.scene.layout.BorderPane
|
||||||
import javafx.scene.text.Font
|
import javafx.scene.text.Font
|
||||||
import javafx.stage.Stage
|
import javafx.stage.Stage
|
||||||
import javafx.util.Callback
|
import javafx.util.Callback
|
||||||
import java.sql.DriverManager
|
import java.sql.DriverManager
|
||||||
import java.util.Locale
|
|
||||||
import java.util.ResourceBundle
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
class WillowApplication : Application() {
|
class WillowApplication : Application() {
|
||||||
@ -28,7 +30,7 @@ class WillowApplication : Application() {
|
|||||||
|
|
||||||
private const val FONT_SIZE = 12.0
|
private const val FONT_SIZE = 12.0
|
||||||
|
|
||||||
private const val JDBC_CONNECTION_STRING = "jdbc:sqlite:dictionary.db"
|
private const val JDBC_CONNECTION_STRING = "jdbc:sqlite::resource:data/dictionary.db"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun init() {
|
override fun init() {
|
||||||
@ -40,18 +42,25 @@ class WillowApplication : Application() {
|
|||||||
autoCommit = false
|
autoCommit = false
|
||||||
}
|
}
|
||||||
val dictionary = SqliteDictionary(connection)
|
val dictionary = SqliteDictionary(connection)
|
||||||
val searchService = SearchService(dictionary)
|
val undoManager = UndoManager()
|
||||||
val findWordsService = FindWordsService(dictionary)
|
val model = Model(
|
||||||
val model = Model(searchService, findWordsService)
|
dictionary,
|
||||||
|
undoManager
|
||||||
|
)
|
||||||
|
val config = Config()
|
||||||
|
config.load()
|
||||||
|
|
||||||
|
val hostServices: HostServices = hostServices
|
||||||
|
|
||||||
val fxmlLoader = FXMLLoader()
|
val fxmlLoader = FXMLLoader()
|
||||||
fxmlLoader.resources = ResourceBundle.getBundle("i18n/willow", Locale.US)
|
fxmlLoader.resources = ResourceBundle.getBundle("i18n/willow", config.locale.value)
|
||||||
fxmlLoader.controllerFactory = Callback { type ->
|
fxmlLoader.controllerFactory = Callback { type ->
|
||||||
when (type) {
|
when (type) {
|
||||||
MainController::class.java -> MainController(model)
|
MainController::class.java -> MainController(model)
|
||||||
MenuController::class.java -> MenuController(model)
|
MenuController::class.java -> MenuController(model, config)
|
||||||
DetailsController::class.java -> DetailsController(model)
|
DetailsController::class.java -> DetailsController(model, config, hostServices)
|
||||||
SearchController::class.java -> SearchController(model)
|
SearchController::class.java -> SearchController(model)
|
||||||
|
SearchResultsController::class.java -> SearchResultsController(model, config, hostServices)
|
||||||
else -> error("Trying to instantiate unknown controller type $type")
|
else -> error("Trying to instantiate unknown controller type $type")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,23 +68,26 @@ class WillowApplication : Application() {
|
|||||||
val root = fxmlLoader.load(javaClass.getResourceAsStream("/fxml/main.fxml")) as BorderPane
|
val root = fxmlLoader.load(javaClass.getResourceAsStream("/fxml/main.fxml")) as BorderPane
|
||||||
|
|
||||||
val primaryScene = Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT)
|
val primaryScene = Scene(root, WINDOW_WIDTH, WINDOW_HEIGHT)
|
||||||
|
// primaryScene.stylesheets.add(javaClass.getResource("/css/dark.css")?.toExternalForm()!!)
|
||||||
|
|
||||||
primaryStage.apply {
|
primaryStage.apply {
|
||||||
title = WINDOW_TITLE
|
title = WINDOW_TITLE
|
||||||
minWidth = WINDOW_MIN_WIDTH
|
minWidth = WINDOW_MIN_WIDTH
|
||||||
minHeight = WINDOW_MIN_HEIGHT
|
minHeight = WINDOW_MIN_HEIGHT
|
||||||
scene = primaryScene
|
scene = primaryScene
|
||||||
|
icons.add(Image(javaClass.getResourceAsStream("/img/icon.png")))
|
||||||
}.show()
|
}.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadFonts() {
|
private fun loadFonts() {
|
||||||
Font.loadFont(javaClass.getResourceAsStream("/fonts/inter.ttf"), FONT_SIZE)
|
Font.loadFont(javaClass.getResourceAsStream("/fonts/inter.ttf"), FONT_SIZE)
|
||||||
Font.loadFont(javaClass.getResourceAsStream("/fonts/tw-kai.ttf"), FONT_SIZE)
|
Font.loadFont(javaClass.getResourceAsStream("/fonts/tw-kai.ttf"), FONT_SIZE)
|
||||||
Font.loadFont(javaClass.getResourceAsStream("/fonts/noto-sans-tc.ttf"), FONT_SIZE)
|
Font.loadFont(javaClass.getResourceAsStream("/fonts/noto-sans-tc-regular.ttf"), FONT_SIZE)
|
||||||
|
Font.loadFont(javaClass.getResourceAsStream("/fonts/noto-sans-tc-bold.ttf"), FONT_SIZE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("SpreadOperator")
|
@Suppress("SpreadOperator")
|
||||||
fun main(args: Array<String>) {
|
fun actualMain(args: Array<String>) {
|
||||||
Application.launch(WillowApplication::class.java, *args)
|
Application.launch(WillowApplication::class.java, *args)
|
||||||
}
|
}
|
||||||
|
@ -1,93 +0,0 @@
|
|||||||
package com.marvinelsen.willow.cedict
|
|
||||||
|
|
||||||
import com.marvinelsen.cedict.api.CedictParser
|
|
||||||
import com.marvinelsen.chinese.transliteration.TransliterationSystem
|
|
||||||
import com.marvinelsen.chinese.transliteration.Zhuyin
|
|
||||||
import kotlinx.serialization.builtins.ListSerializer
|
|
||||||
import kotlinx.serialization.builtins.serializer
|
|
||||||
import kotlinx.serialization.json.Json
|
|
||||||
import java.sql.DriverManager
|
|
||||||
import java.util.zip.GZIPInputStream
|
|
||||||
|
|
||||||
const val JDBC_CONNECTION_STRING = "jdbc:sqlite:dictionary.db"
|
|
||||||
|
|
||||||
@Suppress("MagicNumber", "LongMethod", "MaximumLineLength", "MaxLineLength")
|
|
||||||
fun main() {
|
|
||||||
val connection = DriverManager.getConnection(JDBC_CONNECTION_STRING).apply {
|
|
||||||
autoCommit = false
|
|
||||||
}
|
|
||||||
|
|
||||||
val statement = connection.createStatement()
|
|
||||||
statement.executeUpdate(
|
|
||||||
"""
|
|
||||||
CREATE TABLE IF NOT EXISTS cedict(
|
|
||||||
id INTEGER PRIMARY KEY,
|
|
||||||
traditional TEXT NOT NULL,
|
|
||||||
simplified TEXT NOT NULL,
|
|
||||||
pinyin_with_tone_marks TEXT NOT NULL,
|
|
||||||
pinyin_with_tone_numbers TEXT NOT NULL,
|
|
||||||
zhuyin TEXT NOT NULL,
|
|
||||||
definitions JSON NOT NULL,
|
|
||||||
character_count INTEGER NOT NULL,
|
|
||||||
CONSTRAINT character_count_gte CHECK(character_count > 0)
|
|
||||||
);
|
|
||||||
""".trimIndent()
|
|
||||||
)
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS idx_cedict_traditional ON cedict (traditional)")
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS idx_cedict_simplified ON cedict (simplified)")
|
|
||||||
statement.executeUpdate("CREATE INDEX IF NOT EXISTS idx_cedict_character_count ON cedict (character_count)")
|
|
||||||
|
|
||||||
val cedictParser = CedictParser.instance
|
|
||||||
val cedictEntries =
|
|
||||||
cedictParser.parseCedict(
|
|
||||||
GZIPInputStream(object {}.javaClass.getResourceAsStream("/data/cedict_1_0_ts_utf-8_mdbg.txt.gz")!!)
|
|
||||||
)
|
|
||||||
|
|
||||||
val insertStatement =
|
|
||||||
connection.prepareStatement(
|
|
||||||
"INSERT OR IGNORE INTO cedict(traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions, character_count) VALUES(?,?,?,?,?,?,?)"
|
|
||||||
)
|
|
||||||
for (entry in cedictEntries) {
|
|
||||||
try {
|
|
||||||
insertStatement.setString(1, entry.traditional)
|
|
||||||
insertStatement.setString(2, entry.simplified)
|
|
||||||
insertStatement.setString(
|
|
||||||
3,
|
|
||||||
entry.pinyinSyllables.joinToString(
|
|
||||||
separator = " "
|
|
||||||
) { it.format(TransliterationSystem.PINYIN_WITH_TONE_MARKS) }
|
|
||||||
)
|
|
||||||
insertStatement.setString(
|
|
||||||
4,
|
|
||||||
entry.pinyinSyllables.joinToString(
|
|
||||||
separator = " "
|
|
||||||
) { it.format(TransliterationSystem.PINYIN_WITH_TONE_NUMBERS) }
|
|
||||||
)
|
|
||||||
insertStatement.setString(
|
|
||||||
5,
|
|
||||||
entry.pinyinSyllables.joinToString(
|
|
||||||
separator = Zhuyin.SEPARATOR
|
|
||||||
) { it.format(TransliterationSystem.ZHUYIN) }
|
|
||||||
)
|
|
||||||
insertStatement.setString(
|
|
||||||
6,
|
|
||||||
Json.encodeToString(
|
|
||||||
ListSerializer(ListSerializer(String.serializer())),
|
|
||||||
entry.definitions.map { it.glosses }
|
|
||||||
)
|
|
||||||
)
|
|
||||||
insertStatement.setInt(7, entry.traditional.length)
|
|
||||||
} catch (_: Exception) {
|
|
||||||
// no-op
|
|
||||||
}
|
|
||||||
|
|
||||||
insertStatement.addBatch()
|
|
||||||
}
|
|
||||||
|
|
||||||
insertStatement.executeBatch()
|
|
||||||
connection.commit()
|
|
||||||
|
|
||||||
insertStatement.close()
|
|
||||||
statement.close()
|
|
||||||
connection.close()
|
|
||||||
}
|
|
166
src/main/kotlin/com/marvinelsen/willow/config/Config.kt
Normal file
166
src/main/kotlin/com/marvinelsen/willow/config/Config.kt
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
package com.marvinelsen.willow.config
|
||||||
|
|
||||||
|
import javafx.beans.property.BooleanProperty
|
||||||
|
import javafx.beans.property.IntegerProperty
|
||||||
|
import javafx.beans.property.ObjectProperty
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty
|
||||||
|
import javafx.beans.property.SimpleObjectProperty
|
||||||
|
import java.util.Locale
|
||||||
|
import java.util.prefs.Preferences
|
||||||
|
|
||||||
|
class Config {
|
||||||
|
companion object {
|
||||||
|
private const val LOCALE_KEY = "locale"
|
||||||
|
private const val THEME_KEY = "theme"
|
||||||
|
private const val SCRIPT_KEY = "script"
|
||||||
|
|
||||||
|
private val DEFAULT_THEME = Theme.SYSTEM
|
||||||
|
private val DEFAULT_SCRIPT = Script.SIMPLIFIED
|
||||||
|
private val DEFAULT_LOCALE = Locale.ENGLISH
|
||||||
|
}
|
||||||
|
|
||||||
|
private val preferences = Preferences.userNodeForPackage(this::class.java)
|
||||||
|
val searchResults = SearchResultsConfig(preferences)
|
||||||
|
val details = DetailsConfig(preferences)
|
||||||
|
|
||||||
|
val locale: ObjectProperty<Locale> = SimpleObjectProperty(DEFAULT_LOCALE)
|
||||||
|
val theme: ObjectProperty<Theme> = SimpleObjectProperty(DEFAULT_THEME)
|
||||||
|
val script: ObjectProperty<Script> = SimpleObjectProperty(DEFAULT_SCRIPT)
|
||||||
|
|
||||||
|
fun save() {
|
||||||
|
preferences.put(LOCALE_KEY, locale.value.toLanguageTag())
|
||||||
|
preferences.put(THEME_KEY, theme.value.name)
|
||||||
|
preferences.put(SCRIPT_KEY, script.value.name)
|
||||||
|
|
||||||
|
searchResults.save()
|
||||||
|
details.save()
|
||||||
|
|
||||||
|
preferences.flush()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun load() {
|
||||||
|
preferences.sync()
|
||||||
|
|
||||||
|
theme.value = Theme.valueOf(
|
||||||
|
preferences.get(
|
||||||
|
THEME_KEY,
|
||||||
|
DEFAULT_THEME.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
script.value = Script.valueOf(
|
||||||
|
preferences.get(
|
||||||
|
SCRIPT_KEY,
|
||||||
|
DEFAULT_SCRIPT.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
locale.value = Locale.forLanguageTag(preferences.get(LOCALE_KEY, DEFAULT_LOCALE.toLanguageTag()))
|
||||||
|
|
||||||
|
searchResults.load()
|
||||||
|
details.load()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SearchResultsConfig(private val preferences: Preferences) {
|
||||||
|
companion object {
|
||||||
|
private const val PRONUNCIATION_KEY = "searchResultsPronunciation"
|
||||||
|
private const val HEADWORD_FONT_SIZE_KEY = "searchResultsHeadwordFontSize"
|
||||||
|
private const val PRONUNCIATION_FONT_SIZE_KEY = "searchResultsPronunciationFontSize"
|
||||||
|
private const val DEFINITION_FONT_SIZE_KEY = "searchResultsDefinitionFontSize"
|
||||||
|
private const val SHOULD_SHOW_PRONUNCIATION_KEY = "searchResultsShouldShowPronunciation"
|
||||||
|
private const val SHOULD_SHOW_DEFINITION_KEY = "searchResultsShouldShowDefinition"
|
||||||
|
|
||||||
|
private val DEFAULT_PRONUNCIATION = Pronunciation.PINYIN_WITH_TONE_MARKS
|
||||||
|
private const val DEFAULT_HEADWORD_FONT_SIZE = 20
|
||||||
|
private const val DEFAULT_PRONUNCIATION_FONT_SIZE = 14
|
||||||
|
private const val DEFAULT_DEFINITION_FONT_SIZE = 14
|
||||||
|
private const val DEFAULT_SHOULD_SHOW_PRONUNCIATION = true
|
||||||
|
private const val DEFAULT_SHOULD_SHOW_DEFINITION = true
|
||||||
|
}
|
||||||
|
|
||||||
|
val pronunciation: ObjectProperty<Pronunciation> = SimpleObjectProperty(DEFAULT_PRONUNCIATION)
|
||||||
|
val headwordFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_HEADWORD_FONT_SIZE)
|
||||||
|
val pronunciationFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_PRONUNCIATION_FONT_SIZE)
|
||||||
|
val definitionFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_DEFINITION_FONT_SIZE)
|
||||||
|
val shouldShowPronunciation: BooleanProperty = SimpleBooleanProperty(DEFAULT_SHOULD_SHOW_PRONUNCIATION)
|
||||||
|
val shouldShowDefinition: BooleanProperty = SimpleBooleanProperty(DEFAULT_SHOULD_SHOW_DEFINITION)
|
||||||
|
|
||||||
|
fun save() {
|
||||||
|
preferences.put(PRONUNCIATION_KEY, pronunciation.value.name)
|
||||||
|
preferences.putInt(HEADWORD_FONT_SIZE_KEY, headwordFontSize.value)
|
||||||
|
preferences.putInt(PRONUNCIATION_FONT_SIZE_KEY, pronunciationFontSize.value)
|
||||||
|
preferences.putInt(DEFINITION_FONT_SIZE_KEY, definitionFontSize.value)
|
||||||
|
preferences.putBoolean(SHOULD_SHOW_PRONUNCIATION_KEY, shouldShowPronunciation.value)
|
||||||
|
preferences.putBoolean(SHOULD_SHOW_DEFINITION_KEY, shouldShowDefinition.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun load() {
|
||||||
|
headwordFontSize.value = preferences.getInt(
|
||||||
|
HEADWORD_FONT_SIZE_KEY,
|
||||||
|
DEFAULT_HEADWORD_FONT_SIZE
|
||||||
|
)
|
||||||
|
pronunciationFontSize.value = preferences.getInt(
|
||||||
|
PRONUNCIATION_FONT_SIZE_KEY,
|
||||||
|
DEFAULT_PRONUNCIATION_FONT_SIZE
|
||||||
|
)
|
||||||
|
definitionFontSize.value = preferences.getInt(
|
||||||
|
DEFINITION_FONT_SIZE_KEY,
|
||||||
|
DEFAULT_DEFINITION_FONT_SIZE
|
||||||
|
)
|
||||||
|
shouldShowPronunciation.value = preferences.getBoolean(
|
||||||
|
SHOULD_SHOW_PRONUNCIATION_KEY,
|
||||||
|
DEFAULT_SHOULD_SHOW_PRONUNCIATION
|
||||||
|
)
|
||||||
|
shouldShowDefinition.value = preferences.getBoolean(
|
||||||
|
SHOULD_SHOW_DEFINITION_KEY,
|
||||||
|
DEFAULT_SHOULD_SHOW_DEFINITION
|
||||||
|
)
|
||||||
|
pronunciation.value = Pronunciation.valueOf(
|
||||||
|
preferences.get(
|
||||||
|
PRONUNCIATION_KEY,
|
||||||
|
DEFAULT_PRONUNCIATION.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DetailsConfig(private val preferences: Preferences) {
|
||||||
|
companion object {
|
||||||
|
private const val PRONUNCIATION_KEY = "detailsPronunciation"
|
||||||
|
private const val HEADWORD_FONT_SIZE_KEY = "detailsHeadwordFontSize"
|
||||||
|
private const val PRONUNCIATION_FONT_SIZE_KEY = "detailsPronunciationFontSize"
|
||||||
|
|
||||||
|
private val DEFAULT_PRONUNCIATION = Pronunciation.PINYIN_WITH_TONE_MARKS
|
||||||
|
private const val DEFAULT_HEADWORD_FONT_SIZE = 50
|
||||||
|
private const val DEFAULT_PRONUNCIATION_FONT_SIZE = 16
|
||||||
|
}
|
||||||
|
|
||||||
|
val pronunciation: ObjectProperty<Pronunciation> = SimpleObjectProperty(DEFAULT_PRONUNCIATION)
|
||||||
|
val headwordFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_HEADWORD_FONT_SIZE)
|
||||||
|
val pronunciationFontSize: IntegerProperty = SimpleIntegerProperty(DEFAULT_PRONUNCIATION_FONT_SIZE)
|
||||||
|
|
||||||
|
fun save() {
|
||||||
|
preferences.put(PRONUNCIATION_KEY, pronunciation.value.name)
|
||||||
|
preferences.putInt(HEADWORD_FONT_SIZE_KEY, headwordFontSize.value)
|
||||||
|
preferences.putInt(PRONUNCIATION_FONT_SIZE_KEY, pronunciationFontSize.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun load() {
|
||||||
|
headwordFontSize.value = preferences.getInt(
|
||||||
|
HEADWORD_FONT_SIZE_KEY,
|
||||||
|
DEFAULT_HEADWORD_FONT_SIZE
|
||||||
|
)
|
||||||
|
pronunciationFontSize.value = preferences.getInt(
|
||||||
|
PRONUNCIATION_FONT_SIZE_KEY,
|
||||||
|
DEFAULT_PRONUNCIATION_FONT_SIZE
|
||||||
|
)
|
||||||
|
pronunciation.value = Pronunciation.valueOf(
|
||||||
|
preferences.get(
|
||||||
|
PRONUNCIATION_KEY,
|
||||||
|
DEFAULT_PRONUNCIATION.name
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.marvinelsen.willow.config
|
||||||
|
|
||||||
|
enum class Pronunciation {
|
||||||
|
PINYIN_WITH_TONE_MARKS,
|
||||||
|
PINYIN_WITH_TONE_NUMBERS,
|
||||||
|
ZHUYIN
|
||||||
|
}
|
5
src/main/kotlin/com/marvinelsen/willow/config/Script.kt
Normal file
5
src/main/kotlin/com/marvinelsen/willow/config/Script.kt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.marvinelsen.willow.config
|
||||||
|
|
||||||
|
enum class Script {
|
||||||
|
SIMPLIFIED, TRADITIONAL
|
||||||
|
}
|
5
src/main/kotlin/com/marvinelsen/willow/config/Theme.kt
Normal file
5
src/main/kotlin/com/marvinelsen/willow/config/Theme.kt
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package com.marvinelsen.willow.config
|
||||||
|
|
||||||
|
enum class Theme {
|
||||||
|
SYSTEM, LIGHT, DARK
|
||||||
|
}
|
@ -1,28 +0,0 @@
|
|||||||
package com.marvinelsen.willow.domain
|
|
||||||
|
|
||||||
import java.sql.DriverManager
|
|
||||||
import kotlin.time.measureTimedValue
|
|
||||||
|
|
||||||
const val JDBC_CONNECTION_STRING = "jdbc:sqlite:dictionary.db"
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val connection = DriverManager.getConnection(JDBC_CONNECTION_STRING).apply {
|
|
||||||
autoCommit = false
|
|
||||||
}
|
|
||||||
|
|
||||||
val sqliteDictionary = SqliteDictionary(connection)
|
|
||||||
val (searchResults, time) = measureTimedValue {
|
|
||||||
sqliteDictionary.search("柳", SearchMode.TRADITIONAL)
|
|
||||||
}
|
|
||||||
val (shang, time2) = measureTimedValue {
|
|
||||||
sqliteDictionary.search("上", SearchMode.TRADITIONAL).first()
|
|
||||||
}
|
|
||||||
val (shangWords, time3) = measureTimedValue {
|
|
||||||
sqliteDictionary.findWordsContaining(shang)
|
|
||||||
}
|
|
||||||
println(searchResults)
|
|
||||||
println(shangWords)
|
|
||||||
println(time)
|
|
||||||
println(time2)
|
|
||||||
println(time3)
|
|
||||||
}
|
|
@ -1,8 +1,15 @@
|
|||||||
package com.marvinelsen.willow.domain
|
package com.marvinelsen.willow.domain
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.domain.entities.Sentence
|
||||||
|
|
||||||
interface Dictionary {
|
interface Dictionary {
|
||||||
fun search(query: String, searchMode: SearchMode): List<DictionaryEntry>
|
suspend fun search(query: String, searchMode: SearchMode): List<DictionaryEntry>
|
||||||
fun findWordsContaining(entry: DictionaryEntry): List<DictionaryEntry>
|
|
||||||
fun findSentencesContaining(entry: DictionaryEntry): List<DictionaryEntry>
|
suspend fun findWordsBeginningWith(entry: DictionaryEntry): List<DictionaryEntry>
|
||||||
fun findCharacters(entry: DictionaryEntry): List<DictionaryEntry>
|
suspend fun findWordsContaining(entry: DictionaryEntry): List<DictionaryEntry>
|
||||||
|
|
||||||
|
suspend fun findCharactersOf(entry: DictionaryEntry): List<DictionaryEntry>
|
||||||
|
|
||||||
|
suspend fun findExampleSentencesFor(entry: DictionaryEntry): List<Sentence>
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package com.marvinelsen.willow.domain
|
|
||||||
|
|
||||||
data class DictionaryEntry(
|
|
||||||
val traditional: String,
|
|
||||||
val simplified: String,
|
|
||||||
val pinyinWithToneMarks: String,
|
|
||||||
val pinyinWithToneNumbers: String,
|
|
||||||
val zhuyin: String,
|
|
||||||
val definitions: List<List<String>>
|
|
||||||
)
|
|
@ -1,5 +1,5 @@
|
|||||||
package com.marvinelsen.willow.domain
|
package com.marvinelsen.willow.domain
|
||||||
|
|
||||||
enum class SearchMode {
|
enum class SearchMode {
|
||||||
PINYIN, SIMPLIFIED, TRADITIONAL, ENGLISH
|
PINYIN, SIMPLIFIED, TRADITIONAL, SEGMENTS
|
||||||
}
|
}
|
||||||
|
@ -1,82 +1,206 @@
|
|||||||
package com.marvinelsen.willow.domain
|
package com.marvinelsen.willow.domain
|
||||||
|
|
||||||
|
import com.github.houbb.segment.bs.SegmentBs
|
||||||
|
import com.github.houbb.segment.data.phrase.core.data.SegmentPhraseDatas
|
||||||
|
import com.github.houbb.segment.data.pos.core.data.SegmentPosDatas
|
||||||
|
import com.github.houbb.segment.support.format.impl.SegmentFormats
|
||||||
|
import com.github.houbb.segment.support.segment.impl.Segments
|
||||||
|
import com.github.houbb.segment.support.segment.mode.impl.SegmentModes
|
||||||
|
import com.github.houbb.segment.support.segment.result.impl.SegmentResultHandlers
|
||||||
|
import com.github.houbb.segment.support.tagging.pos.tag.impl.SegmentPosTaggings
|
||||||
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.domain.entities.Sentence
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.withContext
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import java.sql.Connection
|
import java.sql.Connection
|
||||||
import java.sql.PreparedStatement
|
|
||||||
import java.sql.ResultSet
|
import java.sql.ResultSet
|
||||||
|
|
||||||
class SqliteDictionary(private val connection: Connection) : Dictionary {
|
class SqliteDictionary(private val connection: Connection) : Dictionary {
|
||||||
|
private val whitespaceRegex = """\s+""".toRegex()
|
||||||
|
|
||||||
private val searchSimplifiedPreparedStatement: PreparedStatement by lazy {
|
private val dispatcher = Dispatchers.IO
|
||||||
connection.prepareStatement(
|
.limitedParallelism(1)
|
||||||
"""
|
|
||||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
private val segmentBs = SegmentBs.newInstance()
|
||||||
FROM cedict
|
.segment(Segments.defaults())
|
||||||
|
.segmentData(SegmentPhraseDatas.define())
|
||||||
|
.segmentMode(SegmentModes.dict())
|
||||||
|
.segmentFormat(SegmentFormats.chineseSimple())
|
||||||
|
.posTagging(SegmentPosTaggings.simple())
|
||||||
|
.posData(SegmentPosDatas.define())
|
||||||
|
|
||||||
|
private val searchSimplifiedSql = """
|
||||||
|
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
|
FROM entry
|
||||||
WHERE simplified GLOB ?
|
WHERE simplified GLOB ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val searchTraditionalPreparedStatement: PreparedStatement by lazy {
|
private val searchTraditionalSql = """
|
||||||
connection.prepareStatement(
|
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
"""
|
FROM entry
|
||||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
|
||||||
FROM cedict
|
|
||||||
WHERE traditional GLOB ?
|
WHERE traditional GLOB ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val findWordsContaining: PreparedStatement by lazy {
|
private val searchPinyinSql = """
|
||||||
connection.prepareStatement(
|
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
"""
|
FROM entry
|
||||||
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, definitions
|
WHERE searchable_pinyin GLOB ?
|
||||||
FROM cedict
|
OR searchable_pinyin_with_tone_numbers GLOB ?
|
||||||
|
ORDER BY character_count ASC
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
private val searchSegmentsSql = """
|
||||||
|
WITH cte(id, segment) AS (VALUES ?)
|
||||||
|
SELECT entry.traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
|
FROM entry INNER JOIN cte
|
||||||
|
ON cte.segment = entry.traditional OR cte.segment = entry.simplified
|
||||||
|
ORDER BY cte.id
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
private val findWordsBeginningSql = """
|
||||||
|
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
|
FROM entry
|
||||||
|
WHERE traditional GLOB ?
|
||||||
|
ORDER BY character_count ASC
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
private val findWordsContainingSql = """
|
||||||
|
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
|
FROM entry
|
||||||
WHERE traditional LIKE ?
|
WHERE traditional LIKE ?
|
||||||
ORDER BY character_count ASC
|
ORDER BY character_count ASC
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
|
||||||
|
private val findCharactersSql = """
|
||||||
|
WITH cte(id, character, pinyin) AS (VALUES ?)
|
||||||
|
SELECT traditional, simplified, pinyin_with_tone_marks, pinyin_with_tone_numbers, zhuyin, cedict_definitions, cross_straits_definitions, moe_definitions
|
||||||
|
FROM entry INNER JOIN cte
|
||||||
|
ON cte.character = entry.traditional
|
||||||
|
WHERE cte.pinyin = entry.pinyin_with_tone_numbers
|
||||||
|
ORDER BY cte.id
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
private val findExampleSentenceSql = """
|
||||||
|
SELECT traditional, simplified
|
||||||
|
FROM sentence
|
||||||
|
WHERE traditional LIKE ?
|
||||||
|
ORDER BY character_count ASC
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
override suspend fun search(query: String, searchMode: SearchMode) = withContext(dispatcher) {
|
||||||
|
when (searchMode) {
|
||||||
|
SearchMode.SIMPLIFIED -> searchSimplified(query)
|
||||||
|
SearchMode.TRADITIONAL -> searchTraditional(query)
|
||||||
|
SearchMode.PINYIN -> searchPinyin(query)
|
||||||
|
SearchMode.SEGMENTS -> searchSegmentsOf(query)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun search(query: String, searchMode: SearchMode) = when (searchMode) {
|
private fun searchSimplified(simplified: String) =
|
||||||
SearchMode.PINYIN -> TODO()
|
connection.prepareStatement(searchSimplifiedSql).use { preparedStatement ->
|
||||||
SearchMode.SIMPLIFIED -> searchSimplified(query)
|
preparedStatement.setString(1, "$simplified*")
|
||||||
SearchMode.TRADITIONAL -> searchTraditional(query)
|
|
||||||
SearchMode.ENGLISH -> TODO()
|
preparedStatement.executeQuery().use {
|
||||||
|
it.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchTraditional(traditional: String) =
|
||||||
|
connection.prepareStatement(searchTraditionalSql).use { preparedStatement ->
|
||||||
|
preparedStatement.setString(1, "$traditional*")
|
||||||
|
|
||||||
|
preparedStatement.executeQuery().use {
|
||||||
|
it.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun searchPinyin(pinyin: String): List<DictionaryEntry> {
|
||||||
|
val sanitizedPinyin = pinyin.lowercase().replace(whitespaceRegex, "")
|
||||||
|
|
||||||
|
return connection.prepareStatement(searchPinyinSql).use { preparedStatement ->
|
||||||
|
preparedStatement.setString(1, "$sanitizedPinyin*")
|
||||||
|
preparedStatement.setString(2, "$sanitizedPinyin*")
|
||||||
|
|
||||||
|
preparedStatement.executeQuery().use { resultSet ->
|
||||||
|
resultSet.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun findWordsContaining(entry: DictionaryEntry): List<DictionaryEntry> {
|
private fun searchSegmentsOf(phrase: String): List<DictionaryEntry> {
|
||||||
findWordsContaining.setString(1, "_%${entry.traditional}%")
|
val segments = segmentBs.segment(phrase, SegmentResultHandlers.word())
|
||||||
|
|
||||||
val resultSet: ResultSet = findWordsContaining.executeQuery()
|
val segmentsListString = segments
|
||||||
|
.mapIndexed { index, segment -> "($index, '$segment')" }
|
||||||
|
.joinToString(",")
|
||||||
|
|
||||||
return resultSet.toListOfDictionaryEntries()
|
val query = searchSegmentsSql.replace("?", segmentsListString)
|
||||||
|
|
||||||
|
return connection.createStatement().use { statement ->
|
||||||
|
statement.executeQuery(query).use { resultSet ->
|
||||||
|
resultSet.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun findSentencesContaining(entry: DictionaryEntry): List<DictionaryEntry> {
|
override suspend fun findWordsContaining(entry: DictionaryEntry) = withContext(dispatcher) {
|
||||||
return emptyList()
|
connection.prepareStatement(findWordsContainingSql).use { preparedStatement ->
|
||||||
|
preparedStatement.setString(1, "_%${entry.traditional}%")
|
||||||
|
|
||||||
|
preparedStatement.executeQuery().use { resultSet ->
|
||||||
|
resultSet.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun findCharacters(entry: DictionaryEntry): List<DictionaryEntry> {
|
override suspend fun findWordsBeginningWith(entry: DictionaryEntry) = withContext(dispatcher) {
|
||||||
return emptyList()
|
connection.prepareStatement(findWordsBeginningSql).use { preparedStatement ->
|
||||||
|
preparedStatement.setString(1, "${entry.traditional}?*")
|
||||||
|
|
||||||
|
preparedStatement.executeQuery().use { resultSet ->
|
||||||
|
resultSet.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun searchSimplified(query: String): List<DictionaryEntry> {
|
override suspend fun findCharactersOf(entry: DictionaryEntry) = withContext(dispatcher) {
|
||||||
searchSimplifiedPreparedStatement.setString(1, "$query*")
|
val pinyinSyllablesWithToneNumbers = entry.pinyinWithToneNumbers
|
||||||
|
.lowercase()
|
||||||
|
.split(" ")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
|
||||||
val resultSet: ResultSet = searchSimplifiedPreparedStatement.executeQuery()
|
val characters = entry.traditional
|
||||||
|
.split("")
|
||||||
|
.filter { it.isNotBlank() }
|
||||||
|
.filter { it != "," }
|
||||||
|
.filter { it != "·" }
|
||||||
|
|
||||||
return resultSet.toListOfDictionaryEntries()
|
val charactersWithSyllables = characters.zip(pinyinSyllablesWithToneNumbers)
|
||||||
|
|
||||||
|
val queryInput = charactersWithSyllables
|
||||||
|
.mapIndexed { index, s -> "($index, '${s.first}', '${s.second}')" }
|
||||||
|
.joinToString(",")
|
||||||
|
|
||||||
|
val query = findCharactersSql.replace("?", queryInput)
|
||||||
|
|
||||||
|
connection.createStatement().use { statement ->
|
||||||
|
statement.executeQuery(query).use { resultSet ->
|
||||||
|
resultSet.toListOfDictionaryEntries()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun searchTraditional(query: String): List<DictionaryEntry> {
|
override suspend fun findExampleSentencesFor(entry: DictionaryEntry) = withContext(dispatcher) {
|
||||||
searchTraditionalPreparedStatement.setString(1, "$query*")
|
connection.prepareStatement(findExampleSentenceSql).use { preparedStatement ->
|
||||||
|
preparedStatement.setString(1, "_%${entry.traditional}%")
|
||||||
|
|
||||||
val resultSet: ResultSet = searchTraditionalPreparedStatement.executeQuery()
|
preparedStatement.executeQuery().use { resultSet ->
|
||||||
|
resultSet.toListOfSentences()
|
||||||
return resultSet.toListOfDictionaryEntries()
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,13 +211,24 @@ private fun ResultSet.toDictionaryEntry() = DictionaryEntry(
|
|||||||
pinyinWithToneMarks = this.getString(3),
|
pinyinWithToneMarks = this.getString(3),
|
||||||
pinyinWithToneNumbers = this.getString(4),
|
pinyinWithToneNumbers = this.getString(4),
|
||||||
zhuyin = this.getString(5),
|
zhuyin = this.getString(5),
|
||||||
definitions = Json.decodeFromString(this.getString(6))
|
cedictDefinitions = Json.decodeFromString(this.getString(6)),
|
||||||
|
crossStraitsDefinitions = Json.decodeFromString(this.getString(7)),
|
||||||
|
moedictDefinitions = Json.decodeFromString(this.getString(8)),
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun ResultSet.toListOfDictionaryEntries() = buildList {
|
private fun ResultSet.toListOfDictionaryEntries() = buildList {
|
||||||
this@toListOfDictionaryEntries.use {
|
while (this@toListOfDictionaryEntries.next()) {
|
||||||
while (it.next()) {
|
add(this@toListOfDictionaryEntries.toDictionaryEntry())
|
||||||
add(it.toDictionaryEntry())
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ResultSet.toSentence() = Sentence(
|
||||||
|
traditional = this.getString(1),
|
||||||
|
simplified = this.getString(2),
|
||||||
|
)
|
||||||
|
|
||||||
|
private fun ResultSet.toListOfSentences() = buildList {
|
||||||
|
while (this@toListOfSentences.next()) {
|
||||||
|
add(this@toListOfSentences.toSentence())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.marvinelsen.willow.domain.entities
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.domain.entities.definitions.CrossStraitsDefinition
|
||||||
|
import com.marvinelsen.willow.domain.entities.definitions.MoedictDefinition
|
||||||
|
|
||||||
|
data class DictionaryEntry(
|
||||||
|
val traditional: String,
|
||||||
|
val simplified: String,
|
||||||
|
val pinyinWithToneMarks: String,
|
||||||
|
val pinyinWithToneNumbers: String,
|
||||||
|
val zhuyin: String,
|
||||||
|
val cedictDefinitions: List<List<String>>,
|
||||||
|
val crossStraitsDefinitions: List<CrossStraitsDefinition>,
|
||||||
|
val moedictDefinitions: List<MoedictDefinition>,
|
||||||
|
)
|
@ -0,0 +1,6 @@
|
|||||||
|
package com.marvinelsen.willow.domain.entities
|
||||||
|
|
||||||
|
data class Sentence(
|
||||||
|
val traditional: String,
|
||||||
|
val simplified: String,
|
||||||
|
)
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.marvinelsen.willow.domain.entities.definitions
|
||||||
|
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CrossStraitsDefinition(
|
||||||
|
val definition: String,
|
||||||
|
val examples: List<String>,
|
||||||
|
)
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.marvinelsen.willow.domain.entities.definitions
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class MoedictDefinition(
|
||||||
|
@SerialName("def") val definition: String,
|
||||||
|
@SerialName("example") val examples: List<String> = emptyList(),
|
||||||
|
@SerialName("quote") val quotes: List<String> = emptyList(),
|
||||||
|
val type: String? = null,
|
||||||
|
@SerialName("link") val links: List<String> = emptyList(),
|
||||||
|
val synonyms: String? = null,
|
||||||
|
val antonyms: String? = null,
|
||||||
|
)
|
@ -1,3 +0,0 @@
|
|||||||
package com.marvinelsen.willow.ui
|
|
||||||
|
|
||||||
class Configuration
|
|
@ -1,34 +0,0 @@
|
|||||||
package com.marvinelsen.willow.ui
|
|
||||||
|
|
||||||
import com.marvinelsen.willow.domain.DictionaryEntry
|
|
||||||
import javafx.beans.property.SimpleStringProperty
|
|
||||||
import javafx.beans.property.StringProperty
|
|
||||||
import javafx.collections.FXCollections
|
|
||||||
import javafx.collections.ObservableList
|
|
||||||
|
|
||||||
data class DictionaryEntryFx(
|
|
||||||
val traditionalProperty: StringProperty,
|
|
||||||
val simplifiedProperty: StringProperty,
|
|
||||||
val pinyinWithToneMarksProperty: StringProperty,
|
|
||||||
val pinyinWithToneNumbersProperty: StringProperty,
|
|
||||||
val zhuyinProperty: StringProperty,
|
|
||||||
val definitions: ObservableList<List<String>>,
|
|
||||||
)
|
|
||||||
|
|
||||||
fun DictionaryEntry.toFx() = DictionaryEntryFx(
|
|
||||||
traditionalProperty = SimpleStringProperty(this.traditional),
|
|
||||||
simplifiedProperty = SimpleStringProperty(this.simplified),
|
|
||||||
pinyinWithToneMarksProperty = SimpleStringProperty(this.pinyinWithToneMarks),
|
|
||||||
pinyinWithToneNumbersProperty = SimpleStringProperty(this.pinyinWithToneNumbers),
|
|
||||||
zhuyinProperty = SimpleStringProperty(this.zhuyin),
|
|
||||||
definitions = FXCollections.observableList(this.definitions)
|
|
||||||
)
|
|
||||||
|
|
||||||
fun DictionaryEntryFx.toDomain() = DictionaryEntry(
|
|
||||||
traditional = this.traditionalProperty.value,
|
|
||||||
simplified = this.simplifiedProperty.value,
|
|
||||||
pinyinWithToneMarks = this.pinyinWithToneMarksProperty.value,
|
|
||||||
pinyinWithToneNumbers = this.pinyinWithToneNumbersProperty.value,
|
|
||||||
zhuyin = this.zhuyinProperty.value,
|
|
||||||
definitions = this.definitions.toList()
|
|
||||||
)
|
|
@ -0,0 +1,157 @@
|
|||||||
|
package com.marvinelsen.willow.ui.cells
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.config.Pronunciation
|
||||||
|
import com.marvinelsen.willow.config.Script
|
||||||
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.ui.util.createContextMenuForEntry
|
||||||
|
import javafx.application.HostServices
|
||||||
|
import javafx.beans.binding.Bindings
|
||||||
|
import javafx.geometry.VPos
|
||||||
|
import javafx.scene.control.Label
|
||||||
|
import javafx.scene.control.ListCell
|
||||||
|
import javafx.scene.control.ListView
|
||||||
|
import javafx.scene.layout.FlowPane
|
||||||
|
import javafx.scene.layout.VBox
|
||||||
|
import javafx.util.Callback
|
||||||
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
|
class DictionaryEntryCellFactory(
|
||||||
|
private val resources: ResourceBundle,
|
||||||
|
private val config: Config,
|
||||||
|
private val hostServices: HostServices,
|
||||||
|
) : Callback<ListView<DictionaryEntry?>, ListCell<DictionaryEntry?>> {
|
||||||
|
|
||||||
|
override fun call(listView: ListView<DictionaryEntry?>): ListCell<DictionaryEntry?> {
|
||||||
|
val entryCell = EntryCell(resources, config, hostServices)
|
||||||
|
entryCell.prefWidthProperty().bind(listView.widthProperty().subtract(CELL_PADDING))
|
||||||
|
return entryCell
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val CELL_PADDING = 24
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class EntryCell(
|
||||||
|
private val resources: ResourceBundle,
|
||||||
|
private val config: Config,
|
||||||
|
private val hostServices: HostServices,
|
||||||
|
) : ListCell<DictionaryEntry?>() {
|
||||||
|
|
||||||
|
private val labelHeadword by lazy {
|
||||||
|
Label().apply {
|
||||||
|
styleClass.add("headword")
|
||||||
|
styleProperty().bind(
|
||||||
|
Bindings.concat(
|
||||||
|
"-fx-font-size: ",
|
||||||
|
config.searchResults.headwordFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val labelDefinition by lazy {
|
||||||
|
Label().apply {
|
||||||
|
styleClass.add("definition")
|
||||||
|
styleProperty().bind(
|
||||||
|
Bindings.concat(
|
||||||
|
"-fx-font-size: ",
|
||||||
|
config.searchResults.definitionFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
visibleProperty().bind(config.searchResults.shouldShowDefinition)
|
||||||
|
managedProperty().bind(config.searchResults.shouldShowDefinition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val labelPronunciation by lazy {
|
||||||
|
Label().apply {
|
||||||
|
styleClass.add("pronunciation")
|
||||||
|
styleProperty().bind(
|
||||||
|
Bindings.concat(
|
||||||
|
"-fx-font-size: ",
|
||||||
|
config.searchResults.pronunciationFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
visibleProperty().bind(config.searchResults.shouldShowPronunciation)
|
||||||
|
managedProperty().bind(config.searchResults.shouldShowPronunciation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val flowPane by lazy {
|
||||||
|
FlowPane(labelHeadword, labelPronunciation).apply {
|
||||||
|
hgap = FLOW_PANE_HGAP
|
||||||
|
rowValignment = VPos.BASELINE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val root by lazy {
|
||||||
|
VBox(flowPane, labelDefinition).apply {
|
||||||
|
styleClass.add("search-result")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
text = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateItem(entry: DictionaryEntry?, empty: Boolean) {
|
||||||
|
super.updateItem(entry, empty)
|
||||||
|
if (empty || entry == null) {
|
||||||
|
graphic = null
|
||||||
|
contextMenu = null
|
||||||
|
} else {
|
||||||
|
labelHeadword.textProperty().bind(
|
||||||
|
Bindings.createStringBinding(
|
||||||
|
{
|
||||||
|
when (config.script.value!!) {
|
||||||
|
Script.SIMPLIFIED -> entry.simplified
|
||||||
|
Script.TRADITIONAL -> entry.traditional
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config.script
|
||||||
|
)
|
||||||
|
)
|
||||||
|
labelPronunciation.textProperty().bind(
|
||||||
|
Bindings.createStringBinding(
|
||||||
|
{
|
||||||
|
when (config.searchResults.pronunciation.value!!) {
|
||||||
|
Pronunciation.PINYIN_WITH_TONE_MARKS -> entry.pinyinWithToneMarks
|
||||||
|
Pronunciation.PINYIN_WITH_TONE_NUMBERS -> entry.pinyinWithToneNumbers
|
||||||
|
Pronunciation.ZHUYIN -> entry.zhuyin
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config.searchResults.pronunciation
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val definition = when {
|
||||||
|
entry.cedictDefinitions.isNotEmpty() -> entry.cedictDefinitions.joinToString(
|
||||||
|
separator = " / "
|
||||||
|
) { it.joinToString(separator = "; ") }
|
||||||
|
|
||||||
|
entry.crossStraitsDefinitions.isNotEmpty() -> entry.crossStraitsDefinitions.joinToString(
|
||||||
|
separator = " / "
|
||||||
|
) { it.definition }
|
||||||
|
|
||||||
|
entry.moedictDefinitions.isNotEmpty() -> entry.moedictDefinitions.joinToString(
|
||||||
|
separator = " / "
|
||||||
|
) { it.definition }
|
||||||
|
|
||||||
|
else -> error("No definition for entry")
|
||||||
|
}
|
||||||
|
labelDefinition.text = definition
|
||||||
|
|
||||||
|
contextMenu = createContextMenuForEntry(entry, resources, hostServices)
|
||||||
|
graphic = root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val FLOW_PANE_HGAP = 8.0
|
||||||
|
}
|
||||||
|
}
|
@ -1,70 +0,0 @@
|
|||||||
package com.marvinelsen.willow.ui.cells
|
|
||||||
|
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
|
||||||
import com.marvinelsen.willow.ui.util.createContextMenuForEntry
|
|
||||||
import javafx.geometry.VPos
|
|
||||||
import javafx.scene.control.Label
|
|
||||||
import javafx.scene.control.ListCell
|
|
||||||
import javafx.scene.control.ListView
|
|
||||||
import javafx.scene.layout.FlowPane
|
|
||||||
import javafx.scene.layout.VBox
|
|
||||||
import javafx.util.Callback
|
|
||||||
|
|
||||||
class DictionaryEntryCellFactory : Callback<ListView<DictionaryEntryFx?>, ListCell<DictionaryEntryFx?>> {
|
|
||||||
override fun call(listView: ListView<DictionaryEntryFx?>): ListCell<DictionaryEntryFx?> {
|
|
||||||
val entryCell = EntryCell()
|
|
||||||
entryCell.prefWidthProperty().bind(listView.widthProperty().subtract(CELL_PADDING))
|
|
||||||
return entryCell
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val CELL_PADDING = 16
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class EntryCell : ListCell<DictionaryEntryFx?>() {
|
|
||||||
private val labelHeadword = Label().apply {
|
|
||||||
styleClass.add("list-view-entry")
|
|
||||||
}
|
|
||||||
|
|
||||||
private val labelDefinition = Label().apply {
|
|
||||||
styleClass.add("list-view-definition")
|
|
||||||
}
|
|
||||||
|
|
||||||
private val labelPronunciation = Label().apply {
|
|
||||||
styleClass.add("list-view-pronunciation")
|
|
||||||
}
|
|
||||||
|
|
||||||
private val flowPane = FlowPane(labelHeadword, labelPronunciation).apply {
|
|
||||||
hgap = FLOW_PANE_HGAP
|
|
||||||
rowValignment = VPos.BASELINE
|
|
||||||
}
|
|
||||||
|
|
||||||
private val root = VBox(flowPane, labelDefinition)
|
|
||||||
|
|
||||||
init {
|
|
||||||
text = null
|
|
||||||
if (item != null) {
|
|
||||||
contextMenu = createContextMenuForEntry(item!!)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateItem(entry: DictionaryEntryFx?, empty: Boolean) {
|
|
||||||
super.updateItem(entry, empty)
|
|
||||||
if (empty || entry == null) {
|
|
||||||
graphic = null
|
|
||||||
} else {
|
|
||||||
labelHeadword.text = entry.traditionalProperty.value
|
|
||||||
labelPronunciation.text = entry.pinyinWithToneMarksProperty.value
|
|
||||||
|
|
||||||
val definition = entry.definitions.joinToString(separator = " / ") { it.joinToString(separator = "; ") }
|
|
||||||
labelDefinition.text = definition
|
|
||||||
|
|
||||||
graphic = root
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val FLOW_PANE_HGAP = 8.0
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,76 @@
|
|||||||
|
package com.marvinelsen.willow.ui.cells
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.config.Script
|
||||||
|
import com.marvinelsen.willow.domain.entities.Sentence
|
||||||
|
import com.marvinelsen.willow.ui.util.createContextMenuForSentence
|
||||||
|
import javafx.application.HostServices
|
||||||
|
import javafx.beans.binding.Bindings
|
||||||
|
import javafx.scene.control.Label
|
||||||
|
import javafx.scene.control.ListCell
|
||||||
|
import javafx.scene.control.ListView
|
||||||
|
import javafx.scene.layout.VBox
|
||||||
|
import javafx.util.Callback
|
||||||
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
|
class SentenceCellFactory(
|
||||||
|
private val resources: ResourceBundle,
|
||||||
|
private val config: Config,
|
||||||
|
private val hostServices: HostServices,
|
||||||
|
) : Callback<ListView<Sentence?>, ListCell<Sentence?>> {
|
||||||
|
|
||||||
|
override fun call(listView: ListView<Sentence?>): ListCell<Sentence?> {
|
||||||
|
val sentenceCell = SentenceCell(resources, config, hostServices)
|
||||||
|
sentenceCell.prefWidthProperty().bind(listView.widthProperty().subtract(CELL_PADDING))
|
||||||
|
return sentenceCell
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val CELL_PADDING = 16
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class SentenceCell(
|
||||||
|
private val resources: ResourceBundle,
|
||||||
|
private val config: Config,
|
||||||
|
private val hostServices: HostServices,
|
||||||
|
) : ListCell<Sentence?>() {
|
||||||
|
|
||||||
|
private val labelSentence by lazy {
|
||||||
|
Label().apply {
|
||||||
|
styleClass.add("sentence")
|
||||||
|
isWrapText = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val root by lazy {
|
||||||
|
VBox(labelSentence)
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
text = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateItem(sentence: Sentence?, empty: Boolean) {
|
||||||
|
super.updateItem(sentence, empty)
|
||||||
|
if (empty || sentence == null) {
|
||||||
|
graphic = null
|
||||||
|
contextMenu = null
|
||||||
|
} else {
|
||||||
|
labelSentence.textProperty().bind(
|
||||||
|
Bindings.createStringBinding(
|
||||||
|
{
|
||||||
|
when (config.script.value!!) {
|
||||||
|
Script.SIMPLIFIED -> sentence.simplified
|
||||||
|
Script.TRADITIONAL -> sentence.traditional
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config.script
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
contextMenu = createContextMenuForSentence(sentence, resources, hostServices)
|
||||||
|
graphic = root
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,84 +1,406 @@
|
|||||||
package com.marvinelsen.willow.ui.controllers
|
package com.marvinelsen.willow.ui.controllers
|
||||||
|
|
||||||
import com.marvinelsen.willow.Model
|
import com.marvinelsen.willow.Model
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.config.Pronunciation
|
||||||
|
import com.marvinelsen.willow.config.Script
|
||||||
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.domain.entities.Sentence
|
||||||
|
import com.marvinelsen.willow.ui.cells.DictionaryEntryCellFactory
|
||||||
|
import com.marvinelsen.willow.ui.cells.SentenceCellFactory
|
||||||
|
import com.marvinelsen.willow.ui.util.createContextMenuForEntry
|
||||||
|
import javafx.application.HostServices
|
||||||
import javafx.beans.binding.Bindings
|
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.Tab
|
||||||
import javafx.scene.control.TabPane
|
import javafx.scene.control.TabPane
|
||||||
|
import javafx.scene.input.ContextMenuEvent
|
||||||
|
import javafx.scene.layout.FlowPane
|
||||||
import javafx.scene.web.WebView
|
import javafx.scene.web.WebView
|
||||||
|
import kotlinx.html.DIV
|
||||||
|
import kotlinx.html.body
|
||||||
|
import kotlinx.html.div
|
||||||
|
import kotlinx.html.h1
|
||||||
|
import kotlinx.html.html
|
||||||
|
import kotlinx.html.li
|
||||||
|
import kotlinx.html.ol
|
||||||
|
import kotlinx.html.span
|
||||||
|
import kotlinx.html.stream.createHTML
|
||||||
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
class DetailsController(private val model: Model) {
|
@Suppress("UnusedPrivateMember", "TooManyFunctions")
|
||||||
@FXML
|
class DetailsController(
|
||||||
private lateinit var tabPaneDetails: TabPane
|
private val model: Model,
|
||||||
|
private val config: Config,
|
||||||
|
private val hostServices: HostServices,
|
||||||
|
) {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var webViewDefinition: WebView
|
private lateinit var resources: ResourceBundle
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@Suppress("UnusedPrivateProperty")
|
private lateinit var flowPaneHeader: FlowPane
|
||||||
private lateinit var listviewSentences: ListView<DictionaryEntryFx>
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private lateinit var listViewWords: ListView<DictionaryEntryFx>
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
@Suppress("UnusedPrivateProperty")
|
|
||||||
private lateinit var listViewCharacters: ListView<DictionaryEntryFx>
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var labelHeadword: Label
|
private lateinit var labelHeadword: Label
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
@Suppress("UnusedPrivateMember")
|
private lateinit var labelPronunciation: Label
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var tabPaneDetails: TabPane
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var tabCharacters: Tab
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var webViewDefinition: WebView
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var listViewWordsContaining: ListView<DictionaryEntry>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var listViewWordsBeginning: ListView<DictionaryEntry>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var listViewCharacters: ListView<DictionaryEntry>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var progressIndicatorCharacters: ProgressIndicator
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var progressIndicatorWordsContaining: ProgressIndicator
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var progressIndicatorWordsBeginning: ProgressIndicator
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var labelNoCharactersFound: Label
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var labelNoWordsContainingFound: Label
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var labelNoWordsBeginningFound: Label
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var listViewSentences: ListView<Sentence>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var progressIndicatorSentences: ProgressIndicator
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var labelNoSentencesFound: Label
|
||||||
|
|
||||||
|
@FXML
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
val headwordObjectBinding =
|
initializeLabelHeadword()
|
||||||
Bindings.createStringBinding({ model.selectedEntry.value?.traditionalProperty?.value }, model.selectedEntry)
|
initializeLabelPronunciation()
|
||||||
|
initializeTabPaneDetails()
|
||||||
|
initializeListViewWordsContaining()
|
||||||
|
initializeListViewWordsBeginning()
|
||||||
|
initializeListViewCharacters()
|
||||||
|
initializeListViewSentences()
|
||||||
|
initializeWebViewDefinition()
|
||||||
|
}
|
||||||
|
|
||||||
labelHeadword.textProperty().bind(headwordObjectBinding)
|
private fun initializeLabelHeadword() {
|
||||||
|
labelHeadword.apply {
|
||||||
tabPaneDetails.disableProperty().bind(Bindings.isNull(model.selectedEntry))
|
textProperty().bind(
|
||||||
|
Bindings.createStringBinding(
|
||||||
listViewWords.items = model.wordsContaining
|
{
|
||||||
tabPaneDetails.selectionModel.selectedItemProperty().addListener { _, _, selectedTab ->
|
val selectedEntry = model.selectedEntry.value
|
||||||
if (model.selectedEntry.value == null) return@addListener
|
when (config.script.value!!) {
|
||||||
|
Script.SIMPLIFIED -> selectedEntry?.simplified
|
||||||
when (selectedTab.id) {
|
Script.TRADITIONAL -> selectedEntry?.traditional
|
||||||
"tabWords" -> {
|
}
|
||||||
model.findWords()
|
},
|
||||||
}
|
config.script,
|
||||||
|
model.selectedEntry
|
||||||
else -> {}
|
)
|
||||||
}
|
)
|
||||||
}
|
styleProperty().bind(
|
||||||
|
Bindings.concat(
|
||||||
webViewDefinition.apply {
|
"-fx-font-size: ",
|
||||||
isContextMenuEnabled = false
|
config.details.headwordFontSize.asString(),
|
||||||
engine.userStyleSheetLocation =
|
"px;"
|
||||||
this::class.java.getResource("/css/definitions.css")!!.toExternalForm()
|
)
|
||||||
}
|
|
||||||
|
|
||||||
model.selectedEntry.addListener { _, _, newValue ->
|
|
||||||
if (newValue == null) {
|
|
||||||
return@addListener
|
|
||||||
}
|
|
||||||
webViewDefinition.engine.loadContent(
|
|
||||||
buildString {
|
|
||||||
append("<html>")
|
|
||||||
append("<body>")
|
|
||||||
append("<h1>CC-CEDICT</h1>")
|
|
||||||
append("<ol>")
|
|
||||||
for (definition in newValue.definitions) {
|
|
||||||
append("<li>")
|
|
||||||
append(definition.joinToString(separator = "; "))
|
|
||||||
append("</li>")
|
|
||||||
}
|
|
||||||
append("</ol>")
|
|
||||||
append("</body>")
|
|
||||||
append("</html>")
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initializeLabelPronunciation() {
|
||||||
|
labelPronunciation.apply {
|
||||||
|
textProperty().bind(
|
||||||
|
Bindings.createStringBinding(
|
||||||
|
{
|
||||||
|
val selectedEntry = model.selectedEntry.value
|
||||||
|
when (config.details.pronunciation.value!!) {
|
||||||
|
Pronunciation.PINYIN_WITH_TONE_MARKS -> selectedEntry?.pinyinWithToneMarks
|
||||||
|
Pronunciation.PINYIN_WITH_TONE_NUMBERS -> selectedEntry?.pinyinWithToneNumbers
|
||||||
|
Pronunciation.ZHUYIN -> selectedEntry?.zhuyin
|
||||||
|
}
|
||||||
|
},
|
||||||
|
config.details.pronunciation,
|
||||||
|
model.selectedEntry
|
||||||
|
)
|
||||||
|
)
|
||||||
|
styleProperty().bind(
|
||||||
|
Bindings.concat(
|
||||||
|
"-fx-font-size: ",
|
||||||
|
config.details.pronunciationFontSize.asString(),
|
||||||
|
"px;"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeTabPaneDetails() {
|
||||||
|
tabPaneDetails.apply {
|
||||||
|
disableProperty().bind(Bindings.isNull(model.selectedEntry))
|
||||||
|
|
||||||
|
selectionModel.selectedItemProperty().addListener { _, _, selectedTab ->
|
||||||
|
if (model.selectedEntry.value == null) return@addListener
|
||||||
|
|
||||||
|
lazyUpdateTabContent(selectedTab.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.selectedEntry.addListener { _, _, newEntry ->
|
||||||
|
if (newEntry == null) return@addListener
|
||||||
|
|
||||||
|
tabPaneDetails.selectionModel.select(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
tabCharacters.disableProperty().bind(
|
||||||
|
Bindings.createBooleanBinding(
|
||||||
|
{
|
||||||
|
(model.selectedEntry.value?.traditional?.length ?: 0) < 2
|
||||||
|
},
|
||||||
|
model.selectedEntry
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeListViewSentences() {
|
||||||
|
listViewSentences.apply {
|
||||||
|
cellFactory = SentenceCellFactory(resources, config, hostServices)
|
||||||
|
items = model.sentences
|
||||||
|
|
||||||
|
disableProperty().bind(Bindings.or(model.isFindingSentences, Bindings.isEmpty(model.sentences)))
|
||||||
|
}
|
||||||
|
progressIndicatorSentences.visibleProperty().bind(model.isFindingSentences)
|
||||||
|
labelNoSentencesFound
|
||||||
|
.visibleProperty()
|
||||||
|
.bind(Bindings.and(Bindings.isEmpty(model.sentences), Bindings.not(model.isFindingSentences)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeListViewWordsContaining() {
|
||||||
|
listViewWordsContaining.apply {
|
||||||
|
cellFactory = DictionaryEntryCellFactory(resources, config, hostServices)
|
||||||
|
items = model.wordsContaining
|
||||||
|
|
||||||
|
disableProperty().bind(Bindings.or(model.isFindingWordsContaining, Bindings.isEmpty(model.wordsContaining)))
|
||||||
|
|
||||||
|
selectionModel.selectedItemProperty().addListener { _, _, newEntry ->
|
||||||
|
if (newEntry == null) return@addListener
|
||||||
|
model.selectEntry(newEntry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
progressIndicatorWordsContaining.visibleProperty().bind(model.isFindingWordsContaining)
|
||||||
|
labelNoWordsContainingFound
|
||||||
|
.visibleProperty()
|
||||||
|
.bind(Bindings.and(Bindings.isEmpty(model.wordsContaining), Bindings.not(model.isFindingWordsContaining)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeListViewWordsBeginning() {
|
||||||
|
listViewWordsBeginning.apply {
|
||||||
|
cellFactory = DictionaryEntryCellFactory(resources, config, hostServices)
|
||||||
|
items = model.wordsBeginning
|
||||||
|
|
||||||
|
disableProperty().bind(Bindings.or(model.isFindingWordsBeginning, Bindings.isEmpty(model.wordsBeginning)))
|
||||||
|
|
||||||
|
selectionModel.selectedItemProperty().addListener { _, _, newEntry ->
|
||||||
|
if (newEntry == null) return@addListener
|
||||||
|
model.selectEntry(newEntry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
progressIndicatorWordsBeginning.visibleProperty().bind(model.isFindingWordsBeginning)
|
||||||
|
labelNoWordsBeginningFound
|
||||||
|
.visibleProperty()
|
||||||
|
.bind(Bindings.and(Bindings.isEmpty(model.wordsBeginning), Bindings.not(model.isFindingWordsBeginning)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeListViewCharacters() {
|
||||||
|
listViewCharacters.apply {
|
||||||
|
cellFactory = DictionaryEntryCellFactory(resources, config, hostServices)
|
||||||
|
items = model.characters
|
||||||
|
|
||||||
|
disableProperty().bind(Bindings.or(model.isFindingCharacters, Bindings.isEmpty(model.characters)))
|
||||||
|
|
||||||
|
selectionModel.selectedItemProperty().addListener { _, _, newEntry ->
|
||||||
|
if (newEntry == null) return@addListener
|
||||||
|
model.selectEntry(newEntry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
progressIndicatorCharacters.visibleProperty().bind(model.isFindingCharacters)
|
||||||
|
labelNoCharactersFound
|
||||||
|
.visibleProperty()
|
||||||
|
.bind(Bindings.and(Bindings.isEmpty(model.characters), Bindings.not(model.isFindingCharacters)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initializeWebViewDefinition() {
|
||||||
|
webViewDefinition.apply {
|
||||||
|
engine.userStyleSheetLocation = this::class.java.getResource("/css/definitions.css")!!.toExternalForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
model.selectedEntry.addListener { _, _, newEntry ->
|
||||||
|
if (newEntry == null) return@addListener
|
||||||
|
|
||||||
|
webViewDefinition.engine.loadContent(createDefinitionHtml(newEntry))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private fun headerOnContextMenuRequested(contextMenuEvent: ContextMenuEvent) {
|
||||||
|
if (model.selectedEntry.value == null) return
|
||||||
|
|
||||||
|
createContextMenuForEntry(model.selectedEntry.value, resources, hostServices).show(
|
||||||
|
flowPaneHeader.scene.window,
|
||||||
|
contextMenuEvent.screenX,
|
||||||
|
contextMenuEvent.screenY
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("ReturnCount")
|
||||||
|
private fun lazyUpdateTabContent(selectedTabId: String?) {
|
||||||
|
when (selectedTabId) {
|
||||||
|
"tabWords" -> {
|
||||||
|
if (!model.finishedFindingWordsContaining.value) {
|
||||||
|
model.findWordsContaining()
|
||||||
|
}
|
||||||
|
if (!model.finishedFindingWordsBeginning.value) {
|
||||||
|
model.findWordsBeginning()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
"tabCharacters" -> {
|
||||||
|
if (model.finishedFindingCharacters.value) return
|
||||||
|
|
||||||
|
model.findCharacters()
|
||||||
|
}
|
||||||
|
|
||||||
|
"tabSentences" -> {
|
||||||
|
if (model.finishedFindingSentences.value) return
|
||||||
|
|
||||||
|
model.findSentences()
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createDefinitionHtml(entry: DictionaryEntry) = createHTML().html {
|
||||||
|
body {
|
||||||
|
if (entry.cedictDefinitions.isNotEmpty()) {
|
||||||
|
div(classes = "cedict-definition") {
|
||||||
|
h1 {
|
||||||
|
+"CC-CEDICT"
|
||||||
|
}
|
||||||
|
cedictDefinition(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.crossStraitsDefinitions.isNotEmpty()) {
|
||||||
|
div(classes = "cross-straits-definition") {
|
||||||
|
h1 {
|
||||||
|
+"Cross-Straits"
|
||||||
|
}
|
||||||
|
crossStraitsDefinition(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.moedictDefinitions.isNotEmpty()) {
|
||||||
|
div(classes = "moe-definition") {
|
||||||
|
h1 {
|
||||||
|
+"MOE"
|
||||||
|
}
|
||||||
|
moeDefinition(entry)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun DIV.cedictDefinition(entry: DictionaryEntry) = ol {
|
||||||
|
for (definition in entry.cedictDefinitions) {
|
||||||
|
li {
|
||||||
|
+definition.joinToString(separator = "; ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun DIV.crossStraitsDefinition(entry: DictionaryEntry) = ol {
|
||||||
|
entry.crossStraitsDefinitions.forEach { definition ->
|
||||||
|
li {
|
||||||
|
span(classes = "definition") {
|
||||||
|
+definition.definition
|
||||||
|
}
|
||||||
|
if (definition.examples.isNotEmpty()) {
|
||||||
|
span(classes = "example") {
|
||||||
|
+definition.examples.joinToString(
|
||||||
|
prefix = "如:",
|
||||||
|
separator = "、",
|
||||||
|
postfix = "。"
|
||||||
|
) { "「$it」" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun DIV.moeDefinition(entry: DictionaryEntry) =
|
||||||
|
entry.moedictDefinitions.groupBy { it.type ?: "" }.entries.forEach { (type, definitions) ->
|
||||||
|
if (type != "") {
|
||||||
|
span(classes = "type") {
|
||||||
|
+type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ol {
|
||||||
|
definitions.forEach { definition ->
|
||||||
|
li {
|
||||||
|
span(classes = "definition") {
|
||||||
|
+definition.definition
|
||||||
|
}
|
||||||
|
|
||||||
|
definition.examples.forEach { example ->
|
||||||
|
span(classes = "example") {
|
||||||
|
+example
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
definition.quotes.forEach { quote ->
|
||||||
|
span(classes = "quote") {
|
||||||
|
+quote
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
definition.synonyms?.let {
|
||||||
|
span(classes = "synonyms") {
|
||||||
|
+"似:${it.replace(",", "、")}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
definition.antonyms?.let {
|
||||||
|
span(classes = "antonyms") {
|
||||||
|
+"反:${it.replace(",", "、")}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,39 +1,12 @@
|
|||||||
package com.marvinelsen.willow.ui.controllers
|
package com.marvinelsen.willow.ui.controllers
|
||||||
|
|
||||||
import com.marvinelsen.willow.Model
|
import com.marvinelsen.willow.Model
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
|
||||||
import javafx.beans.binding.Bindings
|
|
||||||
import javafx.fxml.FXML
|
import javafx.fxml.FXML
|
||||||
import javafx.scene.control.Label
|
|
||||||
import javafx.scene.control.ListView
|
|
||||||
import javafx.scene.control.ProgressIndicator
|
|
||||||
|
|
||||||
|
@Suppress("UnusedPrivateProperty", "UnusedPrivateMember")
|
||||||
class MainController(private val model: Model) {
|
class MainController(private val model: Model) {
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var progressIndicatorEntries: ProgressIndicator
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
@Suppress("UnusedPrivateProperty")
|
|
||||||
private lateinit var labelNoEntriesFound: Label
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private lateinit var listViewSearchResults: ListView<DictionaryEntryFx>
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
@Suppress("UnusedPrivateMember")
|
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
listViewSearchResults.items = model.searchResults
|
// no-op
|
||||||
listViewSearchResults
|
|
||||||
.disableProperty()
|
|
||||||
.bind(Bindings.or(model.isSearching, Bindings.isEmpty(model.searchResults)))
|
|
||||||
|
|
||||||
progressIndicatorEntries.visibleProperty().bind(model.isSearching)
|
|
||||||
|
|
||||||
listViewSearchResults.selectionModel.selectedItemProperty().addListener { _, _, newValue: DictionaryEntryFx? ->
|
|
||||||
if (newValue == null) {
|
|
||||||
return@addListener
|
|
||||||
}
|
|
||||||
model.selectEntry(newValue)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,23 @@
|
|||||||
package com.marvinelsen.willow.ui.controllers
|
package com.marvinelsen.willow.ui.controllers
|
||||||
|
|
||||||
import com.marvinelsen.willow.Model
|
import com.marvinelsen.willow.Model
|
||||||
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.ui.dialogs.PreferencesDialog
|
||||||
import javafx.application.Platform
|
import javafx.application.Platform
|
||||||
import javafx.beans.binding.Bindings
|
import javafx.beans.binding.Bindings
|
||||||
import javafx.fxml.FXML
|
import javafx.fxml.FXML
|
||||||
|
import javafx.scene.control.MenuBar
|
||||||
import javafx.scene.control.MenuItem
|
import javafx.scene.control.MenuItem
|
||||||
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
@Suppress("UnusedPrivateMember")
|
@Suppress("UnusedPrivateMember")
|
||||||
class MenuController(private val model: Model) {
|
class MenuController(private val model: Model, private val config: Config) {
|
||||||
|
@FXML
|
||||||
|
private lateinit var resources: ResourceBundle
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var menuBar: MenuBar
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var menuItemCopyHeadword: MenuItem
|
private lateinit var menuItemCopyHeadword: MenuItem
|
||||||
|
|
||||||
@ -20,6 +30,16 @@ class MenuController(private val model: Model) {
|
|||||||
menuItemCopyHeadword.disableProperty().bind(Bindings.isNull(model.selectedEntry))
|
menuItemCopyHeadword.disableProperty().bind(Bindings.isNull(model.selectedEntry))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private fun onMenuItemPreferencesAction() {
|
||||||
|
PreferencesDialog(menuBar.scene.window, config, resources).showAndWait().ifPresent { result ->
|
||||||
|
when (result) {
|
||||||
|
PreferencesDialog.Result.SAVE_CHANGES -> config.save()
|
||||||
|
PreferencesDialog.Result.DO_NOT_SAVE_CHANGES -> config.load()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private fun onMenuItemQuitAction() {
|
private fun onMenuItemQuitAction() {
|
||||||
Platform.exit()
|
Platform.exit()
|
||||||
|
@ -3,10 +3,17 @@ package com.marvinelsen.willow.ui.controllers
|
|||||||
import com.marvinelsen.willow.Model
|
import com.marvinelsen.willow.Model
|
||||||
import com.marvinelsen.willow.domain.SearchMode
|
import com.marvinelsen.willow.domain.SearchMode
|
||||||
import javafx.fxml.FXML
|
import javafx.fxml.FXML
|
||||||
|
import javafx.scene.control.Button
|
||||||
import javafx.scene.control.TextField
|
import javafx.scene.control.TextField
|
||||||
import javafx.scene.control.ToggleGroup
|
import javafx.scene.control.ToggleGroup
|
||||||
|
|
||||||
class SearchController(private val model: Model) {
|
class SearchController(private val model: Model) {
|
||||||
|
@FXML
|
||||||
|
private lateinit var buttonUndo: Button
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var buttonRedo: Button
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private lateinit var searchModeToggleGroup: ToggleGroup
|
private lateinit var searchModeToggleGroup: ToggleGroup
|
||||||
|
|
||||||
@ -16,13 +23,29 @@ class SearchController(private val model: Model) {
|
|||||||
@FXML
|
@FXML
|
||||||
@Suppress("UnusedPrivateMember")
|
@Suppress("UnusedPrivateMember")
|
||||||
private fun initialize() {
|
private fun initialize() {
|
||||||
textFieldSearch.textProperty().addListener { _, _, newValue ->
|
textFieldSearch.textProperty().addListener { _, _, _ -> search() }
|
||||||
if (newValue.isNullOrBlank()) {
|
searchModeToggleGroup.selectedToggleProperty().addListener { _, _, _ -> search() }
|
||||||
return@addListener
|
|
||||||
}
|
|
||||||
|
|
||||||
val searchMode = searchModeToggleGroup.selectedToggle.userData as SearchMode
|
buttonUndo.disableProperty().bind(model.canUndo.not())
|
||||||
model.search(newValue, searchMode)
|
buttonRedo.disableProperty().bind(model.canRedo.not())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun search() {
|
||||||
|
val searchQuery = textFieldSearch.text
|
||||||
|
val searchMode = searchModeToggleGroup.selectedToggle.userData as SearchMode
|
||||||
|
|
||||||
|
if (searchQuery.isNullOrBlank()) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.search(searchQuery, searchMode)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onButtonRedoAction() {
|
||||||
|
model.redoSelection()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun onButtonUndoAction() {
|
||||||
|
model.undoSelection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.marvinelsen.willow.ui.controllers
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.Model
|
||||||
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.ui.cells.DictionaryEntryCellFactory
|
||||||
|
import javafx.application.HostServices
|
||||||
|
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 java.util.ResourceBundle
|
||||||
|
|
||||||
|
class SearchResultsController(
|
||||||
|
private val model: Model,
|
||||||
|
private val config: Config,
|
||||||
|
private val hostServices: HostServices,
|
||||||
|
) {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var resources: ResourceBundle
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var progressIndicatorEntries: ProgressIndicator
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
@Suppress("UnusedPrivateProperty")
|
||||||
|
private lateinit var labelNoEntriesFound: Label
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var listViewSearchResults: ListView<DictionaryEntry>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
@Suppress("UnusedPrivateMember")
|
||||||
|
private fun initialize() {
|
||||||
|
listViewSearchResults.cellFactory = DictionaryEntryCellFactory(resources, config, hostServices)
|
||||||
|
listViewSearchResults.items = model.searchResults
|
||||||
|
listViewSearchResults
|
||||||
|
.disableProperty()
|
||||||
|
.bind(Bindings.or(model.isSearching, Bindings.isEmpty(model.searchResults)))
|
||||||
|
|
||||||
|
progressIndicatorEntries.visibleProperty().bind(model.isSearching)
|
||||||
|
labelNoEntriesFound
|
||||||
|
.visibleProperty()
|
||||||
|
.bind(Bindings.and(Bindings.isEmpty(model.searchResults), Bindings.not(model.isSearching)))
|
||||||
|
|
||||||
|
listViewSearchResults.selectionModel.selectedItemProperty().addListener { _, _, newValue: DictionaryEntry? ->
|
||||||
|
if (newValue == null) {
|
||||||
|
return@addListener
|
||||||
|
}
|
||||||
|
model.selectEntry(newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package com.marvinelsen.willow.ui.controllers.dialogs
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.config.Pronunciation
|
||||||
|
import com.marvinelsen.willow.config.Script
|
||||||
|
import com.marvinelsen.willow.config.Theme
|
||||||
|
import com.marvinelsen.willow.ui.formatters.FontSizeTextFormatter
|
||||||
|
import javafx.fxml.FXML
|
||||||
|
import javafx.scene.control.CheckBox
|
||||||
|
import javafx.scene.control.ComboBox
|
||||||
|
import javafx.scene.control.Spinner
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
@Suppress("UnusedPrivateMember")
|
||||||
|
class PreferencesDialogController(private val config: Config) {
|
||||||
|
@FXML
|
||||||
|
private lateinit var comboBoxLocale: ComboBox<Locale>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var comboBoxTheme: ComboBox<Theme>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var comboBoxScript: ComboBox<Script>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var comboBoxPronunciationSearchResults: ComboBox<Pronunciation>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var comboBoxPronunciationDetails: ComboBox<Pronunciation>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var checkBoxShowPronunciationSearchResults: CheckBox
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var checkBoxShowDefinitionSearchResults: CheckBox
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var spinnerHeadwordFontSizeDetails: Spinner<Int>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var spinnerPronunciationFontSizeDetails: Spinner<Int>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var spinnerHeadwordFontSizeSearchResults: Spinner<Int>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var spinnerPronunciationFontSizeSearchResults: Spinner<Int>
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private lateinit var spinnerDefinitionFontSizeSearchResults: Spinner<Int>
|
||||||
|
|
||||||
|
private val entryHeadwordFontSizeObjectProperty = config.details.headwordFontSize.asObject()
|
||||||
|
private val entryPronunciationFontSizeObjectProperty = config.details.pronunciationFontSize.asObject()
|
||||||
|
|
||||||
|
private val searchResultHeadwordFontSizeObjectProperty = config.searchResults.headwordFontSize.asObject()
|
||||||
|
private val searchResultPronunciationFontSizeObjectProperty = config.searchResults.pronunciationFontSize.asObject()
|
||||||
|
private val searchResultDefinitionFontSizeObjectProperty = config.searchResults.definitionFontSize.asObject()
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private fun initialize() {
|
||||||
|
comboBoxLocale.items.addAll(
|
||||||
|
setOf(
|
||||||
|
Locale.ENGLISH,
|
||||||
|
Locale.GERMAN,
|
||||||
|
Locale.CHINA,
|
||||||
|
Locale.TAIWAN
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
comboBoxTheme.valueProperty().bindBidirectional(config.theme)
|
||||||
|
comboBoxScript.valueProperty().bindBidirectional(config.script)
|
||||||
|
comboBoxLocale.valueProperty().bindBidirectional(config.locale)
|
||||||
|
comboBoxPronunciationSearchResults.valueProperty().bindBidirectional(config.searchResults.pronunciation)
|
||||||
|
comboBoxPronunciationDetails.valueProperty().bindBidirectional(config.details.pronunciation)
|
||||||
|
|
||||||
|
checkBoxShowDefinitionSearchResults
|
||||||
|
.selectedProperty()
|
||||||
|
.bindBidirectional(config.searchResults.shouldShowDefinition)
|
||||||
|
checkBoxShowPronunciationSearchResults
|
||||||
|
.selectedProperty()
|
||||||
|
.bindBidirectional(config.searchResults.shouldShowPronunciation)
|
||||||
|
|
||||||
|
with(spinnerHeadwordFontSizeDetails) {
|
||||||
|
editor.textFormatter = FontSizeTextFormatter()
|
||||||
|
valueFactory.valueProperty().bindBidirectional(entryHeadwordFontSizeObjectProperty)
|
||||||
|
}
|
||||||
|
|
||||||
|
with(spinnerPronunciationFontSizeDetails) {
|
||||||
|
editor.textFormatter = FontSizeTextFormatter()
|
||||||
|
valueFactory.valueProperty().bindBidirectional(entryPronunciationFontSizeObjectProperty)
|
||||||
|
}
|
||||||
|
|
||||||
|
with(spinnerHeadwordFontSizeSearchResults) {
|
||||||
|
editor.textFormatter = FontSizeTextFormatter()
|
||||||
|
valueFactory.valueProperty().bindBidirectional(searchResultHeadwordFontSizeObjectProperty)
|
||||||
|
}
|
||||||
|
|
||||||
|
with(spinnerPronunciationFontSizeSearchResults) {
|
||||||
|
editor.textFormatter = FontSizeTextFormatter()
|
||||||
|
valueFactory.valueProperty().bindBidirectional(searchResultPronunciationFontSizeObjectProperty)
|
||||||
|
}
|
||||||
|
|
||||||
|
with(spinnerDefinitionFontSizeSearchResults) {
|
||||||
|
editor.textFormatter = FontSizeTextFormatter()
|
||||||
|
valueFactory.valueProperty().bindBidirectional(searchResultDefinitionFontSizeObjectProperty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.marvinelsen.willow.ui.converters
|
||||||
|
|
||||||
|
import javafx.util.StringConverter
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
class LocaleStringConverter : StringConverter<Locale>() {
|
||||||
|
override fun toString(locale: Locale): String = locale.displayName
|
||||||
|
override fun fromString(string: String) = null
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.marvinelsen.willow.ui.converters
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Pronunciation
|
||||||
|
import javafx.util.StringConverter
|
||||||
|
|
||||||
|
class PronunciationStringConverter : StringConverter<Pronunciation>() {
|
||||||
|
override fun toString(pronunciation: Pronunciation) = when (pronunciation) {
|
||||||
|
Pronunciation.PINYIN_WITH_TONE_MARKS -> "Pinyin with tone marks"
|
||||||
|
Pronunciation.PINYIN_WITH_TONE_NUMBERS -> "Pinyin with tone numbers"
|
||||||
|
Pronunciation.ZHUYIN -> "Zhuyin"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fromString(string: String) = null
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.marvinelsen.willow.ui.converters
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Script
|
||||||
|
import javafx.util.StringConverter
|
||||||
|
|
||||||
|
class ScriptStringConverter : StringConverter<Script>() {
|
||||||
|
override fun toString(script: Script): String = when (script) {
|
||||||
|
Script.SIMPLIFIED -> "Simplified"
|
||||||
|
Script.TRADITIONAL -> "Traditional"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fromString(string: String) = null
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.marvinelsen.willow.ui.converters
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Theme
|
||||||
|
import javafx.util.StringConverter
|
||||||
|
|
||||||
|
class ThemeStringConverter : StringConverter<Theme>() {
|
||||||
|
override fun toString(theme: Theme): String = when (theme) {
|
||||||
|
Theme.SYSTEM -> "System"
|
||||||
|
Theme.LIGHT -> "Light"
|
||||||
|
Theme.DARK -> "Dark"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fromString(string: String) = null
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.marvinelsen.willow.ui.dialogs
|
||||||
|
|
||||||
|
import com.marvinelsen.willow.config.Config
|
||||||
|
import com.marvinelsen.willow.ui.controllers.dialogs.PreferencesDialogController
|
||||||
|
import javafx.fxml.FXMLLoader
|
||||||
|
import javafx.scene.control.ButtonType
|
||||||
|
import javafx.scene.control.Dialog
|
||||||
|
import javafx.scene.control.DialogPane
|
||||||
|
import javafx.stage.Modality
|
||||||
|
import javafx.stage.Stage
|
||||||
|
import javafx.stage.Window
|
||||||
|
import javafx.util.Callback
|
||||||
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
|
class PreferencesDialog(
|
||||||
|
owner: Window?,
|
||||||
|
config: Config,
|
||||||
|
resources: ResourceBundle,
|
||||||
|
) : Dialog<PreferencesDialog.Result>() {
|
||||||
|
companion object {
|
||||||
|
private const val MIN_HEIGHT = 400.0
|
||||||
|
private const val MIN_WIDTH = 400.0
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class Result {
|
||||||
|
SAVE_CHANGES, DO_NOT_SAVE_CHANGES
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
val fxmlLoader = FXMLLoader()
|
||||||
|
fxmlLoader.resources = resources
|
||||||
|
fxmlLoader.controllerFactory = Callback { type ->
|
||||||
|
when (type) {
|
||||||
|
PreferencesDialogController::class.java -> PreferencesDialogController(config)
|
||||||
|
else -> error("Trying to instantiate unknown controller type $type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val root = fxmlLoader.load(javaClass.getResourceAsStream("/fxml/dialogs/preferences.fxml")) as DialogPane
|
||||||
|
root.prefHeightProperty().bind(dialogPane.scene.heightProperty())
|
||||||
|
root.prefWidthProperty().bind(dialogPane.scene.widthProperty())
|
||||||
|
|
||||||
|
dialogPane = root
|
||||||
|
title = "Settings"
|
||||||
|
isResizable = true
|
||||||
|
|
||||||
|
initOwner(owner)
|
||||||
|
initModality(Modality.APPLICATION_MODAL)
|
||||||
|
|
||||||
|
(dialogPane.scene.window as Stage).apply {
|
||||||
|
minWidth = MIN_WIDTH
|
||||||
|
minHeight = MIN_HEIGHT
|
||||||
|
}
|
||||||
|
|
||||||
|
resultConverter = Callback(::convertToResult)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun convertToResult(buttonType: ButtonType) =
|
||||||
|
when (buttonType) {
|
||||||
|
ButtonType.APPLY -> Result.SAVE_CHANGES
|
||||||
|
else -> Result.DO_NOT_SAVE_CHANGES
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.marvinelsen.willow.ui.formatters
|
||||||
|
|
||||||
|
import javafx.scene.control.TextFormatter
|
||||||
|
import javafx.util.converter.IntegerStringConverter
|
||||||
|
import java.util.function.UnaryOperator
|
||||||
|
|
||||||
|
private val digitRegex = """\d*""".toRegex()
|
||||||
|
|
||||||
|
class FontSizeTextFormatter : TextFormatter<Int>(
|
||||||
|
IntegerStringConverter(),
|
||||||
|
1,
|
||||||
|
UnaryOperator { if (digitRegex.matches(it.text)) it else null }
|
||||||
|
)
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.marvinelsen.willow.ui.undo
|
||||||
|
|
||||||
|
interface Command {
|
||||||
|
fun execute()
|
||||||
|
fun undo()
|
||||||
|
fun redo() = execute()
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.marvinelsen.willow.ui.undo
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty
|
||||||
|
import java.util.Stack
|
||||||
|
|
||||||
|
class UndoManager {
|
||||||
|
private val undoStack = Stack<Command>()
|
||||||
|
private val redoStack = Stack<Command>()
|
||||||
|
|
||||||
|
val canUndoProperty = SimpleBooleanProperty(false)
|
||||||
|
val canRedoProperty = SimpleBooleanProperty(false)
|
||||||
|
|
||||||
|
fun execute(command: Command) {
|
||||||
|
redoStack.clear()
|
||||||
|
|
||||||
|
undoStack.push(command).execute()
|
||||||
|
|
||||||
|
canUndoProperty.value = undoStack.size > 1
|
||||||
|
canRedoProperty.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun undo() {
|
||||||
|
if (undoStack.isEmpty()) return
|
||||||
|
|
||||||
|
redoStack.push(undoStack.pop()).undo()
|
||||||
|
|
||||||
|
canUndoProperty.value = undoStack.size > 1
|
||||||
|
canRedoProperty.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun redo() {
|
||||||
|
if (redoStack.isEmpty()) return
|
||||||
|
|
||||||
|
undoStack.push(redoStack.pop()).redo()
|
||||||
|
|
||||||
|
canUndoProperty.value = true
|
||||||
|
canRedoProperty.value = !redoStack.isEmpty()
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,14 @@
|
|||||||
package com.marvinelsen.willow.ui.util
|
package com.marvinelsen.willow.ui.util
|
||||||
|
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
|
||||||
import javafx.scene.input.Clipboard
|
import javafx.scene.input.Clipboard
|
||||||
import javafx.scene.input.ClipboardContent
|
import javafx.scene.input.ClipboardContent
|
||||||
|
|
||||||
object ClipboardHelper {
|
object ClipboardHelper {
|
||||||
private val systemClipboard = Clipboard.getSystemClipboard()
|
private val systemClipboard = Clipboard.getSystemClipboard()
|
||||||
|
|
||||||
fun copyHeadword(entry: DictionaryEntryFx) {
|
fun copyString(string: String) {
|
||||||
val clipboardContent = ClipboardContent()
|
val clipboardContent = ClipboardContent()
|
||||||
clipboardContent.putString(entry.traditionalProperty.value)
|
clipboardContent.putString(string)
|
||||||
systemClipboard.setContent(clipboardContent)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun copyPronunciation(entry: DictionaryEntryFx) {
|
|
||||||
val clipboardContent = ClipboardContent()
|
|
||||||
clipboardContent.putString(entry.pinyinWithToneMarksProperty.value)
|
|
||||||
systemClipboard.setContent(clipboardContent)
|
systemClipboard.setContent(clipboardContent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package com.marvinelsen.willow.ui.util
|
|
||||||
|
|
||||||
import javafx.concurrent.Task
|
|
||||||
|
|
||||||
fun <T> task(block: () -> T) = object : Task<T>() {
|
|
||||||
override fun call() = block()
|
|
||||||
}
|
|
@ -1,18 +1,58 @@
|
|||||||
package com.marvinelsen.willow.ui.util
|
package com.marvinelsen.willow.ui.util
|
||||||
|
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
import com.marvinelsen.willow.domain.entities.DictionaryEntry
|
||||||
|
import com.marvinelsen.willow.domain.entities.Sentence
|
||||||
|
import javafx.application.HostServices
|
||||||
import javafx.event.EventHandler
|
import javafx.event.EventHandler
|
||||||
import javafx.scene.control.ContextMenu
|
import javafx.scene.control.ContextMenu
|
||||||
import javafx.scene.control.MenuItem
|
import javafx.scene.control.MenuItem
|
||||||
|
import java.net.URLEncoder
|
||||||
|
import java.nio.charset.StandardCharsets
|
||||||
|
import java.util.ResourceBundle
|
||||||
|
|
||||||
fun createContextMenuForEntry(entry: DictionaryEntryFx) = ContextMenu().apply {
|
fun createContextMenuForEntry(
|
||||||
val menuItemCopyHeadword = MenuItem("Copy Headword").apply {
|
entry: DictionaryEntry,
|
||||||
onAction = EventHandler { ClipboardHelper.copyHeadword(entry) }
|
resourceBundle: ResourceBundle,
|
||||||
}
|
hostServices: HostServices,
|
||||||
|
) = ContextMenu().apply {
|
||||||
|
val menuItemCopyHeadword =
|
||||||
|
MenuItem(resourceBundle.getString("menubar.edit.copy.headword")).apply {
|
||||||
|
onAction = EventHandler { ClipboardHelper.copyString(entry.traditional) }
|
||||||
|
}
|
||||||
|
|
||||||
val menuItemCopyPronunciation = MenuItem("Copy Pronunciation").apply {
|
val menuItemCopyPronunciation =
|
||||||
onAction = EventHandler { ClipboardHelper.copyPronunciation(entry) }
|
MenuItem(resourceBundle.getString("menubar.edit.copy.pronunciation")).apply {
|
||||||
}
|
onAction = EventHandler { ClipboardHelper.copyString(entry.pinyinWithToneMarks) }
|
||||||
|
}
|
||||||
|
|
||||||
items.addAll(menuItemCopyHeadword, menuItemCopyPronunciation)
|
val menuItemSearchOnWeb =
|
||||||
|
MenuItem(resourceBundle.getString("menubar.edit.search-web")).apply {
|
||||||
|
onAction = EventHandler {
|
||||||
|
val query = URLEncoder.encode(entry.traditional, StandardCharsets.UTF_8)
|
||||||
|
hostServices.showDocument("https://duckduckgo.com/?q=$query")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.addAll(menuItemCopyHeadword, menuItemCopyPronunciation, menuItemSearchOnWeb)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun createContextMenuForSentence(
|
||||||
|
sentence: Sentence,
|
||||||
|
resourceBundle: ResourceBundle,
|
||||||
|
hostServices: HostServices,
|
||||||
|
) = ContextMenu().apply {
|
||||||
|
val menuItemCopySentence =
|
||||||
|
MenuItem(resourceBundle.getString("menubar.edit.copy.sentence")).apply {
|
||||||
|
onAction = EventHandler { ClipboardHelper.copyString(sentence.traditional) }
|
||||||
|
}
|
||||||
|
|
||||||
|
val menuItemSearchOnWeb =
|
||||||
|
MenuItem(resourceBundle.getString("menubar.edit.search-web")).apply {
|
||||||
|
onAction = EventHandler {
|
||||||
|
val query = URLEncoder.encode(sentence.traditional, StandardCharsets.UTF_8)
|
||||||
|
hostServices.showDocument("https://duckduckgo.com/?q=$query")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.addAll(menuItemCopySentence, menuItemSearchOnWeb)
|
||||||
}
|
}
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package com.marvinelsen.willow.ui.util
|
|
||||||
|
|
||||||
import com.marvinelsen.willow.domain.Dictionary
|
|
||||||
import com.marvinelsen.willow.domain.SearchMode
|
|
||||||
import com.marvinelsen.willow.ui.DictionaryEntryFx
|
|
||||||
import com.marvinelsen.willow.ui.toDomain
|
|
||||||
import com.marvinelsen.willow.ui.toFx
|
|
||||||
import javafx.collections.FXCollections
|
|
||||||
import javafx.collections.ObservableList
|
|
||||||
import javafx.concurrent.Service
|
|
||||||
|
|
||||||
class SearchService(private val dictionary: Dictionary) : Service<ObservableList<DictionaryEntryFx>>() {
|
|
||||||
lateinit var searchQuery: String
|
|
||||||
lateinit var searchMode: SearchMode
|
|
||||||
|
|
||||||
override fun createTask() = task {
|
|
||||||
if (!this::searchQuery.isInitialized) error("Search query is not initialized")
|
|
||||||
if (!this::searchMode.isInitialized) error("Search mode is not initialized")
|
|
||||||
|
|
||||||
FXCollections.observableList(dictionary.search(searchQuery, searchMode).map { it.toFx() })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class FindWordsService(private val dictionary: Dictionary) : Service<ObservableList<DictionaryEntryFx>>() {
|
|
||||||
lateinit var entry: DictionaryEntryFx
|
|
||||||
|
|
||||||
override fun createTask() = task {
|
|
||||||
if (!this::entry.isInitialized) error("Entry is not initialized")
|
|
||||||
|
|
||||||
FXCollections.observableList(dictionary.findWordsContaining(entry.toDomain()).map { it.toFx() })
|
|
||||||
}
|
|
||||||
}
|
|
38
src/main/resources/css/dark.css
Normal file
38
src/main/resources/css/dark.css
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
JavaFX CSS Reference Guide
|
||||||
|
https://openjfx.io/javadoc/23/javafx.graphics/javafx/scene/doc-files/cssref.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
.root {
|
||||||
|
willow-background: #282828;
|
||||||
|
willow-foreground: #dfdfdf;
|
||||||
|
|
||||||
|
-fx-base: willow-background;
|
||||||
|
-fx-accent: #5c7654;
|
||||||
|
-fx-focus-color: #3e8f25;
|
||||||
|
|
||||||
|
-fx-background-color: willow-background;
|
||||||
|
-fx-text-fill: willow-foreground;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*.split-pane {
|
||||||
|
-fx-background-color: willow-background;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
.label {
|
||||||
|
-fx-text-fill: willow-foreground;
|
||||||
|
}
|
||||||
|
|
||||||
|
.radio-button {
|
||||||
|
-fx-text-fill: willow-foreground;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-cell:even {
|
||||||
|
-fx-text-fill: willow-foreground;
|
||||||
|
-fx-background: #1e1e1e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-cell:odd {
|
||||||
|
-fx-text-fill: willow-foreground;
|
||||||
|
-fx-background: #292929;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
html {
|
html {
|
||||||
font-family: "Noto Sans TC";
|
font-family: "Noto Sans TC";
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
line-height: 1.7em;
|
line-height: 1.7em;
|
||||||
|
|
||||||
border: 1px solid #B5B5B5;
|
border: 1px solid #B5B5B5;
|
||||||
@ -15,6 +15,11 @@ h1 {
|
|||||||
font-size: 1.25em;
|
font-size: 1.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ol {
|
||||||
|
padding-left: 0;
|
||||||
|
list-style-position: inside;
|
||||||
|
}
|
||||||
|
|
||||||
ol li:only-child {
|
ol li:only-child {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
.headword {
|
.headword {
|
||||||
-fx-font-family: TW-Kai;
|
-fx-font-family: TW-Kai;
|
||||||
-fx-font-size: 40;
|
}
|
||||||
|
|
||||||
|
.pronunciation {
|
||||||
|
-fx-font-family: "Noto Sans TC";
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-view .headword {
|
||||||
|
-fx-font-family: "Noto Sans TC";
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-view .sentence {
|
||||||
|
-fx-font-family: "Noto Sans TC";
|
||||||
|
-fx-font-size: 14px;
|
||||||
}
|
}
|
||||||
|
@ -1,42 +1,3 @@
|
|||||||
.root {
|
.root {
|
||||||
-fx-font-family: "Inter Variable";
|
-fx-font-family: "Inter Variable";
|
||||||
}
|
}
|
||||||
|
|
||||||
.chinese {
|
|
||||||
-fx-font-family: "Noto Sans CJK TC";
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view {
|
|
||||||
-fx-selection-bar: #B8EEFF;
|
|
||||||
-fx-font-family: "Noto Sans CJK TC";
|
|
||||||
/*-fx-selection-bar-non-focused: green;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view-entry {
|
|
||||||
-fx-font-size: 20;
|
|
||||||
-fx-font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view-definition {
|
|
||||||
-fx-font-size: 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view-pronunciation {
|
|
||||||
-fx-font-size: 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view-sentence-cell {
|
|
||||||
-fx-font-size: 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
.moe-definition {
|
|
||||||
-fx-font-size: 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pronunciation {
|
|
||||||
-fx-font: 16 "Noto Sans CJK TC";
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-dialog .content {
|
|
||||||
-fx-padding: 0;
|
|
||||||
}
|
|
3
src/main/resources/css/preferences.css
Normal file
3
src/main/resources/css/preferences.css
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
.preferences-dialog .content {
|
||||||
|
-fx-padding: 0;
|
||||||
|
}
|
17
src/main/resources/css/search-results.css
Normal file
17
src/main/resources/css/search-results.css
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
.list-view:focused .list-cell:filled:focused:selected .search-result {
|
||||||
|
/*-fx-text-fill: red;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.headword {
|
||||||
|
-fx-font-family: "Noto Sans TC";
|
||||||
|
/*-fx-font-weight: bold;*/
|
||||||
|
/*-fx-text-fill: inherit;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.pronunciation {
|
||||||
|
/*-fx-text-fill: inherit;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.definition {
|
||||||
|
/*-fx-text-fill: inherit;*/
|
||||||
|
}
|
@ -1,428 +0,0 @@
|
|||||||
Attribution-ShareAlike 4.0 International
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
|
||||||
does not provide legal services or legal advice. Distribution of
|
|
||||||
Creative Commons public licenses does not create a lawyer-client or
|
|
||||||
other relationship. Creative Commons makes its licenses and related
|
|
||||||
information available on an "as-is" basis. Creative Commons gives no
|
|
||||||
warranties regarding its licenses, any material licensed under their
|
|
||||||
terms and conditions, or any related information. Creative Commons
|
|
||||||
disclaims all liability for damages resulting from their use to the
|
|
||||||
fullest extent possible.
|
|
||||||
|
|
||||||
Using Creative Commons Public Licenses
|
|
||||||
|
|
||||||
Creative Commons public licenses provide a standard set of terms and
|
|
||||||
conditions that creators and other rights holders may use to share
|
|
||||||
original works of authorship and other material subject to copyright
|
|
||||||
and certain other rights specified in the public license below. The
|
|
||||||
following considerations are for informational purposes only, are not
|
|
||||||
exhaustive, and do not form part of our licenses.
|
|
||||||
|
|
||||||
Considerations for licensors: Our public licenses are
|
|
||||||
intended for use by those authorized to give the public
|
|
||||||
permission to use material in ways otherwise restricted by
|
|
||||||
copyright and certain other rights. Our licenses are
|
|
||||||
irrevocable. Licensors should read and understand the terms
|
|
||||||
and conditions of the license they choose before applying it.
|
|
||||||
Licensors should also secure all rights necessary before
|
|
||||||
applying our licenses so that the public can reuse the
|
|
||||||
material as expected. Licensors should clearly mark any
|
|
||||||
material not subject to the license. This includes other CC-
|
|
||||||
licensed material, or material used under an exception or
|
|
||||||
limitation to copyright. More considerations for licensors:
|
|
||||||
wiki.creativecommons.org/Considerations_for_licensors
|
|
||||||
|
|
||||||
Considerations for the public: By using one of our public
|
|
||||||
licenses, a licensor grants the public permission to use the
|
|
||||||
licensed material under specified terms and conditions. If
|
|
||||||
the licensor's permission is not necessary for any reason--for
|
|
||||||
example, because of any applicable exception or limitation to
|
|
||||||
copyright--then that use is not regulated by the license. Our
|
|
||||||
licenses grant only permissions under copyright and certain
|
|
||||||
other rights that a licensor has authority to grant. Use of
|
|
||||||
the licensed material may still be restricted for other
|
|
||||||
reasons, including because others have copyright or other
|
|
||||||
rights in the material. A licensor may make special requests,
|
|
||||||
such as asking that all changes be marked or described.
|
|
||||||
Although not required by our licenses, you are encouraged to
|
|
||||||
respect those requests where reasonable. More considerations
|
|
||||||
for the public:
|
|
||||||
wiki.creativecommons.org/Considerations_for_licensees
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons Attribution-ShareAlike 4.0 International Public
|
|
||||||
License
|
|
||||||
|
|
||||||
By exercising the Licensed Rights (defined below), You accept and agree
|
|
||||||
to be bound by the terms and conditions of this Creative Commons
|
|
||||||
Attribution-ShareAlike 4.0 International Public License ("Public
|
|
||||||
License"). To the extent this Public License may be interpreted as a
|
|
||||||
contract, You are granted the Licensed Rights in consideration of Your
|
|
||||||
acceptance of these terms and conditions, and the Licensor grants You
|
|
||||||
such rights in consideration of benefits the Licensor receives from
|
|
||||||
making the Licensed Material available under these terms and
|
|
||||||
conditions.
|
|
||||||
|
|
||||||
|
|
||||||
Section 1 -- Definitions.
|
|
||||||
|
|
||||||
a. Adapted Material means material subject to Copyright and Similar
|
|
||||||
Rights that is derived from or based upon the Licensed Material
|
|
||||||
and in which the Licensed Material is translated, altered,
|
|
||||||
arranged, transformed, or otherwise modified in a manner requiring
|
|
||||||
permission under the Copyright and Similar Rights held by the
|
|
||||||
Licensor. For purposes of this Public License, where the Licensed
|
|
||||||
Material is a musical work, performance, or sound recording,
|
|
||||||
Adapted Material is always produced where the Licensed Material is
|
|
||||||
synched in timed relation with a moving image.
|
|
||||||
|
|
||||||
b. Adapter's License means the license You apply to Your Copyright
|
|
||||||
and Similar Rights in Your contributions to Adapted Material in
|
|
||||||
accordance with the terms and conditions of this Public License.
|
|
||||||
|
|
||||||
c. BY-SA Compatible License means a license listed at
|
|
||||||
creativecommons.org/compatiblelicenses, approved by Creative
|
|
||||||
Commons as essentially the equivalent of this Public License.
|
|
||||||
|
|
||||||
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
||||||
closely related to copyright including, without limitation,
|
|
||||||
performance, broadcast, sound recording, and Sui Generis Database
|
|
||||||
Rights, without regard to how the rights are labeled or
|
|
||||||
categorized. For purposes of this Public License, the rights
|
|
||||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
||||||
Rights.
|
|
||||||
|
|
||||||
e. Effective Technological Measures means those measures that, in the
|
|
||||||
absence of proper authority, may not be circumvented under laws
|
|
||||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
||||||
Treaty adopted on December 20, 1996, and/or similar international
|
|
||||||
agreements.
|
|
||||||
|
|
||||||
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
||||||
any other exception or limitation to Copyright and Similar Rights
|
|
||||||
that applies to Your use of the Licensed Material.
|
|
||||||
|
|
||||||
g. License Elements means the license attributes listed in the name
|
|
||||||
of a Creative Commons Public License. The License Elements of this
|
|
||||||
Public License are Attribution and ShareAlike.
|
|
||||||
|
|
||||||
h. Licensed Material means the artistic or literary work, database,
|
|
||||||
or other material to which the Licensor applied this Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
i. Licensed Rights means the rights granted to You subject to the
|
|
||||||
terms and conditions of this Public License, which are limited to
|
|
||||||
all Copyright and Similar Rights that apply to Your use of the
|
|
||||||
Licensed Material and that the Licensor has authority to license.
|
|
||||||
|
|
||||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
||||||
under this Public License.
|
|
||||||
|
|
||||||
k. Share means to provide material to the public by any means or
|
|
||||||
process that requires permission under the Licensed Rights, such
|
|
||||||
as reproduction, public display, public performance, distribution,
|
|
||||||
dissemination, communication, or importation, and to make material
|
|
||||||
available to the public including in ways that members of the
|
|
||||||
public may access the material from a place and at a time
|
|
||||||
individually chosen by them.
|
|
||||||
|
|
||||||
l. Sui Generis Database Rights means rights other than copyright
|
|
||||||
resulting from Directive 96/9/EC of the European Parliament and of
|
|
||||||
the Council of 11 March 1996 on the legal protection of databases,
|
|
||||||
as amended and/or succeeded, as well as other essentially
|
|
||||||
equivalent rights anywhere in the world.
|
|
||||||
|
|
||||||
m. You means the individual or entity exercising the Licensed Rights
|
|
||||||
under this Public License. Your has a corresponding meaning.
|
|
||||||
|
|
||||||
|
|
||||||
Section 2 -- Scope.
|
|
||||||
|
|
||||||
a. License grant.
|
|
||||||
|
|
||||||
1. Subject to the terms and conditions of this Public License,
|
|
||||||
the Licensor hereby grants You a worldwide, royalty-free,
|
|
||||||
non-sublicensable, non-exclusive, irrevocable license to
|
|
||||||
exercise the Licensed Rights in the Licensed Material to:
|
|
||||||
|
|
||||||
a. reproduce and Share the Licensed Material, in whole or
|
|
||||||
in part; and
|
|
||||||
|
|
||||||
b. produce, reproduce, and Share Adapted Material.
|
|
||||||
|
|
||||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
||||||
Exceptions and Limitations apply to Your use, this Public
|
|
||||||
License does not apply, and You do not need to comply with
|
|
||||||
its terms and conditions.
|
|
||||||
|
|
||||||
3. Term. The term of this Public License is specified in Section
|
|
||||||
6(a).
|
|
||||||
|
|
||||||
4. Media and formats; technical modifications allowed. The
|
|
||||||
Licensor authorizes You to exercise the Licensed Rights in
|
|
||||||
all media and formats whether now known or hereafter created,
|
|
||||||
and to make technical modifications necessary to do so. The
|
|
||||||
Licensor waives and/or agrees not to assert any right or
|
|
||||||
authority to forbid You from making technical modifications
|
|
||||||
necessary to exercise the Licensed Rights, including
|
|
||||||
technical modifications necessary to circumvent Effective
|
|
||||||
Technological Measures. For purposes of this Public License,
|
|
||||||
simply making modifications authorized by this Section 2(a)
|
|
||||||
(4) never produces Adapted Material.
|
|
||||||
|
|
||||||
5. Downstream recipients.
|
|
||||||
|
|
||||||
a. Offer from the Licensor -- Licensed Material. Every
|
|
||||||
recipient of the Licensed Material automatically
|
|
||||||
receives an offer from the Licensor to exercise the
|
|
||||||
Licensed Rights under the terms and conditions of this
|
|
||||||
Public License.
|
|
||||||
|
|
||||||
b. Additional offer from the Licensor -- Adapted Material.
|
|
||||||
Every recipient of Adapted Material from You
|
|
||||||
automatically receives an offer from the Licensor to
|
|
||||||
exercise the Licensed Rights in the Adapted Material
|
|
||||||
under the conditions of the Adapter's License You apply.
|
|
||||||
|
|
||||||
c. No downstream restrictions. You may not offer or impose
|
|
||||||
any additional or different terms or conditions on, or
|
|
||||||
apply any Effective Technological Measures to, the
|
|
||||||
Licensed Material if doing so restricts exercise of the
|
|
||||||
Licensed Rights by any recipient of the Licensed
|
|
||||||
Material.
|
|
||||||
|
|
||||||
6. No endorsement. Nothing in this Public License constitutes or
|
|
||||||
may be construed as permission to assert or imply that You
|
|
||||||
are, or that Your use of the Licensed Material is, connected
|
|
||||||
with, or sponsored, endorsed, or granted official status by,
|
|
||||||
the Licensor or others designated to receive attribution as
|
|
||||||
provided in Section 3(a)(1)(A)(i).
|
|
||||||
|
|
||||||
b. Other rights.
|
|
||||||
|
|
||||||
1. Moral rights, such as the right of integrity, are not
|
|
||||||
licensed under this Public License, nor are publicity,
|
|
||||||
privacy, and/or other similar personality rights; however, to
|
|
||||||
the extent possible, the Licensor waives and/or agrees not to
|
|
||||||
assert any such rights held by the Licensor to the limited
|
|
||||||
extent necessary to allow You to exercise the Licensed
|
|
||||||
Rights, but not otherwise.
|
|
||||||
|
|
||||||
2. Patent and trademark rights are not licensed under this
|
|
||||||
Public License.
|
|
||||||
|
|
||||||
3. To the extent possible, the Licensor waives any right to
|
|
||||||
collect royalties from You for the exercise of the Licensed
|
|
||||||
Rights, whether directly or through a collecting society
|
|
||||||
under any voluntary or waivable statutory or compulsory
|
|
||||||
licensing scheme. In all other cases the Licensor expressly
|
|
||||||
reserves any right to collect such royalties.
|
|
||||||
|
|
||||||
|
|
||||||
Section 3 -- License Conditions.
|
|
||||||
|
|
||||||
Your exercise of the Licensed Rights is expressly made subject to the
|
|
||||||
following conditions.
|
|
||||||
|
|
||||||
a. Attribution.
|
|
||||||
|
|
||||||
1. If You Share the Licensed Material (including in modified
|
|
||||||
form), You must:
|
|
||||||
|
|
||||||
a. retain the following if it is supplied by the Licensor
|
|
||||||
with the Licensed Material:
|
|
||||||
|
|
||||||
i. identification of the creator(s) of the Licensed
|
|
||||||
Material and any others designated to receive
|
|
||||||
attribution, in any reasonable manner requested by
|
|
||||||
the Licensor (including by pseudonym if
|
|
||||||
designated);
|
|
||||||
|
|
||||||
ii. a copyright notice;
|
|
||||||
|
|
||||||
iii. a notice that refers to this Public License;
|
|
||||||
|
|
||||||
iv. a notice that refers to the disclaimer of
|
|
||||||
warranties;
|
|
||||||
|
|
||||||
v. a URI or hyperlink to the Licensed Material to the
|
|
||||||
extent reasonably practicable;
|
|
||||||
|
|
||||||
b. indicate if You modified the Licensed Material and
|
|
||||||
retain an indication of any previous modifications; and
|
|
||||||
|
|
||||||
c. indicate the Licensed Material is licensed under this
|
|
||||||
Public License, and include the text of, or the URI or
|
|
||||||
hyperlink to, this Public License.
|
|
||||||
|
|
||||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
||||||
reasonable manner based on the medium, means, and context in
|
|
||||||
which You Share the Licensed Material. For example, it may be
|
|
||||||
reasonable to satisfy the conditions by providing a URI or
|
|
||||||
hyperlink to a resource that includes the required
|
|
||||||
information.
|
|
||||||
|
|
||||||
3. If requested by the Licensor, You must remove any of the
|
|
||||||
information required by Section 3(a)(1)(A) to the extent
|
|
||||||
reasonably practicable.
|
|
||||||
|
|
||||||
b. ShareAlike.
|
|
||||||
|
|
||||||
In addition to the conditions in Section 3(a), if You Share
|
|
||||||
Adapted Material You produce, the following conditions also apply.
|
|
||||||
|
|
||||||
1. The Adapter's License You apply must be a Creative Commons
|
|
||||||
license with the same License Elements, this version or
|
|
||||||
later, or a BY-SA Compatible License.
|
|
||||||
|
|
||||||
2. You must include the text of, or the URI or hyperlink to, the
|
|
||||||
Adapter's License You apply. You may satisfy this condition
|
|
||||||
in any reasonable manner based on the medium, means, and
|
|
||||||
context in which You Share Adapted Material.
|
|
||||||
|
|
||||||
3. You may not offer or impose any additional or different terms
|
|
||||||
or conditions on, or apply any Effective Technological
|
|
||||||
Measures to, Adapted Material that restrict exercise of the
|
|
||||||
rights granted under the Adapter's License You apply.
|
|
||||||
|
|
||||||
|
|
||||||
Section 4 -- Sui Generis Database Rights.
|
|
||||||
|
|
||||||
Where the Licensed Rights include Sui Generis Database Rights that
|
|
||||||
apply to Your use of the Licensed Material:
|
|
||||||
|
|
||||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
||||||
to extract, reuse, reproduce, and Share all or a substantial
|
|
||||||
portion of the contents of the database;
|
|
||||||
|
|
||||||
b. if You include all or a substantial portion of the database
|
|
||||||
contents in a database in which You have Sui Generis Database
|
|
||||||
Rights, then the database in which You have Sui Generis Database
|
|
||||||
Rights (but not its individual contents) is Adapted Material,
|
|
||||||
including for purposes of Section 3(b); and
|
|
||||||
|
|
||||||
c. You must comply with the conditions in Section 3(a) if You Share
|
|
||||||
all or a substantial portion of the contents of the database.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 4 supplements and does not
|
|
||||||
replace Your obligations under this Public License where the Licensed
|
|
||||||
Rights include other Copyright and Similar Rights.
|
|
||||||
|
|
||||||
|
|
||||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
||||||
|
|
||||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
||||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
||||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
||||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
||||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
||||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
||||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
||||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
||||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
||||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
||||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
||||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
||||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
||||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
||||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
||||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
c. The disclaimer of warranties and limitation of liability provided
|
|
||||||
above shall be interpreted in a manner that, to the extent
|
|
||||||
possible, most closely approximates an absolute disclaimer and
|
|
||||||
waiver of all liability.
|
|
||||||
|
|
||||||
|
|
||||||
Section 6 -- Term and Termination.
|
|
||||||
|
|
||||||
a. This Public License applies for the term of the Copyright and
|
|
||||||
Similar Rights licensed here. However, if You fail to comply with
|
|
||||||
this Public License, then Your rights under this Public License
|
|
||||||
terminate automatically.
|
|
||||||
|
|
||||||
b. Where Your right to use the Licensed Material has terminated under
|
|
||||||
Section 6(a), it reinstates:
|
|
||||||
|
|
||||||
1. automatically as of the date the violation is cured, provided
|
|
||||||
it is cured within 30 days of Your discovery of the
|
|
||||||
violation; or
|
|
||||||
|
|
||||||
2. upon express reinstatement by the Licensor.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
||||||
right the Licensor may have to seek remedies for Your violations
|
|
||||||
of this Public License.
|
|
||||||
|
|
||||||
c. For the avoidance of doubt, the Licensor may also offer the
|
|
||||||
Licensed Material under separate terms or conditions or stop
|
|
||||||
distributing the Licensed Material at any time; however, doing so
|
|
||||||
will not terminate this Public License.
|
|
||||||
|
|
||||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
|
|
||||||
Section 7 -- Other Terms and Conditions.
|
|
||||||
|
|
||||||
a. The Licensor shall not be bound by any additional or different
|
|
||||||
terms or conditions communicated by You unless expressly agreed.
|
|
||||||
|
|
||||||
b. Any arrangements, understandings, or agreements regarding the
|
|
||||||
Licensed Material not stated herein are separate from and
|
|
||||||
independent of the terms and conditions of this Public License.
|
|
||||||
|
|
||||||
|
|
||||||
Section 8 -- Interpretation.
|
|
||||||
|
|
||||||
a. For the avoidance of doubt, this Public License does not, and
|
|
||||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
||||||
conditions on any use of the Licensed Material that could lawfully
|
|
||||||
be made without permission under this Public License.
|
|
||||||
|
|
||||||
b. To the extent possible, if any provision of this Public License is
|
|
||||||
deemed unenforceable, it shall be automatically reformed to the
|
|
||||||
minimum extent necessary to make it enforceable. If the provision
|
|
||||||
cannot be reformed, it shall be severed from this Public License
|
|
||||||
without affecting the enforceability of the remaining terms and
|
|
||||||
conditions.
|
|
||||||
|
|
||||||
c. No term or condition of this Public License will be waived and no
|
|
||||||
failure to comply consented to unless expressly agreed to by the
|
|
||||||
Licensor.
|
|
||||||
|
|
||||||
d. Nothing in this Public License constitutes or may be interpreted
|
|
||||||
as a limitation upon, or waiver of, any privileges and immunities
|
|
||||||
that apply to the Licensor or You, including from the legal
|
|
||||||
processes of any jurisdiction or authority.
|
|
||||||
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons is not a party to its public
|
|
||||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
|
||||||
its public licenses to material it publishes and in those instances
|
|
||||||
will be considered the “Licensor.” The text of the Creative Commons
|
|
||||||
public licenses is dedicated to the public domain under the CC0 Public
|
|
||||||
Domain Dedication. Except for the limited purpose of indicating that
|
|
||||||
material is shared under a Creative Commons public license or as
|
|
||||||
otherwise permitted by the Creative Commons policies published at
|
|
||||||
creativecommons.org/policies, Creative Commons does not authorize the
|
|
||||||
use of the trademark "Creative Commons" or any other trademark or logo
|
|
||||||
of Creative Commons without its prior written consent including,
|
|
||||||
without limitation, in connection with any unauthorized modifications
|
|
||||||
to any of its public licenses or any other arrangements,
|
|
||||||
understandings, or agreements concerning use of licensed material. For
|
|
||||||
the avoidance of doubt, this paragraph does not form part of the
|
|
||||||
public licenses.
|
|
||||||
|
|
||||||
Creative Commons may be contacted at creativecommons.org.
|
|
||||||
|
|
Binary file not shown.
BIN
src/main/resources/fonts/noto-sans-tc-bold.ttf
Normal file
BIN
src/main/resources/fonts/noto-sans-tc-bold.ttf
Normal file
Binary file not shown.
BIN
src/main/resources/fonts/noto-sans-tc-regular.ttf
Normal file
BIN
src/main/resources/fonts/noto-sans-tc-regular.ttf
Normal file
Binary file not shown.
@ -1,30 +1,80 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.web.WebView?>
|
<?import javafx.scene.web.WebView?>
|
||||||
<?import javafx.geometry.Insets?>
|
<VBox stylesheets="/css/details.css" xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
<VBox xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
fx:controller="com.marvinelsen.willow.ui.controllers.DetailsController">
|
||||||
fx:controller="com.marvinelsen.willow.ui.controllers.DetailsController"
|
<FlowPane fx:id="flowPaneHeader" hgap="8.0" vgap="8.0" rowValignment="BASELINE" VBox.vgrow="NEVER"
|
||||||
stylesheets="/css/details.css">
|
onContextMenuRequested="#headerOnContextMenuRequested">
|
||||||
<Label fx:id="labelHeadword" styleClass="headword" text="Label">
|
|
||||||
<padding>
|
<padding>
|
||||||
<Insets left="8" right="8" top="8" bottom="8"/>
|
<Insets bottom="6.0" left="6.0" right="6.0" top="6.0"/>
|
||||||
</padding>
|
</padding>
|
||||||
</Label>
|
<Label fx:id="labelHeadword" styleClass="headword"/>
|
||||||
<TabPane fx:id="tabPaneDetails" tabClosingPolicy="UNAVAILABLE" disable="true" VBox.vgrow="ALWAYS">
|
<Label fx:id="labelPronunciation" styleClass="pronunciation"/>
|
||||||
<Tab closable="false" disable="false" text="%tab.definition">
|
</FlowPane>
|
||||||
<WebView fx:id="webViewDefinition" minHeight="-1.0" minWidth="-1.0" prefHeight="-1.0"
|
<TabPane fx:id="tabPaneDetails" tabClosingPolicy="UNAVAILABLE" VBox.vgrow="ALWAYS">
|
||||||
prefWidth="-1.0"/>
|
<Tab closable="false" text="%details.tab.definition">
|
||||||
|
<WebView fx:id="webViewDefinition"/>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab id="tabSentences" closable="false" disable="false" text="%tab.sentences">
|
<Tab id="tabSentences" closable="false" text="%details.tab.sentences">
|
||||||
<ListView fx:id="listviewSentences"/>
|
<StackPane>
|
||||||
|
<ProgressIndicator fx:id="progressIndicatorSentences" visible="false"/>
|
||||||
|
<Label fx:id="labelNoSentencesFound" text="%details.list.no_sentences_found" textAlignment="CENTER"
|
||||||
|
visible="false" wrapText="true">
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0"/>
|
||||||
|
</padding>
|
||||||
|
</Label>
|
||||||
|
<ListView fx:id="listViewSentences"/>
|
||||||
|
</StackPane>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab id="tabWords" closable="false" disable="false" text="%tab.words">
|
<Tab id="tabWords" closable="false" text="%details.tab.words">
|
||||||
<ListView fx:id="listViewWords"/>
|
<VBox maxHeight="1.7976931348623157E308">
|
||||||
|
<TitledPane animated="false" maxHeight="-Infinity" text="%details.list.words_beginning" VBox.vgrow="ALWAYS">
|
||||||
|
<StackPane>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="0.0" left="0.0" right="0.0" top="0.0"/>
|
||||||
|
</padding>
|
||||||
|
<ProgressIndicator fx:id="progressIndicatorWordsBeginning" visible="false"/>
|
||||||
|
<Label fx:id="labelNoWordsBeginningFound" text="%details.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>
|
||||||
|
<ListView fx:id="listViewWordsBeginning" prefHeight="4000"/>
|
||||||
|
</StackPane>
|
||||||
|
</TitledPane>
|
||||||
|
<TitledPane animated="false" maxHeight="-Infinity" text="%details.list.words_containing" VBox.vgrow="ALWAYS">
|
||||||
|
<StackPane>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="0.0" left="0.0" right="0.0" top="0.0"/>
|
||||||
|
</padding>
|
||||||
|
<ProgressIndicator fx:id="progressIndicatorWordsContaining" visible="false"/>
|
||||||
|
<Label fx:id="labelNoWordsContainingFound" text="%details.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>
|
||||||
|
<ListView fx:id="listViewWordsContaining" prefHeight="4000"/>
|
||||||
|
</StackPane>
|
||||||
|
</TitledPane>
|
||||||
|
</VBox>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab closable="false" disable="false" text="%tab.characters">
|
<Tab fx:id="tabCharacters" id="tabCharacters" closable="false" text="%details.tab.characters">
|
||||||
<ListView fx:id="listViewCharacters"/>
|
<StackPane>
|
||||||
|
<ListView fx:id="listViewCharacters"/>
|
||||||
|
<Label fx:id="labelNoCharactersFound" text="%details.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>
|
||||||
|
175
src/main/resources/fxml/dialogs/preferences.fxml
Normal file
175
src/main/resources/fxml/dialogs/preferences.fxml
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import com.marvinelsen.willow.config.*?>
|
||||||
|
<?import com.marvinelsen.willow.ui.converters.*?>
|
||||||
|
<?import javafx.collections.FXCollections?>
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.*?>
|
||||||
|
<?import javafx.scene.layout.*?>
|
||||||
|
<DialogPane styleClass="preferences-dialog" xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
stylesheets="/css/preferences.css"
|
||||||
|
fx:controller="com.marvinelsen.willow.ui.controllers.dialogs.PreferencesDialogController">
|
||||||
|
<fx:define>
|
||||||
|
<FXCollections fx:factory="observableArrayList" fx:id="phoneticAlphabets">
|
||||||
|
<Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/>
|
||||||
|
<Pronunciation fx:value="PINYIN_WITH_TONE_NUMBERS"/>
|
||||||
|
<Pronunciation fx:value="ZHUYIN"/>
|
||||||
|
</FXCollections>
|
||||||
|
<FXCollections fx:factory="observableArrayList" fx:id="themes">
|
||||||
|
<Theme fx:value="SYSTEM"/>
|
||||||
|
<Theme fx:value="LIGHT"/>
|
||||||
|
<Theme fx:value="DARK"/>
|
||||||
|
</FXCollections>
|
||||||
|
<FXCollections fx:factory="observableArrayList" fx:id="scripts">
|
||||||
|
<Script fx:value="SIMPLIFIED"/>
|
||||||
|
<Script fx:value="TRADITIONAL"/>
|
||||||
|
</FXCollections>
|
||||||
|
</fx:define>
|
||||||
|
<content>
|
||||||
|
<TabPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
|
||||||
|
tabClosingPolicy="UNAVAILABLE">
|
||||||
|
<Tab closable="false" text="General">
|
||||||
|
<GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/>
|
||||||
|
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/>
|
||||||
|
</padding>
|
||||||
|
<Label text="Script:" GridPane.rowIndex="3"/>
|
||||||
|
<ComboBox fx:id="comboBoxScript" items="$scripts" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||||
|
<value>
|
||||||
|
<Script fx:value="SIMPLIFIED"/>
|
||||||
|
</value>
|
||||||
|
<converter>
|
||||||
|
<ScriptStringConverter/>
|
||||||
|
</converter>
|
||||||
|
</ComboBox>
|
||||||
|
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="2"/>
|
||||||
|
<Label text="Language:" GridPane.rowIndex="0"/>
|
||||||
|
<ComboBox fx:id="comboBoxLocale" GridPane.rowIndex="0" GridPane.columnIndex="1">
|
||||||
|
<converter>
|
||||||
|
<LocaleStringConverter/>
|
||||||
|
</converter>
|
||||||
|
</ComboBox>
|
||||||
|
<Label text="Theme:" GridPane.rowIndex="1"/>
|
||||||
|
<ComboBox fx:id="comboBoxTheme" items="$themes" GridPane.rowIndex="1" GridPane.columnIndex="1">
|
||||||
|
<value>
|
||||||
|
<Theme fx:value="SYSTEM"/>
|
||||||
|
</value>
|
||||||
|
<converter>
|
||||||
|
<ThemeStringConverter/>
|
||||||
|
</converter>
|
||||||
|
</ComboBox>
|
||||||
|
</GridPane>
|
||||||
|
</Tab>
|
||||||
|
<Tab closable="false" text="Details View">
|
||||||
|
<GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/>
|
||||||
|
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/>
|
||||||
|
</padding>
|
||||||
|
<Label text="Pronunciation:"/>
|
||||||
|
<ComboBox fx:id="comboBoxPronunciationDetails" items="$phoneticAlphabets" GridPane.columnIndex="1">
|
||||||
|
<value>
|
||||||
|
<Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/>
|
||||||
|
</value>
|
||||||
|
<converter>
|
||||||
|
<PronunciationStringConverter/>
|
||||||
|
</converter>
|
||||||
|
</ComboBox>
|
||||||
|
<Label text="Headword font size:" GridPane.rowIndex="2"/>
|
||||||
|
<Label text="Pronunciation font size:" GridPane.rowIndex="3"/>
|
||||||
|
<Spinner fx:id="spinnerPronunciationFontSizeDetails" editable="true" GridPane.columnIndex="1"
|
||||||
|
GridPane.rowIndex="3">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Spinner fx:id="spinnerHeadwordFontSizeDetails" editable="true" GridPane.columnIndex="1"
|
||||||
|
GridPane.rowIndex="2">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/>
|
||||||
|
</GridPane>
|
||||||
|
</Tab>
|
||||||
|
<Tab closable="false" text="Search Results">
|
||||||
|
<GridPane alignment="TOP_CENTER" hgap="8.0" vgap="8.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="RIGHT" hgrow="ALWAYS"/>
|
||||||
|
<ColumnConstraints halignment="LEFT" hgrow="ALWAYS"/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
<RowConstraints valignment="BASELINE" vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="12.0" left="12.0" right="12.0" top="12.0"/>
|
||||||
|
</padding>
|
||||||
|
<Label text="Pronunciation:"/>
|
||||||
|
<ComboBox fx:id="comboBoxPronunciationSearchResults" items="$phoneticAlphabets"
|
||||||
|
GridPane.columnIndex="1">
|
||||||
|
<value>
|
||||||
|
<Pronunciation fx:value="PINYIN_WITH_TONE_MARKS"/>
|
||||||
|
</value>
|
||||||
|
<converter>
|
||||||
|
<PronunciationStringConverter/>
|
||||||
|
</converter>
|
||||||
|
</ComboBox>
|
||||||
|
<Label text="Headword font size:" GridPane.rowIndex="5"/>
|
||||||
|
<Label text="Pronunciation font size:" GridPane.rowIndex="6"/>
|
||||||
|
<Spinner fx:id="spinnerPronunciationFontSizeSearchResults" editable="true" GridPane.columnIndex="1"
|
||||||
|
GridPane.rowIndex="6">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Spinner fx:id="spinnerHeadwordFontSizeSearchResults" editable="true" GridPane.columnIndex="1"
|
||||||
|
GridPane.rowIndex="5">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Spinner fx:id="spinnerDefinitionFontSizeSearchResults" editable="true" GridPane.columnIndex="1"
|
||||||
|
GridPane.rowIndex="7">
|
||||||
|
<valueFactory>
|
||||||
|
<SpinnerValueFactory.IntegerSpinnerValueFactory amountToStepBy="1" max="300" min="1"/>
|
||||||
|
</valueFactory>
|
||||||
|
</Spinner>
|
||||||
|
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="4"/>
|
||||||
|
<Label text="Definition font size:" GridPane.rowIndex="7"/>
|
||||||
|
<Label text="Display:" GridPane.rowIndex="2"/>
|
||||||
|
<CheckBox fx:id="checkBoxShowPronunciationSearchResults" mnemonicParsing="false" selected="true"
|
||||||
|
text="Show pronunciation" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||||
|
<CheckBox fx:id="checkBoxShowDefinitionSearchResults" mnemonicParsing="false" selected="true"
|
||||||
|
text="Show definition" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||||
|
<Separator prefWidth="200.0" GridPane.columnSpan="2147483647" GridPane.rowIndex="1"/>
|
||||||
|
</GridPane>
|
||||||
|
</Tab>
|
||||||
|
</TabPane>
|
||||||
|
</content>
|
||||||
|
<ButtonType fx:constant="APPLY"/>
|
||||||
|
<ButtonType fx:constant="CANCEL"/>
|
||||||
|
</DialogPane>
|
@ -1,13 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import com.marvinelsen.willow.ui.cells.DictionaryEntryCellFactory?>
|
|
||||||
<?import javafx.geometry.Insets?>
|
<?import javafx.geometry.Insets?>
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.control.ListView?>
|
|
||||||
<?import javafx.scene.control.ProgressIndicator?>
|
|
||||||
<?import javafx.scene.control.SplitPane?>
|
<?import javafx.scene.control.SplitPane?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<BorderPane xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
<BorderPane xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.marvinelsen.willow.ui.controllers.MainController"
|
fx:controller="com.marvinelsen.willow.ui.controllers.MainController"
|
||||||
stylesheets="/css/main.css">
|
stylesheets="/css/main.css">
|
||||||
<top>
|
<top>
|
||||||
@ -20,22 +16,9 @@
|
|||||||
</BorderPane.margin>
|
</BorderPane.margin>
|
||||||
<fx:include source="/fxml/search.fxml"/>
|
<fx:include source="/fxml/search.fxml"/>
|
||||||
<SplitPane dividerPositions="0.33" VBox.vgrow="ALWAYS">
|
<SplitPane dividerPositions="0.33" VBox.vgrow="ALWAYS">
|
||||||
<StackPane>
|
<fx:include source="/fxml/search-results.fxml"/>
|
||||||
<ListView fx:id="listViewSearchResults" disable="true">
|
|
||||||
<cellFactory>
|
|
||||||
<DictionaryEntryCellFactory/>
|
|
||||||
</cellFactory>
|
|
||||||
</ListView>
|
|
||||||
<Label fx:id="labelNoEntriesFound" text="%list.no_entries_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="progressIndicatorEntries" visible="false"/>
|
|
||||||
</StackPane>
|
|
||||||
<fx:include source="/fxml/details.fxml"/>
|
<fx:include source="/fxml/details.fxml"/>
|
||||||
</SplitPane>
|
</SplitPane>
|
||||||
</VBox>
|
</VBox>
|
||||||
</center>
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
@ -3,11 +3,12 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.input.KeyCodeCombination?>
|
<?import javafx.scene.input.KeyCodeCombination?>
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
<MenuBar xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
<MenuBar xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:id="menuBar"
|
||||||
fx:controller="com.marvinelsen.willow.ui.controllers.MenuController" BorderPane.alignment="CENTER"
|
fx:controller="com.marvinelsen.willow.ui.controllers.MenuController" BorderPane.alignment="CENTER"
|
||||||
useSystemMenuBar="true">
|
useSystemMenuBar="true">
|
||||||
<Menu text="%menubar.file">
|
<Menu text="%menubar.file">
|
||||||
<MenuItem text="%menubar.file.settings">
|
<MenuItem text="%menubar.file.preferences" onAction="#onMenuItemPreferencesAction">
|
||||||
<accelerator>
|
<accelerator>
|
||||||
<KeyCodeCombination alt="UP" code="COMMA" control="UP" meta="UP" shift="UP"
|
<KeyCodeCombination alt="UP" code="COMMA" control="UP" meta="UP" shift="UP"
|
||||||
shortcut="DOWN"/>
|
shortcut="DOWN"/>
|
||||||
@ -23,7 +24,7 @@
|
|||||||
<Menu text="%menubar.edit">
|
<Menu text="%menubar.edit">
|
||||||
<MenuItem fx:id="menuItemCopyHeadword" text="%menubar.edit.copy.headword" onAction="#onMenuItemCopyHeadwordAction">
|
<MenuItem fx:id="menuItemCopyHeadword" text="%menubar.edit.copy.headword" onAction="#onMenuItemCopyHeadwordAction">
|
||||||
<accelerator>
|
<accelerator>
|
||||||
<KeyCodeCombination alt="UP" code="C" control="UP" meta="UP" shift="UP"
|
<KeyCodeCombination alt="UP" code="H" control="UP" meta="UP" shift="UP"
|
||||||
shortcut="DOWN"/>
|
shortcut="DOWN"/>
|
||||||
</accelerator>
|
</accelerator>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
19
src/main/resources/fxml/search-results.fxml
Normal file
19
src/main/resources/fxml/search-results.fxml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.ListView?>
|
||||||
|
<?import javafx.scene.control.ProgressIndicator?>
|
||||||
|
<?import javafx.scene.layout.StackPane?>
|
||||||
|
<StackPane minWidth="100" xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="com.marvinelsen.willow.ui.controllers.SearchResultsController"
|
||||||
|
stylesheets="/css/search-results.css">
|
||||||
|
<ListView fx:id="listViewSearchResults" disable="true"/>
|
||||||
|
<Label fx:id="labelNoEntriesFound" text="%search.results.list.no_entries_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="progressIndicatorEntries" visible="false"/>
|
||||||
|
</StackPane>
|
@ -5,9 +5,31 @@
|
|||||||
<?import javafx.scene.layout.FlowPane?>
|
<?import javafx.scene.layout.FlowPane?>
|
||||||
<?import javafx.scene.layout.HBox?>
|
<?import javafx.scene.layout.HBox?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<VBox xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||||
|
<VBox xmlns="http://javafx.com/javafx/23" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.marvinelsen.willow.ui.controllers.SearchController" spacing="8">
|
fx:controller="com.marvinelsen.willow.ui.controllers.SearchController" spacing="8">
|
||||||
<TextField fx:id="textFieldSearch" promptText="%search.prompt" HBox.hgrow="ALWAYS"/>
|
|
||||||
|
<HBox alignment="CENTER_LEFT" prefHeight="0.0" spacing="6.0" VBox.vgrow="NEVER">
|
||||||
|
<Button fx:id="buttonUndo" contentDisplay="GRAPHIC_ONLY" disable="true" graphicTextGap="0.0"
|
||||||
|
mnemonicParsing="false" onAction="#onButtonUndoAction">
|
||||||
|
<graphic>
|
||||||
|
<FontIcon iconLiteral="mdal-arrow_back" iconSize="16"/>
|
||||||
|
</graphic>
|
||||||
|
<tooltip>
|
||||||
|
<Tooltip text="Go back one search (Alt+Left Arrow)"/>
|
||||||
|
</tooltip>
|
||||||
|
</Button>
|
||||||
|
<Button fx:id="buttonRedo" contentDisplay="GRAPHIC_ONLY" disable="true" graphicTextGap="0.0"
|
||||||
|
mnemonicParsing="false" onAction="#onButtonRedoAction">
|
||||||
|
<graphic>
|
||||||
|
<FontIcon iconLiteral="mdal-arrow_forward" iconSize="16"/>
|
||||||
|
</graphic>
|
||||||
|
<tooltip>
|
||||||
|
<Tooltip text="Go forward one search (Alt+Right Arrow)"/>
|
||||||
|
</tooltip>
|
||||||
|
</Button>
|
||||||
|
<TextField fx:id="textFieldSearch" promptText="%search.prompt" HBox.hgrow="ALWAYS"/>
|
||||||
|
</HBox>
|
||||||
<FlowPane hgap="8.0" vgap="8.0">
|
<FlowPane hgap="8.0" vgap="8.0">
|
||||||
<Label text="%search.mode"/>
|
<Label text="%search.mode"/>
|
||||||
<RadioButton mnemonicParsing="false" selected="true" text="%search.mode.simplified">
|
<RadioButton mnemonicParsing="false" selected="true" text="%search.mode.simplified">
|
||||||
@ -18,22 +40,19 @@
|
|||||||
<SearchMode fx:value="SIMPLIFIED"/>
|
<SearchMode fx:value="SIMPLIFIED"/>
|
||||||
</userData>
|
</userData>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton mnemonicParsing="false" text="%search.mode.traditional"
|
<RadioButton mnemonicParsing="false" text="%search.mode.traditional" toggleGroup="$searchModeToggleGroup">
|
||||||
toggleGroup="$searchModeToggleGroup">
|
|
||||||
<userData>
|
<userData>
|
||||||
<SearchMode fx:value="TRADITIONAL"/>
|
<SearchMode fx:value="TRADITIONAL"/>
|
||||||
</userData>
|
</userData>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton mnemonicParsing="false" text="%search.mode.pinyin"
|
<RadioButton mnemonicParsing="false" text="%search.mode.pinyin" toggleGroup="$searchModeToggleGroup">
|
||||||
toggleGroup="$searchModeToggleGroup">
|
|
||||||
<userData>
|
<userData>
|
||||||
<SearchMode fx:value="PINYIN"/>
|
<SearchMode fx:value="PINYIN"/>
|
||||||
</userData>
|
</userData>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
<RadioButton mnemonicParsing="false" text="%search.mode.english"
|
<RadioButton mnemonicParsing="false" text="%search.mode.phrase" toggleGroup="$searchModeToggleGroup">
|
||||||
toggleGroup="$searchModeToggleGroup">
|
|
||||||
<userData>
|
<userData>
|
||||||
<SearchMode fx:value="ENGLISH"/>
|
<SearchMode fx:value="SEGMENTS"/>
|
||||||
</userData>
|
</userData>
|
||||||
</RadioButton>
|
</RadioButton>
|
||||||
</FlowPane>
|
</FlowPane>
|
||||||
|
@ -1,19 +1,34 @@
|
|||||||
|
# Search
|
||||||
search.prompt=Search dictionary…
|
search.prompt=Search dictionary…
|
||||||
search.mode=Searching:
|
search.mode=Search mode:
|
||||||
search.mode.pinyin=Pinyin
|
search.mode.pinyin=Pinyin
|
||||||
search.mode.traditional=Traditional Chinese
|
search.mode.traditional=Traditional
|
||||||
search.mode.simplified=Simplified Chinese
|
search.mode.simplified=Simplified
|
||||||
search.mode.english=English
|
search.mode.phrase=Phrase
|
||||||
tab.definition=Definition
|
|
||||||
tab.sentences=Sentences
|
# Details
|
||||||
tab.words=Words
|
details.tab.definition=Definition
|
||||||
tab.characters=Characters
|
details.tab.sentences=Sentences
|
||||||
|
details.tab.words=Words
|
||||||
|
details.tab.characters=Characters
|
||||||
|
|
||||||
|
details.list.no_characters_found=No characters found
|
||||||
|
details.list.no_words_found=No words found
|
||||||
|
details.list.no_sentences_found=No sentences found.
|
||||||
|
details.list.words_beginning=Words beginning
|
||||||
|
details.list.words_containing=Words containing
|
||||||
|
|
||||||
|
# Menubar
|
||||||
menubar.file=_File
|
menubar.file=_File
|
||||||
menubar.file.quit=_Quit
|
menubar.file.quit=_Quit
|
||||||
menubar.file.settings=_Settings…
|
menubar.file.preferences=_Preferences…
|
||||||
menubar.edit=_Edit
|
menubar.edit=_Edit
|
||||||
menubar.edit.copy.headword=Copy Headword
|
menubar.edit.copy.headword=Copy Headword
|
||||||
menubar.edit.copy.pronunciation=Copy Pronunciation
|
menubar.edit.copy.pronunciation=Copy Pronunciation
|
||||||
|
menubar.edit.copy.sentence=Copy Sentence
|
||||||
|
menubar.edit.search-web=Search on Web...
|
||||||
menubar.help=_Help
|
menubar.help=_Help
|
||||||
menubar.help.about=_About…
|
menubar.help.about=_About…
|
||||||
list.no_entries_found=No matching entries found
|
|
||||||
|
# Search results
|
||||||
|
search.results.list.no_entries_found=No matching entries found
|
@ -1,19 +1,34 @@
|
|||||||
|
# Search
|
||||||
search.prompt=Durchsuche Wörterbuch…
|
search.prompt=Durchsuche Wörterbuch…
|
||||||
search.mode=Suche:
|
search.mode=Suchmodus:
|
||||||
search.mode.pinyin=Pinyin
|
search.mode.pinyin=Pinyin
|
||||||
search.mode.traditional=Langzeichen
|
search.mode.traditional=Langzeichen
|
||||||
search.mode.simplified=Kurzzeichen
|
search.mode.simplified=Kurzzeichen
|
||||||
search.mode.english=Englisch
|
search.mode.phrase=Satz
|
||||||
tab.definition=Definition
|
|
||||||
tab.sentences=Sätze
|
# Details
|
||||||
tab.words=Wörter
|
details.tab.definition=Definition
|
||||||
tab.characters=Schriftzeichen
|
details.tab.sentences=Sätze
|
||||||
|
details.tab.words=Wörter
|
||||||
|
details.tab.characters=Schriftzeichen
|
||||||
|
|
||||||
|
details.list.no_characters_found=Keine Schriftzeichen gefunden
|
||||||
|
details.list.no_words_found=Keine Wörter gefunden
|
||||||
|
details.list.no_sentences_found=Keine Sätze gefunden
|
||||||
|
details.list.words_beginning=Am Wortanfang
|
||||||
|
details.list.words_containing=Im Wort
|
||||||
|
|
||||||
|
# Menubar
|
||||||
menubar.file=_Datei
|
menubar.file=_Datei
|
||||||
menubar.file.quit=_Beenden
|
menubar.file.quit=_Beenden
|
||||||
menubar.file.settings=_Einstellungen…
|
menubar.file.preferences=_Einstellungen…
|
||||||
menubar.edit=_Bearbeiten
|
menubar.edit=_Bearbeiten
|
||||||
menubar.edit.copy.headword=Kopiere Wort
|
menubar.edit.copy.headword=Kopiere Wort
|
||||||
menubar.edit.copy.pronunciation=Kopiere Aussprache
|
menubar.edit.copy.pronunciation=Kopiere Aussprache
|
||||||
|
menubar.edit.copy.sentence=Copy Sentence
|
||||||
|
menubar.edit.search-web=Search on Web...
|
||||||
menubar.help=_Hilfe
|
menubar.help=_Hilfe
|
||||||
menubar.help.about=_Über…
|
menubar.help.about=_Über…
|
||||||
list.no_entries_found=No matching entries found
|
|
||||||
|
# Search results
|
||||||
|
search.results.list.no_entries_found=Keine passenden Einträge gefunden
|
@ -1,19 +1,34 @@
|
|||||||
|
# Search
|
||||||
search.prompt=Search dictionary…
|
search.prompt=Search dictionary…
|
||||||
search.mode=Searching:
|
search.mode=Search mode:
|
||||||
search.mode.pinyin=Pinyin
|
search.mode.pinyin=Pinyin
|
||||||
search.mode.traditional=Traditional Chinese
|
search.mode.traditional=Traditional
|
||||||
search.mode.simplified=Simplified Chinese
|
search.mode.simplified=Simplified
|
||||||
search.mode.english=English
|
search.mode.phrase=Phrase
|
||||||
tab.definition=Definition
|
|
||||||
tab.sentences=Sentences
|
# Details
|
||||||
tab.words=Words
|
details.tab.definition=Definition
|
||||||
tab.characters=Characters
|
details.tab.sentences=Sentences
|
||||||
|
details.tab.words=Words
|
||||||
|
details.tab.characters=Characters
|
||||||
|
|
||||||
|
details.list.no_characters_found=No characters found
|
||||||
|
details.list.no_words_found=No words found
|
||||||
|
details.list.no_sentences_found=No sentences found.
|
||||||
|
details.list.words_beginning=Words beginning
|
||||||
|
details.list.words_containing=Words containing
|
||||||
|
|
||||||
|
# Menubar
|
||||||
menubar.file=_File
|
menubar.file=_File
|
||||||
menubar.file.quit=_Quit
|
menubar.file.quit=_Quit
|
||||||
menubar.file.settings=_Settings…
|
menubar.file.preferences=_Preferences…
|
||||||
menubar.edit=_Edit
|
menubar.edit=_Edit
|
||||||
menubar.edit.copy.headword=Copy Headword
|
menubar.edit.copy.headword=Copy Headword
|
||||||
menubar.edit.copy.pronunciation=Copy Pronunciation
|
menubar.edit.copy.pronunciation=Copy Pronunciation
|
||||||
|
menubar.edit.copy.sentence=Copy Sentence
|
||||||
|
menubar.edit.search-web=Search on Web...
|
||||||
menubar.help=_Help
|
menubar.help=_Help
|
||||||
menubar.help.about=_About…
|
menubar.help.about=_About…
|
||||||
list.no_entries_found=No matching entries found
|
|
||||||
|
# Search results
|
||||||
|
search.results.list.no_entries_found=No matching entries found
|
@ -1,19 +1,34 @@
|
|||||||
|
#Search
|
||||||
search.prompt=搜尋…
|
search.prompt=搜尋…
|
||||||
search.mode=搜尋:
|
search.mode=搜尋模式:
|
||||||
search.mode.pinyin=漢語拼音
|
search.mode.pinyin=漢語拼音
|
||||||
search.mode.traditional=繁體字
|
search.mode.traditional=繁體字
|
||||||
search.mode.simplified=簡體字
|
search.mode.simplified=簡體字
|
||||||
search.mode.english=英文
|
search.mode.phrase=句子
|
||||||
tab.definition=Definition
|
|
||||||
tab.sentences=例句
|
# Details
|
||||||
tab.words=詞
|
details.tab.definition=釋義
|
||||||
tab.characters=字
|
details.tab.sentences=例句
|
||||||
|
details.tab.words=詞
|
||||||
|
details.tab.characters=字
|
||||||
|
|
||||||
|
details.list.no_characters_found=No characters found
|
||||||
|
details.list.no_words_found=No words found
|
||||||
|
details.list.no_sentences_found=No sentences found.
|
||||||
|
details.list.words_beginning=Words beginning
|
||||||
|
details.list.words_containing=Words containing
|
||||||
|
|
||||||
|
# Menubar
|
||||||
menubar.file=_檔案
|
menubar.file=_檔案
|
||||||
menubar.file.quit=_結束 Willow
|
menubar.file.quit=_結束 Willow
|
||||||
menubar.file.settings=_設定…
|
menubar.file.preferences=_設定…
|
||||||
menubar.edit=_編輯
|
menubar.edit=_編輯
|
||||||
menubar.edit.copy.headword=複製 Wort
|
menubar.edit.copy.headword=複製 Wort
|
||||||
menubar.edit.copy.pronunciation=複製 Aussprache
|
menubar.edit.copy.pronunciation=複製 Aussprache
|
||||||
|
menubar.edit.copy.sentence=Copy Sentence
|
||||||
|
menubar.edit.search-web=Search on Web...
|
||||||
menubar.help=_說明
|
menubar.help=_說明
|
||||||
menubar.help.about=_關於 Willow…
|
menubar.help.about=_關於 Willow…
|
||||||
list.no_entries_found=No matching entries found
|
|
||||||
|
# Search results
|
||||||
|
search.results.list.no_entries_found=No matching entries found
|
@ -1,19 +1,34 @@
|
|||||||
|
# Search
|
||||||
search.prompt=搜尋…
|
search.prompt=搜尋…
|
||||||
search.mode=搜尋:
|
search.mode=搜尋模式:
|
||||||
search.mode.pinyin=漢語拼音
|
search.mode.pinyin=漢語拼音
|
||||||
search.mode.traditional=繁體字
|
search.mode.traditional=繁體字
|
||||||
search.mode.simplified=簡體字
|
search.mode.simplified=簡體字
|
||||||
search.mode.english=英文
|
search.mode.phrase=句子
|
||||||
tab.definition=Definition
|
|
||||||
tab.sentences=例句
|
# Details
|
||||||
tab.words=詞
|
details.tab.definition=釋義
|
||||||
tab.characters=字
|
details.tab.sentences=例句
|
||||||
|
details.tab.words=詞
|
||||||
|
details.tab.characters=字
|
||||||
|
|
||||||
|
details.list.no_characters_found=No characters found
|
||||||
|
details.list.no_words_found=No words found
|
||||||
|
details.list.no_sentences_found=No sentences found
|
||||||
|
details.list.words_beginning=Words beginning
|
||||||
|
details.list.words_containing=Words containing
|
||||||
|
|
||||||
|
# Menubar
|
||||||
menubar.file=_檔案
|
menubar.file=_檔案
|
||||||
menubar.file.quit=_結束 Willow
|
menubar.file.quit=_結束 Willow
|
||||||
menubar.file.settings=_設定…
|
menubar.file.preferences=_設定…
|
||||||
menubar.edit=_編輯
|
menubar.edit=_編輯
|
||||||
menubar.edit.copy.headword=複製 Wort
|
menubar.edit.copy.headword=複製 Wort
|
||||||
menubar.edit.copy.pronunciation=複製 Aussprache
|
menubar.edit.copy.pronunciation=複製 Aussprache
|
||||||
|
menubar.edit.copy.sentence=Copy Sentence
|
||||||
|
menubar.edit.search-web=Search on Web...
|
||||||
menubar.help=_說明
|
menubar.help=_說明
|
||||||
menubar.help.about=_關於 Willow…
|
menubar.help.about=_關於 Willow…
|
||||||
list.no_entries_found=No matching entries found
|
|
||||||
|
# Search results
|
||||||
|
search.results.list.no_entries_found=No matching entries found
|
BIN
src/main/resources/img/icon.png
Normal file
BIN
src/main/resources/img/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
BIN
src/main/resources/img/logo.xcf
Normal file
BIN
src/main/resources/img/logo.xcf
Normal file
Binary file not shown.
236182
src/main/resources/segment_phrase_dict_define.txt
Normal file
236182
src/main/resources/segment_phrase_dict_define.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user