-
-
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
Rename the Review Tab into Comments Tab #3658
Merged
+265
−67
Merged
Changes from 9 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
289c2d2
Rename the Review Tab into Comments Tab
LinusDietz 351b1db
Remove Localization Key for Review
LinusDietz ac341e4
Merge branch 'master' into comment-tab
LinusDietz 07a8965
Use Comment field in the Comment tab
LinusDietz 6a75c6a
Migration for the Review field
LinusDietz af9022a
Merge remote-tracking branch 'origin/comment-tab' into comment-tab
LinusDietz afe5476
Remove Comment Field from General Tab
LinusDietz 995b965
Tests
LinusDietz 056ef9d
Simplify tests
LinusDietz 9d9c5a6
Fix Codacy
LinusDietz 4a6886e
Package refactoring, streamline naming
LinusDietz a5a2994
Also move tests
LinusDietz 37a247c
Merge branch 'master' of https://github.com/JabRef/jabref into commen…
LinusDietz 1e0d56e
Add Confirmation Dialog for Merging Fields
LinusDietz e949025
Localize Tests
LinusDietz c93b490
Fix tests
LinusDietz e405f67
Fix Codacy
LinusDietz 6cca4ab
fixed issue 298
grotepfn b7ca150
updated Changes
grotepfn 38750e8
Update CHANGELOG.md
grotepfn 2d2bb7e
User decides now once for all migrations.
LinusDietz dfeda8d
fix localization
LinusDietz 4828955
Merge pull request #3726 from grotepfn/patch-3
lenhard 5962710
Remove 'no' button
LinusDietz 4c1905d
Merge branch 'master' of https://github.com/JabRef/jabref into commen…
LinusDietz 38e6139
Merge branch 'comment-tab' of https://github.com/JabRef/jabref into c…
LinusDietz b246cfe
Mark Database as changed after the LoadDatabaseMigration
LinusDietz 303ed4d
Getters and Setters
LinusDietz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/org/jabref/logic/importer/util/RenameReviewToComment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.jabref.logic.importer.util; | ||
|
||
import java.util.Objects; | ||
|
||
import org.jabref.logic.importer.ParserResult; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.FieldName; | ||
|
||
public class RenameReviewToComment implements PostOpenAction { | ||
|
||
@Override | ||
public void performAction(ParserResult parserResult) { | ||
Objects.requireNonNull(parserResult); | ||
|
||
for (BibEntry entry : parserResult.getDatabase().getEntries()) { | ||
if (entry.getField(FieldName.REVIEW).isPresent()) { | ||
String review = entry.getField(FieldName.REVIEW).get(); | ||
review = concatCommentFieldIfPresent(entry, review); | ||
updateFields(entry, review); | ||
} | ||
} | ||
} | ||
|
||
private String concatCommentFieldIfPresent(BibEntry entry, String review) { | ||
if (entry.getField(FieldName.COMMENT).isPresent()) { | ||
String comment = entry.getField(FieldName.COMMENT).get().trim(); | ||
if (!comment.isEmpty()) { | ||
review = String.format("%s\nReview:\n%s", comment, review.trim()); | ||
} | ||
} | ||
|
||
return review; | ||
} | ||
|
||
private void updateFields(BibEntry entry, String review) { | ||
entry.setField(FieldName.COMMENT, review); | ||
entry.clearField(FieldName.REVIEW); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/test/java/org/jabref/logic/importer/util/RenameReviewToCommentTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.jabref.logic.importer.util; | ||
|
||
import java.util.Collections; | ||
|
||
import org.jabref.logic.importer.ParserResult; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.FieldName; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class RenameReviewToCommentTest { | ||
|
||
private RenameReviewToComment action; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
action = new RenameReviewToComment(); | ||
} | ||
|
||
@Test | ||
void noFields() { | ||
BibEntry entry = createMinimalBibEntry(); | ||
ParserResult actualParserResult = new ParserResult(Collections.singletonList(entry)); | ||
|
||
action.performAction(actualParserResult); | ||
|
||
assertEquals(entry, actualParserResult.getDatabase().getEntryByKey("Entry1").get()); | ||
} | ||
|
||
@Test | ||
void reviewField() { | ||
BibEntry actualEntry = createMinimalBibEntry(); | ||
actualEntry.setField(FieldName.REVIEW, "My Review"); | ||
ParserResult actualParserResult = new ParserResult(Collections.singletonList(actualEntry)); | ||
|
||
BibEntry expectedEntry = createMinimalBibEntry(); | ||
expectedEntry.setField(FieldName.COMMENT, "My Review"); | ||
|
||
action.performAction(actualParserResult); | ||
|
||
assertEquals(expectedEntry, actualParserResult.getDatabase().getEntryByKey("Entry1").get()); | ||
} | ||
|
||
@Test | ||
void commentField() { | ||
BibEntry entry = createMinimalBibEntry(); | ||
entry.setField(FieldName.COMMENT, "My Comment"); | ||
ParserResult actualParserResult = new ParserResult(Collections.singletonList(entry)); | ||
|
||
action.performAction(actualParserResult); | ||
|
||
assertEquals(entry, actualParserResult.getDatabase().getEntryByKey("Entry1").get()); | ||
} | ||
|
||
|
||
@Test | ||
void reviewAndCommentField() { | ||
BibEntry actualEntry = createMinimalBibEntry(); | ||
actualEntry.setField(FieldName.REVIEW, "My Review"); | ||
actualEntry.setField(FieldName.COMMENT, "My Comment"); | ||
|
||
ParserResult actualParserResult = new ParserResult(Collections.singletonList(actualEntry)); | ||
|
||
BibEntry expectedEntry = createMinimalBibEntry(); | ||
expectedEntry.setField(FieldName.COMMENT, "My Comment\nReview:\nMy Review"); | ||
|
||
action.performAction(actualParserResult); | ||
|
||
assertEquals(expectedEntry, actualParserResult.getDatabase().getEntryByKey("Entry1").get()); | ||
} | ||
|
||
private BibEntry createMinimalBibEntry() { | ||
BibEntry entry = new BibEntry(); | ||
entry.setCiteKey("Entry1"); | ||
entry.setField(FieldName.TITLE, "A random entry!"); | ||
entry.setField(FieldName.AUTHOR, "JabRef DEVELOPERS"); | ||
return entry; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you move the complete class into
org.jabref.migrations
? Because that's what it actually does, it migrates an opened bib file to a newer version of JabRef. I think it makes sense to bundle all this stuff in a dedicated package, because then it gets easier for us to see what sort of conversions are performed on open.While you're doing that, could you also move the
ConvertLegacyExplicitGroups
?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.
Done. I also renamed these actions to what they are: migrations