warn user to expand folders before downloading them

java-i2p-warning
Zlatin Balevsky 2022-08-29 12:52:42 +01:00
parent 7d3f004ae3
commit 1359a0d1af
No known key found for this signature in database
GPG Key ID: A72832072D525E41
4 changed files with 32 additions and 1 deletions

View File

@ -167,6 +167,11 @@ class BrowseController {
if (selectedResults == null || selectedResults.isEmpty())
return
if (model.treeVisible && model.session != null && model.session.supportsIncremental() &&
view.resultsTree.selectedUnfetchedFolder()) {
view.showUnexpandedFolderWarning()
return
}
File downloadsFolder = application.context.get("muwire-settings").downloadLocation
List<ResultAndTargets> targets = view.decorateResults(selectedResults)

View File

@ -300,6 +300,8 @@ SELECT_SINGLE_RESULT=Select a single result to see who sent it
# Search table popup menu
COPY_NAME_TO_CLIPBOARD=Copy name to clipboard
EXPAND_FULLY=Expand fully
WARNING_UNEXPANDED_FOLDER_TITLE=Cannot download folder
WARNING_UNEXPANDED_FOLDER_BODY=Before you can download this folder you need to expand it fully
## Result details tab

View File

@ -5,6 +5,7 @@ import griffon.core.artifact.GriffonView
import javax.swing.AbstractAction
import javax.swing.Action
import javax.swing.JComponent
import javax.swing.JOptionPane
import javax.swing.JPanel
import javax.swing.JTable
import javax.swing.JTextField
@ -408,6 +409,11 @@ class BrowseView {
rv
}
void showUnexpandedFolderWarning() {
JOptionPane.showMessageDialog(null, trans("WARNING_UNEXPANDED_FOLDER_BODY"),
trans("WARNING_UNEXPANDED_FOLDER_TITLE"), JOptionPane.WARNING_MESSAGE)
}
def showTree = {
model.treeVisible = true
resultsPanel.getLayout().show(resultsPanel, "tree")

View File

@ -86,7 +86,7 @@ class ResultTree extends JTree{
List<TreePath> selectedFolderPaths() {
TreePath[] selected = getSelectionPaths()
if (selected == null)
return
return Collections.emptyList()
List<TreePath> rv = []
for (TreePath path : selected) {
def obj = path.getLastPathComponent().getUserObject()
@ -95,5 +95,23 @@ class ResultTree extends JTree{
}
rv
}
/**
* @return true if an unfetched folder has been selected
*/
boolean selectedUnfetchedFolder() {
List<TreePath> selected = selectedFolderPaths()
if (selected.isEmpty())
return false
List<?> userObjects = []
for (TreePath path : selected) {
TreeUtil.getLeafs(path.getLastPathComponent(), userObjects)
}
for (Object o : userObjects) {
if (o == ResultTreeRenderer.PLACEHOLDER)
return true
}
false
}
}