* some refactoring in ChecksumTableSaveAction
This commit is contained in:
parent
1208b6c924
commit
58d0244668
|
@ -18,7 +18,7 @@ public class ResourceManager {
|
|||
|
||||
|
||||
public static ImageIcon getIcon(String name, String def) {
|
||||
URL resource = getResource(name, def);
|
||||
URL resource = getImageResource(name, def);
|
||||
|
||||
if (resource != null)
|
||||
return new ImageIcon(resource);
|
||||
|
@ -39,23 +39,23 @@ public class ResourceManager {
|
|||
|
||||
public static Image getImage(String name) {
|
||||
try {
|
||||
return ImageIO.read(getResource(name));
|
||||
return ImageIO.read(getImageResource(name));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static URL getResource(String name) {
|
||||
private static URL getImageResource(String name) {
|
||||
return ResourceManager.class.getResource(name + ".png");
|
||||
}
|
||||
|
||||
|
||||
private static URL getResource(String name, String def) {
|
||||
URL resource = getResource(name);
|
||||
private static URL getImageResource(String name, String def) {
|
||||
URL resource = getImageResource(name);
|
||||
|
||||
if (resource == null)
|
||||
resource = getResource(def);
|
||||
resource = getImageResource(def);
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
|
|
@ -103,27 +103,38 @@ public class SfvPanel extends FileBotPanel {
|
|||
private File selectedColumn = null;
|
||||
|
||||
|
||||
public ChecksumTableSaveAction() {
|
||||
super(sfvTable.getExportHandler());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ChecksumTableExportHandler getExportHandler() {
|
||||
return (ChecksumTableExportHandler) super.getExportHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canExport() {
|
||||
return selectedColumn != null && sfvTable.getExportHandler().canExport();
|
||||
return selectedColumn != null && super.canExport();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void export(File file) throws IOException {
|
||||
sfvTable.getExportHandler().export(file, selectedColumn);
|
||||
getExportHandler().export(file, selectedColumn);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return sfvTable.getExportHandler().getDefaultFileName(selectedColumn);
|
||||
return getExportHandler().getDefaultFileName(selectedColumn);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected File getDefaultFolder() {
|
||||
// if column is a folder use it as default folder in file dialog
|
||||
// if the column is a folder use it as default folder in the file dialog
|
||||
return selectedColumn.isDirectory() ? selectedColumn : null;
|
||||
}
|
||||
|
||||
|
@ -135,10 +146,10 @@ public class SfvPanel extends FileBotPanel {
|
|||
this.selectedColumn = null;
|
||||
|
||||
if (options.size() == 1) {
|
||||
// auto-select if there is only one option
|
||||
// auto-select option if there is only one option
|
||||
this.selectedColumn = options.get(0);
|
||||
} else if (options.size() > 1) {
|
||||
// show user his/her options
|
||||
// user must select one option
|
||||
SelectDialog<File> selectDialog = new SelectDialog<File>(SwingUtilities.getWindowAncestor(SfvPanel.this), options) {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.sourceforge.filebot.resources.ResourceManager;
|
|||
|
||||
public class SaveAction extends AbstractAction {
|
||||
|
||||
protected final FileExportHandler exportHandler;
|
||||
private final FileExportHandler exportHandler;
|
||||
|
||||
|
||||
public SaveAction(FileExportHandler exportHandler) {
|
||||
|
@ -27,23 +27,23 @@ public class SaveAction extends AbstractAction {
|
|||
}
|
||||
|
||||
|
||||
protected SaveAction() {
|
||||
this(null);
|
||||
public FileExportHandler getExportHandler() {
|
||||
return exportHandler;
|
||||
}
|
||||
|
||||
|
||||
protected boolean canExport() {
|
||||
return exportHandler.canExport();
|
||||
return getExportHandler().canExport();
|
||||
}
|
||||
|
||||
|
||||
protected void export(File file) throws IOException {
|
||||
exportHandler.export(file);
|
||||
getExportHandler().export(file);
|
||||
}
|
||||
|
||||
|
||||
protected String getDefaultFileName() {
|
||||
return exportHandler.getDefaultFileName();
|
||||
return getExportHandler().getDefaultFileName();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue