-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
base: main
Are you sure you want to change the base?
Changes from 27 commits
f98f73a
0e9031e
cb04787
0be84ae
9b08e71
80497e2
e1c798a
a4d645f
c8b26d2
75b2c92
a8d24fe
a2052cb
3481df7
b2deaea
42002c5
88dff39
7c3d3ad
b38061e
2fb2e59
e04dfc9
343e8ba
c063060
ebfdbb5
0d44e4d
0741516
9b86cc1
a39ff62
3eb74c4
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 |
---|---|---|
|
@@ -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(); | ||
|
@@ -108,6 +110,18 @@ public void initialize() { | |
laTexSpecificFileDirSwitchTooltip.setText(isAbsolute ? switchToRelativeText : switchToAbsoluteText); | ||
}); | ||
|
||
String userHost = preferences.getUsername() + "@" + preferences.getHostname(); | ||
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. 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
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. |
||
|
||
Platform.runLater(() -> { | ||
librarySpecificFileDirectoryValidationVisualizer.initVisualization(viewModel.librarySpecificFileDirectoryStatus(), librarySpecificFileDirectory); | ||
userSpecificFileDirectoryValidationVisualizer.initVisualization(viewModel.userSpecificFileDirectoryStatus(), userSpecificFileDirectory); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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(); | ||
} | ||
Siedlerchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** Shortcut for getUserAndHost().getHost() */ | ||
default String getHostname() { | ||
return getUserAndHost().host(); | ||
} | ||
Siedlerchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Comment on lines
+49
to
+60
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. YAGNI. This clutters CliPreferences. Too much noise. getUserAndHost().host() is simple enough. |
||
InternalPreferences getInternalPreferences(); | ||
|
||
BibEntryPreferences getBibEntryPreferences(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -411,7 +412,7 @@ public class JabRefCliPreferences implements CliPreferences { | |
/** | ||
* Cache variables | ||
*/ | ||
private String userAndHost; | ||
private UserAndHost userAndHost; | ||
|
||
private LibraryPreferences libraryPreferences; | ||
private DOIPreferences doiPreferences; | ||
|
@@ -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(), | ||
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. 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(), | ||
|
@@ -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; | ||
} | ||
|
||
|
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) { | ||
} |
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.
This must be put in the Unreleased section