* incomplete matches do not get a context
This commit is contained in:
parent
8c0ce2ed21
commit
333510b7e2
|
@ -1,5 +1,6 @@
|
|||
package net.filebot.ui.rename;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
@ -134,7 +135,13 @@ public class RenameModel extends MatchModel<Object, File> {
|
|||
return defaultFormatter;
|
||||
}
|
||||
|
||||
public Map<File, Object> getMatchContext() {
|
||||
public Map<File, Object> getMatchContext(Match<Object, File> match) {
|
||||
// incomplete matches have no context
|
||||
if (match.getValue() == null || match.getCandidate() == null) {
|
||||
return emptyMap();
|
||||
}
|
||||
|
||||
// provide matches context on demand
|
||||
return new AbstractMap<File, Object>() {
|
||||
|
||||
@Override
|
||||
|
@ -207,7 +214,7 @@ public class RenameModel extends MatchModel<Object, File> {
|
|||
Match<Object, File> match = getMatch(index);
|
||||
|
||||
// create new future
|
||||
final FormattedFuture future = new FormattedFuture(match, getFormatter(match), getMatchContext());
|
||||
final FormattedFuture future = new FormattedFuture(match, getFormatter(match), getMatchContext(match));
|
||||
|
||||
// update data
|
||||
if (type == ListEvent.INSERT) {
|
||||
|
@ -254,7 +261,8 @@ public class RenameModel extends MatchModel<Object, File> {
|
|||
|
||||
for (int i = 0; i < size(); i++) {
|
||||
FormattedFuture obsolete = futures.get(i);
|
||||
FormattedFuture future = new FormattedFuture(obsolete.getMatch(), getFormatter(obsolete.getMatch()), getMatchContext());
|
||||
Match<Object, File> match = obsolete.getMatch();
|
||||
FormattedFuture future = new FormattedFuture(match, getFormatter(match), getMatchContext(match));
|
||||
|
||||
// replace and cancel old future
|
||||
cancel(futures.set(i, future));
|
||||
|
|
|
@ -292,7 +292,7 @@ public class RenamePanel extends JComponent {
|
|||
JList list = (JList) evt.getSource();
|
||||
if (list.getSelectedIndex() >= 0) {
|
||||
Match<Object, File> match = renameModel.getMatch(list.getSelectedIndex());
|
||||
Map<File, Object> context = renameModel.getMatchContext();
|
||||
Map<File, Object> context = renameModel.getMatchContext(match);
|
||||
|
||||
MediaBindingBean sample = new MediaBindingBean(match.getValue(), match.getCandidate(), context);
|
||||
showFormatEditor(sample);
|
||||
|
|
Loading…
Reference in New Issue