* Format Source

This commit is contained in:
Reinhard Pointner 2015-07-25 22:47:19 +00:00
parent 38a046bf2d
commit 8299e849aa
194 changed files with 2700 additions and 2622 deletions

View File

@ -35,6 +35,7 @@ public class ApacheVFS implements ArchiveExtractor, Closeable {
this.archive = fsm.createFileSystem(fsm.toFileObject(file));
}
@Override
public List<FileInfo> listFiles() throws Exception {
List<FileInfo> paths = new ArrayList<FileInfo>();
for (FileObject it : archive.findFiles(ALL_FILES)) {
@ -46,10 +47,12 @@ public class ApacheVFS implements ArchiveExtractor, Closeable {
return paths;
}
@Override
public void extract(File outputDir) throws Exception {
extract(outputDir, null);
}
@Override
public void extract(File outputDir, FileFilter filter) throws Exception {
fsm.toFileObject(outputDir).copyFrom(archive, filter == null ? ALL_FILES : new FileFilterSelector(filter));
}

View File

@ -36,6 +36,7 @@ class ArchiveOpenVolumeCallback implements IArchiveOpenVolumeCallback, IArchiveO
*
* @see IArchiveOpenVolumeCallback#getProperty(PropID)
*/
@Override
public Object getProperty(PropID propID) throws SevenZipException {
switch (propID) {
case NAME:
@ -56,6 +57,7 @@ class ArchiveOpenVolumeCallback implements IArchiveOpenVolumeCallback, IArchiveO
* <li>test.part001.rar - first part of a multi-part archive. "00" indicates, that at least 100 volumes must exist.</li>
* </ul>
*/
@Override
public IInStream getStream(String filename) throws SevenZipException {
try {
// We use caching of opened streams, so check cache first
@ -98,6 +100,7 @@ class ArchiveOpenVolumeCallback implements IArchiveOpenVolumeCallback, IArchiveO
/**
* Close all opened streams
*/
@Override
public void close() throws IOException {
for (RandomAccessFile file : openedRandomAccessFileList.values()) {
file.close();

View File

@ -29,6 +29,7 @@ class ExtractCallback implements IArchiveExtractCallback {
}
@Override
public ISequentialOutStream getStream(int index, ExtractAskMode extractAskMode) throws SevenZipException {
if (extractAskMode != ExtractAskMode.EXTRACT) {
return null;
@ -54,10 +55,12 @@ class ExtractCallback implements IArchiveExtractCallback {
}
@Override
public void prepareOperation(ExtractAskMode extractAskMode) throws SevenZipException {
}
@Override
public void setOperationResult(ExtractOperationResult extractOperationResult) throws SevenZipException {
if (output != null) {
try {
@ -75,10 +78,12 @@ class ExtractCallback implements IArchiveExtractCallback {
}
@Override
public void setCompleted(long completeValue) throws SevenZipException {
}
@Override
public void setTotal(long total) throws SevenZipException {
}

View File

@ -61,6 +61,7 @@ public class SevenZipExecutable implements ArchiveExtractor {
}
}
@Override
public List<FileInfo> listFiles() throws IOException {
List<FileInfo> paths = new ArrayList<FileInfo>();
@ -81,11 +82,13 @@ public class SevenZipExecutable implements ArchiveExtractor {
return paths;
}
@Override
public void extract(File outputDir) throws IOException {
// e.g. 7z x -y -aos archive.7z
execute(get7zCommand(), "x", "-y", "-aos", archive.getPath(), "-o" + outputDir.getCanonicalPath());
}
@Override
public void extract(File outputDir, FileFilter filter) throws IOException {
// e.g. 7z x -y -aos archive.7z file.txt image.png info.nfo
Stream<String> command = Stream.of(get7zCommand(), "x", "-y", "-aos", archive.getPath(), "-o" + outputDir.getCanonicalPath());

View File

@ -60,6 +60,7 @@ public class SevenZipNativeBindings implements ArchiveExtractor, Closeable {
return item;
}
@Override
public List<FileInfo> listFiles() throws SevenZipException {
List<FileInfo> paths = new ArrayList<FileInfo>();

View File

@ -292,6 +292,7 @@ public class GroovyPad extends JFrame {
private class ConsoleOutputStream extends ByteArrayOutputStream {
@Override
public void flush() {
try {
String message = this.toString("UTF-8");

View File

@ -57,7 +57,7 @@ public class ScriptShellMethods {
}
public static List<File> listFiles(File self, Closure<?> closure) {
return (List<File>) DefaultGroovyMethods.findAll(FileUtilities.getChildren(self), closure);
return DefaultGroovyMethods.findAll(FileUtilities.getChildren(self), closure);
}
public static boolean isVideo(File self) {
@ -121,7 +121,7 @@ public class ScriptShellMethods {
List<File> files = FileUtilities.listFiles(roots);
if (closure != null) {
files = (List<File>) DefaultGroovyMethods.findAll(files, closure);
files = DefaultGroovyMethods.findAll(files, closure);
}
return FileUtilities.sortByUniquePath(files);
@ -144,7 +144,7 @@ public class ScriptShellMethods {
List<File> folders = FileUtilities.listFolders(roots);
if (closure != null) {
folders = (List<File>) DefaultGroovyMethods.findAll(folders, closure);
folders = DefaultGroovyMethods.findAll(folders, closure);
}
return FileUtilities.sortByUniquePath(folders);

View File

@ -909,6 +909,7 @@ public class MediaBindingBean {
private AssociativeScriptObject createBindingObject(File file, Object info, Map<File, Object> context) {
MediaBindingBean mediaBindingBean = new MediaBindingBean(info, file, context) {
@Override
@Define(undefined)
public <T> T undefined(String name) {
return null; // never throw exceptions for empty or null values

View File

@ -284,6 +284,7 @@ public class DropToUnlock extends JList<File> {
return true;
}
@Override
public void handleTransferable(Transferable tr, TransferAction action) throws Exception {
List<File> files = FileTransferable.getFilesFromTransferable(tr);
if (files != null) {
@ -318,6 +319,7 @@ public class DropToUnlock extends JList<File> {
protected static class FileChooserAction extends MouseAdapter {
@Override
public void mouseClicked(MouseEvent evt) {
DropToUnlock list = (DropToUnlock) evt.getSource();
if (evt.getClickCount() > 0) {

View File

@ -33,6 +33,7 @@ public class SmartSeasonEpisodeMatcher extends SeasonEpisodeMatcher {
return super.match(new File(clean(file.getPath())));
}
@Override
public String head(String name) {
return super.head(clean(name));
}

View File

@ -88,6 +88,7 @@ public enum SubtitleMetrics implements SimilarityMetric {
return 0;
}
@Override
protected float similarity(String match, String s1, String s2) {
return match.length() > 0 ? 1 : 0;
}
@ -153,10 +154,12 @@ public enum SubtitleMetrics implements SimilarityMetric {
private final String FPS = "FPS";
private final String SECONDS = "SECS";
@Override
public float getSimilarity(Object o1, Object o2) {
return o1 instanceof SubtitleDescriptor ? super.getSimilarity(o1, o2) : super.getSimilarity(o2, o1); // make sure that SubtitleDescriptor is o1
};
@Override
protected Map<String, Object> getProperties(Object object) {
if (object instanceof OpenSubtitlesSubtitleDescriptor) {
return getSubtitleProperties((OpenSubtitlesSubtitleDescriptor) object);

View File

@ -97,11 +97,13 @@ public class LanguageComboBoxModel extends AbstractListModel implements ComboBox
return data.get(index);
}
@Override
public boolean add(Language element) {
// add first
return addIfAbsent(0, element);
}
@Override
public void add(int index, Language element) {
addIfAbsent(index, element);
}

View File

@ -125,10 +125,12 @@ public class MainFrame extends JFrame {
GroovyPad pad = new GroovyPad();
pad.addWindowListener(new WindowAdapter() {
@Override
public void windowOpened(WindowEvent e) {
MainFrame.this.setVisible(false);
};
@Override
public void windowClosing(WindowEvent e) {
MainFrame.this.setVisible(true);
};

View File

@ -37,6 +37,7 @@ public class AnalyzePanel extends JComponent {
private final PropertyChangeListener filetreeListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
// stopped loading, refresh tools
for (int i = 0; i < toolsPanel.getTabCount(); i++) {

View File

@ -114,6 +114,7 @@ public class FileTree extends JTree {
putValue("files", files);
}
@Override
public void actionPerformed(ActionEvent event) {
UserFiles.revealFiles((Collection<File>) getValue("files"));
}

View File

@ -7,7 +7,6 @@ import static net.filebot.util.FileUtilities.*;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
@ -15,8 +14,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JScrollPane;

View File

@ -42,6 +42,7 @@ class MatchAction extends AbstractAction {
putValue(SMALL_ICON, ResourceManager.getIcon(strict ? "action.match.strict" : "action.match"));
}
@Override
public void actionPerformed(ActionEvent evt) {
if (model.names().isEmpty() || model.files().isEmpty()) {
return;

View File

@ -237,6 +237,7 @@ public class PresetEditor extends JDialog {
private final ListCellRenderer<Object> parent = (ListCellRenderer<Object>) combo.getRenderer();
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) parent.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
@ -278,7 +279,7 @@ public class PresetEditor extends JDialog {
JLabel label = (JLabel) parent.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Language) {
Language it = (Language) value;
Language it = value;
label.setText(it.getName());
label.setIcon(ResourceManager.getFlagIcon(it.getCode()));
}

View File

@ -126,6 +126,7 @@ class RenameList<E> extends FileBotList<E> {
private final AbstractAction upAction = new AbstractAction("Align Up", ResourceManager.getIcon("action.up")) {
@Override
public void actionPerformed(ActionEvent e) {
int index = getListComponent().getSelectedIndex();
@ -138,6 +139,7 @@ class RenameList<E> extends FileBotList<E> {
private final AbstractAction downAction = new AbstractAction("Align Down", ResourceManager.getIcon("action.down")) {
@Override
public void actionPerformed(ActionEvent e) {
int index = getListComponent().getSelectedIndex();

View File

@ -274,7 +274,7 @@ public class RenamePanel extends JComponent {
try {
JList list = (JList) evt.getSource();
if (list.getSelectedIndex() >= 0) {
UserFiles.revealFiles((List<File>) list.getSelectedValuesList());
UserFiles.revealFiles(list.getSelectedValuesList());
}
} catch (Exception e) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
@ -702,6 +702,7 @@ public class RenamePanel extends JComponent {
this.preset = preset;
}
@Override
public List<File> getFiles(ActionEvent evt) {
List<File> input = new ArrayList<File>();
if (preset.getInputFolder() != null) {
@ -725,10 +726,12 @@ public class RenamePanel extends JComponent {
return input;
}
@Override
public boolean isStrict(ActionEvent evt) {
return preset.getMatchMode() != null ? MATCH_MODE_STRICT.equals(preset.getMatchMode()) : super.isStrict(evt);
}
@Override
public SortOrder getSortOrder(ActionEvent evt) {
return preset.getSortOrder() != null ? preset.getSortOrder() : super.getSortOrder(evt);
}

View File

@ -171,6 +171,7 @@ class ChecksumRow {
private final PropertyChangeListener updateStateListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if ("state".equals(evt.getPropertyName())) {
setState(getState(hashes.values()));

View File

@ -242,6 +242,7 @@ class ChecksumTableModel extends AbstractTableModel {
private final PropertyChangeListener progressListener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
ChecksumCell cell = (ChecksumCell) evt.getSource();

View File

@ -32,6 +32,7 @@ class SwingWorkerCellRenderer extends JPanel implements TableCellRenderer {
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
setBackground(isSelected ? table.getSelectionBackground() : table.getBackground());

View File

@ -46,6 +46,7 @@ class TotalProgressPanel extends JComponent {
private final DelayedToggle delayed = new DelayedToggle();
@Override
public void propertyChange(PropertyChangeEvent evt) {
final int completedTaskCount = getComputationService(evt).getCompletedTaskCount();
final int totalTaskCount = getComputationService(evt).getTotalTaskCount();
@ -80,6 +81,7 @@ class TotalProgressPanel extends JComponent {
private final ActionListener visibilityActionHandler = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setVisible(e.getActionCommand() == SHOW);
}

View File

@ -216,6 +216,7 @@ abstract class SubtitleDropTarget extends JButton {
return true;
}
@Override
protected Icon getIcon(DropAction dropAction) {
switch (dropAction) {
case Accept:
@ -307,6 +308,7 @@ abstract class SubtitleDropTarget extends JButton {
return null;
}
@Override
protected Icon getIcon(DropAction dropAction) {
if (dropAction == DropAction.Accept)
return ResourceManager.getIcon("subtitle.exact.upload");

View File

@ -73,6 +73,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
private final SubtitleDropTarget uploadDropTarget = new SubtitleDropTarget.Upload() {
@Override
public OpenSubtitlesClient getSubtitleService() {
return WebServices.OpenSubtitles;
};
@ -114,6 +115,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
return WebServices.getSubtitleProviders();
}
@Override
public OpenSubtitlesClient getSubtitleService() {
return WebServices.OpenSubtitles;
};
@ -149,6 +151,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
}
};
@Override
protected Collection<String> getHistory(SubtitleProvider engine) throws Exception {
List<String> names = new ArrayList<String>();
for (SubtitleSearchResult it : MediaDetection.releaseInfo.getOpenSubtitlesIndex()) {

View File

@ -61,7 +61,6 @@ import net.filebot.web.Movie;
import net.filebot.web.OpenSubtitlesClient;
import net.filebot.web.SearchResult;
import net.filebot.web.SubtitleSearchResult;
import net.filebot.web.TheTVDBSearchResult;
import net.filebot.web.TheTVDBSeriesInfo;
import net.filebot.web.VideoHashSubtitleService.CheckResult;
import net.miginfocom.swing.MigLayout;
@ -690,7 +689,7 @@ public class SubtitleUploadDialog extends JDialog {
for (String name : seriesNames) {
List<SearchResult> options = WebServices.TheTVDB.search(name, Locale.ENGLISH);
for (SearchResult entry : options) {
TheTVDBSeriesInfo seriesInfo = (TheTVDBSeriesInfo) WebServices.TheTVDB.getSeriesInfo((TheTVDBSearchResult) entry, Locale.ENGLISH);
TheTVDBSeriesInfo seriesInfo = (TheTVDBSeriesInfo) WebServices.TheTVDB.getSeriesInfo(entry, Locale.ENGLISH);
if (seriesInfo.getImdbId() != null) {
int imdbId = grepImdbId(seriesInfo.getImdbId()).iterator().next();
mapping.setIdentity(WebServices.OpenSubtitles.getMovieDescriptor(new Movie(null, 0, imdbId, -1), Locale.ENGLISH));

View File

@ -39,6 +39,7 @@ public class LoadAction extends AbstractAction {
return null;
}
@Override
public void actionPerformed(ActionEvent evt) {
try {
// get transferable policy from action properties

View File

@ -45,6 +45,7 @@ public class SaveAction extends AbstractAction {
return new File(validateFileName(getExportHandler().getDefaultFileName()));
}
@Override
public void actionPerformed(ActionEvent evt) {
try {
if (canExport()) {

View File

@ -14,12 +14,14 @@ import javax.swing.TransferHandler;
public abstract class TextFileExportHandler implements TransferableExportHandler, FileExportHandler {
@Override
public abstract boolean canExport();
public abstract void export(PrintWriter out);
@Override
public abstract String getDefaultFileName();

View File

@ -36,6 +36,7 @@ public class DefaultThreadFactory implements ThreadFactory {
}
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(group, r, String.format("%s-thread-%d", group.getName(), threadNumber.incrementAndGet()));

View File

@ -20,6 +20,7 @@ public class ListChangeSynchronizer<E> implements ListEventListener<E> {
}
@Override
public void listChanged(ListEvent<E> listChanges) {
EventList<E> source = listChanges.getSourceList();

View File

@ -58,50 +58,62 @@ public class UnicodeReader extends Reader {
}
}
@Override
public int hashCode() {
return reader.hashCode();
}
@Override
public int read(CharBuffer target) throws IOException {
return reader.read(target);
}
@Override
public boolean equals(Object obj) {
return reader.equals(obj);
}
@Override
public int read(char[] cbuf) throws IOException {
return reader.read(cbuf);
}
@Override
public int read() throws IOException {
return reader.read();
}
@Override
public int read(char[] cbuf, int offset, int length) throws IOException {
return reader.read(cbuf, offset, length);
}
@Override
public long skip(long n) throws IOException {
return reader.skip(n);
}
@Override
public boolean ready() throws IOException {
return reader.ready();
}
@Override
public void close() throws IOException {
reader.close();
}
@Override
public boolean markSupported() {
return reader.markSupported();
}
@Override
public void mark(int readAheadLimit) throws IOException {
reader.mark(readAheadLimit);
}
@Override
public void reset() throws IOException {
reader.reset();
}

View File

@ -26,11 +26,13 @@ public class FilePreferencesFactory implements PreferencesFactory {
public static final String SYSTEM_PROPERTY_FILE = "net.filebot.util.prefs.file";
@Override
public Preferences systemRoot() {
return userRoot();
}
@Override
public Preferences userRoot() {
if (rootPreferences == null) {
rootPreferences = new FilePreferences(null, "");

View File

@ -148,6 +148,7 @@ public class ListView extends JList {
private Point origin;
@Override
public void mousePressed(MouseEvent e) {
if (SwingUtilities.isLeftMouseButton(e) && !isSelectedIndex(locationToIndex(e.getPoint()))) {
origin = e.getPoint();

View File

@ -226,6 +226,7 @@ public class SelectButton<T> extends JButton {
this.icon = icon;
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2d = (Graphics2D) g;
@ -237,10 +238,12 @@ public class SelectButton<T> extends JButton {
g2d.fill(arrow);
}
@Override
public int getIconWidth() {
return 30;
}
@Override
public int getIconHeight() {
return 20;
}

View File

@ -10,6 +10,7 @@ import javax.swing.SwingWorker.StateValue;
public abstract class SwingWorkerPropertyChangeAdapter implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("progress")) {
progress(evt);

View File

@ -80,6 +80,7 @@ public class QueueNotificationLayout implements NotificationLayout {
}
@Override
public void add(NotificationWindow notification) {
notifications.add(notification);
align(notification.getGraphicsConfiguration());
@ -103,6 +104,7 @@ public class QueueNotificationLayout implements NotificationLayout {
}
@Override
public void remove(NotificationWindow notification) {
if (notifications.remove(notification)) {
align(notification.getGraphicsConfiguration());

View File

@ -55,6 +55,7 @@ public class SimpleNotificationLayout implements NotificationLayout {
}
@Override
public void add(NotificationWindow notification) {
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(notification.getGraphicsConfiguration());
@ -71,6 +72,7 @@ public class SimpleNotificationLayout implements NotificationLayout {
}
@Override
public void remove(NotificationWindow notification) {
}

View File

@ -20,6 +20,7 @@ public class SimpleFileInfo implements FileInfo, Comparable<FileInfo> {
return path;
}
@Override
public String getName() {
return getNameWithoutExtension(new File(path).getName());
}
@ -29,6 +30,7 @@ public class SimpleFileInfo implements FileInfo, Comparable<FileInfo> {
return getExtension(path);
}
@Override
public long getLength() {
return length;
}

View File

@ -54,6 +54,7 @@ public abstract class AbstractEpisodeListProvider implements EpisodeListProvider
return getSeriesData(searchResult, null, language).getSeriesInfo();
}
@Override
public SeriesInfo getSeriesInfo(int id, Locale language) throws Exception {
return getSeriesInfo(createSearchResult(id), language);
}

View File

@ -131,7 +131,7 @@ public class AcoustIDClient implements MusicIdentificationService {
}
public AudioTrack parseResult(String json, final int targetDuration) throws IOException {
Map<?, ?> data = (Map<?, ?>) JsonReader.jsonToMaps(json);
Map<?, ?> data = JsonReader.jsonToMaps(json);
if (!data.get("status").equals("ok")) {
throw new IOException("acoustid responded with error: " + data.get("status"));

View File

@ -371,7 +371,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
// search for movies and series
List<SubtitleSearchResult> result = getCache().getSearchResult("search", query);
if (result != null) {
return (List<SubtitleSearchResult>) result;
return result;
}
// require login
@ -469,7 +469,7 @@ public class OpenSubtitlesClient implements SubtitleProvider, VideoHashSubtitleS
@Override
public URI getSubtitleListLink(SubtitleSearchResult searchResult, String languageName) {
Movie movie = (Movie) searchResult;
Movie movie = searchResult;
String sublanguageid = "all";
if (languageName != null) {

View File

@ -334,6 +334,7 @@ public class OpenSubtitlesXmlRpc {
protected Map<?, ?> invoke(String method, Object... arguments) throws XmlRpcFault {
try {
XmlRpcClient rpc = new XmlRpcClient(getXmlRpcUrl(), false) {
@Override
public void parse(InputStream input) throws XmlRpcException {
try {
super.parse(new GZIPInputStream(input));

View File

@ -9,12 +9,14 @@ import net.filebot.vfs.FileInfo;
public interface SubtitleDescriptor extends FileInfo {
@Override
String getName();
String getLanguageName();
@Override
String getType();

View File

@ -314,6 +314,7 @@ public class TheTVDBClient extends AbstractEpisodeListProvider {
protected Document getXmlResource(final MirrorType mirrorType, final String path) throws IOException {
CachedXmlResource resource = new CachedXmlResource(path) {
@Override
protected URL getResourceLocation(String path) throws IOException {
return getResourceURL(mirrorType, path);
};