-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add value selection(like for month) for custom fields (#11162)
* Add editor class for custom fields to enable value selection from a dropdown * resolve conflicts with CHANGELOG.md * fix formatting in FieldEditors and remove contributor name in CHANGELOG * Update CHANGELOG.md --------- Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
- Loading branch information
1 parent
1ee1add
commit 6e6523f
Showing
5 changed files
with
45 additions
and
2 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
39 changes: 39 additions & 0 deletions
39
src/main/java/org/jabref/gui/fieldeditors/CustomFieldEditorViewModel.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.gui.fieldeditors; | ||
|
||
import java.util.List; | ||
|
||
import javax.swing.undo.UndoManager; | ||
|
||
import org.jabref.gui.autocompleter.SuggestionProvider; | ||
import org.jabref.logic.integrity.FieldCheckers; | ||
import org.jabref.model.database.BibDatabaseContext; | ||
import org.jabref.model.entry.field.Field; | ||
|
||
import com.google.common.collect.BiMap; | ||
import com.google.common.collect.HashBiMap; | ||
|
||
public class CustomFieldEditorViewModel extends MapBasedEditorViewModel<String> { | ||
|
||
private BiMap<String, String> itemMap; | ||
|
||
public CustomFieldEditorViewModel(Field field, SuggestionProvider<?> suggestionProvider, | ||
FieldCheckers fieldCheckers, UndoManager undoManager, BibDatabaseContext databaseContext) { | ||
super(field, suggestionProvider, fieldCheckers, undoManager); | ||
|
||
List<String> values = databaseContext.getMetaData().getContentSelectorValuesForField(field); | ||
itemMap = HashBiMap.create(values.size()); | ||
for (String value : values) { | ||
itemMap.put(value, value); | ||
} | ||
} | ||
|
||
@Override | ||
protected BiMap<String, String> getItemMap() { | ||
return itemMap; | ||
} | ||
|
||
@Override | ||
public String convertToDisplayText(String object) { | ||
return object; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -26,5 +26,6 @@ public enum FieldProperty { | |
TYPE, | ||
VERBATIM, | ||
YES_NO, | ||
COMMENT | ||
COMMENT, | ||
CUSTOM_FIELD | ||
} |
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