Skip to content

user-specific file directory should show user name #13380

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

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

pranav0510s
Copy link
Contributor

@pranav0510s pranav0510s commented Jun 19, 2025

Closes Issue #12269

In this PR, I’ve refactored the CLI preferences to expose getUsername() and getHostname() default methods on CliPreferences, updated JabRefCliPreferences to implement the public getUserAndHost() interface method, and wired the General tab’s “User‐specific file directory” tooltip to display user@host instead of the old String-array approach.

Steps to test

  1. Build and launch JabRef.
  2. Open Options → Library properties and switch to the General tab.
  3. Hover over the User-specific file directory label or text field. You should see your OS username and hostname in the format username@hostname.
  4. Verify that hovering over LaTeX file directory still shows the directory description as before.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • [/] Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • [/] Screenshots added in PR description (if change is visible to the user)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

henmesh and others added 11 commits June 17, 2025 10:14
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
@pranav0510s pranav0510s marked this pull request as draft June 19, 2025 11:05
userSpecificFileDirectoryTooltip.setText(userHost);
laTexFileDirectoryTooltip.textProperty().bind(
viewModel.laTexFileDirectoryProperty().map(path ->
Localization.lang(path.isEmpty() ? "Directory for LaTeX files: (not set)" : "Directory for LaTeX files: %0", path)
Copy link
Member

Choose a reason for hiding this comment

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

This won't work this way, I think. You need to put the path.isEmpty check before and then have two separate Locallization.lang(...) calls

@@ -0,0 +1,23 @@
package org.jabref.logic.util;

public class UserAndHost {
Copy link
Member

Choose a reason for hiding this comment

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

This can be made a recod

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can i know what do you mean by record?

Copy link
Member

Choose a reason for hiding this comment

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

Google for Java record

Or do Ctrl+Shift+F record in Intellij to see other record code.

Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
# Conflicts:
#	.github/workflows/pr-comment.yml
@@ -76,7 +76,7 @@ jobs:
echo "workflow_run_id=${{ github.event.workflow_run.id }}" >> $GITHUB_OUTPUT
fi

- name: Check if PR has 'dev: no-bot-comments' label
Copy link
Member

Choose a reason for hiding this comment

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

Why was there a need to touch the workflow file?

FieldPreferences getFieldPreferences();

Copy link
Member

Choose a reason for hiding this comment

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

I think it was intentional to have each method separated by an empty line

@@ -0,0 +1,23 @@
package org.jabref.logic.util;

public class UserAndHost {
Copy link
Member

Choose a reason for hiding this comment

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

Google for Java record

Or do Ctrl+Shift+F record in Intellij to see other record code.

private final String host;

public UserAndHost(String user, String host) {
this.user = Objects.requireNonNull(user, "user must not be null");
Copy link
Member

Choose a reason for hiding this comment

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

Use JSpecify annotations instead of requireNonNull

pranav0510s and others added 5 commits June 19, 2025 22:37
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
@Siedlerchr Siedlerchr changed the title Issue 12269 user-specific file directory should show user name Jun 19, 2025
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
pranav0510s and others added 2 commits June 20, 2025 02:41
Signed-off-by: pranavdikshith <dikshithpranav@gmail.com>
@pranav0510s pranav0510s marked this pull request as ready for review June 19, 2025 17:20
@koppor
Copy link
Member

koppor commented Jun 22, 2025

@pranav0510s Please check your CHANGELOG.md modifications. You seem to have modified a section describing changes of a released version. See also the output of our tests.

CHANGELOG.md Outdated
@@ -107,6 +107,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- We added path validation to file directories in library properties dialog. [#11840](https://github.com/JabRef/jabref/issues/11840)
- We now support usage of custom CSL styles in the Open/LibreOffice integration. [#12337](https://github.com/JabRef/jabref/issues/12337)
- We added support for citation-only CSL styles which don't specify bibliography formatting. [#12996](https://github.com/JabRef/jabref/pull/12996)
- We added tooltips to the "User-specific file directory" and "LaTeX file directory" fields of the library properties window. [#12269](https://github.com/JabRef/jabref/issues/12269)
Copy link
Member

Choose a reason for hiding this comment

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

This must be put in the Unreleased section

Copy link

trag-bot bot commented Jun 23, 2025

@trag-bot didn't find any issues in the code! ✅✨

@jabref-machine
Copy link
Collaborator

Your pull request needs to link an issue correctly.

To ease organizational workflows, please link this pull-request to the issue with syntax as described in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue:

Linking a pull request to an issue using a keyword

You can link a pull request to an issue by using a supported keyword in the pull request's description or in a commit message.

Examples

  • Fixes #xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes https://github.com/JabRef/jabref/issues/xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes https://github.com/Koppor/jabref/issues/xyz links pull-request to issue. Merging the PR will close the issue.
  • Fixes [#xyz](https://github.com/JabRef/jabref/issues/xyz) links pull-request to issue. Merging the PR will NOT close the issue.

@jabref-machine
Copy link
Collaborator

You modified Markdown (*.md) files and did not meet JabRef's rules for consistently formatted Markdown files. To ensure consistent styling, we have markdown-lint in place. Markdown lint's rules help to keep our Markdown files consistent within this repository and consistent with the Markdown files outside here.

You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "Markdown".

@@ -108,6 +110,18 @@ public void initialize() {
laTexSpecificFileDirSwitchTooltip.setText(isAbsolute ? switchToRelativeText : switchToAbsoluteText);
});

String userHost = preferences.getUsername() + "@" + preferences.getHostname();
Copy link
Member

Choose a reason for hiding this comment

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

Should be part of record, maybe call method "getCanonicalForm()".

Comment on lines +49 to +60
UserAndHost getUserAndHost();

/** Shortcut for getUserAndHost().getUser() */
default String getUsername() {
return getUserAndHost().user();
}

/** Shortcut for getUserAndHost().getHost() */
default String getHostname() {
return getUserAndHost().host();
}

Copy link
Member

Choose a reason for hiding this comment

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

YAGNI. This clutters CliPreferences. Too much noise. getUserAndHost().host() is simple enough.

@@ -1456,7 +1457,7 @@ public InternalPreferences getInternalPreferences() {
Version.parse(get(VERSION_IGNORED_UPDATE)),
getBoolean(VERSION_CHECK_ENABLED),
getPath(PREFS_EXPORT_PATH, getDefaultPath()),
getUserAndHost(),
getUserAndHost().toString(),
Copy link
Member

Choose a reason for hiding this comment

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

toString returns internal jdk string representation. this is outside of your control, use custom getCanonnicalForm() method instead.

Comment on lines +115 to +123
laTexFileDirectoryTooltip.textProperty().bind(
viewModel.laTexFileDirectoryProperty().map(path -> {
if (path.isEmpty()) {
return Localization.lang("Directory for LaTeX files: (not set)");
} else {
return Localization.lang("Directory for LaTeX files: %0", path);
}
})
);
Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants