* refactor
This commit is contained in:
parent
694c0ec049
commit
3f65c370a5
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue