Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete "Comments" tab configuration #11011

Merged
merged 4 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading