From 3777474a64b0bd8c30015e31ea8a8fe22d3b2cff Mon Sep 17 00:00:00 2001 From: grimes2 Date: Tue, 27 Sep 2016 13:04:11 +0200 Subject: [PATCH 1/3] Other fields changes --- CHANGELOG.md | 2 ++ .../jabref/gui/entryeditor/EntryEditor.java | 32 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c96981eb269..e41bea0b7dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - [#1779](https://github.com/JabRef/jabref/issues/1779) Implemented integrity check for `bibtexkey` field: Empty BibTeX key - Prohibit more than one connections to the same shared database. - Implemented integrity check for `journaltitle` field: BibLaTeX field only (BibTeX) +- Added all BibLaTeX fields to `other fields` (BibTeX) ### Fixed - Fixed [#2054](https://github.com/JabRef/jabref/issues/2054): Ignoring a new version now works as expected @@ -81,6 +82,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - 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. +- Removed optional fields from `other fields` (BibTeX), Removed deprecated fields from `other fields` (BibLaTeX) 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 60d24ddd85c..04598fe64aa 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; @@ -229,16 +228,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()); @@ -246,7 +250,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(); @@ -263,7 +266,6 @@ private void setupFieldPanels() { } // Get all optional fields which are deprecated - Set usedOptionalFieldsDeprecated = new HashSet<>(deprecatedFields); usedOptionalFieldsDeprecated.retainAll(optionalFieldsAndAliases); // Add tabs @@ -272,8 +274,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()) { @@ -283,16 +285,24 @@ 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()); + EntryType biblatextype = EntryTypes.getTypeOrDefault(entry.getType(), BibDatabaseMode.BIBLATEX); + List displayedFields = type.getAllFields().stream().map(String::toLowerCase) + .collect(Collectors.toList()); + List otherFields = biblatextype.getAllFields().stream().map(String::toLowerCase) + .filter(f -> !displayedFields.contains(f)).collect(Collectors.toList()); + otherFields.addAll(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()); From 0c704cb563f502299bb9a43617e991e4b1287193 Mon Sep 17 00:00:00 2001 From: grimes2 Date: Fri, 30 Sep 2016 01:56:28 +0200 Subject: [PATCH 2/3] Fix other fields --- CHANGELOG.md | 2 +- .../java/net/sf/jabref/gui/BasePanel.java | 26 +++++-------------- .../jabref/gui/entryeditor/EntryEditor.java | 5 +--- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5cd0aae6d3..5cf2f855118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,7 +53,6 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - [#463](https://github.com/JabRef/jabref/issues/463): Disable certain menu items, toolbar buttons and context menu items while multiple entries are selected - [#490](https://github.com/JabRef/jabref/issues/490) Added right click menu to main table and entry editor to allow copying doi url - [#549](https://github.com/JabRef/jabref/issues/549) Added new shortcut to copy the BibTeX key as a hyperlink to its url to the clipboard -- Added all BibLaTeX fields to `other fields` (BibTeX) ### Fixed - Fixed [koppor#160](https://github.com/koppor/jabref/issues/160): Tooltips now working in the main table @@ -82,6 +81,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Fixed [#1958](https://github.com/JabRef/jabref/issues/1958): Verbatim fields are no longer checked for HTML encoded characters by integrity checks - Fixed [#1937](https://github.com/JabRef/jabref/issues/1937): If no help page for the current chosen language exists, the english help page will be shown - Fixed [#2060](https://github.com/JabRef/jabref/issues/2060): Medline fetcher now imports data in UTF-8 encoding +- 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 diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index 0e5a7002d3a..6c3f939ba2b 100644 --- a/src/main/java/net/sf/jabref/gui/BasePanel.java +++ b/src/main/java/net/sf/jabref/gui/BasePanel.java @@ -1658,28 +1658,14 @@ 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 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); - 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); - } + entryEditors.put(entry.getType(), entryEditor); return entryEditor; } 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 10771153a94..03147d63f4c 100644 --- a/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/net/sf/jabref/gui/entryeditor/EntryEditor.java @@ -290,13 +290,10 @@ private void setupFieldPanels() { } // other fields - EntryType biblatextype = EntryTypes.getTypeOrDefault(entry.getType(), BibDatabaseMode.BIBLATEX); List displayedFields = type.getAllFields().stream().map(String::toLowerCase) .collect(Collectors.toList()); - List otherFields = biblatextype.getAllFields().stream().map(String::toLowerCase) + List otherFields = entry.getFieldNames().stream().map(String::toLowerCase) .filter(f -> !displayedFields.contains(f)).collect(Collectors.toList()); - otherFields.addAll(entry.getFieldNames().stream().map(String::toLowerCase) - .filter(f -> !displayedFields.contains(f)).collect(Collectors.toList())); if (!usedOptionalFieldsDeprecated.isEmpty()) { otherFields.removeAll(usedOptionalFieldsDeprecated); } From 7313f14d828a67bb5dd78e1c91ed379e9d0a59ed Mon Sep 17 00:00:00 2001 From: grimes2 Date: Mon, 3 Oct 2016 09:03:35 +0200 Subject: [PATCH 3/3] Entry editors cache removed --- .../java/net/sf/jabref/gui/BasePanel.java | 44 +++---------------- .../jabref/gui/EntryCustomizationDialog.java | 3 -- .../sf/jabref/gui/GenFieldsCustomizer.java | 1 - .../java/net/sf/jabref/gui/JabRefFrame.java | 8 ---- .../gui/preftabs/EntryEditorPrefsTab.java | 13 ------ .../gui/preftabs/PreferencesDialog.java | 1 - .../migrations/FileLinksUpgradeWarning.java | 1 - 7 files changed, 7 insertions(+), 64 deletions(-) diff --git a/src/main/java/net/sf/jabref/gui/BasePanel.java b/src/main/java/net/sf/jabref/gui/BasePanel.java index 6c3f939ba2b..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 { @@ -1659,13 +1641,12 @@ public void showEntry(final BibEntry be) { public EntryEditor getEntryEditor(BibEntry entry) { EntryEditor entryEditor; - // We must instantiate a new editor for this type. First make sure the old one + // 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); - entryEditors.put(entry.getType(), entryEditor); return entryEditor; } @@ -1795,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; @@ -2420,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/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(); }