-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create user specific comment field * User can make user-specific comments * User specific comment will not display in other fields * Refactor the code * Make changes * Force to make user specific comments * Fix error * Test if to show the other user's comments * Delete useless code * Add changes in CHANGELOG * Make changes only author can edit user specific comment * Specify the user specific comment does not belong to current user * Add test case for comments tab * Refactor code based on the feedback * Refactor tests about the CommentsTab * Add missing localization keys in the English language file. * Modify the failing checkstyle tests * Modify the order of import * Separate the UndoManager import * Make changes * Update the user specific comment field * Remove the dependency on the entry type for presence of comments * Change code for checkstyle * Additional logic to parseField to better handle user specific comment. * Fetch the username using PreferencesService to improve simplicity. * Merge "All-Comments" into tab "Comments" * Minor code beautification * Simplify tests (and add one more test) * Always list "Comment" field * Refine CHANGELOG entry * Remove tool tip (not containing much additional information) --------- Co-authored-by: Christoph <siedlerkiller@gmail.com> Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
- Loading branch information
1 parent
2a621f0
commit 76e2ce7
Showing
21 changed files
with
352 additions
and
23 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.jabref.gui.entryeditor; | ||
|
||
import java.util.LinkedHashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import org.jabref.gui.DialogService; | ||
import org.jabref.gui.StateManager; | ||
import org.jabref.gui.autocompleter.SuggestionProviders; | ||
import org.jabref.gui.fieldeditors.FieldEditorFX; | ||
import org.jabref.gui.icon.IconTheme; | ||
import org.jabref.gui.theme.ThemeManager; | ||
import org.jabref.gui.util.TaskExecutor; | ||
import org.jabref.logic.journals.JournalAbbreviationRepository; | ||
import org.jabref.logic.l10n.Localization; | ||
import org.jabref.logic.pdf.search.indexing.IndexingTaskManager; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.field.Field; | ||
import org.jabref.model.entry.field.StandardField; | ||
import org.jabref.model.entry.field.UserSpecificCommentField; | ||
import org.jabref.preferences.PreferencesService; | ||
|
||
public class CommentsTab extends FieldsEditorTab { | ||
public static final String NAME = "Comments"; | ||
|
||
private final String defaultOwner; | ||
public CommentsTab(PreferencesService preferences, | ||
BibDatabaseContext databaseContext, | ||
SuggestionProviders suggestionProviders, | ||
UndoManager undoManager, | ||
DialogService dialogService, | ||
StateManager stateManager, | ||
ThemeManager themeManager, | ||
IndexingTaskManager indexingTaskManager, | ||
TaskExecutor taskExecutor, | ||
JournalAbbreviationRepository journalAbbreviationRepository) { | ||
super( | ||
false, | ||
databaseContext, | ||
suggestionProviders, | ||
undoManager, | ||
dialogService, | ||
preferences, | ||
stateManager, | ||
themeManager, | ||
taskExecutor, | ||
journalAbbreviationRepository, | ||
indexingTaskManager | ||
); | ||
this.defaultOwner = preferences.getOwnerPreferences().getDefaultOwner(); | ||
setText(Localization.lang("Comments")); | ||
setGraphic(IconTheme.JabRefIcons.COMMENT.getGraphicNode()); | ||
} | ||
|
||
@Override | ||
protected Set<Field> determineFieldsToShow(BibEntry entry) { | ||
UserSpecificCommentField defaultCommentField = new UserSpecificCommentField(defaultOwner); | ||
|
||
// As default: Show BibTeX comment field and the user-specific comment field of the default owner | ||
Set<Field> comments = new LinkedHashSet<>(Set.of(defaultCommentField, StandardField.COMMENT)); | ||
|
||
comments.addAll(entry.getFields().stream() | ||
.filter(field -> field instanceof UserSpecificCommentField || | ||
field.getName().toLowerCase().contains("comment")) | ||
.collect(Collectors.toSet())); | ||
|
||
return comments; | ||
} | ||
|
||
@Override | ||
protected void setupPanel(BibEntry entry, boolean compressed) { | ||
super.setupPanel(entry, compressed); | ||
|
||
for (Map.Entry<Field, FieldEditorFX> fieldEditorEntry : editors.entrySet()) { | ||
Field field = fieldEditorEntry.getKey(); | ||
FieldEditorFX editor = fieldEditorEntry.getValue(); | ||
|
||
if (field instanceof UserSpecificCommentField) { | ||
if (field.getName().contains(defaultOwner)) { | ||
editor.getNode().setDisable(false); | ||
} | ||
} else { | ||
editor.getNode().setDisable(!field.getName().equals(StandardField.COMMENT.getName())); | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,5 +23,6 @@ public enum FieldProperty { | |
SINGLE_ENTRY_LINK, | ||
TYPE, | ||
VERBATIM, | ||
YES_NO | ||
YES_NO, | ||
COMMENT | ||
} |
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
Oops, something went wrong.