|
1 | 1 | package org.jabref.gui.libraryproperties.general; |
2 | 2 |
|
| 3 | +import java.net.InetAddress; |
3 | 4 | import java.nio.charset.Charset; |
4 | 5 | import java.nio.charset.StandardCharsets; |
5 | 6 | import java.nio.file.Path; |
@@ -33,6 +34,10 @@ public class GeneralPropertiesViewModel implements PropertiesTabViewModel { |
33 | 34 | private final SimpleObjectProperty<BibDatabaseMode> selectedDatabaseModeProperty = new SimpleObjectProperty<>(BibDatabaseMode.BIBLATEX); |
34 | 35 | private final StringProperty generalFileDirectoryProperty = new SimpleStringProperty(""); |
35 | 36 | private final StringProperty userSpecificFileDirectoryProperty = new SimpleStringProperty(""); |
| 37 | + private final StringProperty hostProperty = new SimpleStringProperty(""); |
| 38 | + |
| 39 | + |
| 40 | + private final StringProperty usernameProperty = new SimpleStringProperty(""); |
36 | 41 | private final StringProperty laTexFileDirectoryProperty = new SimpleStringProperty(""); |
37 | 42 |
|
38 | 43 | private final DialogService dialogService; |
@@ -61,6 +66,16 @@ public void setValues() { |
61 | 66 | selectedDatabaseModeProperty.setValue(metaData.getMode().orElse(BibDatabaseMode.BIBLATEX)); |
62 | 67 | generalFileDirectoryProperty.setValue(metaData.getDefaultFileDirectory().orElse("").trim()); |
63 | 68 | 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 | + |
64 | 79 | laTexFileDirectoryProperty.setValue(metaData.getLatexFileDirectory(preferencesService.getFilePreferences().getUserAndHost()).map(Path::toString).orElse("")); |
65 | 80 | } |
66 | 81 |
|
@@ -141,4 +156,16 @@ public StringProperty userSpecificFileDirectoryProperty() { |
141 | 156 | public StringProperty laTexFileDirectoryProperty() { |
142 | 157 | return this.laTexFileDirectoryProperty; |
143 | 158 | } |
| 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 | + } |
144 | 171 | } |
0 commit comments