Skip to content

Commit

Permalink
Fix #3994 Duplicate unmodifiable list for sorting (#3996)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-kolb authored Apr 29, 2018
1 parent f703f3e commit 3c1336d
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@
import org.slf4j.LoggerFactory;

public class ExportToClipboardAction extends AbstractWorker {

private static final Logger LOGGER = LoggerFactory.getLogger(ExportToClipboardAction.class);

private final JabRefFrame frame;

/**
* written by run() and read by update()
*/
// written by run() and read by update()
private String message;


public ExportToClipboardAction(JabRefFrame frame) {
this.frame = Objects.requireNonNull(frame);
}
Expand All @@ -55,9 +51,8 @@ public void run() {
return;
}

List<Exporter> exporters = Globals.exportFactory.getExporters();
exporters.sort(Comparator.comparing(Exporter::getDisplayName));
List<String> exportFormatDisplayNames = exporters.stream().map(Exporter::getDisplayName).collect(Collectors.toList());
List<Exporter> sortedExporters = Globals.exportFactory.getExporters().stream().sorted(Comparator.comparing(Exporter::getDisplayName)).collect(Collectors.toList());
List<String> exportFormatDisplayNames = sortedExporters.stream().map(Exporter::getDisplayName).collect(Collectors.toList());

JList<String> list = new JList<>(exportFormatDisplayNames.toArray(new String[exportFormatDisplayNames.size()]));
list.setBorder(BorderFactory.createEtchedBorder());
Expand All @@ -72,7 +67,7 @@ public void run() {
return;
}

Exporter exporter = exporters.get(list.getSelectedIndex());
Exporter exporter = sortedExporters.get(list.getSelectedIndex());

// Set the global variable for this database's file directory before exporting,
// so formatters can resolve linked files correctly.
Expand Down

0 comments on commit 3c1336d

Please sign in to comment.