Use database icon for custom Presets instead of the generic "Run Script" icon

This commit is contained in:
Reinhard Pointner 2017-03-03 22:20:24 +08:00
parent c960fd85a7
commit 76838cb1ba
2 changed files with 7 additions and 1 deletions

View File

@ -11,6 +11,8 @@ import java.util.List;
import java.util.logging.Level;
import java.util.stream.Stream;
import javax.swing.Icon;
import net.filebot.CachedResource.Transform;
import net.filebot.Language;
import net.filebot.StandardRenameAction;
@ -84,6 +86,10 @@ public class Preset {
return getValue(database, id -> getService(id, getSupportedServices()));
}
public Icon getIcon() {
return getValue(database, id -> getService(id, getSupportedServices()).getIcon());
}
private <T> T getValue(String s, Transform<String, T> t) {
try {
return s == null || s.isEmpty() ? null : t.transform(s);

View File

@ -688,7 +688,7 @@ public class RenamePanel extends JComponent {
private Preset preset;
public ApplyPresetAction(Preset preset) {
super(preset.getName(), preset.getDatasource().getIcon(), preset::getAutoCompleteMatcher);
super(preset.getName(), preset.getIcon(), preset::getAutoCompleteMatcher);
this.preset = preset;
}