Skip to content

Commit

Permalink
Merge branch 'main' into refine-bibentrytypes
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored Mar 14, 2024
2 parents 38dc44f + 2207b79 commit 9b6c050
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 33 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We changed the duplicate handling in the Import entries dialog. Potential duplicate entries are marked with an icon and importing will now trigger the merge dialog [#10914](https://github.com/JabRef/jabref/pull/10914)
- We made the command "Push to TexShop" more robust to allow cite commands with a character before the first slash. [forum#2699](https://discourse.jabref.org/t/push-to-texshop-mac/2699/17?u=siedlerchr)
- We only show the notification "Saving library..." if the library contains more than 2000 entries. [#9803](https://github.com/JabRef/jabref/issues/9803)
- JabRef now keeps previous log files upon start. [#11023](https://github.com/JabRef/jabref/pull/11023)
- We enhanced the dialog for adding new fields in the content selector with a selection box containing a list of standard fields. [#10912](https://github.com/JabRef/jabref/pull/10912)
- We store the citation relations in an LRU cache to avoid bloating the memory and out-of-memory exceptions. [#10958](https://github.com/JabRef/jabref/issues/10958)
- Keywords filed are now displayed as tags. [#10910](https://github.com/JabRef/jabref/pull/10910)
Expand All @@ -53,6 +54,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We fixed an issue where the preview panel showing the wrong entry (an entry that is not selected in the entry table). [#9172](https://github.com/JabRef/jabref/issues/9172)
- We fixed an issue where HTML-reserved characters like '&' and '<', in addition to HTML entities like '&amp;' were not rendered correctly in entry preview. [#10677](https://github.com/JabRef/jabref/issues/10677)
- The last page of a PDF is now indexed by the full text search. [#10193](https://github.com/JabRef/jabref/issues/10193)
- The entry editor respects the configured custom tabs when showing "Other fields". [#11012](https://github.com/JabRef/jabref/pull/11012)
- The default owner of an entry can be changed again. [#10924](https://github.com/JabRef/jabref/issues/10924)
- We fixed an issue where the duplicate check did not take umlauts or other LaTeX-encoded characters into account. [#10744](https://github.com/JabRef/jabref/pull/10744)
- We fixed the colors of the icon on hover for unset special fields. [#10431](https://github.com/JabRef/jabref/issues/10431)
Expand Down
2 changes: 1 addition & 1 deletion config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Style-checks are done for each pull request and installing this code style confi
# Eclipse:

The Eclipse code formatter style is stored in the `eclipse.gradle` file and gets imported automatically.
In case the formatter style needs to be adapted, configure it and export in in eclipse.
In case the formatter style needs to be adapted, configure it and export in eclipse.

1. Right click on the eclipse project "JabRef"
2. Select "Export > General > Preferences"
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/org/jabref/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
import java.util.List;
import java.util.Map;

import org.jabref.architecture.AllowedToUseStandardStreams;
import org.jabref.cli.ArgumentProcessor;
import org.jabref.cli.JabRefCLI;
import org.jabref.gui.Globals;
import org.jabref.gui.JabRefGUI;
import org.jabref.logic.UiCommand;
import org.jabref.logic.journals.JournalAbbreviationLoader;
import org.jabref.logic.journals.predatory.PredatoryJournalListLoader;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.ProxyAuthenticator;
import org.jabref.logic.net.ProxyPreferences;
import org.jabref.logic.net.ProxyRegisterer;
Expand Down Expand Up @@ -48,7 +46,6 @@
* - Handle the command line arguments
* - Start the JavaFX application (if not in cli mode)
*/
@AllowedToUseStandardStreams("Direct output to the user")
public class Launcher {
private static Logger LOGGER;
private static boolean isDebugEnabled;
Expand Down Expand Up @@ -140,11 +137,14 @@ private static void addLogToDisk() {
// The "Shared File Writer" is explained at
// https://tinylog.org/v2/configuration/#shared-file-writer
Map<String, String> configuration = Map.of(
"writerFile", "shared file",
"writerFile.level", isDebugEnabled ? "debug" : "info",
"level", isDebugEnabled ? "debug" : "info",
"writerFile.file", directory.resolve("log.txt").toString(),
"writerFile.charset", "UTF-8");
"writerFile", "rolling file",
"writerFile.level", isDebugEnabled ? "debug" : "info",
// We need to manually join the path, because ".resolve" does not work on Windows, because ":" is not allowed in file names on Windows
"writerFile.file", directory + File.separator + "log_{date:yyyy-MM-dd_HH-mm-ss}.txt",
"writerFile.charset", "UTF-8",
"writerFile.policies", "startup",
"writerFile.backups", "30");

configuration.forEach(Configuration::set);
initializeLogger();
Expand All @@ -169,9 +169,8 @@ private static boolean handleMultipleAppInstances(String[] args, RemotePreferenc
LOGGER.debug("Passing arguments passed on to running JabRef...");
if (remoteClient.sendCommandLineArguments(args)) {
// So we assume it's all taken care of, and quit.
LOGGER.debug("Arguments passed on to running JabRef instance.");
// Used for script-use output etc. to the user
System.out.println(Localization.lang("Arguments passed on to running JabRef instance. Shutting down."));
// Output to both to the log and the screen. Therefore, we do not have an additional System.out.println.
LOGGER.info("Arguments passed on to running JabRef instance. Shutting down.");
return false;
} else {
LOGGER.warn("Could not communicate with other running JabRef instance.");
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/org/jabref/gui/entryeditor/OtherFieldsTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.BibEntryType;
import org.jabref.model.entry.BibEntryTypesManager;
import org.jabref.model.entry.field.BibField;
import org.jabref.model.entry.field.Field;
import org.jabref.model.entry.field.InternalField;
import org.jabref.model.entry.field.StandardField;
Expand All @@ -36,7 +35,7 @@
public class OtherFieldsTab extends FieldsEditorTab {

public static final String NAME = "Other fields";
private final List<Field> customTabFieldNames;
private final List<Field> customTabsFieldNames;
private final BibEntryTypesManager entryTypesManager;

public OtherFieldsTab(BibDatabaseContext databaseContext,
Expand All @@ -63,8 +62,8 @@ public OtherFieldsTab(BibDatabaseContext databaseContext,
indexingTaskManager);

this.entryTypesManager = entryTypesManager;
this.customTabFieldNames = new ArrayList<>();
preferences.getEntryEditorPreferences().getDefaultEntryEditorTabs().values().forEach(customTabFieldNames::addAll);
this.customTabsFieldNames = new ArrayList<>();
preferences.getEntryEditorPreferences().getEntryEditorTabs().values().forEach(customTabsFieldNames::addAll);

setText(Localization.lang("Other fields"));
setTooltip(new Tooltip(Localization.lang("Show remaining fields")));
Expand All @@ -76,15 +75,21 @@ protected SequencedSet<Field> determineFieldsToShow(BibEntry entry) {
BibDatabaseMode mode = databaseContext.getMode();
Optional<BibEntryType> entryType = entryTypesManager.enrich(entry.getType(), mode);
if (entryType.isPresent()) {
// Get all required and optional fields configured for the entry
Set<Field> allKnownFields = entryType.get().getAllFields();
// Remove all fields being required or optional
SequencedSet<Field> otherFields = entry.getFields().stream()
.filter(field -> !allKnownFields.contains(field) &&
!(field.equals(StandardField.COMMENT) || field instanceof UserSpecificCommentField))
.filter(field -> !allKnownFields.contains(field))
.collect(Collectors.toCollection(LinkedHashSet::new));
otherFields.removeAll(entryType.get().getDeprecatedFields(mode));
otherFields.removeAll(entryType.get().getOptionalFields().stream().map(BibField::field).toList());
// The key field is in the required tab, but has a special treatment
otherFields.remove(InternalField.KEY_FIELD);
customTabFieldNames.forEach(otherFields::remove);
// Remove all fields contained in JabRef's tab "Deprecated"
otherFields.removeAll(entryType.get().getDeprecatedFields(mode));
// Remove all fields contained in the custom tabs
customTabsFieldNames.forEach(otherFields::remove);
// Remove all user-comment fields (tab org.jabref.gui.entryeditor.CommentsTab)
otherFields.removeIf(field -> field.equals(StandardField.COMMENT));
otherFields.removeIf(field -> field instanceof UserSpecificCommentField);
return otherFields;
} else {
// Entry type unknown -> treat all fields as required (thus no other fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void doPostCleanup(BibEntry entry) {
FieldFormatterCleanups cleanups = new FieldFormatterCleanups(true,
List.of(
new FieldFormatterCleanup(StandardField.TIMESTAMP, new ClearFormatter()),
// unescape the the contents of the URL field, e.g., some\_url\_part becomes some_url_part
// unescape the contents of the URL field, e.g., some\_url\_part becomes some_url_part
new FieldFormatterCleanup(StandardField.URL, new LayoutFormatterBasedFormatter(new RemoveLatexCommandsFormatter()))
));
cleanups.applySaveActions(entry);
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/org/jabref/migrations/PreferencesMigrations.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import javafx.scene.control.TableColumn;

import org.jabref.gui.entryeditor.CommentsTab;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.maintable.ColumnPreferences;
import org.jabref.gui.maintable.MainTableColumnModel;
import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern;
Expand Down Expand Up @@ -57,13 +59,14 @@ public static void runMigrations(JabRefPreferences preferences, BibEntryTypesMan
addCrossRefRelatedFieldsForAutoComplete(preferences);
upgradePreviewStyle(preferences);
// changeColumnVariableNamesFor51 needs to be run before upgradeColumnPre50Preferences to ensure
// backwardcompatibility, as it copies the old values to new variable names and keeps th old sored with the old
// backward compatibility, as it copies the old values to new variable names and keeps th old sored with the old
// variable names. However, the variables from 5.0 need to be copied to the new variable name too.
changeColumnVariableNamesFor51(preferences);
upgradeColumnPreferences(preferences);
restoreVariablesForBackwardCompatibility(preferences);
upgradeCleanups(preferences);
moveApiKeysToKeyring(preferences);
removeCommentsFromCustomEditorTabs(preferences);
}

/**
Expand Down Expand Up @@ -545,4 +548,12 @@ static void moveApiKeysToKeyring(JabRefPreferences preferences) {
}
}
}

/**
* The tab "Comments" is hard coded using {@link CommentsTab} since v5.10 (and thus hard-wired in {@link EntryEditor#createTabs()}.
* Thus, the configuration ih the preferences is obsolete
*/
static void removeCommentsFromCustomEditorTabs(JabRefPreferences preferences) {
preferences.getEntryEditorPreferences().getEntryEditorTabs().remove("Comments");
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ public Optional<String> getFieldOrAlias(Field field) {
}

/**
* Return the LaTeX-free contents of the given field or its alias an an Optional
* Return the LaTeX-free contents of the given field or its alias an Optional
* <p>
* For details see also {@link #getFieldOrAlias(Field)}
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/model/entry/field/OrFields.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* <br>
* The class OrFields is used to model "year/date" in this case.
* <p>
* Example is that a BibEntry requires either an author or an editor, but both can be be present.
* Example is that a BibEntry requires either an author or an editor, but both can be present.
*/
public class OrFields implements Comparable<OrFields> {

Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.SequencedMap;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
Expand Down Expand Up @@ -835,10 +836,6 @@ public void setLanguageDependentDefaultValues() {
defaults.put(CUSTOM_TAB_FIELDS + "_def1", StandardField.ABSTRACT.getName());
defaults.put(CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract"));

// Entry editor tab 2: Comments Field - used for research comments, etc.
defaults.put(CUSTOM_TAB_FIELDS + "_def2", StandardField.COMMENT.getName());
defaults.put(CUSTOM_TAB_NAME + "_def2", Localization.lang("Comments"));

defaults.put(EMAIL_SUBJECT, Localization.lang("References"));
}

Expand Down Expand Up @@ -1508,7 +1505,7 @@ private Map<String, Set<Field>> getEntryEditorTabs() {
List<String> tabFields = getSeries(CUSTOM_TAB_FIELDS);

if (tabNames.isEmpty() || (tabNames.size() != tabFields.size())) {
// Nothing set, so we use the default values
// Nothing set (or wrong configuration), then we use default values
tabNames = getSeries(CUSTOM_TAB_NAME + "_def");
tabFields = getSeries(CUSTOM_TAB_FIELDS + "_def");
}
Expand Down Expand Up @@ -1543,8 +1540,8 @@ private void storeEntryEditorTabs(Map<String, Set<Field>> customTabs) {
getEntryEditorTabs();
}

private Map<String, Set<Field>> getDefaultEntryEditorTabs() {
Map<String, Set<Field>> customTabsMap = new LinkedHashMap<>();
private SequencedMap<String, Set<Field>> getDefaultEntryEditorTabs() {
SequencedMap<String, Set<Field>> customTabsMap = new LinkedHashMap<>();

int defNumber = 0;
while (true) {
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ Application\ to\ push\ entries\ to=Application to push entries to

Apply=Apply

Arguments\ passed\ on\ to\ running\ JabRef\ instance.\ Shutting\ down.=Arguments passed on to running JabRef instance. Shutting down.

Assign\ the\ original\ group's\ entries\ to\ this\ group?=Assign the original group's entries to this group?

Assigned\ %0\ entries\ to\ group\ "%1".=Assigned %0 entries to group "%1".
Expand Down

0 comments on commit 9b6c050

Please sign in to comment.