Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename General File Directory to Library-Specific File Directory #12037

Merged
merged 17 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6e15691
Change enum & localisation preferences from "General File Directory" …
tomeg09 Oct 15, 2024
4d200aa
change 'generalFileDirectory' to 'libraryFileDirectory' in codebase
tomeg09 Oct 15, 2024
fea698a
change 'generalFileDirectory' to 'libraryFileDirectory' in test code
tomeg09 Oct 15, 2024
1226465
Merge branch 'JabRef:main' into fix-naming
rl712 Oct 15, 2024
5e6540c
Merge branch 'JabRef:main' into fix-naming
rl712 Oct 17, 2024
83e116e
Merge branch 'JabRef:main' into fix-naming
rl712 Oct 17, 2024
e9aa9d0
Merge branch 'JabRef:main' into fix-naming
rl712 Oct 18, 2024
42fbaed
Merge branch 'JabRef:main' into fix-naming
rl712 Oct 18, 2024
8c60495
change 'General file directory' to 'Library file directory' in places…
tomeg09 Oct 19, 2024
66a4c61
amendment to prior commits: should show up in GUI as "Library-specifi…
tomeg09 Oct 20, 2024
92d65bb
update CHANGELOG.md to document activity in this branch.
tomeg09 Oct 20, 2024
2f18413
Merge branch 'JabRef:main' into rename-to-library-specific-directory
rl712 Oct 22, 2024
336a4e8
Additional/missed locations: change 'General File Directory' to 'Libr…
tomeg09 Oct 24, 2024
83ee3bc
Per Koppor's instructions: unify front/back end to "Library-specific …
tomeg09 Oct 24, 2024
daa8090
update code comments to reflect change from library file directory to…
tomeg09 Oct 24, 2024
d302bb1
Merge branch 'refs/heads/fix-naming' into rename-to-library-specific-…
tomeg09 Oct 24, 2024
bd45c1d
updated en localisation per unit tests:
tomeg09 Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We changed instances of 'Search Selected' to 'Search Pre-configured' in Web Search Preferences UI. [#11871](https://github.com/JabRef/jabref/pull/11871)
- We added a new CSS style class `main-table` for the main table. [#11881](https://github.com/JabRef/jabref/pull/11881)
- When renaming a file, the old extension is now used if there is none provided in the new name. [#11903](https://github.com/JabRef/jabref/issues/11903)
- We changed the name of the library-based file directory from 'General File Directory' to 'Library-specific File Directory' per issue [#571](https://github.com/koppor/jabref/issues/571)
Copy link
Contributor Author

@tomeg09 tomeg09 Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koppor I had already added a CHANGELOG.md entry. Please let me know if this needs to be adjusted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, my mobile client kind of hid it. Thank you for the quick note!


### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ private String getDifferenceString(MetaDataDiff.DifferenceType changeType) {
Localization.lang("Save actions");
case MODE ->
Localization.lang("Library mode");
case GENERAL_FILE_DIRECTORY ->
Localization.lang("General file directory");
case LIBRARY_SPECIFIC_FILE_DIRECTORY ->
Localization.lang("Library-specific file directory");
case CONTENT_SELECTOR ->
Localization.lang("Content selectors");
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

<Label styleClass="sectionHeader" text="%Override default file directories"
GridPane.columnSpan="3" GridPane.rowIndex="0"/>
<Label text="%General file directory"
<Label text="%Library-specific file directory"
GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<TextField fx:id="generalFileDirectory"
<TextField fx:id="librarySpecificFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Button onAction="#browseGeneralFileDirectory"
<Button onAction="#browseLibrarySpecificFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="1">
<graphic>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
public class GeneralPropertiesView extends AbstractPropertiesTabView<GeneralPropertiesViewModel> {
@FXML private ComboBox<Charset> encoding;
@FXML private ComboBox<BibDatabaseMode> databaseMode;
@FXML private TextField generalFileDirectory;
@FXML private TextField librarySpecificFileDirectory;
@FXML private TextField userSpecificFileDirectory;
@FXML private TextField laTexFileDirectory;

Expand Down Expand Up @@ -54,14 +54,14 @@ public void initialize() {
databaseMode.itemsProperty().bind(viewModel.databaseModesProperty());
databaseMode.valueProperty().bindBidirectional(viewModel.selectedDatabaseModeProperty());

generalFileDirectory.textProperty().bindBidirectional(viewModel.generalFileDirectoryPropertyProperty());
librarySpecificFileDirectory.textProperty().bindBidirectional(viewModel.librarySpecificDirectoryPropertyProperty());
userSpecificFileDirectory.textProperty().bindBidirectional(viewModel.userSpecificFileDirectoryProperty());
laTexFileDirectory.textProperty().bindBidirectional(viewModel.laTexFileDirectoryProperty());
}

@FXML
public void browseGeneralFileDirectory() {
viewModel.browseGeneralDir();
public void browseLibrarySpecificFileDirectory() {
viewModel.browseLibrarySpecificDir();
}

@FXML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel {
private final ObjectProperty<Charset> selectedEncodingProperty = new SimpleObjectProperty<>(Encodings.getCharsets().getFirst());
private final ListProperty<BibDatabaseMode> databaseModesProperty = new SimpleListProperty<>(FXCollections.observableArrayList(BibDatabaseMode.values()));
private final SimpleObjectProperty<BibDatabaseMode> selectedDatabaseModeProperty = new SimpleObjectProperty<>(BibDatabaseMode.BIBLATEX);
private final StringProperty generalFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty librarySpecificDirectoryProperty = new SimpleStringProperty("");
private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty("");

Expand Down Expand Up @@ -59,7 +59,7 @@ public void setValues() {

selectedEncodingProperty.setValue(metaData.getEncoding().orElse(StandardCharsets.UTF_8));
selectedDatabaseModeProperty.setValue(metaData.getMode().orElse(BibDatabaseMode.BIBLATEX));
generalFileDirectoryProperty.setValue(metaData.getDefaultFileDirectory().orElse("").trim());
tomeg09 marked this conversation as resolved.
Show resolved Hide resolved
librarySpecificDirectoryProperty.setValue(metaData.getLibrarySpecificFileDirectory().orElse("").trim());
userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferences.getFilePreferences().getUserAndHost()).orElse("").trim());
laTexFileDirectoryProperty.setValue(metaData.getLatexFileDirectory(preferences.getFilePreferences().getUserAndHost()).map(Path::toString).orElse(""));
}
Expand All @@ -71,11 +71,11 @@ public void storeSettings() {
newMetaData.setEncoding(selectedEncodingProperty.getValue());
newMetaData.setMode(selectedDatabaseModeProperty.getValue());

String generalFileDirectory = generalFileDirectoryProperty.getValue().trim();
if (generalFileDirectory.isEmpty()) {
newMetaData.clearDefaultFileDirectory();
String librarySpecificFileDirectory = librarySpecificDirectoryProperty.getValue().trim();
if (librarySpecificFileDirectory.isEmpty()) {
newMetaData.clearLibrarySpecificFileDirectory();
} else {
newMetaData.setDefaultFileDirectory(generalFileDirectory);
newMetaData.setLibrarySpecificFileDirectory(librarySpecificFileDirectory);
}

String userSpecificFileDirectory = userSpecificFileDirectoryProperty.getValue();
Expand All @@ -95,9 +95,9 @@ public void storeSettings() {
databaseContext.setMetaData(newMetaData);
}

public void browseGeneralDir() {
public void browseLibrarySpecificDir() {
dialogService.showDirectorySelectionDialog(directoryDialogConfiguration)
.ifPresent(dir -> generalFileDirectoryProperty.setValue(dir.toAbsolutePath().toString()));
.ifPresent(dir -> librarySpecificDirectoryProperty.setValue(dir.toAbsolutePath().toString()));
}

public void browseUserDir() {
Expand Down Expand Up @@ -130,8 +130,8 @@ public SimpleObjectProperty<BibDatabaseMode> selectedDatabaseModeProperty() {
return selectedDatabaseModeProperty;
}

public StringProperty generalFileDirectoryPropertyProperty() {
return this.generalFileDirectoryProperty;
public StringProperty librarySpecificDirectoryPropertyProperty() {
return this.librarySpecificDirectoryProperty;
}

public StringProperty userSpecificFileDirectoryProperty() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public enum DifferenceType {
CONTENT_SELECTOR,
DEFAULT_KEY_PATTERN,
ENCODING,
GENERAL_FILE_DIRECTORY,
LIBRARY_SPECIFIC_FILE_DIRECTORY,
GROUPS,
KEY_PATTERNS,
LATEX_FILE_DIRECTORY,
Expand Down Expand Up @@ -114,7 +114,7 @@ public List<Difference> getDifferences(GlobalCitationKeyPatterns globalCitationK
addToListIfDiff(changes, DifferenceType.DEFAULT_KEY_PATTERN, originalMetaData.getDefaultCiteKeyPattern(), newMetaData.getDefaultCiteKeyPattern());
addToListIfDiff(changes, DifferenceType.SAVE_ACTIONS, originalMetaData.getSaveActions(), newMetaData.getSaveActions());
addToListIfDiff(changes, DifferenceType.MODE, originalMetaData.getMode(), newMetaData.getMode());
addToListIfDiff(changes, DifferenceType.GENERAL_FILE_DIRECTORY, originalMetaData.getDefaultFileDirectory(), newMetaData.getDefaultFileDirectory());
addToListIfDiff(changes, DifferenceType.LIBRARY_SPECIFIC_FILE_DIRECTORY, originalMetaData.getLibrarySpecificFileDirectory(), newMetaData.getLibrarySpecificFileDirectory());
addToListIfDiff(changes, DifferenceType.CONTENT_SELECTOR, originalMetaData.getContentSelectors(), newMetaData.getContentSelectors());
return changes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static Map<String, String> getSerializedStringMap(MetaData metaData,
stringyMetaData.putAll(serializeCiteKeyPatterns(metaData, globalCiteKeyPatterns));
metaData.getMode().ifPresent(
mode -> stringyMetaData.put(MetaData.DATABASE_TYPE, Collections.singletonList(mode.getAsString())));
metaData.getDefaultFileDirectory().ifPresent(
metaData.getLibrarySpecificFileDirectory().ifPresent(
path -> stringyMetaData.put(MetaData.FILE_DIRECTORY, Collections.singletonList(path.trim())));
metaData.getUserFileDirectories().forEach((user, path) -> stringyMetaData
.put(MetaData.FILE_DIRECTORY + '-' + user, Collections.singletonList(path.trim())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public MetaData parse(MetaData metaData, Map<String, String> data, Character key
// edge case, it might be one special field e.g. article from biblatex-apa, but we can't distinguish this from any other field and rather prefer to handle it as UnknownField
metaData.addContentSelector(ContentSelectors.parse(FieldFactory.parseField(entry.getKey().substring(MetaData.SELECTOR_META_PREFIX.length())), StringUtil.unquote(entry.getValue(), MetaData.ESCAPE_CHARACTER)));
} else if (entry.getKey().equals(MetaData.FILE_DIRECTORY)) {
metaData.setDefaultFileDirectory(parseDirectory(entry.getValue()));
metaData.setLibrarySpecificFileDirectory(parseDirectory(entry.getValue()));
} else if (entry.getKey().startsWith(MetaData.FILE_DIRECTORY + '-')) {
// The user name starts directly after FILE_DIRECTORY + '-'
String user = entry.getKey().substring(MetaData.FILE_DIRECTORY.length() + 1);
Expand Down Expand Up @@ -170,7 +170,7 @@ public MetaData parse(MetaData metaData, Map<String, String> data, Character key
* We do not use unescaped value (created by @link{#getAsList(java.lang.String)}),
* because this leads to difficulties with UNC names.
*
* No normalization is done - the general file directory could be passed as Mac OS X path, but the user could sit on Windows.
* No normalization is done - the library-specific file directory could be passed as Mac OS X path, but the user could sit on Windows.
*
* @param value the raw value (as stored in the .bib file)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public boolean isStudy() {
* <ol>
* <li>next to the .bib file.</li>
* <li>the preferences can specify a default one.</li>
* <li>the database's metadata can specify a general directory.</li>
* <li>the database's metadata can specify a library-specific directory.</li>
* <li>the database's metadata can specify a user-specific directory.</li>
* </ol>
* <p>
Expand All @@ -165,12 +165,12 @@ public List<Path> getFileDirectories(FilePreferences preferences) {
Optional<Path> userFileDirectory = metaData.getUserFileDirectory(preferences.getUserAndHost()).map(dir -> getFileDirectoryPath(dir));
userFileDirectory.ifPresent(fileDirs::add);

Optional<Path> generalFileDirectory = metaData.getDefaultFileDirectory().map(dir -> getFileDirectoryPath(dir));
generalFileDirectory.ifPresent(fileDirs::add);
Optional<Path> librarySpecificFileDirectory = metaData.getLibrarySpecificFileDirectory().map(dir -> getFileDirectoryPath(dir));
librarySpecificFileDirectory.ifPresent(fileDirs::add);

// fileDirs.isEmpty() is true after these two if there are no directories set in the BIB file itself:
// 1) no user-specific file directory set (in the metadata of the bib file) and
// 2) no general file directory is set (in the metadata of the bib file)
// 2) no library-specific file directory is set (in the metadata of the bib file)

// BIB file directory or main file directory (according to (global) preferences)
if (preferences.shouldStoreFilesRelativeToBibFile()) {
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/jabref/model/metadata/MetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class MetaData {
private FieldFormatterCleanups saveActions;
private BibDatabaseMode mode;
private boolean isProtected;
private String defaultFileDirectory;
private String librarySpecificFileDirectory;
private final ContentSelectors contentSelectors = new ContentSelectors();
private final Map<String, List<String>> unknownMetaData = new HashMap<>();
private boolean isEventPropagationEnabled = true;
Expand Down Expand Up @@ -221,12 +221,12 @@ public List<String> getContentSelectorValuesForField(Field field) {
return contentSelectors.getSelectorValuesForField(field);
}

public Optional<String> getDefaultFileDirectory() {
return Optional.ofNullable(defaultFileDirectory);
public Optional<String> getLibrarySpecificFileDirectory() {
return Optional.ofNullable(librarySpecificFileDirectory);
}

public void setDefaultFileDirectory(String path) {
defaultFileDirectory = Objects.requireNonNull(path).trim();
public void setLibrarySpecificFileDirectory(String path) {
librarySpecificFileDirectory = Objects.requireNonNull(path).trim();
postChange();
}

Expand All @@ -248,8 +248,8 @@ public void markAsProtected() {
postChange();
}

public void clearDefaultFileDirectory() {
defaultFileDirectory = null;
public void clearLibrarySpecificFileDirectory() {
librarySpecificFileDirectory = null;
postChange();
}

Expand Down Expand Up @@ -398,19 +398,19 @@ public boolean equals(Object o) {
&& Objects.equals(defaultCiteKeyPattern, that.defaultCiteKeyPattern)
&& Objects.equals(saveActions, that.saveActions)
&& (mode == that.mode)
&& Objects.equals(defaultFileDirectory, that.defaultFileDirectory)
&& Objects.equals(librarySpecificFileDirectory, that.librarySpecificFileDirectory)
&& Objects.equals(contentSelectors, that.contentSelectors)
&& Objects.equals(versionDBStructure, that.versionDBStructure);
}

@Override
public int hashCode() {
return Objects.hash(isProtected, groupsRoot.getValue(), encoding, encodingExplicitlySupplied, saveOrder, citeKeyPatterns, userFileDirectory,
laTexFileDirectory, defaultCiteKeyPattern, saveActions, mode, defaultFileDirectory, contentSelectors, versionDBStructure);
laTexFileDirectory, defaultCiteKeyPattern, saveActions, mode, librarySpecificFileDirectory, contentSelectors, versionDBStructure);
}

@Override
public String toString() {
return "MetaData [citeKeyPatterns=" + citeKeyPatterns + ", userFileDirectory=" + userFileDirectory + ", laTexFileDirectory=" + laTexFileDirectory + ", groupsRoot=" + groupsRoot + ", encoding=" + encoding + ", saveOrderConfig=" + saveOrder + ", defaultCiteKeyPattern=" + defaultCiteKeyPattern + ", saveActions=" + saveActions + ", mode=" + mode + ", isProtected=" + isProtected + ", defaultFileDirectory=" + defaultFileDirectory + ", contentSelectors=" + contentSelectors + ", encodingExplicitlySupplied=" + encodingExplicitlySupplied + ", VersionDBStructure=" + versionDBStructure + "]";
return "MetaData [citeKeyPatterns=" + citeKeyPatterns + ", userFileDirectory=" + userFileDirectory + ", laTexFileDirectory=" + laTexFileDirectory + ", groupsRoot=" + groupsRoot + ", encoding=" + encoding + ", saveOrderConfig=" + saveOrder + ", defaultCiteKeyPattern=" + defaultCiteKeyPattern + ", saveActions=" + saveActions + ", mode=" + mode + ", isProtected=" + isProtected + ", librarySpecificFileDirectory=" + librarySpecificFileDirectory + ", contentSelectors=" + contentSelectors + ", encodingExplicitlySupplied=" + encodingExplicitlySupplied + ", VersionDBStructure=" + versionDBStructure + "]";
}
}
2 changes: 1 addition & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ Waiting\ for\ background\ tasks\ to\ finish.\ Quit\ anyway?=Waiting for backgrou
Find\ and\ remove\ duplicate\ citation\ keys=Find and remove duplicate citation keys
Expected\ syntax\ for\ --fetch\='<name\ of\ fetcher>\:<query>'=Expected syntax for --fetch='<name of fetcher>:<query>'

General\ file\ directory=General file directory
Library-specific\ file\ directory=Library-specific file directory
User-specific\ file\ directory=User-specific file directory
LaTeX\ file\ directory=LaTeX file directory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void setUp(@TempDir Path bibFolder) throws IOException {
Files.createDirectory(pdfPath);

MetaData metaData = new MetaData();
metaData.setDefaultFileDirectory(pdfPath.toAbsolutePath().toString());
metaData.setLibrarySpecificFileDirectory(pdfPath.toAbsolutePath().toString());
BibDatabaseContext context = new BibDatabaseContext(new BibDatabase(), metaData);
Files.createFile(bibFolder.resolve("test.bib"));
context.setDatabasePath(bibFolder.resolve("test.bib"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void setUp(@TempDir Path bibFolder) throws IOException {
Files.createFile(fileBefore);

MetaData metaData = new MetaData();
metaData.setDefaultFileDirectory(defaultFileFolder.toAbsolutePath().toString());
metaData.setLibrarySpecificFileDirectory(defaultFileFolder.toAbsolutePath().toString());
databaseContext = new BibDatabaseContext(new BibDatabase(), metaData);
Files.createFile(bibFolder.resolve("test.bib"));
databaseContext.setDatabasePath(bibFolder.resolve("test.bib"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void setUp(@TempDir Path bibFolder) throws IOException {
Files.createFile(fileBefore);

MetaData metaData = new MetaData();
metaData.setDefaultFileDirectory(newFileFolder.toAbsolutePath().toString());
metaData.setLibrarySpecificFileDirectory(newFileFolder.toAbsolutePath().toString());

BibDatabaseContext databaseContext = new BibDatabaseContext(new BibDatabase(), metaData);
Files.createFile(testBibFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ void writeProtectedFlag() throws Exception {

@Test
void writeFileDirectories() throws Exception {
metaData.setDefaultFileDirectory("\\Literature\\");
metaData.setLibrarySpecificFileDirectory("\\Literature\\");
metaData.setUserFileDirectory("defaultOwner-user", "D:\\Documents");
metaData.setLatexFileDirectory("defaultOwner-user", Path.of("D:\\Latex"));

Expand Down
Loading
Loading