mirror of https://github.com/zlatinb/muwire
warn user to expand folders before downloading them
parent
7d3f004ae3
commit
1359a0d1af
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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()
|
||||
|
@ -96,4 +96,22 @@ 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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue