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
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f98f73a
Added tooltips for user-specific file directory and LaTeX directory
henmesh May 1, 2025
0e9031e
Removed unused metadata variable from earlier version
henmesh May 2, 2025
cb04787
Added changes to CHANGELOG.md
henmesh May 2, 2025
0be84ae
Merged upstream, fixed conflicts
henmesh May 10, 2025
9b08e71
Fixed OS variable import issue
pranav0510s Jun 19, 2025
80497e2
Fixed GeneralProperties.fxml
pranav0510s Jun 19, 2025
e1c798a
refactor: expose username and hostname via default methods
pranav0510s Jun 19, 2025
a4d645f
feat: wire user-specific directory tooltip to show user@host
pranav0510s Jun 19, 2025
c8b26d2
fix: make getUserAndHost() public to implement interface
pranav0510s Jun 19, 2025
75b2c92
Update pr-comment.yml
pranav0510s Jun 19, 2025
a8d24fe
Merge branch 'main' into issue-12269
pranav0510s Jun 19, 2025
a2052cb
Fixed the "null" issues
pranav0510s Jun 19, 2025
3481df7
Fixed the "null" issues
pranav0510s Jun 19, 2025
b2deaea
Merge remote-tracking branch 'origin/issue-12269' into issue-12269
pranav0510s Jun 19, 2025
42002c5
Fixed the the space issue issues
pranav0510s Jun 19, 2025
88dff39
Merge branch 'main' into issue-12269
pranav0510s Jun 19, 2025
7c3d3ad
Merge remote-tracking branch 'origin/issue-12269' into issue-12269
pranav0510s Jun 19, 2025
b38061e
invoked a distinct Localization.lang call
pranav0510s Jun 19, 2025
2fb2e59
resolved few conflicts
pranav0510s Jun 19, 2025
e04dfc9
fixed space
pranav0510s Jun 19, 2025
343e8ba
fixed space
pranav0510s Jun 19, 2025
c063060
fixed space
pranav0510s Jun 19, 2025
ebfdbb5
fixed localization.lang
pranav0510s Jun 19, 2025
0d44e4d
Merge branch 'main' into issue-12269
pranav0510s Jun 19, 2025
0741516
Merge branch 'main' into issue-12269
pranav0510s Jun 20, 2025
9b86cc1
Discard changes to .github/workflows/pr-comment.yml
koppor Jun 22, 2025
a39ff62
Merge branch 'main' into issue-12269
Siedlerchr Jun 23, 2025
3eb74c4
move changelog
Siedlerchr Jun 23, 2025
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 @@ -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


### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class GeneralPropertiesView extends AbstractPropertiesTabView<GeneralProp
@FXML private Tooltip libSpecificFileDirSwitchTooltip;
@FXML private Tooltip userSpecificFileDirSwitchTooltip;
@FXML private Tooltip laTexSpecificFileDirSwitchTooltip;
@FXML private Tooltip userSpecificFileDirectoryTooltip;
@FXML private Tooltip laTexFileDirectoryTooltip;

private final ControlsFxVisualizer librarySpecificFileDirectoryValidationVisualizer = new ControlsFxVisualizer();
private final ControlsFxVisualizer userSpecificFileDirectoryValidationVisualizer = new ControlsFxVisualizer();
Expand Down Expand Up @@ -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()".

userSpecificFileDirectoryTooltip.setText(userHost);
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);
}
})
);
Comment on lines +115 to +123
Copy link
Member

Choose a reason for hiding this comment

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


