Skip to content

Commit 1c42777

Browse files
Siedlerchrkoppor
andauthored
Fix several aux group issues (#13861)
* Add sbom file and remove external libraries * add workflow * fix newline * address comments * remove import * refine * Update .github/workflows/sbom-pr.yml Co-authored-by: Oliver Kopp <[email protected]> * address comments * address comments * Fix latex file directory issues Fixes username and host logic and fixes a relativize file Open aux files dir chooser at last opened dir * Pass user and host down to texgroup * Pass user and host down to texgroup * fix mocks * revert relative * reenable * changelog * fix tests * to absolute path * roundtrip for absolute/relative * fix test * Update CHANGELOG.md Co-authored-by: Oliver Kopp <[email protected]> * fix style --------- Co-authored-by: Oliver Kopp <[email protected]>
1 parent 5fa313d commit 1c42777

File tree

27 files changed

+114
-214
lines changed

27 files changed

+114
-214
lines changed

.github/workflows/sbom-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
Generated via Gradle task `cyclonedxBom` using the org.cyclonedx.bom plugin configured in the build.
5959
branch: chore/update-sbom
6060
delete-branch: true
61-
labels: "dev: dependencies""
61+
labels: "dev: dependencies"
6262
add-paths: |
6363
bom.json
6464
bom.xml

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
133133
- We removed unnecessary spacing and margin in the AutomaticFieldEditor. [#13792](https://github.com/JabRef/jabref/pull/13792)
134134
- We fixed an issue where global search auto-completion only worked after switching tabs. [#11428](https://github.com/JabRef/jabref/issues/11428)
135135
- We fixed an issue where hierarchical keywords would only show the parent keyword in the entry editor. [#11390](https://github.com/JabRef/jabref/issues/11390)
136+
- We fixed an issue where some file choosers regarding LaTeX-aux files did not open in the directory of the last selected file. [#13861](https://github.com/JabRef/jabref/pull/13861)
137+
- We fixed an issue where the LaTeX file directory was not stored correctly in combination with the usage of groups from aux files. [#8344](https://github.com/JabRef/jabref/issues/8344)
136138

137139
### Removed
138140

jabgui/src/main/java/org/jabref/gui/auximport/FromAuxDialogViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public void browse() {
8282
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
8383
.addExtensionFilter(StandardFileType.AUX)
8484
.withDefaultExtension(StandardFileType.AUX)
85-
.withInitialDirectory(preferences.getFilePreferences().getWorkingDirectory()).build();
85+
.withInitialDirectory(auxFileProperty.get() == null ? preferences.getFilePreferences().getWorkingDirectory().toString() : auxFileProperty.get()).build();
8686
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(file -> auxFileProperty.setValue(file.toAbsolutePath().toString()));
8787
}
8888

jabgui/src/main/java/org/jabref/gui/entryeditor/LatexCitationsTabViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void setLatexDirectory() {
132132
.withInitialDirectory(directory.get()).build();
133133

134134
dialogService.showDirectorySelectionDialog(directoryDialogConfiguration).ifPresent(selectedDirectory ->
135-
currentDatabaseContext.getMetaData().setLatexFileDirectory(preferences.getFilePreferences().getUserAndHost(), selectedDirectory.toAbsolutePath()));
135+
currentDatabaseContext.getMetaData().setLatexFileDirectory(preferences.getFilePreferences().getUserAndHost(), selectedDirectory.toAbsolutePath().toString()));
136136

137137
checkAndUpdateDirectory();
138138
}

jabgui/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ private void setupValidation() {
231231
return false;
232232
}
233233
return FileUtil.getFileExtension(input)
234-
.map("aux"::equalsIgnoreCase)
235-
.orElse(false);
234+
.map("aux"::equalsIgnoreCase)
235+
.orElse(false);
236236
}
237237
},
238238
ValidationMessage.error(Localization.lang("Please provide a valid aux file.")));
@@ -373,7 +373,9 @@ public AbstractGroup resultConverter(ButtonType button) {
373373
Path.of(texGroupFilePathProperty.getValue().trim()),
374374
new DefaultAuxParser(new BibDatabase()),
375375
fileUpdateMonitor,
376-
currentDatabase.getMetaData());
376+
currentDatabase.getMetaData(),
377+
preferences.getFilePreferences().getUserAndHost()
378+
);
377379
}
378380

