@@ -19,6 +19,7 @@ package com.valaphee.blit
1919import com.valaphee.blit.data.config.Config
2020import com.valaphee.blit.data.config.ConfigView
2121import com.valaphee.blit.data.config.ConfigViewGeneral
22+ import com.valaphee.blit.data.config.ConfigViewNetwork
2223import com.valaphee.blit.data.config.ConfigViewSources
2324import com.valaphee.blit.data.locale.Locale
2425import com.valaphee.blit.data.manifest.IconManifest
@@ -28,6 +29,7 @@ import com.valaphee.blit.source.SourceConfig
2829import javafx.beans.property.SimpleObjectProperty
2930import javafx.beans.property.SimpleStringProperty
3031import javafx.scene.control.ContextMenu
32+ import javafx.scene.control.Label
3133import javafx.scene.control.SelectionMode
3234import javafx.scene.control.TableColumnBase
3335import javafx.scene.control.TreeItem
@@ -41,9 +43,7 @@ import javafx.scene.input.TransferMode
4143import javafx.scene.layout.Priority
4244import javafx.scene.layout.VBox
4345import javafx.stage.Stage
44- import jfxtras.styles.jmetro.JMetro
4546import jfxtras.styles.jmetro.JMetroStyleClass
46- import jfxtras.styles.jmetro.Style
4747import org.bridj.cpp.com.COMRuntime
4848import org.bridj.cpp.com.shell.ITaskbarList3
4949import org.controlsfx.control.BreadCrumbBar
@@ -77,6 +77,7 @@ import java.awt.Desktop
7777import java.io.File
7878import java.io.FileInputStream
7979import java.io.FileOutputStream
80+ import java.io.IOException
8081import java.text.DateFormat
8182import java.util.concurrent.CompletableFuture
8283
@@ -105,7 +106,7 @@ class MainView : View("Blit") {
105106 private val dateFormat = DateFormat .getDateTimeInstance(DateFormat .SHORT , DateFormat .SHORT , locale.toJavaLocale())
106107
107108 override val root = vbox {
108- JMetro (this , Style . DARK )
109+ _config .theme. apply (this )
109110 styleClass.add(JMetroStyleClass .BACKGROUND )
110111
111112 prefWidth = 1000.0
@@ -129,6 +130,14 @@ class MainView : View("Blit") {
129130 }
130131 }
131132 }
133+ item(locale[" main.menu.file.network.name" ]) {
134+ action {
135+ find<ConfigView > {
136+ select<ConfigViewNetwork >()
137+ openModal()
138+ }
139+ }
140+ }
132141 separator()
133142 item(locale[" main.menu.file.exit.name" ]) { action { (scene.window as Stage ).close() } }
134143 }
@@ -234,6 +243,8 @@ class MainView : View("Blit") {
234243 isShowRoot = false
235244 selectionModel.selectionMode = SelectionMode .MULTIPLE
236245
246+ placeholder = Label (" " )
247+
237248 column(locale[" main.tree.column.name.title" ], Entry <T >::self) {
238249 tableColumnBaseSetWidth(this , 250.0 )
239250 cellFormat {
@@ -291,10 +302,19 @@ class MainView : View("Blit") {
291302
292303 selectionModel.selectedItems.onChange {
293304 contextMenu = ContextMenu ().apply {
294- item(locale[" main.tree.menu.open.name" ]) { action { it.list.firstOrNull { it.value.directory }?.value?.let { navigateRelative(it.toString()) } ? : it.list.forEach(::open) } }
295- separator()
296- item(locale[" main.tree.menu.rename.name" ]) { action { it.list.forEach(::rename) } }
297- item(locale[" main.tree.menu.delete.name" ]) { action { it.list.forEach(::delete) } }
305+ if (it.list.isEmpty()) {
306+ item(locale[" main.tree.menu.parent.name" ]) { action { navigateRelative(" .." ) } }
307+ separator()
308+ item(locale[" main.tree.menu.new_directory.name" ]) { action {} }
309+ item(locale[" main.tree.menu.new_file.name" ]) { action {} }
310+ separator()
311+ item(locale[" main.tree.menu.refresh.name" ]) { action { populate(root) } }
312+ } else {
313+ item(locale[" main.tree.menu.open.name" ]) { action { it.list.firstOrNull { it.value.directory }?.value?.let { navigateRelative(it.toString()) } ? : it.list.forEach(::open) } }
314+ separator()
315+ item(locale[" main.tree.menu.rename.name" ]) { action { it.list.forEach(::rename) } }
316+ item(locale[" main.tree.menu.delete.name" ]) { action { it.list.forEach(::delete) } }
317+ }
298318 }
299319 }
300320
@@ -328,15 +348,18 @@ class MainView : View("Blit") {
328348 KeyCode .F5 -> populate(root)
329349 }
330350 }
331- setOnMousePressed {
332- if (it.isPrimaryButtonDown && it.clickCount == 2 ) selectionModel.selectedItem?.let { if (! it.value.directory) open(it) }
333- }
351+ setOnMousePressed { if (it.isPrimaryButtonDown && it.clickCount == 2 ) selectionModel.selectedItem?.let { if (! it.value.directory) open(it) } }
334352 }
335353
336354 private fun open (item : TreeItem <Entry <T >>) {
337355 if (Desktop .isDesktopSupported()) {
338356 val entry = item.value
339- activity.launch(locale[" main.tree.task.download.name" , entry]) { Desktop .getDesktop().open(File (_config .temporaryPath, entry.name).apply { FileOutputStream (this ).use { entry.transferTo(it) } }) } // TODO: Desktop.open throws IOException (No application is associated with the specific file for this operation.)
357+ activity.launch(locale[" main.tree.task.download.name" , entry]) {
358+ val file = File (_config .temporaryPath, entry.name).apply { FileOutputStream (this ).use { entry.transferTo(it) } }
359+ try {
360+ Desktop .getDesktop().open(file)
361+ } catch (_: IOException ) {}
362+ }
340363 }
341364 }
342365
0 commit comments