-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix menu bar gone on macOS #10967
Fix menu bar gone on macOS #10967
Conversation
@@ -2204,7 +2202,7 @@ public FilePreferences getFilePreferences() { | |||
// We choose the data directory, because a ".bak" file should survive cache cleanups | |||
getPath(BACKUP_DIRECTORY, OS.getNativeDesktop().getBackupDirectory()), | |||
getBoolean(CONFIRM_LINKED_FILE_DELETE), | |||
getBoolean(TRASH_INSTEAD_OF_DELETE)); | |||
getBoolean(TRASH_INSTEAD_OF_DELETE, OS.getNativeDesktop().moveToTrashSupported())); |
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 is wrong. Can this be enabled in the preferences even though it is not supported?
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.
Was already wrong before the chris change. 😉 isSupported is logic, not a preferences option.
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.
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.
moveToTrash.setDisable(!OS.getNativeDesktop().moveToTrashSupported()); |
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.
Nevertheless, the preference should not be true if it is not supported system-wide. I thought, in #10591 I implemented it as: "default = supported by OS" and then "disabled/enabled = supported by OS".
Maybe an additional line:
if (!OS.getNativeDesktop().moveToTrashSupported()) {
moveToTrash.setValue(false)
}
to ensure that it is both disabled and false if trash is not supported.
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.
It was in defaults. but this broke the system menu bar in macOS. This is why i removed it in defaults and just added it as fallback value
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.
Which part exactly broke the menu bar? The issue did not show any exception, so I cannot understand the root cause.
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.
My suggestion would be just to make true the default, but it's greyed out in the preferences and where moveToTrash is used, there is an additional check, if this is supported. Check could go to JabRefDesktop#moveToTrash or sthg and then delete instead.
Failing tests are "only" architecture tests
|
Ah, I think |
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.
I don't know, how to solve this.
My thoughts:
- Users should not be required to set any preference on first use.
- JabRef should not delete data if it can do other way
- Trashing files instead of deleting files is a way to prevent data loss.
- Some operating systems do not support trashing
- Thus, the default for trashing is the OS support for trashing.
Point 5 seemed to cause troubles with OSX. I don't know which troubles. @calixtus says, OS-depended defaults are not OK. I am curious about our ideas how to resolve points 1 to 4 above.
/** | ||
* Moves the given file to the trash. | ||
* | ||
* @throws UnsupportedOperationException if the current platform does not support the {@link Desktop.Action#MOVE_TO_TRASH} action | ||
* @see Desktop#moveToTrash(File) | ||
*/ | ||
public static void moveToTrash(Path path) { | ||
NATIVE_DESKTOP.moveToTrash(path); | ||
} | ||
|
||
public static boolean moveToTrashSupported() { | ||
return NATIVE_DESKTOP.moveToTrashSupported(); | ||
} | ||
|
||
public static Path getApplicationDirectory() { | ||
return NATIVE_DESKTOP.getApplicationDirectory(); | ||
} | ||
|
||
public static Path getFulltextIndexBaseDirectory() { | ||
return NATIVE_DESKTOP.getFulltextIndexBaseDirectory(); | ||
} | ||
} |
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.
Please keep the methods here. OS.getNativeDesktop()
may only be used by certain classes. See org.jabref.architecture.MainArchitectureTest#nativeDesktopIsRestricted
.
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.
For me this is a code smell because we essentially have duplicate methods now. Before the mentioned PR we didn't have this architecture check
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.
When introducing, I checked all calls to JabRef desktop and refactored out the implied ArchitectureCheck.
I like the FacadePattern :p
@@ -710,7 +709,6 @@ private JabRefPreferences() { | |||
defaults.put(WARN_BEFORE_OVERWRITING_KEY, Boolean.TRUE); | |||
defaults.put(CONFIRM_DELETE, Boolean.TRUE); | |||
defaults.put(CONFIRM_LINKED_FILE_DELETE, Boolean.TRUE); | |||
defaults.put(TRASH_INSTEAD_OF_DELETE, JabRefDesktop.moveToTrashSupported()); |
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 there a true
be put?
OK, what if the OS does not support move to trash?
This were my thoughts. Therefore, I made the default rely on the current OS's capabilities.
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.
Exactly this line broke the menu bar! That's why I moved the check. I guess it has something to do with the initalization order of javafx <-> awt because we are here in a static context early at startup. That's why I moved the check down where the value is first read
@@ -2204,7 +2202,7 @@ public FilePreferences getFilePreferences() { | |||
// We choose the data directory, because a ".bak" file should survive cache cleanups | |||
getPath(BACKUP_DIRECTORY, OS.getNativeDesktop().getBackupDirectory()), | |||
getBoolean(CONFIRM_LINKED_FILE_DELETE), | |||
getBoolean(TRASH_INSTEAD_OF_DELETE)); | |||
getBoolean(TRASH_INSTEAD_OF_DELETE, OS.getNativeDesktop().moveToTrashSupported())); |
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.
Which part exactly broke the menu bar? The issue did not show any exception, so I cannot understand the root cause.
The build for this PR is no longer available. Please visit https://builds.jabref.org/main/ for the latest build. |
Fixes #10966
was introduced in bec55f8
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)