* refactor

This commit is contained in:
Reinhard Pointner 2015-07-26 11:52:11 +00:00
parent 694c0ec049
commit 3f65c370a5
2 changed files with 32 additions and 8 deletions

View File

@ -0,0 +1,31 @@
package net.filebot.ui.rename;
import java.io.File;
import java.io.FileFilter;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.filebot.format.ExpressionFilter;
import net.filebot.format.MediaBindingBean;
public class ExpressionFileFilter implements FileFilter {
private final ExpressionFilter filter;
private final boolean errorResult;
public ExpressionFileFilter(ExpressionFilter filter, boolean errorResult) {
this.filter = filter;
this.errorResult = errorResult;
}
@Override
public boolean accept(File f) {
try {
return filter.matches(new MediaBindingBean(f, f));
} catch (Exception e) {
Logger.getLogger(ExpressionFileFilter.class.getName()).log(Level.WARNING, e.toString());
return errorResult;
}
}
}

View File

@ -708,14 +708,7 @@ public class RenamePanel extends JComponent {
input.addAll(FileUtilities.listFiles(preset.getInputFolder()));
ExpressionFilter filter = preset.getIncludeFilter();
if (filter != null) {
input = FileUtilities.filter(input, (File f) -> {
try {
return filter.matches(new MediaBindingBean(f, f));
} catch (Exception e) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.toString());
return false;
}
});
input = FileUtilities.filter(input, new ExpressionFileFilter(filter, false));
}
renameModel.clear();
renameModel.files().addAll(input);