Skip to content

Commit

Permalink
feat: Add user name and host name to user-specific file directory
Browse files Browse the repository at this point in the history
This commit adds hower to user-specific file directory, if the mouse is on the hower, jabref display: host: hostname, username: username
Fixes #572
  • Loading branch information
JoleneSun111 committed Oct 22, 2023
1 parent 432811c commit 0d8df17
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
- 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)
- We added a fetcher for [LOBID](https://lobid.org/resources/api) resources. [koppor#386](https://github.com/koppor/jabref/issues/386)
- 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`.

- 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)
### Changed

- The export formats `listrefs`, `tablerefs`, `tablerefsabsbib`, now use the ISO date format in the footer [#10383](https://github.com/JabRef/jabref/pull/10383).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@
</Button>

<Label text="%User-specific file directory"
GridPane.columnIndex="0" GridPane.rowIndex="2"/>
GridPane.columnIndex="0" GridPane.rowIndex="2">
</Label>
<TextField fx:id="userSpecificFileDirectory"
GridPane.columnIndex="1" GridPane.rowIndex="2"/>

<Button onAction="#browseUserSpecificFileDirectory"
styleClass="icon-button,narrow" prefHeight="20.0" prefWidth="20.0"
GridPane.columnIndex="2" GridPane.rowIndex="2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.nio.charset.Charset;

import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.control.Tooltip;

import org.jabref.gui.libraryproperties.AbstractPropertiesTabView;
import org.jabref.gui.util.ViewModelListCellFactory;
Expand All @@ -31,6 +33,8 @@ public GeneralPropertiesView(BibDatabaseContext databaseContext) {
ViewLoader.view(this)
.root(this)
.load();
// Get the ViewModel
viewModel.setUsername(preferencesService.getFilePreferences().getUserAndHost());
}

@Override
Expand All @@ -53,9 +57,11 @@ public void initialize() {
.install(databaseMode);
databaseMode.itemsProperty().bind(viewModel.databaseModesProperty());
databaseMode.valueProperty().bindBidirectional(viewModel.selectedDatabaseModeProperty());

generalFileDirectory.textProperty().bindBidirectional(viewModel.generalFileDirectoryPropertyProperty());
userSpecificFileDirectory.textProperty().bindBidirectional(viewModel.userSpecificFileDirectoryProperty());
Tooltip tooltip = new Tooltip();
tooltip.textProperty().bind(Bindings.concat("Host: ", viewModel.hostPropertyProperty(), "\nUsername: ", viewModel.usernamePropertyProperty()));
userSpecificFileDirectory.setTooltip(tooltip);
laTexFileDirectory.textProperty().bindBidirectional(viewModel.laTexFileDirectoryProperty());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.jabref.gui.libraryproperties.general;

import java.net.InetAddress;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
Expand Down Expand Up @@ -33,6 +34,10 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel {
private final SimpleObjectProperty<BibDatabaseMode> selectedDatabaseModeProperty = new SimpleObjectProperty<>(BibDatabaseMode.BIBLATEX);
private final StringProperty generalFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty("");
private final StringProperty hostProperty = new SimpleStringProperty("");


private final StringProperty usernameProperty = new SimpleStringProperty("");
private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty("");

private final DialogService dialogService;
Expand Down Expand Up @@ -61,6 +66,16 @@ public void setValues() {
selectedDatabaseModeProperty.setValue(metaData.getMode().orElse(BibDatabaseMode.BIBLATEX));
generalFileDirectoryProperty.setValue(metaData.getDefaultFileDirectory().orElse("").trim());
userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).orElse("").trim());
userSpecificFileDirectoryProperty.setValue(metaData.getUserFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).map(path -> usernameProperty.getValue() + ": " + path).orElse("").trim());
String username = preferencesService.getFilePreferences().getUserAndHost(); // get the username
usernameProperty.setValue(username);
try {
InetAddress localHost = InetAddress.getLocalHost();
hostProperty.set(localHost.getHostName()); // get the host Name
} catch (Exception e) {
hostProperty.set("N/A"); // if fail to get host, display N/A(Not Available)
}

laTexFileDirectoryProperty.setValue(metaData.getLatexFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).map(Path::toString).orElse(""));
}

Expand Down Expand Up @@ -141,4 +156,16 @@ public StringProperty userSpecificFileDirectoryProperty() {
public StringProperty laTexFileDirectoryProperty() {
return this.laTexFileDirectoryProperty;
}

public void setUsername(String username) {
usernameProperty.setValue(username);
}

public StringProperty usernamePropertyProperty() {
return usernameProperty;
}

public StringProperty hostPropertyProperty() {
return hostProperty;
}
}

0 comments on commit 0d8df17

Please sign in to comment.