Skip to content

Commit

Permalink
[Copy] Include string constants in copy (#11)
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Blomqvist <[email protected]>
  • Loading branch information
andersblomqvist authored Mar 1, 2024
1 parent 7317c2e commit a0d6f72
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import org.jabref.model.database.event.EntriesAddedEvent;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.BibtexString;
import org.jabref.model.util.FileUpdateMonitor;
import org.jabref.preferences.PreferencesService;

Expand Down Expand Up @@ -257,8 +258,14 @@ public void copy() {
List<BibEntry> selectedEntries = getSelectedEntries();

if (!selectedEntries.isEmpty()) {
List<BibtexString> stringConstants = getStringValues();

try {
clipBoardManager.setContent(selectedEntries, entryTypesManager);
if (!stringConstants.isEmpty()) {
clipBoardManager.setContent(selectedEntries, entryTypesManager, stringConstants);
} else {
clipBoardManager.setContent(selectedEntries, entryTypesManager);
}
dialogService.notify(Localization.lang("Copied %0 entry(ies)", selectedEntries.size()));
} catch (IOException e) {
LOGGER.error("Error while copying selected entries to clipboard.", e);
Expand Down Expand Up @@ -489,4 +496,11 @@ private Optional<BibEntryTableViewModel> findEntry(BibEntry entry) {
.filter(viewModel -> viewModel.getEntry().equals(entry))
.findFirst();
}

private List<BibtexString> getStringValues() {
return database.getDatabase()
.getStringValues()
.stream()
.toList();
}
}

0 comments on commit a0d6f72

Please sign in to comment.