Skip to content

Commit

Permalink
Remove obsolete "Comments" tab configuration (JabRef#11011)
Browse files Browse the repository at this point in the history
* Remove obsolete "Comments" tab configuration

* Fix typo

* Add migration

* Add version info

---------

Co-authored-by: Carl Christian Snethlage <[email protected]>
  • Loading branch information
koppor and calixtus authored Mar 12, 2024
1 parent 6f57cfe commit 85b3a76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
13 changes: 12 additions & 1 deletion src/main/java/org/jabref/migrations/PreferencesMigrations.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import javafx.scene.control.TableColumn;

import org.jabref.gui.entryeditor.CommentsTab;
import org.jabref.gui.entryeditor.EntryEditor;
import org.jabref.gui.maintable.ColumnPreferences;
import org.jabref.gui.maintable.MainTableColumnModel;
import org.jabref.logic.citationkeypattern.GlobalCitationKeyPattern;
Expand Down Expand Up @@ -57,13 +59,14 @@ public static void runMigrations(JabRefPreferences preferences, BibEntryTypesMan
addCrossRefRelatedFieldsForAutoComplete(preferences);
upgradePreviewStyle(preferences);
// changeColumnVariableNamesFor51 needs to be run before upgradeColumnPre50Preferences to ensure
// backwardcompatibility, as it copies the old values to new variable names and keeps th old sored with the old
// backward compatibility, as it copies the old values to new variable names and keeps th old sored with the old
// variable names. However, the variables from 5.0 need to be copied to the new variable name too.
changeColumnVariableNamesFor51(preferences);
upgradeColumnPreferences(preferences);
restoreVariablesForBackwardCompatibility(preferences);
upgradeCleanups(preferences);
moveApiKeysToKeyring(preferences);
removeCommentsFromCustomEditorTabs(preferences);
}

/**
Expand Down Expand Up @@ -545,4 +548,12 @@ static void moveApiKeysToKeyring(JabRefPreferences preferences) {
}
}
}

/**
* The tab "Comments" is hard coded using {@link CommentsTab} since v5.10 (and thus hard-wired in {@link EntryEditor#createTabs()}.
* Thus, the configuration ih the preferences is obsolete
*/
static void removeCommentsFromCustomEditorTabs(JabRefPreferences preferences) {
preferences.getEntryEditorPreferences().getEntryEditorTabs().remove("Comments");
}
}
11 changes: 4 additions & 7 deletions src/main/java/org/jabref/preferences/JabRefPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.SequencedMap;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
Expand Down Expand Up @@ -835,10 +836,6 @@ public void setLanguageDependentDefaultValues() {
defaults.put(CUSTOM_TAB_FIELDS + "_def1", StandardField.ABSTRACT.getName());
defaults.put(CUSTOM_TAB_NAME + "_def1", Localization.lang("Abstract"));

// Entry editor tab 2: Comments Field - used for research comments, etc.
defaults.put(CUSTOM_TAB_FIELDS + "_def2", StandardField.COMMENT.getName());
defaults.put(CUSTOM_TAB_NAME + "_def2", Localization.lang("Comments"));

defaults.put(EMAIL_SUBJECT, Localization.lang("References"));
}

Expand Down Expand Up @@ -1508,7 +1505,7 @@ private Map<String, Set<Field>> getEntryEditorTabs() {
List<String> tabFields = getSeries(CUSTOM_TAB_FIELDS);

if (tabNames.isEmpty() || (tabNames.size() != tabFields.size())) {
// Nothing set, so we use the default values
// Nothing set (or wrong configuration), then we use default values
tabNames = getSeries(CUSTOM_TAB_NAME + "_def");
tabFields = getSeries(CUSTOM_TAB_FIELDS + "_def");
}
Expand Down Expand Up @@ -1543,8 +1540,8 @@ private void storeEntryEditorTabs(Map<String, Set<Field>> customTabs) {
getEntryEditorTabs();
}

private Map<String, Set<Field>> getDefaultEntryEditorTabs() {
Map<String, Set<Field>> customTabsMap = new LinkedHashMap<>();
private SequencedMap<String, Set<Field>> getDefaultEntryEditorTabs() {
SequencedMap<String, Set<Field>> customTabsMap = new LinkedHashMap<>();

int defNumber = 0;
while (true) {
Expand Down

0 comments on commit 85b3a76

Please sign in to comment.