Skip to content
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

Add option for direct attached file renaming #4887

Merged
merged 23 commits into from
Apr 17, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9f066f3
Add Rename file item on right click menu.
kaiquekk Apr 12, 2019
a4de3ce
Create a function to rename the file on button click.
yurickyh Apr 12, 2019
c33fa3f
Implement direct file renaming
kaiquekk Apr 12, 2019
95277f7
Change Rename button location
kaiquekk Apr 12, 2019
66d637b
Remove useless imports.
yurickyh Apr 14, 2019
b3bd9fe
Import and use the new class 'LinkedFileRenameDialogView'
yurickyh Apr 14, 2019
c5f4d5a
Create a fxml file for the Rename Dialog.
yurickyh Apr 14, 2019
bb158ec
Create a view class for the Rename Dialog.
yurickyh Apr 14, 2019
a490d6a
Create a Model for the Rename Dialog.
yurickyh Apr 14, 2019
ad1bf8b
Add changes to CHANGELOG
kaiquekk Apr 14, 2019
f7cca2f
Fix no newline on the end of properties file
kaiquekk Apr 15, 2019
c8bc1ab
Adjust dialog to change only filename
kaiquekk Apr 15, 2019
41ab5ed
Rename link label to "New Filename"
kaiquekk Apr 15, 2019
83919e9
Add the two ButtonType ('Apply' and 'Cancel'). Also, the height was d…
yurickyh Apr 15, 2019
b9cf37c
The definition of the buttons was moved to the .fxml file and they we…
yurickyh Apr 15, 2019
4cf8d8d
Remove unnecessary lines
kaiquekk Apr 15, 2019
169af5c
Simplify the code to get the new path
kaiquekk Apr 16, 2019
29a3c5c
Change rename dialog to a simple TextInputDialog
kaiquekk Apr 16, 2019
417e654
Relabel the 'Rename file' option to 'Rename file to defined pattern'.
yurickyh Apr 17, 2019
dd87b00
Use the new method showInputDialogWithDefaultAndWait and set in the t…
yurickyh Apr 17, 2019
0448faa
Implement the new method showInputDialogWithDefaultAndWait.
yurickyh Apr 17, 2019
44edc83
Create a new interface for the new method showInputDialogWithDefaultA…
yurickyh Apr 17, 2019
4d80247
Add the 'Rename file to defined pattern' string.
yurickyh Apr 17, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We made modifications to improve contrast of UI elements. [#4583](https://github.com/JabRef/jabref/issues/4583)
- We added an option in the settings to set the default action in JabRef when right clicking on any entry in any database and selecting "Open folder". [#4763](https://github.com/JabRef/jabref/issues/4763)
- The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345)
- We added an option on the Linked File Viewer to rename the attached file of an entry directly on the JabRef. [#4844](https://github.com/JabRef/jabref/issues/4844)


### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.jabref.logic.externalfiles.LinkedFileHandler;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.net.URLDownload;
import org.jabref.logic.util.io.FileUtil;
import org.jabref.logic.xmp.XmpPreferences;
import org.jabref.logic.xmp.XmpUtilWriter;
import org.jabref.model.database.BibDatabaseContext;
Expand Down Expand Up @@ -344,7 +345,6 @@ public boolean delete() {
}

public void edit() {

LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(this.linkedFile);

Optional<LinkedFile> editedFile = dialog.showAndWait();
Expand All @@ -355,6 +355,16 @@ public void edit() {
});
}

public void renameFile() {
String oldFile = this.linkedFile.getLink();
Optional<String> editedFile = dialogService.showInputDialogAndWait(Localization.lang("Rename file"), Localization.lang("New Filename"));
editedFile.ifPresent(file -> {
Path newFile = Paths.get(oldFile).resolveSibling(file);
this.linkedFile.setLink(newFile.toString());
FileUtil.renameFile(Paths.get(oldFile), newFile);
});
}

public void writeXMPMetadata() {
// Localization.lang("Writing XMP-metadata...")
BackgroundTask<Void> writeTask = BackgroundTask.wrap(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ private ContextMenu createContextMenuForFile(LinkedFileViewModel linkedFile) {
renameFile.setOnAction(event -> linkedFile.rename());
renameFile.setDisable(linkedFile.getFile().isOnlineLink() || linkedFile.isGeneratedNameSameAsOriginal());

MenuItem renameFileName = new MenuItem(Localization.lang("Rename file to a given name"));
renameFileName.setOnAction(event -> linkedFile.renameFile());

MenuItem moveFile = new MenuItem(Localization.lang("Move file to file directory"));
moveFile.setOnAction(event -> linkedFile.moveToDefaultDirectory());
moveFile.setDisable(linkedFile.getFile().isOnlineLink() || linkedFile.isGeneratedPathSameAsOriginal());
Expand All @@ -244,7 +247,7 @@ private ContextMenu createContextMenuForFile(LinkedFileViewModel linkedFile) {
if (linkedFile.getFile().isOnlineLink()) {
menu.getItems().add(download);
}
menu.getItems().addAll(renameFile, moveFile, renameAndMoveFile, deleteLink, deleteFile);
menu.getItems().addAll(renameFile, renameFileName, moveFile, renameAndMoveFile, deleteLink, deleteFile);

return menu;
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2088,3 +2088,5 @@ A\ string\ with\ the\ label\ '%0'\ already\ exists.=A string with the label '%0'

Executing\ command\ "%0"...=Executing command "%0"...

Rename\ file\ to\ a\ given\ name=Rename file to a given name
New\ Filename=New Filename