mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 16:28:51 -05:00
* maybe fixed visual update issue in VideoHashSubtitleDownloadDialog
This commit is contained in:
parent
f51b234667
commit
d3331f3053
@ -132,7 +132,11 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
|
||||
if (containsOnly(files, FOLDERS)) {
|
||||
// collect all video files from the dropped folders
|
||||
return handleDownload(filter(listFiles(files, 0), VIDEO_FILES));
|
||||
List<File> videoFiles = filter(listFiles(files, 0), VIDEO_FILES);
|
||||
|
||||
if (videoFiles.size() > 0) {
|
||||
return handleDownload(videoFiles);
|
||||
}
|
||||
}
|
||||
|
||||
if (containsOnly(files, SUBTITLE_FILES)) {
|
||||
@ -149,14 +153,25 @@ abstract class SubtitleDropTarget extends JButton {
|
||||
}
|
||||
|
||||
|
||||
private boolean containsOnlyVideoSubtitleMatches(List<File> files) {
|
||||
List<File> subtitles = filter(files, SUBTITLE_FILES);
|
||||
|
||||
if (subtitles.isEmpty())
|
||||
return false;
|
||||
|
||||
// number of subtitle files must match the number of video files
|
||||
return subtitles.size() == filter(files, VIDEO_FILES).size();
|
||||
}
|
||||
|
||||
|
||||
private DropAction getDropAction(List<File> files) {
|
||||
// video files only, or any folder, containing video files
|
||||
if (containsOnly(files, VIDEO_FILES) || (containsOnly(files, FOLDERS) && filter(listFiles(files, 0), VIDEO_FILES).size() > 0)) {
|
||||
return DropAction.Download;
|
||||
}
|
||||
|
||||
// subtitle files only, or video/subtitle pairs
|
||||
if (containsOnly(files, SUBTITLE_FILES) || filter(files, VIDEO_FILES).size() == filter(files, SUBTITLE_FILES).size()) {
|
||||
// subtitle files only, or video/subtitle matches
|
||||
if (containsOnly(files, SUBTITLE_FILES) || containsOnlyVideoSubtitleMatches(files)) {
|
||||
return DropAction.Upload;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class SubtitlePanel extends AbstractSearchPanel<SubtitleProvider, Subtitl
|
||||
add(languageComboBox, 1);
|
||||
|
||||
// add at the top right corner
|
||||
add(dropTarget, "width 1.6cm, height 1.2cm, pos n 0% 100% n", 0);
|
||||
add(dropTarget, "width 1.6cm!, height 1.2cm!, pos n 0% 100% n", 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,6 @@ import javax.swing.Action;
|
||||
import javax.swing.DefaultCellEditor;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.DefaultListSelectionModel;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
@ -58,6 +57,7 @@ import net.sourceforge.filebot.web.SubtitleDescriptor;
|
||||
import net.sourceforge.filebot.web.VideoHashSubtitleService;
|
||||
import net.sourceforge.tuned.FileUtilities;
|
||||
import net.sourceforge.tuned.ui.AbstractBean;
|
||||
import net.sourceforge.tuned.ui.EmptySelectionModel;
|
||||
import net.sourceforge.tuned.ui.LinkButton;
|
||||
import net.sourceforge.tuned.ui.RoundBorder;
|
||||
|
||||
@ -103,6 +103,9 @@ class VideoHashSubtitleDownloadDialog extends JDialog {
|
||||
|
||||
JComboBox editor = new SimpleComboBox();
|
||||
editor.setRenderer(new SubtitleOptionRenderer());
|
||||
|
||||
// disable selection
|
||||
table.setSelectionModel(new EmptySelectionModel());
|
||||
editor.setFocusable(false);
|
||||
|
||||
table.setDefaultEditor(SubtitleMapping.class, new DefaultCellEditor(editor) {
|
||||
@ -119,33 +122,6 @@ class VideoHashSubtitleDownloadDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
|
||||
// disable selection
|
||||
table.setSelectionModel(new DefaultListSelectionModel() {
|
||||
|
||||
@Override
|
||||
public void addSelectionInterval(int from, int to) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectionInterval(int from, int to) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAnchorSelectionIndex(int anchorIndex) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLeadSelectionIndex(int leadIndex) {
|
||||
// ignore
|
||||
}
|
||||
});
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@ -429,6 +405,9 @@ class VideoHashSubtitleDownloadDialog extends JDialog {
|
||||
|
||||
|
||||
public void setOptionColumnVisible(boolean optionColumnVisible) {
|
||||
if (this.optionColumnVisible == optionColumnVisible)
|
||||
return;
|
||||
|
||||
this.optionColumnVisible = optionColumnVisible;
|
||||
|
||||
// update columns
|
||||
@ -512,9 +491,7 @@ class VideoHashSubtitleDownloadDialog extends JDialog {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
// update state and subtitle options
|
||||
if (optionColumnVisible) {
|
||||
fireTableCellUpdated(index, 1);
|
||||
}
|
||||
fireTableRowsUpdated(index, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -539,6 +516,9 @@ class VideoHashSubtitleDownloadDialog extends JDialog {
|
||||
|
||||
|
||||
public File getSubtitleFile() {
|
||||
if (selectedOption == null)
|
||||
throw new IllegalStateException("Selected option must not be null");
|
||||
|
||||
return new File(videoFile.getParentFile(), FileUtilities.getName(videoFile) + '.' + selectedOption.getType());
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ public abstract class AbstractBean {
|
||||
|
||||
|
||||
public AbstractBean() {
|
||||
// always notify on EDT
|
||||
pcs = new SwingPropertyChangeSupport(this, true);
|
||||
}
|
||||
|
||||
|
118
source/net/sourceforge/tuned/ui/EmptySelectionModel.java
Normal file
118
source/net/sourceforge/tuned/ui/EmptySelectionModel.java
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
package net.sourceforge.tuned.ui;
|
||||
|
||||
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
|
||||
|
||||
public class EmptySelectionModel implements ListSelectionModel {
|
||||
|
||||
@Override
|
||||
public void addListSelectionListener(ListSelectionListener x) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addSelectionInterval(int from, int to) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void clearSelection() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getAnchorSelectionIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLeadSelectionIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMaxSelectionIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getMinSelectionIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSelectionMode() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getValueIsAdjusting() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void insertIndexInterval(int index, int length, boolean before) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSelectedIndex(int index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSelectionEmpty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeIndexInterval(int from, int to) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeListSelectionListener(ListSelectionListener listener) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeSelectionInterval(int from, int to) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setAnchorSelectionIndex(int index) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setLeadSelectionIndex(int index) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectionInterval(int from, int to) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectionMode(int selectionMode) {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setValueIsAdjusting(boolean valueIsAdjusting) {
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user