-
Notifications
You must be signed in to change notification settings - Fork 15
Add user name and host name to user-specific file directory #658
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -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; | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This return username AND hostname. -- You can add new methods to the getFilePreferences to return the username and the hostname separately. - The |
||
usernameProperty.setValue(username); | ||
try { | ||
InetAddress localHost = InetAddress.getLocalHost(); | ||
hostProperty.set(localHost.getHostName()); // get the host Name | ||
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this code - JabRef already knows the host name. It is returned in |
||
} 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("")); | ||
} | ||
|
||
|
@@ -141,4 +156,16 @@ public StringProperty userSpecificFileDirectoryProperty() { | |
public StringProperty laTexFileDirectoryProperty() { | ||
return this.laTexFileDirectoryProperty; | ||
} | ||
|
||
public void setUsername(String username) { | ||
usernameProperty.setValue(username); | ||
} | ||
Comment on lines
+160
to
+162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not necessary - because the change of the username would be handled in other places in JabRef. |
||
|
||
public StringProperty usernamePropertyProperty() { | ||
return usernameProperty; | ||
} | ||
|
||
public StringProperty hostPropertyProperty() { | ||
return hostProperty; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this more be a binding?