Skip to content

Commit e66f5be

Browse files
DominikVoigtkoppor
andauthored
Add date fields (#7334)
Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
1 parent 727602b commit e66f5be

36 files changed

+529
-257
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
1515
- We added the extension support and the external application support (For Texshow, Texmaker and LyX) to the flatpak [#7248](https://github.com/JabRef/jabref/pull/7248)
1616
- We added some symbols and keybindings to the context menu in the entry editor. [#7268](https://github.com/JabRef/jabref/pull/7268)
1717
- We added keybindings for setting and clearing the read status. [#7264](https://github.com/JabRef/jabref/issues/7264)
18+
- We added two new fields to track the creation and most recent modification date and time for each entry. [koppor#130](https://github.com/koppor/jabref/issues/130)
1819

1920
### Changed
2021

22+
- The content of the field `timestamp` is migrated to `creationdate`. In case one configured "udpate timestampe", it is migrated to `modificationdate`. [koppor#130](https://github.com/koppor/jabref/issues/130)
23+
2124
### Fixed
2225

2326
- We fixed an issue where the "Normalize page numbers" formatter did not replace en-dashes or em-dashes with a hyphen-minus sign. [#7239](https://github.com/JabRef/jabref/issues/7239)

src/main/java/org/jabref/cli/ArgumentProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ private static Optional<ParserResult> importFile(Path file, String importFormat)
144144
// * means "guess the format":
145145
System.out.println(Localization.lang("Importing in unknown format") + ": " + file);
146146

147-
ImportFormatReader.UnknownFormatImport importResult = Globals.IMPORT_FORMAT_READER.importUnknownFormat(file, new DummyFileUpdateMonitor());
147+
ImportFormatReader.UnknownFormatImport importResult = Globals.IMPORT_FORMAT_READER.importUnknownFormat(file, Globals.prefs.getTimestampPreferences(), new DummyFileUpdateMonitor());
148148

149149
System.out.println(Localization.lang("Format used") + ": " + importResult.format);
150150
return Optional.of(importResult.parserResult);
@@ -321,7 +321,7 @@ private List<ParserResult> importAndOpenFiles() {
321321
boolean bibExtension = aLeftOver.toLowerCase(Locale.ENGLISH).endsWith("bib");
322322
ParserResult pr = new ParserResult();
323323
if (bibExtension) {
324-
pr = OpenDatabase.loadDatabase(aLeftOver, Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());
324+
pr = OpenDatabase.loadDatabase(aLeftOver, Globals.prefs.getImportFormatPreferences(), Globals.prefs.getTimestampPreferences(), Globals.getFileUpdateMonitor());
325325
}
326326

327327
if (!bibExtension || (pr.isEmpty())) {

src/main/java/org/jabref/gui/JabRefGUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ private void openLastEditedDatabases() {
275275
}
276276

277277
ParserResult parsedDatabase = OpenDatabase.loadDatabase(fileName,
278-
Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());
278+
Globals.prefs.getImportFormatPreferences(), Globals.prefs.getTimestampPreferences(), Globals.getFileUpdateMonitor());
279279

280280
if (parsedDatabase.isEmpty()) {
281281
LOGGER.error(Localization.lang("Error opening file") + " '" + dbFile.getPath() + "'");

src/main/java/org/jabref/gui/StartLiteratureReviewAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void execute() {
5858
}
5959
final Crawler crawler;
6060
try {
61-
crawler = new Crawler(studyDefinitionFile.get(), new GitHandler(studyDefinitionFile.get().getParent()), fileUpdateMonitor, importFormatPreferneces, savePreferences, new BibEntryTypesManager());
61+
crawler = new Crawler(studyDefinitionFile.get(), new GitHandler(studyDefinitionFile.get().getParent()), fileUpdateMonitor, importFormatPreferneces, savePreferences, preferencesService.getTimestampPreferences(), new BibEntryTypesManager());
6262
} catch (IOException | ParseException | GitAPIException e) {
6363
LOGGER.error("Error during reading of study definition file.", e);
6464
dialogService.showErrorDialogAndWait(Localization.lang("Error during reading of study definition file."), e);

src/main/java/org/jabref/gui/UpdateTimestampListener.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jabref.gui;
22

33
import org.jabref.model.entry.event.EntryChangedEvent;
4+
import org.jabref.model.entry.field.StandardField;
45
import org.jabref.preferences.PreferencesService;
56

67
import com.google.common.eventbus.Subscribe;
@@ -17,8 +18,8 @@ class UpdateTimestampListener {
1718

1819
@Subscribe
1920
public void listen(EntryChangedEvent event) {
20-
if (preferencesService.getTimestampPreferences().shouldIncludeTimestamps()) {
21-
event.getBibEntry().setField(preferencesService.getTimestampPreferences().getTimestampField(),
21+
if (preferencesService.getTimestampPreferences().shouldAddModificationDate()) {
22+
event.getBibEntry().setField(StandardField.MODIFICATIONDATE,
2223
preferencesService.getTimestampPreferences().now());
2324
}
2425
}

src/main/java/org/jabref/gui/collab/ChangeScanner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public List<DatabaseChangeViewModel> scanForChanges() {
4040
// Parse the modified file
4141
// Important: apply all post-load actions
4242
ImportFormatPreferences importFormatPreferences = preferencesService.getImportFormatPreferences();
43-
ParserResult result = OpenDatabase.loadDatabase(database.getDatabasePath().get(), importFormatPreferences, new DummyFileUpdateMonitor());
43+
ParserResult result = OpenDatabase.loadDatabase(database.getDatabasePath().get(), importFormatPreferences, preferencesService.getTimestampPreferences(), new DummyFileUpdateMonitor());
4444
BibDatabaseContext databaseOnDisk = result.getDatabaseContext();
4545

4646
// Start looking at changes.

src/main/java/org/jabref/gui/externalfiles/ImportHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public ImportHandler(DialogService dialogService,
5454
this.stateManager = stateManager;
5555

5656
this.linker = new ExternalFilesEntryLinker(externalFileTypes, preferencesService.getFilePreferences(), database);
57-
this.contentImporter = new ExternalFilesContentImporter(preferencesService.getImportFormatPreferences());
57+
this.contentImporter = new ExternalFilesContentImporter(preferencesService.getImportFormatPreferences(), preferencesService.getTimestampPreferences());
5858
this.undoManager = undoManager;
5959
}
6060

src/main/java/org/jabref/gui/importer/ImportAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private List<ImportFormatReader.UnknownFormatImport> doImport(List<Path> files)
110110
// Unknown format:
111111
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().notify(Localization.lang("Importing in unknown format") + "..."));
112112
// This import method never throws an IOException:
113-
imports.add(Globals.IMPORT_FORMAT_READER.importUnknownFormat(filename, Globals.getFileUpdateMonitor()));
113+
imports.add(Globals.IMPORT_FORMAT_READER.importUnknownFormat(filename, prefs.getTimestampPreferences(), Globals.getFileUpdateMonitor()));
114114
} else {
115115
DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().notify(Localization.lang("Importing in %0 format", importer.get().getName()) + "..."));
116116
// Specific importer:

src/main/java/org/jabref/gui/importer/actions/OpenDatabaseAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private ParserResult loadDatabase(Path file) throws Exception {
184184
}
185185

186186
ParserResult result = OpenDatabase.loadDatabase(fileToLoad.toString(),
187-
Globals.prefs.getImportFormatPreferences(), Globals.getFileUpdateMonitor());
187+
Globals.prefs.getImportFormatPreferences(), Globals.prefs.getTimestampPreferences(), Globals.getFileUpdateMonitor());
188188

189189
if (result.getDatabase().isShared()) {
190190
try {

src/main/java/org/jabref/gui/preferences/GeneralTab.fxml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,6 @@
5656
</HBox>
5757

5858
<Label styleClass="sectionHeader" text="%Time stamp"/>
59-
<CheckBox fx:id="markTimestamp" text="%Mark new entries with addition date"/>
60-
<HBox spacing="10.0">
61-
<GridPane hgap="10.0" vgap="4.0">
62-
<columnConstraints>
63-
<ColumnConstraints hgrow="SOMETIMES"/>
64-
<ColumnConstraints hgrow="SOMETIMES"/>
65-
<ColumnConstraints hgrow="SOMETIMES"/>
66-
<ColumnConstraints hgrow="SOMETIMES"/>
67-
</columnConstraints>
68-
<rowConstraints>
69-
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
70-
<RowConstraints minHeight="10.0" vgrow="SOMETIMES"/>
71-
</rowConstraints>
72-
<Label fx:id="markTimeStampFormatLabel" text="%Date format"/>
73-
<TextField fx:id="markTimeStampFormat" prefWidth="200.0" GridPane.columnIndex="1"/>
74-
<CheckBox fx:id="markTimeStampOverwrite" text="%Overwrite" GridPane.columnIndex="2">
75-
<tooltip>
76-
<Tooltip text="%If a pasted or imported entry already has the field set, overwrite."/>
77-
</tooltip>
78-
</CheckBox>
79-
<Button fx:id="markTimeStampHelp" prefWidth="20.0" GridPane.columnIndex="3"/>
80-
<Label fx:id="markTimeStampFieldNameLabel" text="%Field name" GridPane.rowIndex="1"/>
81-
<TextField fx:id="markTimeStampFieldName" prefWidth="200.0" GridPane.columnIndex="1"
82-
GridPane.rowIndex="1"/>
83-
</GridPane>
84-
</HBox>
85-
<CheckBox fx:id="updateTimeStamp" text="%Update timestamp on modification"/>
59+
<CheckBox fx:id="addCreationDate" text="%Add timestamp to new entries (field &quot;creationdate&quot;)"/>
60+
<CheckBox fx:id="addModificationDate" text="%Add timestamp to modified entries (field &quot;modificationdate&quot;)"/>
8661
</fx:root>

0 commit comments

Comments
 (0)