Platform.runLater(() -> {
librarySpecificFileDirectoryValidationVisualizer.initVisualization(viewModel.librarySpecificFileDirectoryStatus(), librarySpecificFileDirectory);
userSpecificFileDirectoryValidationVisualizer.initVisualization(viewModel.userSpecificFileDirectoryStatus(), userSpecificFileDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@
</tooltip>
</Button>

<fx:define>
<Tooltip fx:id="userSpecificFileDirectoryTooltip"/>
</fx:define>
<Label text="%User-specific file directory"
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
GridPane.columnIndex="0" GridPane.rowIndex="2"
tooltip="$userSpecificFileDirectoryTooltip"/>
<TextField fx:id="userSpecificFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Button fx:id="userSpecificFileDirSwitchId" onAction="#userSpecificFileDirPathSwitch"
GridPane.columnIndex="1" GridPane.rowIndex="2" tooltip="$userSpecificFileDirectoryTooltip"/>
<Button fx:id="userSpecificFileDirSwitchId" onAction="#browseUserSpecificFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="2">
<graphic>
Expand All @@ -82,11 +86,15 @@
</tooltip>
</Button>

<fx:define>
<Tooltip fx:id="laTexFileDirectoryTooltip"/>
</fx:define>
<Label text="%LaTeX file directory"
GridPane.columnIndex="0" GridPane.rowIndex="3"/>
GridPane.columnIndex="0" GridPane.rowIndex="3"
tooltip="$laTexFileDirectoryTooltip"/>
<TextField fx:id="laTexFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="3"/>
<Button fx:id="laTexSpecificFileDirSwitchId" onAction="#laTexSpecificFileDirPathSwitch"
GridPane.columnIndex="1" GridPane.rowIndex="3" tooltip="$laTexFileDirectoryTooltip"/>
<Button fx:id="laTexSpecificFileDirSwitchId" onAction="#browseLatexFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="3">
<graphic>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
import org.jabref.logic.protectedterms.ProtectedTermsPreferences;
import org.jabref.logic.remote.RemotePreferences;
import org.jabref.logic.search.SearchPreferences;
import org.jabref.logic.util.UserAndHost;
import org.jabref.logic.util.io.AutoLinkPreferences;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.model.entry.BibEntryPreferences;
import org.jabref.model.entry.BibEntryTypesManager;

public interface CliPreferences {

void clear() throws BackingStoreException;

void deleteKey(String key) throws IllegalArgumentException;
Expand All @@ -44,6 +46,18 @@ public interface CliPreferences {

void importPreferences(Path file) throws JabRefException;

UserAndHost getUserAndHost();

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

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

Comment on lines +49 to +60
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.

InternalPreferences getInternalPreferences();

BibEntryPreferences getBibEntryPreferences();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import org.jabref.logic.shared.security.Password;
import org.jabref.logic.util.BuildInfo;
import org.jabref.logic.util.Directories;
import org.jabref.logic.util.UserAndHost;
import org.jabref.logic.util.Version;
import org.jabref.logic.util.io.AutoLinkPreferences;
import org.jabref.logic.util.io.FileHistory;
Expand Down Expand Up @@ -411,7 +412,7 @@ public class JabRefCliPreferences implements CliPreferences {
/**
* Cache variables
*/
private String userAndHost;
private UserAndHost userAndHost;

private LibraryPreferences libraryPreferences;
private DOIPreferences doiPreferences;
Expand Down Expand Up @@ -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.

getBoolean(MEMORY_STICK_MODE));

EasyBind.listen(internalPreferences.ignoredVersionProperty(),
Expand All @@ -1480,11 +1481,14 @@ public InternalPreferences getInternalPreferences() {
return internalPreferences;
}

private String getUserAndHost() {
if (StringUtil.isNotBlank(userAndHost)) {
@Override
public UserAndHost getUserAndHost() {
if (userAndHost != null) {
return userAndHost;
}
userAndHost = get(DEFAULT_OWNER) + '-' + OS.getHostName();
String user = get(DEFAULT_OWNER);
String host = OS.getHostName();
userAndHost = new UserAndHost(user, host);
return userAndHost;
}

Expand Down
3 changes: 3 additions & 0 deletions jablib/src/main/java/org/jabref/logic/util/UserAndHost.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.jabref.logic.util;
public record UserAndHost(String user, String host) {
}
3 changes: 3 additions & 0 deletions jablib/src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2808,6 +2808,9 @@ Pushing\ citations\ to\ TeXShop\ is\ only\ possible\ on\ macOS\!=Pushing citatio

Single\ instance=Single instance

Directory\ for\ LaTeX\ files\:\ %0=Directory for LaTeX files: %0
Directory\ for\ LaTeX\ files\:\ (not\ set)=Directory for LaTeX files: (not set)

Copied\ %0\ entry(s)=Copied %0 entry(s)
Cut\ %0\ entry(s)=Cut %0 entry(s)
Deleted\ %0\ entry(s)=Deleted %0 entry(s)
Expand Down
Loading