From b02433b34b8384be1b090fdf8301d187ba9701db Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 14 May 2017 14:23:17 +0200 Subject: [PATCH] Fix empty entry editor --- .../org/jabref/gui/entryeditor/EntryEditor.java | 14 +++++++------- .../org/jabref/gui/entryeditor/EntryEditorTab.java | 4 +++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 826e3cac1cb..f4d1de6e529 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -219,7 +219,7 @@ public class EntryEditor extends JPanel implements EntryContainer { public EntryEditor(JabRefFrame frame, BasePanel panel, BibEntry entry) { this.frame = frame; this.panel = panel; - this.entry = entry; + this.entry = Objects.requireNonNull(entry); entry.registerListener(this); entry.registerListener(SpecialFieldUpdateListener.getInstance()); @@ -293,7 +293,7 @@ private void setupFieldPanels() { // Add tabs EntryEditorTab optPan2 = new EntryEditorTab(frame, panel, optionalFieldsNotPrimaryOrDeprecated, this, - false, true, Localization.lang("Optional fields 2")); + false, true, Localization.lang("Optional fields 2"), entry); tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan2.getPane(), Localization.lang("Show optional fields")); tabs.add(optPan2); @@ -301,7 +301,7 @@ private void setupFieldPanels() { if (!usedOptionalFieldsDeprecated.isEmpty()) { EntryEditorTab optPan3; optPan3 = new EntryEditorTab(frame, panel, new ArrayList<>(usedOptionalFieldsDeprecated), this, - false, true, Localization.lang("Deprecated fields")); + false, true, Localization.lang("Deprecated fields"), entry); tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan3.getPane(), Localization.lang("Show deprecated BibTeX fields")); tabs.add(optPan3); @@ -346,7 +346,7 @@ private void addGeneralTabs() { EntryEditorTabList tabList = Globals.prefs.getEntryEditorTabList(); for (int i = 0; i < tabList.getTabCount(); i++) { EntryEditorTab newTab = new EntryEditorTab(frame, panel, tabList.getTabFields(i), this, false, - false, tabList.getTabName(i)); + false, tabList.getTabName(i), entry); tabbed.addTab(tabList.getTabName(i), newTab.getPane()); tabs.add(newTab); } @@ -381,7 +381,7 @@ private void addSourceTab() { private void addOtherTab(List otherFields) { EntryEditorTab otherPanel = new EntryEditorTab(frame, panel, otherFields, this, - false, false, Localization.lang("Other fields")); + false, false, Localization.lang("Other fields"), entry); tabbed.addTab(Localization.lang("Other fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), otherPanel .getPane(), Localization.lang("Show remaining fields")); tabs.add(otherPanel); @@ -391,7 +391,7 @@ private List addRequiredTab(EntryType type) { List requiredFields = type.getRequiredFieldsFlat(); EntryEditorTab requiredPanel = new EntryEditorTab(frame, panel, requiredFields, this, true, false, - Localization.lang("Required fields")); + Localization.lang("Required fields"), entry); tabbed.addTab(Localization.lang("Required fields"), IconTheme.JabRefIcon.REQUIRED.getSmallIcon(), requiredPanel .getPane(), Localization.lang("Show required fields")); tabs.add(requiredPanel); @@ -422,7 +422,7 @@ private void addRelatedArticlesTab() { private void addOptionalTab(EntryType type) { EntryEditorTab optionalPanel = new EntryEditorTab(frame, panel, type.getPrimaryOptionalFields(), this, - false, true, Localization.lang("Optional fields")); + false, true, Localization.lang("Optional fields"), entry); tabbed.addTab(Localization.lang("Optional fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optionalPanel.getPane(), Localization.lang("Show optional fields")); tabs.add(optionalPanel); diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java index 52050cd0e68..ea20743f872 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditorTab.java @@ -10,6 +10,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.stream.Stream; @@ -67,7 +68,8 @@ class EntryEditorTab { public EntryEditorTab(JabRefFrame frame, BasePanel basePanel, List fields, EntryEditor parent, - boolean addKeyField, boolean compressed, String tabTitle) { + boolean addKeyField, boolean compressed, String tabTitle, BibEntry entry) { + this.entry = Objects.requireNonNull(entry); if (fields == null) { this.fields = new ArrayList<>(); } else {