diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e85b7874b..1fdc5a4a25b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,12 +86,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Fixed [#2060](https://github.com/JabRef/jabref/issues/2060): Medline fetcher now imports data in UTF-8 encoding - Fixed file menu displays wrong hotkey in the German translation - Fixed [#2090](https://github.com/JabRef/jabref/issues/#2090): If special fields were not selected, two menu item separator were shown +- Fixed [#2064](https://github.com/JabRef/jabref/issues/2064): Not all `other fields` are shown on entry change of same type ### Removed - Removed 2nd preview style - The non-supported feature of being able to define file directories for any extension is removed. Still, it should work for older databases using the legacy `ps` and `pdf` fields, although we strongly encourage using the `file` field. - Automatic migration for the `evastar_pdf` field is removed. - We removed the customizable "content selectors" since they are replaced by the auto-completion feature +- Removed optional fields from `other fields` (BibTeX), Removed deprecated fields from `other fields` (BibLaTeX) diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index 0e5a7002d3a..d3bba981a85 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -195,8 +195,6 @@ public class BasePanel extends JPanel implements ClipboardOwner, FileUpdateListe // Variable to prevent erroneous update of back/forward histories at the time // when a Back or Forward operation is being processed: private boolean backOrForwardInProgress; - // To indicate which entry is currently shown. - private final Map entryEditors = new HashMap<>(); // in switching between entries. private PreambleEditor preambleEditor; @@ -1487,10 +1485,6 @@ public void setupMainPanel() { createMainTable(); - for (EntryEditor ee : entryEditors.values()) { - ee.validateAllFields(); - } - splitPane.setTopComponent(mainTable.getPane()); // Remove borders @@ -1619,25 +1613,13 @@ public void showEntry(final BibEntry be) { divLoc = splitPane.getDividerLocation(); } - if (entryEditors.containsKey(be.getType())) { - // We already have an editor for this entry type. - entryEditor = entryEditors.get(be.getType()); - entryEditor.switchTo(be); - if (visName != null) { - entryEditor.setVisiblePanel(visName); - } - splitPane.setBottomComponent(entryEditor); - } else { - // We must instantiate a new editor for this type. - entryEditor = new EntryEditor(frame, BasePanel.this, be); - if (visName != null) { - entryEditor.setVisiblePanel(visName); - } - splitPane.setBottomComponent(entryEditor); - - entryEditors.put(be.getType(), entryEditor); - + // We must instantiate a new editor. + entryEditor = new EntryEditor(frame, BasePanel.this, be); + if (visName != null) { + entryEditor.setVisiblePanel(visName); } + splitPane.setBottomComponent(entryEditor); + if (divLoc > 0) { splitPane.setDividerLocation(divLoc); } else { @@ -1658,28 +1640,13 @@ public void showEntry(final BibEntry be) { */ public EntryEditor getEntryEditor(BibEntry entry) { EntryEditor entryEditor; - if (entryEditors.containsKey(entry.getType())) { - EntryEditor visibleNow = currentEditor; - // We already have an editor for this entry type. - entryEditor = entryEditors.get(entry.getType()); - - // If the cached editor is not the same as the currently shown one, - // make sure the current one stores its current edit: - if ((visibleNow != null) && (!(entryEditor.equals(visibleNow)))) { - visibleNow.storeCurrentEdit(); - } + // We must instantiate a new editor. First make sure the old one + // stores its last edit: + storeCurrentEdit(); + // Then start the new one: + entryEditor = new EntryEditor(frame, BasePanel.this, entry); - entryEditor.switchTo(entry); - } else { - // We must instantiate a new editor for this type. First make sure the old one - // stores its last edit: - storeCurrentEdit(); - // Then start the new one: - entryEditor = new EntryEditor(frame, BasePanel.this, entry); - - entryEditors.put(entry.getType(), entryEditor); - } return entryEditor; } @@ -1809,13 +1776,6 @@ public void storeCurrentEdit() { } } - public void rebuildAllEntryEditors() { - for (Map.Entry stringEntryEditorEntry : entryEditors.entrySet()) { - EntryEditor ed = stringEntryEditorEntry.getValue(); - ed.rebuildPanels(); - } - } - public void markBaseChanged() { baseChanged = true; @@ -2434,10 +2394,6 @@ public MainTable getMainTable() { return mainTable; } - public Map getEntryEditors() { - return entryEditors; - } - public BibDatabaseContext getDatabaseContext() { return bibDatabaseContext; } diff --git a/src/main/java/net/sf/jabref/gui/EntryCustomizationDialog.java b/src/main/java/net/sf/jabref/gui/EntryCustomizationDialog.java index 25964c1a652..601e16169ea 100644 --- a/src/main/java/net/sf/jabref/gui/EntryCustomizationDialog.java +++ b/src/main/java/net/sf/jabref/gui/EntryCustomizationDialog.java @@ -379,9 +379,6 @@ public void actionPerformed(ActionEvent e) { private void updateTypesForEntries(String typeName) { for (BasePanel bp : frame.getBasePanelList()) { - // Invalidate associated cached entry editor - bp.getEntryEditors().remove(typeName); - for (BibEntry entry : bp.getDatabase().getEntries()) { EntryTypes.getType(entry.getType(), bibDatabaseMode).ifPresent(entry::setType); } diff --git a/src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java b/src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java index 38ac080a637..cbee03605c2 100644 --- a/src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java +++ b/src/main/java/net/sf/jabref/gui/GenFieldsCustomizer.java @@ -139,7 +139,6 @@ private void okActionPerformed() { Globals.prefs.purgeSeries(JabRefPreferences.CUSTOM_TAB_FIELDS, i); Globals.prefs.updateEntryEditorTabList(); - parentFrame.removeCachedEntryEditors(); dispose(); } diff --git a/src/main/java/net/sf/jabref/gui/JabRefFrame.java b/src/main/java/net/sf/jabref/gui/JabRefFrame.java index 8399712e750..42f50fa6445 100644 --- a/src/main/java/net/sf/jabref/gui/JabRefFrame.java +++ b/src/main/java/net/sf/jabref/gui/JabRefFrame.java @@ -543,7 +543,6 @@ public void actionPerformed(ActionEvent evt) { // update all elements in current base panel JabRefFrame.this.getCurrentBasePanel().hideBottomComponent(); - JabRefFrame.this.getCurrentBasePanel().rebuildAllEntryEditors(); JabRefFrame.this.getCurrentBasePanel().updateEntryEditorIfShowing(); } @@ -1817,13 +1816,6 @@ public FileHistoryMenu getFileHistory() { return fileHistory; } - public void removeCachedEntryEditors() { - for (int j = 0; j < tabbedPane.getTabCount(); j++) { - BasePanel bp = (BasePanel) tabbedPane.getComponentAt(j); - bp.getEntryEditors().clear(); - } - } - /** * This method shows a wait cursor and blocks all input to the JFrame's contents. */ diff --git a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java index 5e5a55567b1..03147d63f4c 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -25,7 +25,6 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; -import java.util.stream.Stream; import javax.swing.AbstractAction; import javax.swing.Action; @@ -226,16 +225,21 @@ private void setupFieldPanels() { tabbed.removeAll(); tabs.clear(); - EntryType type = EntryTypes.getTypeOrDefault(entry.getType(), this.frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); + EntryType type = EntryTypes.getTypeOrDefault(entry.getType(), + this.frame.getCurrentBasePanel().getBibDatabaseContext().getMode()); // required fields - List requiredFields = addRequiredTab(type); + addRequiredTab(type); // optional fields List displayedOptionalFields = new ArrayList<>(); + Set deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet()); + Set usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields); if ((type.getOptionalFields() != null) && !type.getOptionalFields().isEmpty()) { if (!frame.getCurrentBasePanel().getBibDatabaseContext().isBiblatexMode()) { + displayedOptionalFields.addAll(type.getOptionalFields()); + addOptionalTab(type); } else { displayedOptionalFields.addAll(type.getPrimaryOptionalFields()); @@ -243,7 +247,6 @@ private void setupFieldPanels() { addOptionalTab(type); - Set deprecatedFields = new HashSet<>(EntryConverter.FIELD_ALIASES_TEX_TO_LTX.keySet()); deprecatedFields.add(FieldName.YEAR); deprecatedFields.add(FieldName.MONTH); List secondaryOptionalFields = type.getSecondaryOptionalFields(); @@ -260,7 +263,6 @@ private void setupFieldPanels() { } // Get all optional fields which are deprecated - Set usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields); usedOptionalFieldsDeprecated.retainAll(optionalFieldsAndAliases); // Add tabs @@ -269,8 +271,8 @@ private void setupFieldPanels() { if (optPan2.fileListEditor != null) { fileListEditor = optPan2.fileListEditor; } - tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan2 - .getPane(), Localization.lang("Show optional fields")); + tabbed.addTab(Localization.lang("Optional fields 2"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), + optPan2.getPane(), Localization.lang("Show optional fields")); tabs.add(optPan2); if (!usedOptionalFieldsDeprecated.isEmpty()) { @@ -280,16 +282,21 @@ private void setupFieldPanels() { if (optPan3.fileListEditor != null) { fileListEditor = optPan3.fileListEditor; } - tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), optPan3 - .getPane(), Localization.lang("Show deprecated BibTeX fields")); + tabbed.addTab(Localization.lang("Deprecated fields"), IconTheme.JabRefIcon.OPTIONAL.getSmallIcon(), + optPan3.getPane(), Localization.lang("Show deprecated BibTeX fields")); tabs.add(optPan3); } } } // other fields - List displayedFields = Stream.concat(requiredFields.stream(), displayedOptionalFields.stream()).map(String::toLowerCase).collect(Collectors.toList()); - List otherFields = entry.getFieldNames().stream().map(String::toLowerCase).filter(f -> !displayedFields.contains(f)).collect(Collectors.toList()); + List displayedFields = type.getAllFields().stream().map(String::toLowerCase) + .collect(Collectors.toList()); + List otherFields = entry.getFieldNames().stream().map(String::toLowerCase) + .filter(f -> !displayedFields.contains(f)).collect(Collectors.toList()); + if (!usedOptionalFieldsDeprecated.isEmpty()) { + otherFields.removeAll(usedOptionalFieldsDeprecated); + } otherFields.remove(BibEntry.KEY_FIELD); otherFields.removeAll(Globals.prefs.getCustomTabFieldNames()); diff --git a/src/main/java/net/sf/jabref/gui/preftabs/EntryEditorPrefsTab.java b/src/main/java/net/sf/jabref/gui/preftabs/EntryEditorPrefsTab.java index b2f0bf789d2..630517f773e 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/EntryEditorPrefsTab.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/EntryEditorPrefsTab.java @@ -13,7 +13,6 @@ import javax.swing.JTextField; import javax.swing.SpinnerNumberModel; -import net.sf.jabref.gui.BasePanel; import net.sf.jabref.gui.JabRefFrame; import net.sf.jabref.gui.keyboard.EmacsKeyBindings; import net.sf.jabref.logic.autocompleter.AutoCompleteFirstNameMode; @@ -250,18 +249,6 @@ else if (autoCompFF.isSelected()) { } else { autoCompletePreferences.setFirstnameMode(AutoCompleteFirstNameMode.BOTH); } - - // We need to remove all entry editors from cache if the source panel setting - // or the autocompletion settings have been changed: - if ((oldAutoComplete != autoComplete.isSelected()) - || !oldAutoCompFields.equals(autoCompFields.getText()) || - (oldAutoCompFF != autoCompFF.isSelected()) || (oldAutoCompLF != autoCompLF.isSelected()) || - (oldAutoCompFModeAbbr != firstNameModeAbbr.isSelected()) || - (oldAutoCompFModeFull != firstNameModeFull.isSelected())) { - for (BasePanel panel : frame.getBasePanelList()) { - panel.getEntryEditors().clear(); - } - } } @Override diff --git a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java index b4deeb113d8..ca8d5476c47 100644 --- a/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java +++ b/src/main/java/net/sf/jabref/gui/preftabs/PreferencesDialog.java @@ -226,7 +226,6 @@ private void updateAfterPreferenceChanges() { SavePreferences savePreferences = SavePreferences.loadForExportFromPreferences(Globals.prefs); ExportFormats.initAllExports(customFormats, layoutPreferences, savePreferences); - frame.removeCachedEntryEditors(); Globals.prefs.updateEntryEditorTabList(); } diff --git a/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java b/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java index 42a62634049..529b4056f28 100644 --- a/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java +++ b/src/main/java/net/sf/jabref/migrations/FileLinksUpgradeWarning.java @@ -207,7 +207,6 @@ private void makeChanges(BasePanel panel, ParserResult pr, boolean upgradePrefs, sb.append(FieldName.FILE); Globals.prefs.put(JabRefPreferences.CUSTOM_TAB_FIELDS + "0", sb.toString()); Globals.prefs.updateEntryEditorTabList(); - panel.frame().removeCachedEntryEditors(); } panel.frame().setupAllTables(); }