Skip to content

Commit

Permalink
Merge remote-tracking branch 'GitHub/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Mar 28, 2015
2 parents 12acf77 + 1e9a17d commit 6ff9f7c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ target/
# Gradle
.gradle/
build/

# WinMerge
*.bak

Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
// Show
this.saveAllSourcesView.show(file)
// Execute background task
executor.submit(new Callable<Void>() {
Void call() throws Exception {
executor.execute(new Runnable() {
void run() {
int fileCount = savable.fileCount
int quotient = (fileCount / 100)

Expand All @@ -56,10 +56,15 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
def path = Paths.get(file.toURI())
Files.deleteIfExists(path)

savable.save(api, this as SourcesSavable.Controller, this as SourcesSavable.Listener, path)
try {
savable.save(api, this as SourcesSavable.Controller, this as SourcesSavable.Listener, path)
} catch (Exception e) {
saveAllSourcesView.showActionFailedDialog()
cancel = true
}

if (cancel) {
Files.delete(path)
Files.deleteIfExists(path)
}

saveAllSourcesView.hide()
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/groovy/jd/gui/view/SaveAllSourcesView.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import groovy.swing.SwingBuilder
import jd.gui.api.API
import jd.gui.model.configuration.Configuration

import javax.swing.JDialog
import javax.swing.JOptionPane
import java.awt.event.WindowAdapter
import java.awt.event.WindowEvent

Expand Down Expand Up @@ -73,4 +75,9 @@ class SaveAllSourcesView {
saveAllSourcesDialog.visible = false
}
}

void showActionFailedDialog() {
JOptionPane.showMessageDialog(
swing.saveAllSourcesDialog, '"Save All Sources" action failed.', 'Error', JOptionPane.ERROR_MESSAGE)
}
}
Binary file added dist/jd-gui-1.0.0-RC2.jar
Binary file not shown.
Binary file added dist/jd-gui-osx-1.0.0-RC2.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,23 @@ class GenericContainer implements Container {
}

protected Collection<Container.Entry> loadChildrenFromDirectoryEntry() {
return Files.newDirectoryStream(fsPath).collect { Path subPath -> new Entry(this, subPath, null) }.sort()
DirectoryStream<Path> stream = null

try {
def children = new ArrayList<Container.Entry>()
int parentNameCount = fsPath.nameCount
stream = Files.newDirectoryStream(fsPath)

for (def subPath : stream) {
if (subPath.nameCount > parentNameCount) {
children.add(new Entry(this, subPath, null))
}
}

return children.sort()
} finally {
stream?.close()
}
}

protected Collection<Container.Entry> loadChildrenFromFileEntry() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class ClassFileLoaderProvider extends AbstractFileLoaderProvider {
def path = file.path

while (! path.endsWith(pathSuffix)) {
int index = pathSuffix.indexOf(File.separatorChar)
int index = pathSuffix.indexOf(File.separator)

if (index == -1) {
pathSuffix = ''
} else {
pathSuffix = pathSuffix.substring(index)
pathSuffix = pathSuffix.substring(index+1)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import jd.gui.spi.SourceSaver

import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.StandardCopyOption
import java.util.regex.Pattern

class FileSourceSaverProvider implements SourceSaver {
Expand All @@ -28,7 +29,7 @@ class FileSourceSaverProvider implements SourceSaver {
listener.pathSaved(path)

entry.inputStream.withStream { InputStream is ->
Files.copy(is, path)
Files.copy(is, path, StandardCopyOption.REPLACE_EXISTING)
}
}
}

0 comments on commit 6ff9f7c

Please sign in to comment.