diff --git a/source/net/filebot/ui/list/ListPanel.java b/source/net/filebot/ui/list/ListPanel.java index eb3de48e..0b2d9db5 100644 --- a/source/net/filebot/ui/list/ListPanel.java +++ b/source/net/filebot/ui/list/ListPanel.java @@ -69,7 +69,7 @@ public class ListPanel extends JComponent { list.getRemoveAction().setEnabled(true); - list.setTransferablePolicy(new FileListTransferablePolicy(list::setTitle, editor::setText, this::createItemSequence)); + list.setTransferablePolicy(new FileListTransferablePolicy(list::setTitle, this::setFormatTemplate, this::createItemSequence)); FileBotListExportHandler exportHandler = new FileBotListExportHandler(list, (item, out) -> out.println(item.getFormattedValue())); list.setExportHandler(exportHandler); @@ -188,6 +188,7 @@ public class ListPanel extends JComponent { } private ExpressionFormat format; + private String template; public ListItem createItem(Object object, int i, int from, int to, List context) { return new ListItem(new IndexedBindingBean(object, i, from, to, context), format); @@ -217,13 +218,20 @@ public class ListPanel extends JComponent { List context = IntStream.rangeClosed(from, to).boxed().collect(toList()); List items = context.stream().map(it -> createItem(it, it.intValue(), from, to, context)).collect(toList()); - editor.setText(DEFAULT_SEQUENCE_FORMAT); + setFormatTemplate(DEFAULT_SEQUENCE_FORMAT); list.setTitle("Sequence"); list.getListComponent().clearSelection(); list.getModel().clear(); list.getModel().addAll(items); } + public void setFormatTemplate(String format) { + if (template != format) { + template = format; + editor.setText(format); + } + } + @Subscribe public void handle(Transferable transferable) throws Exception { TransferablePolicy handler = list.getTransferablePolicy();