379381
if (resultingGroup != null) {
@@ -485,9 +487,10 @@ public void texGroupBrowse() {
485487
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
486488
.addExtensionFilter(StandardFileType.AUX)
487489
.withDefaultExtension(StandardFileType.AUX)
488-
.withInitialDirectory(currentDatabase.getMetaData()
489-
.getLatexFileDirectory(preferences.getFilePreferences().getUserAndHost())
490-
.orElse(FileUtil.getInitialDirectory(currentDatabase, preferences.getFilePreferences().getWorkingDirectory()))).build();
490+
.withInitialDirectory(texGroupFilePathProperty.getValue().isBlank() ?
491+
currentDatabase.getMetaData()
492+
.getLatexFileDirectory(preferences.getFilePreferences().getUserAndHost())
493+
.orElse(FileUtil.getInitialDirectory(currentDatabase, preferences.getFilePreferences().getWorkingDirectory())).toString() : texGroupFilePathProperty.get()).build();
491494
dialogService.showFileOpenDialog(fileDialogConfiguration)
492495
.ifPresent(file -> texGroupFilePathProperty.setValue(
493496
FileUtil.relativize(file.toAbsolutePath(), getFileDirectoriesAsPaths()).toString()

jabgui/src/main/java/org/jabref/gui/libraryproperties/general/GeneralPropertiesViewModel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void storeSettings() {
113113
if (latexFileDirectory.isEmpty()) {
114114
newMetaData.clearLatexFileDirectory(preferences.getFilePreferences().getUserAndHost());
115115
} else if (laTexFileDirectoryStatus().isValid()) {
116-
newMetaData.setLatexFileDirectory(preferences.getFilePreferences().getUserAndHost(), Path.of(latexFileDirectory));
116+
newMetaData.setLatexFileDirectory(preferences.getFilePreferences().getUserAndHost(), latexFileDirectory);
117117
}
118118

119119
databaseContext.setMetaData(newMetaData);
@@ -271,7 +271,8 @@ public void togglePath(StringProperty fileDirectory) {
271271
if (!currPath.isAbsolute()) {
272272
newPath = parentPath.resolve(fileDirectory.get()).toAbsolutePath().toString();
273273
} else if (currPath.isAbsolute()) {
274-
newPath = parentPath.relativize(currPath).toString();
274+
Path rel = parentPath.relativize(currPath);
275+
newPath = rel.toString().isEmpty() ? "." : rel.toString();
275276
} else {
276277
// case: convert to relative path and currPath is relative
277278
return;

jabgui/src/main/java/org/jabref/gui/shared/SharedDatabaseUIManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ private BibDatabaseContext getBibDatabaseContextForSharedDatabase() {
221221
preferences.getBibEntryPreferences().getKeywordSeparator(),
222222
preferences.getFieldPreferences(),
223223
preferences.getCitationKeyPatternPreferences().getKeyPatterns(),
224-
fileUpdateMonitor);
224+
fileUpdateMonitor,
225+
preferences.getFilePreferences().getUserAndHost());
225226
bibDatabaseContext.convertToSharedDatabase(synchronizer);
226227
return bibDatabaseContext;
227228
}

jablib/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public static Map<String, String> getSerializedStringMap(MetaData metaData,
5757
metaData.getUserFileDirectories().forEach((user, path) -> stringyMetaData
5858
.put(MetaData.FILE_DIRECTORY + '-' + user, List.of(path.trim())));
5959
metaData.getLatexFileDirectories().forEach((user, path) -> stringyMetaData
60-
.put(MetaData.FILE_DIRECTORY_LATEX + '-' + user, List.of(path.toString().trim())));
60+
.put(MetaData.FILE_DIRECTORY_LATEX + '-' + user, List.of(path.trim())));
6161
metaData.getVersionDBStructure().ifPresent(
6262
versionDBStructure -> stringyMetaData.put(MetaData.VERSION_DB_STRUCT, List.of(versionDBStructure.trim())));
6363
metaData.getBlgFilePaths().forEach((user, path) -> stringyMetaData.put(MetaData.BLG_FILE_PATH + "-" + user, List.of(path.toString().trim())));

jablib/src/main/java/org/jabref/logic/importer/ImportFormatPreferences.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jabref.logic.importer;
22

3+
import org.jabref.logic.FilePreferences;
34
import org.jabref.logic.bibtex.FieldPreferences;
45
import org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences;
56
import org.jabref.logic.importer.util.GrobidPreferences;
@@ -13,5 +14,6 @@ public record ImportFormatPreferences(
1314
FieldPreferences fieldPreferences,
1415
XmpPreferences xmpPreferences,
1516
DOIPreferences doiPreferences,
16-
GrobidPreferences grobidPreferences) {
17+
GrobidPreferences grobidPreferences,
18+
FilePreferences filePreferences) {
1719
}

jablib/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ private ParserResult parseFileContent() throws IOException {
273273
try {
274274
MetaData metaData = metaDataParser.parse(
275275
meta,
276-
importFormatPreferences.bibEntryPreferences().getKeywordSeparator());
276+
importFormatPreferences.bibEntryPreferences().getKeywordSeparator(),
277+
importFormatPreferences.filePreferences().getUserAndHost());
277278
if (bibDeskGroupTreeNode != null) {
278279
metaData.getGroups().ifPresentOrElse(existingGroupTree -> {
279280
String existingGroups = meta.get(MetaData.GROUPSTREE);

0 commit comments

Comments
 (0)