* user proper table event to send a repaint request from the table model to the jtable
* avoid null pointner exceptions
This commit is contained in:
parent
2b9c8e840a
commit
94290d46a0
|
@ -39,7 +39,7 @@ public class FileBotPanel extends JPanel {
|
||||||
|
|
||||||
public static FileBotPanel forName(String name) {
|
public static FileBotPanel forName(String name) {
|
||||||
for (FileBotPanel panel : registry) {
|
for (FileBotPanel panel : registry) {
|
||||||
if (name.equalsIgnoreCase(panel.getPanelName()))
|
if (panel.getPanelName().equalsIgnoreCase(name))
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ package net.sourceforge.filebot.ui.panel.sfv;
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.beans.PropertyChangeSupport;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -12,7 +11,9 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
import net.sourceforge.filebot.FileFormat;
|
import net.sourceforge.filebot.FileFormat;
|
||||||
|
|
||||||
|
@ -184,25 +185,13 @@ class ChecksumTableModel extends AbstractTableModel {
|
||||||
return checksumMap;
|
return checksumMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyChangeListener checksumListener = new PropertyChangeListener() {
|
private final PropertyChangeListener checksumListener = new PropertyChangeListener() {
|
||||||
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
propertyChangeSupport.firePropertyChange(evt);
|
fireTableChanged(new ChecksumTableModelEvent(ChecksumTableModel.this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
|
|
||||||
|
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
|
||||||
propertyChangeSupport.addPropertyChangeListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
|
||||||
propertyChangeSupport.removePropertyChangeListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static class Entry {
|
public static class Entry {
|
||||||
|
|
||||||
|
@ -241,4 +230,17 @@ class ChecksumTableModel extends AbstractTableModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static class ChecksumTableModelEvent extends TableModelEvent {
|
||||||
|
|
||||||
|
public static final int CHECKSUM_PROGRESS = 10;
|
||||||
|
|
||||||
|
|
||||||
|
public ChecksumTableModelEvent(TableModel source) {
|
||||||
|
super(source);
|
||||||
|
type = CHECKSUM_PROGRESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
package net.sourceforge.filebot.ui.panel.sfv;
|
package net.sourceforge.filebot.ui.panel.sfv;
|
||||||
|
|
||||||
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -14,10 +12,12 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.ListSelectionModel;
|
import javax.swing.ListSelectionModel;
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
import javax.swing.table.TableModel;
|
import javax.swing.table.TableModel;
|
||||||
|
|
||||||
import net.sourceforge.filebot.FileFormat;
|
import net.sourceforge.filebot.FileFormat;
|
||||||
|
import net.sourceforge.filebot.ui.panel.sfv.ChecksumTableModel.ChecksumTableModelEvent;
|
||||||
import net.sourceforge.filebot.ui.panel.sfv.renderer.ChecksumTableCellRenderer;
|
import net.sourceforge.filebot.ui.panel.sfv.renderer.ChecksumTableCellRenderer;
|
||||||
import net.sourceforge.filebot.ui.panel.sfv.renderer.StateIconTableCellRenderer;
|
import net.sourceforge.filebot.ui.panel.sfv.renderer.StateIconTableCellRenderer;
|
||||||
import net.sourceforge.filebot.ui.panel.sfv.renderer.TextTableCellRenderer;
|
import net.sourceforge.filebot.ui.panel.sfv.renderer.TextTableCellRenderer;
|
||||||
|
@ -40,7 +40,6 @@ class SfvTable extends JTable implements TransferablePolicySupport, Saveable {
|
||||||
|
|
||||||
public SfvTable() {
|
public SfvTable() {
|
||||||
final ChecksumTableModel model = (ChecksumTableModel) getModel();
|
final ChecksumTableModel model = (ChecksumTableModel) getModel();
|
||||||
model.addPropertyChangeListener(repaintListener);
|
|
||||||
|
|
||||||
setFillsViewportHeight(true);
|
setFillsViewportHeight(true);
|
||||||
|
|
||||||
|
@ -96,14 +95,7 @@ class SfvTable extends JTable implements TransferablePolicySupport, Saveable {
|
||||||
((ChecksumTableModel) getModel()).clear();
|
((ChecksumTableModel) getModel()).clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyChangeListener repaintListener = new PropertyChangeListener() {
|
|
||||||
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
public TransferablePolicy getTransferablePolicy() {
|
public TransferablePolicy getTransferablePolicy() {
|
||||||
return transferablePolicy;
|
return transferablePolicy;
|
||||||
}
|
}
|
||||||
|
@ -141,6 +133,16 @@ class SfvTable extends JTable implements TransferablePolicySupport, Saveable {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tableChanged(TableModelEvent e) {
|
||||||
|
if (e.getType() == ChecksumTableModelEvent.CHECKSUM_PROGRESS) {
|
||||||
|
repaint();
|
||||||
|
} else {
|
||||||
|
super.tableChanged(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void save(File file, int checksumColumnIndex) {
|
public void save(File file, int checksumColumnIndex) {
|
||||||
try {
|
try {
|
||||||
PrintStream out = new PrintStream(file);
|
PrintStream out = new PrintStream(file);
|
||||||
|
|
|
@ -28,7 +28,7 @@ public abstract class EpisodeListClient {
|
||||||
|
|
||||||
public static EpisodeListClient forName(String name) {
|
public static EpisodeListClient forName(String name) {
|
||||||
for (EpisodeListClient client : registry) {
|
for (EpisodeListClient client : registry) {
|
||||||
if (name.equalsIgnoreCase(client.getName()))
|
if (client.getName().equalsIgnoreCase(name))
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue