Skip to content

Commit 0d8df17

Browse files
committed
feat: Add user name and host name to user-specific file directory
This commit adds hower to user-specific file directory, if the mouse is on the hower, jabref display: host: hostname, username: username Fixes JabRef#572
1 parent 432811c commit 0d8df17

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
1919
- We added a link "Get more themes..." in the preferences to that points to [themes.jabref.org](https://themes.jabref.org) allowing the user to download new themes. [#10243](https://github.com/JabRef/jabref/issues/10243)
2020
- We added a fetcher for [LOBID](https://lobid.org/resources/api) resources. [koppor#386](https://github.com/koppor/jabref/issues/386)
2121
- When in `biblatex` mode, the [integrity check](https://docs.jabref.org/finding-sorting-and-cleaning-entries/checkintegrity) for journal titles now also checks the field `journal`.
22-
22+
- We added a hover on user-specific file directory. If the mouse is on hower, JabRef displays: user: {username}, host: {hostname}. [#572](https://github.com/koppor/jabref/issues/572)
2323
### Changed
2424

2525
- The export formats `listrefs`, `tablerefs`, `tablerefsabsbib`, now use the ISO date format in the footer [#10383](https://github.com/JabRef/jabref/pull/10383).

src/main/java/org/jabref/gui/libraryproperties/general/GeneralProperties.fxml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@
4747
</Button>
4848

4949
<Label text="%User-specific file directory"
50-
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
50+
GridPane.columnIndex="0" GridPane.rowIndex="2">
51+
</Label>
5152
<TextField fx:id="userSpecificFileDirectory"
5253
GridPane.columnIndex="1" GridPane.rowIndex="2"/>
54+
5355
<Button onAction="#browseUserSpecificFileDirectory"
5456
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
5557
GridPane.columnIndex="2" GridPane.rowIndex="2">

src/main/java/org/jabref/gui/libraryproperties/general/GeneralPropertiesView.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import java.nio.charset.Charset;
44

5+
import javafx.beans.binding.Bindings;
56
import javafx.fxml.FXML;
67
import javafx.scene.control.ComboBox;
78
import javafx.scene.control.TextField;
9+
import javafx.scene.control.Tooltip;
810

911
import org.jabref.gui.libraryproperties.AbstractPropertiesTabView;
1012
import org.jabref.gui.util.ViewModelListCellFactory;
@@ -31,6 +33,8 @@ public GeneralPropertiesView(BibDatabaseContext databaseContext) {
3133
ViewLoader.view(this)
3234
.root(this)
3335
.load();
36+
// Get the ViewModel
37+
viewModel.setUsername(preferencesService.getFilePreferences().getUserAndHost());
3438
}
3539

3640
@Override
@@ -53,9 +57,11 @@ public void initialize() {
5357
.install(databaseMode);
5458
databaseMode.itemsProperty().bind(viewModel.databaseModesProperty());
5559
databaseMode.valueProperty().bindBidirectional(viewModel.selectedDatabaseModeProperty());
56-
5760
generalFileDirectory.textProperty().bindBidirectional(viewModel.generalFileDirectoryPropertyProperty());
5861
userSpecificFileDirectory.textProperty().bindBidirectional(viewModel.userSpecificFileDirectoryProperty());
62+
Tooltip tooltip = new Tooltip();
63+
tooltip.textProperty().bind(Bindings.concat("Host: ", viewModel.hostPropertyProperty(), "\nUsername: ", viewModel.usernamePropertyProperty()));
64+
userSpecificFileDirectory.setTooltip(tooltip);
5965
laTexFileDirectory.textProperty().bindBidirectional(viewModel.laTexFileDirectoryProperty());
6066
}
6167

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.jabref.gui.libraryproperties.general;
22

3+
import java.net.InetAddress;
34
import java.nio.charset.Charset;
45
import java.nio.charset.StandardCharsets;
56
import java.nio.file.Path;
@@ -33,6 +34,10 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel {
3334
private final SimpleObjectProperty<BibDatabaseMode> selectedDatabaseModeProperty = new SimpleObjectProperty<>(BibDatabaseMode.BIBLATEX);
3435
private final StringProperty generalFileDirectoryProperty = new SimpleStringProperty("");
3536
private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty("");
37+
private final StringProperty hostProperty = new SimpleStringProperty("");
38+
39+
40+
private final StringProperty usernameProperty = new SimpleStringProperty("");
3641
private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty("");
3742

3843
private final DialogService dialogService;
@@ -61,6 +66,16 @@ public void setValues() {
6166
selectedDatabaseModeProperty.setValue(metaData.getMode().orElse(BibDatabaseMode.BIBLATEX));
6267
generalFileDirectoryProperty.setValue(metaData.getDefaultFileDirectory().orElse("").trim());
6368
userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).orElse("").trim());
69+
userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).map(path -> usernameProperty.getValue() + ": " + path).orElse("").trim());
70+
String username = preferencesService.getFilePreferences().getUserAndHost(); // get the username
71+
usernameProperty.setValue(username);
72+
try {
73+
InetAddress localHost = InetAddress.getLocalHost();
74+
hostProperty.set(localHost.getHostName()); // get the host Name
75+
} catch (Exception e) {
76+
hostProperty.set("N/A"); // if fail to get host, display N/A(Not Available)
77+
}
78+
6479
laTexFileDirectoryProperty.setValue(metaData.getLatexFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).map(Path::toString).orElse(""));
6580
}
6681

@@ -141,4 +156,16 @@ public StringProperty userSpecificFileDirectoryProperty() {
141156
public StringProperty laTexFileDirectoryProperty() {
142157
return this.laTexFileDirectoryProperty;
143158
}
159+
160+
public void setUsername(String username) {
161+
usernameProperty.setValue(username);
162+
}
163+
164+
public StringProperty usernamePropertyProperty() {
165+
return usernameProperty;
166+
}
167+
168+
public StringProperty hostPropertyProperty() {
169+
return hostProperty;
170+
}
144171
}

0 commit comments

Comments
 (0)