1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-16 14:25:02 -05:00

Preserve format if type didn't change

This commit is contained in:
Reinhard Pointner 2016-04-06 14:48:03 +00:00
parent 9e33199776
commit 28ee8b5e30

View File

@ -69,7 +69,7 @@ public class ListPanel extends JComponent {
list.getRemoveAction().setEnabled(true); 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<ListItem> exportHandler = new FileBotListExportHandler<ListItem>(list, (item, out) -> out.println(item.getFormattedValue())); FileBotListExportHandler<ListItem> exportHandler = new FileBotListExportHandler<ListItem>(list, (item, out) -> out.println(item.getFormattedValue()));
list.setExportHandler(exportHandler); list.setExportHandler(exportHandler);
@ -188,6 +188,7 @@ public class ListPanel extends JComponent {
} }
private ExpressionFormat format; private ExpressionFormat format;
private String template;
public ListItem createItem(Object object, int i, int from, int to, List<?> context) { public ListItem createItem(Object object, int i, int from, int to, List<?> context) {
return new ListItem(new IndexedBindingBean(object, i, from, to, context), format); return new ListItem(new IndexedBindingBean(object, i, from, to, context), format);
@ -217,13 +218,20 @@ public class ListPanel extends JComponent {
List<Integer> context = IntStream.rangeClosed(from, to).boxed().collect(toList()); List<Integer> context = IntStream.rangeClosed(from, to).boxed().collect(toList());
List<ListItem> items = context.stream().map(it -> createItem(it, it.intValue(), from, to, context)).collect(toList()); List<ListItem> 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.setTitle("Sequence");
list.getListComponent().clearSelection(); list.getListComponent().clearSelection();
list.getModel().clear(); list.getModel().clear();
list.getModel().addAll(items); list.getModel().addAll(items);
} }
public void setFormatTemplate(String format) {
if (template != format) {
template = format;
editor.setText(format);
}
}
@Subscribe @Subscribe
public void handle(Transferable transferable) throws Exception { public void handle(Transferable transferable) throws Exception {
TransferablePolicy handler = list.getTransferablePolicy(); TransferablePolicy handler = list.getTransferablePolicy();