mirror of
https://github.com/dev-claw/vripper-project.git
synced 2026-08-19 08:35:41 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08fcd7a87d | ||
|
|
f39c7a15c7 | ||
|
|
1c239d435b | ||
|
|
d8cba97d05 | ||
|
|
a362a3fa7f | ||
|
|
4163f2a53f |
@@ -12,5 +12,5 @@
|
||||
<module>vripper-gui</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
</project>
|
||||
|
||||
@@ -11,13 +11,15 @@
|
||||
</parent>
|
||||
<groupId>me.mnlr.vripper</groupId>
|
||||
<artifactId>vripper-core</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
<name>vripper-core</name>
|
||||
<description>vripper-core</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<kotlin.version>1.8.21</kotlin.version>
|
||||
<maven.deploy.skip>false</maven.deploy.skip>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package me.mnlr.vripper.model
|
||||
|
||||
class Settings {
|
||||
var maxEventLog: Int = 1_000
|
||||
var connectionSettings = ConnectionSettings()
|
||||
var downloadSettings = DownloadSettings()
|
||||
var viperSettings = ViperSettings()
|
||||
var clipboardSettings = ClipboardSettings()
|
||||
}
|
||||
data class Settings(
|
||||
var maxEventLog: Int = 1_000,
|
||||
var connectionSettings: ConnectionSettings = ConnectionSettings(),
|
||||
var downloadSettings: DownloadSettings = DownloadSettings(),
|
||||
var viperSettings: ViperSettings = ViperSettings(),
|
||||
var clipboardSettings: ClipboardSettings = ClipboardSettings()
|
||||
)
|
||||
|
||||
data class ViperSettings(
|
||||
var login: Boolean = false,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.mnlr.vripper.services
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class AppVersion(@param:Value("\${build.version}") val version: String, @param:Value("\${build.timestamp}") val timestamp: String)
|
||||
@@ -14,7 +14,12 @@ class XpathService {
|
||||
@Throws(XpathException::class)
|
||||
fun getAsNode(source: Node?, xpathExpression: String?): Node? {
|
||||
return try {
|
||||
xpath.compile(xpathExpression).evaluate(source, XPathConstants.NODE) as Node
|
||||
val value = xpath.compile(xpathExpression).evaluate(source, XPathConstants.NODE)
|
||||
if(value != null) {
|
||||
value as Node
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
throw XpathException(e)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
build.version=@project.version@
|
||||
build.timestamp=@timestamp@
|
||||
logging.level.org.springframework.web=INFO
|
||||
logging.level.root=INFO
|
||||
logging.level.org.springframework.web.socket.config.WebSocketMessageBrokerStats=ERROR
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@
|
||||
</parent>
|
||||
<groupId>me.mnlr.vripper</groupId>
|
||||
<artifactId>vripper-gui</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
<name>vripper-gui</name>
|
||||
<description>vripper-gui</description>
|
||||
<dependencies>
|
||||
@@ -99,7 +99,7 @@
|
||||
<dependency>
|
||||
<artifactId>vripper-core</artifactId>
|
||||
<groupId>me.mnlr.vripper</groupId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -25,6 +25,10 @@ class VripperGuiApplication : App(
|
||||
|
||||
private lateinit var context: ConfigurableApplicationContext //We are going to set application context here
|
||||
private var initialized = false
|
||||
|
||||
init {
|
||||
APP_INSTANCE = this
|
||||
}
|
||||
override fun start(stage: Stage) {
|
||||
with(stage) {
|
||||
width = 1200.0
|
||||
@@ -73,6 +77,10 @@ class VripperGuiApplication : App(
|
||||
}
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
companion object {
|
||||
lateinit var APP_INSTANCE: Application
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.mnlr.vripper.controller
|
||||
|
||||
import me.mnlr.vripper.services.AppVersion
|
||||
import tornadofx.*
|
||||
|
||||
class MainController : Controller() {
|
||||
private val appVersion: AppVersion by di()
|
||||
|
||||
val version = appVersion.version
|
||||
val timestamp = appVersion.timestamp
|
||||
}
|
||||
@@ -1,17 +1,23 @@
|
||||
package me.mnlr.vripper.view
|
||||
|
||||
import me.mnlr.vripper.controller.MainController
|
||||
import me.mnlr.vripper.view.actionbar.ActionBarView
|
||||
import me.mnlr.vripper.view.main.MainView
|
||||
import me.mnlr.vripper.view.status.StatusBarView
|
||||
import tornadofx.View
|
||||
import tornadofx.borderpane
|
||||
|
||||
class AppView : View("Vripper") {
|
||||
class AppView : View() {
|
||||
|
||||
private val mainController: MainController by inject()
|
||||
|
||||
init {
|
||||
title = "VRipper ${mainController.version}"
|
||||
}
|
||||
|
||||
override val root = borderpane {
|
||||
top<ActionBarView>()
|
||||
center<MainView>()
|
||||
bottom<StatusBarView>()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.mnlr.vripper.view
|
||||
|
||||
import com.sun.jna.WString
|
||||
import me.mnlr.vripper.VripperGuiApplication
|
||||
import me.mnlr.vripper.utils.Shell32
|
||||
|
||||
fun openFileDirectory(path: String) {
|
||||
val os = System.getProperty("os.name")
|
||||
if(os.contains("Windows")) {
|
||||
Shell32.INSTANCE.ShellExecuteW(null, WString("open"), WString(path), null, null, 1)
|
||||
} else if(os.contains("Linux")) {
|
||||
Runtime.getRuntime().exec("xdg-open $path")
|
||||
} else if(os.contains("Mac")) {
|
||||
Runtime.getRuntime().exec("open -R $path")
|
||||
}
|
||||
}
|
||||
|
||||
fun openLink(path: String) {
|
||||
VripperGuiApplication.APP_INSTANCE.hostServices.showDocument(path)
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package me.mnlr.vripper.view
|
||||
|
||||
import javafx.application.Platform
|
||||
import reactor.core.scheduler.Schedulers
|
||||
|
||||
val FxScheduler = Schedulers.fromExecutor(Platform::runLater)
|
||||
@@ -6,7 +6,7 @@ import javafx.util.Duration
|
||||
import me.mnlr.vripper.event.ApplicationInitialized
|
||||
import tornadofx.*
|
||||
|
||||
class LoadingView : View("Vripper") {
|
||||
class LoadingView : View("VRipper") {
|
||||
|
||||
private val appView: AppView by inject()
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package me.mnlr.vripper.view
|
||||
|
||||
import javafx.beans.value.ObservableValue
|
||||
import javafx.event.EventHandler
|
||||
import javafx.scene.control.ProgressBar
|
||||
import javafx.scene.control.TableCell
|
||||
import javafx.scene.control.TableColumn
|
||||
import javafx.scene.input.MouseEvent
|
||||
|
||||
class ProgressTableCell<S> : TableCell<S, Double>() {
|
||||
|
||||
/* *************************************************************************
|
||||
* *
|
||||
* Fields *
|
||||
* *
|
||||
**************************************************************************/
|
||||
private var progressBar: ProgressBar
|
||||
|
||||
private var observable: ObservableValue<Double>? = null
|
||||
|
||||
init {
|
||||
styleClass.add("progress-bar-table-cell")
|
||||
progressBar = ProgressBar()
|
||||
progressBar.maxWidth = Double.MAX_VALUE
|
||||
}
|
||||
|
||||
fun setOnMouseClick(clickEvent: EventHandler<in MouseEvent>) {
|
||||
progressBar.onMouseClicked = clickEvent
|
||||
}
|
||||
|
||||
override fun updateItem(item: Double?, empty: Boolean) {
|
||||
super.updateItem(item, empty)
|
||||
if (empty) {
|
||||
setGraphic(null)
|
||||
} else {
|
||||
progressBar.progressProperty().unbind()
|
||||
val column: TableColumn<S, Double>? = tableColumn
|
||||
observable = column?.getCellObservableValue(index)
|
||||
if (observable != null) {
|
||||
progressBar.progressProperty().bind(observable)
|
||||
} else if (item != null) {
|
||||
progressBar.progress = item
|
||||
}
|
||||
setGraphic(progressBar)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import me.mnlr.vripper.gui.Styles
|
||||
import me.mnlr.vripper.view.settings.SettingsView
|
||||
import tornadofx.*
|
||||
|
||||
class ActionBarView : View("Vripper") {
|
||||
class ActionBarView : View() {
|
||||
|
||||
override val root = borderpane {
|
||||
padding = insets(all = 5)
|
||||
|
||||
@@ -3,12 +3,17 @@ package me.mnlr.vripper.view.tables
|
||||
import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.TableView
|
||||
import javafx.scene.control.*
|
||||
import javafx.scene.image.ImageView
|
||||
import javafx.scene.input.MouseButton
|
||||
import javafx.util.Callback
|
||||
import me.mnlr.vripper.controller.ImageController
|
||||
import me.mnlr.vripper.event.Event
|
||||
import me.mnlr.vripper.event.EventBus
|
||||
import me.mnlr.vripper.model.ImageModel
|
||||
import me.mnlr.vripper.view.ProgressTableCell
|
||||
import me.mnlr.vripper.view.openLink
|
||||
import me.mnlr.vripper.view.FxScheduler
|
||||
import tornadofx.*
|
||||
|
||||
class ImagesTableView : Fragment("Photos") {
|
||||
@@ -27,36 +32,53 @@ class ImagesTableView : Fragment("Photos") {
|
||||
runLater {
|
||||
items.addAll(imageController.findImages(postId))
|
||||
tableView.sort()
|
||||
}
|
||||
|
||||
val disposable = eventBus.flux()
|
||||
.filter { it!!.kind == Event.Kind.IMAGE_UPDATE }
|
||||
.subscribe { event ->
|
||||
imageController
|
||||
.findImageById(event!!.data as Long)
|
||||
.filter { it.postId == postId }
|
||||
.ifPresent {
|
||||
// search
|
||||
val find = items
|
||||
.find { image -> image.id == it.id }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
progress = it.progress
|
||||
status = it.status
|
||||
}
|
||||
} else {
|
||||
items.add(it)
|
||||
}
|
||||
}
|
||||
val disposable = eventBus
|
||||
.flux()
|
||||
.filter { it!!.kind == Event.Kind.IMAGE_UPDATE }
|
||||
.map { imageController.findImageById(it!!.data as Long) }
|
||||
.filter { it.isPresent }
|
||||
.map { it.get() }
|
||||
.filter { it.postId == postId }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe {
|
||||
val find = items
|
||||
.find { image -> image.id == it.id }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
progress = it.progress
|
||||
status = it.status
|
||||
}
|
||||
} else {
|
||||
items.add(it)
|
||||
}
|
||||
|
||||
whenUndocked {
|
||||
disposable.dispose()
|
||||
}
|
||||
|
||||
whenUndocked {
|
||||
disposable.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
override val root = vbox(alignment = Pos.CENTER_RIGHT) {
|
||||
tableView = tableview(items) {
|
||||
setRowFactory {
|
||||
val tableRow = TableRow<ImageModel>()
|
||||
val urlItem = MenuItem("Open link").apply {
|
||||
setOnAction {
|
||||
openLink(tableRow.item.url)
|
||||
}
|
||||
graphic = ImageView("open-in-browser.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
val contextMenu = ContextMenu()
|
||||
contextMenu.items.addAll(urlItem)
|
||||
tableRow.contextMenuProperty().bind(tableRow.emptyProperty()
|
||||
.map { empty -> if (empty) null else contextMenu })
|
||||
tableRow
|
||||
}
|
||||
column("Index", ImageModel::indexProperty) {
|
||||
sortOrder.add(this)
|
||||
}
|
||||
@@ -64,31 +86,21 @@ class ImagesTableView : Fragment("Photos") {
|
||||
prefWidth = 200.0
|
||||
}
|
||||
column("Progress", ImageModel::progressProperty) {
|
||||
cellFormat {
|
||||
addClass(Stylesheet.progressBarTableCell)
|
||||
graphic = cache {
|
||||
progressbar(itemProperty().doubleBinding { it?.toDouble() ?: 0.0 }) {
|
||||
setOnMouseClicked {
|
||||
when (it.clickCount) {
|
||||
1 -> {
|
||||
this@tableview.requestFocus()
|
||||
this@tableview.focusModel.focus(this@cellFormat.tableRow.index)
|
||||
if (it.isControlDown && it.button.equals(MouseButton.PRIMARY)) {
|
||||
if (this@tableview.selectionModel.isSelected(this@cellFormat.tableRow.index)) {
|
||||
this@tableview.selectionModel.clearSelection(this@cellFormat.tableRow.index)
|
||||
} else {
|
||||
this@tableview.selectionModel.select(this@cellFormat.tableRow.index)
|
||||
}
|
||||
} else if (it.button.equals(MouseButton.PRIMARY)) {
|
||||
this@tableview.selectionModel.clearSelection()
|
||||
this@tableview.selectionModel.select(this@cellFormat.tableRow.index)
|
||||
}
|
||||
}
|
||||
cellFactory = Callback {
|
||||
val cell = ProgressTableCell<ImageModel>()
|
||||
cell.setOnMouseClick {
|
||||
when (it.clickCount) {
|
||||
1 -> {
|
||||
this@tableview.requestFocus()
|
||||
this@tableview.focusModel.focus(cell.tableRow.index)
|
||||
if (it.button.equals(MouseButton.PRIMARY)) {
|
||||
this@tableview.selectionModel.clearSelection()
|
||||
this@tableview.selectionModel.select(cell.tableRow.index)
|
||||
}
|
||||
}
|
||||
useMaxWidth = true
|
||||
}
|
||||
}
|
||||
cell as TableCell<ImageModel, Number>
|
||||
}
|
||||
}
|
||||
column("Status", ImageModel::statusProperty)
|
||||
|
||||
@@ -8,9 +8,10 @@ import me.mnlr.vripper.controller.LogController
|
||||
import me.mnlr.vripper.event.Event
|
||||
import me.mnlr.vripper.event.EventBus
|
||||
import me.mnlr.vripper.model.LogModel
|
||||
import me.mnlr.vripper.view.FxScheduler
|
||||
import tornadofx.*
|
||||
|
||||
class LogTableView : View("Log") {
|
||||
class LogTableView : View() {
|
||||
|
||||
private val logController: LogController by inject()
|
||||
private val eventBus: EventBus by di()
|
||||
@@ -20,30 +21,42 @@ class LogTableView : View("Log") {
|
||||
var items: ObservableList<LogModel> = FXCollections.observableArrayList()
|
||||
|
||||
init {
|
||||
titleProperty.bind(items.sizeProperty.map {
|
||||
if (it.toLong() > 0) {
|
||||
"Log (${it.toLong()})"
|
||||
} else {
|
||||
"Log"
|
||||
}
|
||||
})
|
||||
items.addAll(logController.findAll())
|
||||
|
||||
eventBus.flux()
|
||||
.doOnNext { event ->
|
||||
if (event!!.kind.equals(Event.Kind.LOG_EVENT_UPDATE)) {
|
||||
logController.find(event.data as Long)
|
||||
.ifPresent {
|
||||
// search
|
||||
val find = items
|
||||
.find { threadModel -> threadModel.id == it.id }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
status = it.status
|
||||
message = it.message
|
||||
}
|
||||
} else {
|
||||
items.add(it)
|
||||
}
|
||||
}
|
||||
} else if (event.kind.equals(Event.Kind.LOG_EVENT_REMOVE)) {
|
||||
items.removeIf { it.id == event.data }
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it!!.kind == Event.Kind.LOG_EVENT_UPDATE }
|
||||
.map { logController.find(it.data as Long) }
|
||||
.filter { it.isPresent }
|
||||
.map { it.get() }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe {
|
||||
val find = items
|
||||
.find { threadModel -> threadModel.id == it.id }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
status = it.status
|
||||
message = it.message
|
||||
}
|
||||
} else {
|
||||
items.add(it)
|
||||
}
|
||||
}
|
||||
.subscribe()
|
||||
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it.kind == Event.Kind.LOG_EVENT_REMOVE }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe { event ->
|
||||
items.removeIf { it.id == event.data }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDock() {
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package me.mnlr.vripper.view.tables
|
||||
|
||||
import com.sun.jna.WString
|
||||
import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.scene.control.*
|
||||
import javafx.scene.image.ImageView
|
||||
import javafx.scene.input.MouseButton
|
||||
import javafx.util.Callback
|
||||
import me.mnlr.vripper.controller.PostController
|
||||
import me.mnlr.vripper.event.Event
|
||||
import me.mnlr.vripper.event.EventBus
|
||||
import me.mnlr.vripper.model.PostModel
|
||||
import me.mnlr.vripper.utils.Shell32
|
||||
import me.mnlr.vripper.view.ProgressTableCell
|
||||
import me.mnlr.vripper.view.openFileDirectory
|
||||
import me.mnlr.vripper.view.openLink
|
||||
import me.mnlr.vripper.view.FxScheduler
|
||||
import tornadofx.*
|
||||
|
||||
|
||||
class PostsTableView : View("Download") {
|
||||
class PostsTableView : View() {
|
||||
|
||||
private val postController: PostController by inject()
|
||||
private val eventBus: EventBus by di()
|
||||
@@ -23,13 +26,23 @@ class PostsTableView : View("Download") {
|
||||
private var items: ObservableList<PostModel> = FXCollections.observableArrayList()
|
||||
|
||||
init {
|
||||
titleProperty.bind(items.sizeProperty.map {
|
||||
if (it.toLong() > 0) {
|
||||
"Download (${it.toLong()})"
|
||||
} else {
|
||||
"Download"
|
||||
}
|
||||
})
|
||||
items.addAll(postController.findAllPosts())
|
||||
|
||||
eventBus.flux().filter {
|
||||
it!!.kind == Event.Kind.POST_UPDATE || it.kind == Event.Kind.METADATA_UPDATE
|
||||
}.subscribe { event ->
|
||||
postController.findById(event!!.data as Long).ifPresent {
|
||||
// search
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it!!.kind == Event.Kind.POST_UPDATE || it.kind == Event.Kind.METADATA_UPDATE }
|
||||
.map { postController.findById(it!!.data as Long) }
|
||||
.filter { it.isPresent }
|
||||
.map { it.get() }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe {
|
||||
val find = items.find { postModel -> postModel.postId == it.postId }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
@@ -42,19 +55,17 @@ class PostsTableView : View("Download") {
|
||||
}
|
||||
} else {
|
||||
items.add(it)
|
||||
runLater {
|
||||
this.tableView.refresh()
|
||||
}
|
||||
this.tableView.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
eventBus.flux().filter {
|
||||
it!!.kind == Event.Kind.POST_REMOVE
|
||||
}.subscribe { event ->
|
||||
items.removeIf { p -> p.postId == event.data as String }
|
||||
}
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it!!.kind == Event.Kind.POST_REMOVE }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe {
|
||||
items.removeIf { p -> p.postId == it.data as String }
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDock() {
|
||||
@@ -72,54 +83,69 @@ class PostsTableView : View("Download") {
|
||||
}
|
||||
}
|
||||
|
||||
val startItem = MenuItem("Start").apply {
|
||||
setOnAction {
|
||||
startSelected()
|
||||
}
|
||||
graphic = ImageView("play.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val stopItem = MenuItem("Stop").apply {
|
||||
setOnAction {
|
||||
stopSelected()
|
||||
}
|
||||
graphic = ImageView("pause.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val deleteItem = MenuItem("Delete").apply {
|
||||
setOnAction {
|
||||
deleteSelected()
|
||||
}
|
||||
graphic = ImageView("trash.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val detailsItem = MenuItem("Images").apply {
|
||||
setOnAction {
|
||||
openPhotos(tableRow.item.postId)
|
||||
}
|
||||
graphic = ImageView("details.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val locationItem = MenuItem("Open containing folder").apply {
|
||||
setOnAction {
|
||||
openFileDirectory(tableRow.item.path)
|
||||
}
|
||||
graphic = ImageView("file-explorer.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val urlItem = MenuItem("Open link").apply {
|
||||
setOnAction {
|
||||
openLink(tableRow.item.url)
|
||||
}
|
||||
graphic = ImageView("open-in-browser.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val contextMenu = ContextMenu()
|
||||
val startItem = MenuItem("Start")
|
||||
startItem.setOnAction {
|
||||
startSelected()
|
||||
}
|
||||
val playIcon = ImageView("play.png")
|
||||
playIcon.fitWidth = 18.0
|
||||
playIcon.fitHeight = 18.0
|
||||
startItem.graphic = playIcon
|
||||
|
||||
val stopItem = MenuItem("Stop")
|
||||
stopItem.setOnAction {
|
||||
stopSelected()
|
||||
}
|
||||
val stopIcon = ImageView("pause.png")
|
||||
stopIcon.fitWidth = 18.0
|
||||
stopIcon.fitHeight = 18.0
|
||||
stopItem.graphic = stopIcon
|
||||
|
||||
val deleteItem = MenuItem("Delete")
|
||||
deleteItem.setOnAction {
|
||||
deleteSelected()
|
||||
}
|
||||
val deleteIcon = ImageView("trash.png")
|
||||
deleteIcon.fitWidth = 18.0
|
||||
deleteIcon.fitHeight = 18.0
|
||||
deleteItem.graphic = deleteIcon
|
||||
|
||||
val detailsItem = MenuItem("Images")
|
||||
detailsItem.setOnAction {
|
||||
openPhotos(tableRow.item.postId)
|
||||
}
|
||||
val detailsIcon = ImageView("details.png")
|
||||
detailsIcon.fitWidth = 18.0
|
||||
detailsIcon.fitHeight = 18.0
|
||||
detailsItem.graphic = detailsIcon
|
||||
|
||||
val locationItem = MenuItem("Open Download Directory")
|
||||
locationItem.setOnAction {
|
||||
openFileDirectory(tableRow.item.path)
|
||||
}
|
||||
val locationIcon = ImageView("file-explorer.png")
|
||||
locationIcon.fitWidth = 18.0
|
||||
locationIcon.fitHeight = 18.0
|
||||
locationItem.graphic = locationIcon
|
||||
|
||||
contextMenu.items.addAll(
|
||||
startItem, stopItem, deleteItem, SeparatorMenuItem(), detailsItem, locationItem
|
||||
startItem, stopItem, deleteItem, SeparatorMenuItem(), detailsItem, locationItem, urlItem
|
||||
)
|
||||
tableRow.contextMenuProperty()
|
||||
.bind(tableRow.emptyProperty().map { empty -> if (empty) null else contextMenu })
|
||||
@@ -129,32 +155,41 @@ class PostsTableView : View("Download") {
|
||||
prefWidth = 300.0
|
||||
}
|
||||
column("Progress", PostModel::progressProperty) {
|
||||
cellFormat {
|
||||
addClass(Stylesheet.progressBarTableCell)
|
||||
graphic = cache {
|
||||
progressbar(itemProperty().doubleBinding { it?.toDouble() ?: 0.0 }) {
|
||||
setOnMouseClicked {
|
||||
cellFactory = Callback {
|
||||
val cell = ProgressTableCell<PostModel>()
|
||||
cell.setOnMouseClick {
|
||||
when (it.button) {
|
||||
MouseButton.SECONDARY -> {
|
||||
this@tableview.requestFocus()
|
||||
this@tableview.focusModel.focus(cell.tableRow.index)
|
||||
if (!this@tableview.selectionModel.isSelected(cell.tableRow.index)) {
|
||||
this@tableview.selectionModel.clearSelection()
|
||||
this@tableview.selectionModel.select(cell.tableRow.index)
|
||||
}
|
||||
}
|
||||
MouseButton.PRIMARY -> {
|
||||
when (it.clickCount) {
|
||||
1 -> {
|
||||
this@tableview.requestFocus()
|
||||
this@tableview.focusModel.focus(this@cellFormat.tableRow.index)
|
||||
this@tableview.focusModel.focus(cell.tableRow.index)
|
||||
if (it.isControlDown && it.button.equals(MouseButton.PRIMARY)) {
|
||||
if (this@tableview.selectionModel.isSelected(this@cellFormat.tableRow.index)) {
|
||||
this@tableview.selectionModel.clearSelection(this@cellFormat.tableRow.index)
|
||||
if (this@tableview.selectionModel.isSelected(cell.tableRow.index)) {
|
||||
this@tableview.selectionModel.clearSelection(cell.tableRow.index)
|
||||
} else {
|
||||
this@tableview.selectionModel.select(this@cellFormat.tableRow.index)
|
||||
this@tableview.selectionModel.select(cell.tableRow.index)
|
||||
}
|
||||
} else if (it.button.equals(MouseButton.PRIMARY)) {
|
||||
this@tableview.selectionModel.clearSelection()
|
||||
this@tableview.selectionModel.select(this@cellFormat.tableRow.index)
|
||||
this@tableview.selectionModel.select(cell.tableRow.index)
|
||||
}
|
||||
}
|
||||
2 -> openPhotos(this@cellFormat.tableRow.item.postId)
|
||||
2 -> openPhotos(cell.tableRow.item.postId)
|
||||
}
|
||||
}
|
||||
useMaxWidth = true
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
cell as TableCell<PostModel, Number>
|
||||
}
|
||||
}
|
||||
column("Status", PostModel::statusProperty)
|
||||
@@ -168,17 +203,6 @@ class PostsTableView : View("Download") {
|
||||
}
|
||||
}
|
||||
|
||||
private fun openFileDirectory(path: String) {
|
||||
val os = System.getProperty("os.name")
|
||||
if(os.contains("Windows")) {
|
||||
Shell32.INSTANCE.ShellExecuteW(null, WString("open"), WString(path), null, null, 1)
|
||||
} else if(os.contains("Linux")) {
|
||||
Runtime.getRuntime().exec("xdg-open $path")
|
||||
} else if(os.contains("Mac")) {
|
||||
Runtime.getRuntime().exec("open -R $path")
|
||||
}
|
||||
}
|
||||
|
||||
fun deleteSelected() {
|
||||
val postIdList = tableView.selectionModel.selectedItems.map { it.postId }
|
||||
confirm(
|
||||
|
||||
+19
-5
@@ -3,12 +3,12 @@ package me.mnlr.vripper.view.tables
|
||||
import javafx.collections.FXCollections
|
||||
import javafx.collections.ObservableList
|
||||
import javafx.geometry.Pos
|
||||
import javafx.scene.control.Label
|
||||
import javafx.scene.control.SelectionMode
|
||||
import javafx.scene.control.TableRow
|
||||
import javafx.scene.control.TableView
|
||||
import javafx.scene.control.*
|
||||
import javafx.scene.image.ImageView
|
||||
import javafx.scene.input.MouseButton
|
||||
import me.mnlr.vripper.controller.ThreadController
|
||||
import me.mnlr.vripper.model.ThreadSelectionModel
|
||||
import me.mnlr.vripper.view.openLink
|
||||
import tornadofx.*
|
||||
|
||||
class ThreadSelectionTableView : Fragment("Thread") {
|
||||
@@ -37,12 +37,26 @@ class ThreadSelectionTableView : Fragment("Thread") {
|
||||
val tableRow = TableRow<ThreadSelectionModel>()
|
||||
|
||||
tableRow.setOnMouseClicked {
|
||||
if (it.clickCount == 2 && tableRow.item != null) {
|
||||
if (it.button.equals(MouseButton.PRIMARY) && it.clickCount == 2 && tableRow.item != null) {
|
||||
threadController.download(listOf(tableRow.item))
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
val urlItem = MenuItem("Open link").apply {
|
||||
setOnAction {
|
||||
openLink(tableRow.item.url)
|
||||
}
|
||||
graphic = ImageView("open-in-browser.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
val contextMenu = ContextMenu()
|
||||
contextMenu.items.addAll(urlItem)
|
||||
tableRow.contextMenuProperty().bind(tableRow.emptyProperty()
|
||||
.map { empty -> if (empty) null else contextMenu })
|
||||
|
||||
tableRow
|
||||
}
|
||||
column("Post Index", ThreadSelectionModel::indexProperty) {
|
||||
|
||||
@@ -8,10 +8,11 @@ import me.mnlr.vripper.controller.ThreadController
|
||||
import me.mnlr.vripper.event.Event
|
||||
import me.mnlr.vripper.event.EventBus
|
||||
import me.mnlr.vripper.model.ThreadModel
|
||||
import me.mnlr.vripper.view.main.MainView
|
||||
import me.mnlr.vripper.view.openLink
|
||||
import me.mnlr.vripper.view.FxScheduler
|
||||
import tornadofx.*
|
||||
|
||||
class ThreadTableView : View("Threads") {
|
||||
class ThreadTableView : View() {
|
||||
|
||||
private val threadController: ThreadController by inject()
|
||||
private val eventBus: EventBus by di()
|
||||
@@ -21,42 +22,49 @@ class ThreadTableView : View("Threads") {
|
||||
private var items: ObservableList<ThreadModel> = FXCollections.observableArrayList()
|
||||
|
||||
init {
|
||||
titleProperty.bind(items.sizeProperty.map {
|
||||
if (it.toLong() > 0) {
|
||||
"Threads (${it.toLong()})"
|
||||
} else {
|
||||
"Threads"
|
||||
}
|
||||
})
|
||||
items.addAll(threadController.findAll())
|
||||
|
||||
eventBus.flux()
|
||||
.filter { it!!.kind == Event.Kind.THREAD_UPDATE || it.kind == Event.Kind.THREAD_REMOVE || it.kind == Event.Kind.THREAD_CLEAR }
|
||||
.subscribe { event ->
|
||||
when (event!!.kind) {
|
||||
Event.Kind.THREAD_UPDATE -> {
|
||||
threadController.find(event.data as Long).ifPresent {
|
||||
// search
|
||||
val find =
|
||||
items.find { threadModel -> threadModel.threadId == it.threadId }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
total = it.total
|
||||
}
|
||||
} else {
|
||||
items.add(it)
|
||||
runLater {
|
||||
find<MainView>().root.selectionModel.select(1)
|
||||
tableView.selectionModel.clearSelection()
|
||||
tableView.selectionModel.select(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it!!.kind == Event.Kind.THREAD_UPDATE }
|
||||
.map { threadController.find(it.data as Long) }
|
||||
.filter { it.isPresent }
|
||||
.map { it.get() }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe {
|
||||
val find =
|
||||
items.find { threadModel -> threadModel.threadId == it.threadId }
|
||||
if (find != null) {
|
||||
find.apply {
|
||||
total = it.total
|
||||
}
|
||||
|
||||
Event.Kind.THREAD_REMOVE -> {
|
||||
tableView.items.removeIf { it.threadId == event.data as String }
|
||||
}
|
||||
|
||||
Event.Kind.THREAD_CLEAR -> {
|
||||
tableView.items.clear()
|
||||
}
|
||||
else -> {}
|
||||
} else {
|
||||
items.add(it)
|
||||
}
|
||||
}
|
||||
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it.kind == Event.Kind.THREAD_REMOVE }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe { event ->
|
||||
tableView.items.removeIf { it.threadId == event.data as String }
|
||||
}
|
||||
|
||||
eventBus
|
||||
.flux()
|
||||
.filter { it.kind == Event.Kind.THREAD_CLEAR }
|
||||
.publishOn(FxScheduler)
|
||||
.subscribe {
|
||||
tableView.items.clear()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDock() {
|
||||
@@ -75,28 +83,40 @@ class ThreadTableView : View("Threads") {
|
||||
}
|
||||
}
|
||||
|
||||
val selectItem = MenuItem("Select posts").apply {
|
||||
setOnAction {
|
||||
selectPosts(tableRow.item.threadId)
|
||||
}
|
||||
graphic = ImageView("popup.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val urlItem = MenuItem("Open link").apply {
|
||||
setOnAction {
|
||||
openLink(tableRow.item.link)
|
||||
}
|
||||
graphic = ImageView("open-in-browser.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val deleteItem = MenuItem("Delete").apply {
|
||||
setOnAction {
|
||||
deleteSelected()
|
||||
}
|
||||
graphic = ImageView("trash.png").apply {
|
||||
fitWidth = 18.0
|
||||
fitHeight = 18.0
|
||||
}
|
||||
}
|
||||
|
||||
val contextMenu = ContextMenu()
|
||||
val selectItem = MenuItem("Select posts")
|
||||
selectItem.setOnAction {
|
||||
selectPosts(tableRow.item.threadId)
|
||||
}
|
||||
val selectIcon = ImageView("popup.png")
|
||||
selectIcon.fitWidth = 18.0
|
||||
selectIcon.fitHeight = 18.0
|
||||
selectItem.graphic = selectIcon
|
||||
|
||||
val deleteItem = MenuItem("Delete")
|
||||
deleteItem.setOnAction {
|
||||
deleteSelected()
|
||||
}
|
||||
val deleteIcon = ImageView("trash.png")
|
||||
deleteIcon.fitWidth = 18.0
|
||||
deleteIcon.fitHeight = 18.0
|
||||
deleteItem.graphic = deleteIcon
|
||||
|
||||
contextMenu.items.addAll(selectItem, SeparatorMenuItem(), deleteItem)
|
||||
contextMenu.items.addAll(selectItem, urlItem, SeparatorMenuItem(), deleteItem)
|
||||
tableRow.contextMenuProperty().bind(tableRow.emptyProperty()
|
||||
.map { empty -> if (empty) null else contextMenu })
|
||||
.map { empty -> if (empty) null else contextMenu })
|
||||
tableRow
|
||||
}
|
||||
column("URL", ThreadModel::linkProperty) {
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 702 B |
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>me.mnlr</groupId>
|
||||
<artifactId>vripper-web-ui</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
<name>vripper-web-ui</name>
|
||||
<build>
|
||||
<resources>
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@
|
||||
</parent>
|
||||
<groupId>me.mnlr.vripper</groupId>
|
||||
<artifactId>vripper-web</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
<name>vripper-web</name>
|
||||
<description>vripper-web</description>
|
||||
<properties>
|
||||
@@ -41,12 +41,12 @@
|
||||
<dependency>
|
||||
<groupId>me.mnlr.vripper</groupId>
|
||||
<artifactId>vripper-core</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.mnlr</groupId>
|
||||
<artifactId>vripper-web-ui</artifactId>
|
||||
<version>4.3.0</version>
|
||||
<version>4.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
Reference in New Issue
Block a user