-
-
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
Make attached files relative to the file directory #4212
Changes from 2 commits
482e7aa
c32aca6
cfa2365
a19125c
971b3c7
4aba5a4
447288d
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.filelist; | ||
|
||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
import org.jabref.Globals; | ||
|
@@ -9,6 +10,7 @@ | |
import org.jabref.gui.undo.UndoableFieldChange; | ||
import org.jabref.gui.util.FileDialogConfiguration; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.util.io.FileUtil; | ||
import org.jabref.model.FieldChange; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.LinkedFile; | ||
|
@@ -32,11 +34,14 @@ public void execute() { | |
} | ||
BibEntry entry = panel.getSelectedEntries().get(0); | ||
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() | ||
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)) | ||
.build(); | ||
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)) | ||
.build(); | ||
|
||
dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(newFile -> { | ||
LinkedFile newLinkedFile = new LinkedFile("", newFile.toString(), ""); | ||
|
||
Path relativePath = FileUtil.shortenFileName(newFile, panel.getBibDatabaseContext().getFileDirectoriesAsPaths(Globals.prefs.getFileDirectoryPreferences())); | ||
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. In my opinion, this code should be refactored to use the same code as the same action in the entry editor. Otherwise, we will again run into a similar problem where the two actions are different in behavior. 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. Changed it |
||
LinkedFile newLinkedFile = new LinkedFile("", relativePath.toString(), ""); | ||
|
||
|
||
LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(newLinkedFile); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,7 +119,7 @@ public ObjectProperty<ExternalFileType> selectedExternalFileTypeProperty() { | |
} | ||
|
||
public LinkedFile getNewLinkedFile() { | ||
return new LinkedFile(description.getValue(), link.getValue(), selectedExternalFileType.getValue().toString()); | ||
return new LinkedFile(description.getValue(), link.getValue(), selectedExternalFileType.getValue() == null ? null : selectedExternalFileType.getValue().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. As we wanted to get ride of null's, I don't like this change. Maybe we should use a |
||
|
||
} | ||
|
||
|
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 add a short comment explaining what is done here.