Skip to content

Commit 0e5c463

Browse files
calixtusSiedlerchr
andauthored
No sync of specialfields to keywords as default (#6846)
* Change default keyword syncing to not sync * Refactored to use SpecialFieldsPreferences and some Cleanups * CHANGELOG.md * Reworded and fixed some small cleanups * Update CHANGELOG.md Co-authored-by: Christoph <[email protected]>
1 parent 41ef812 commit 0e5c463

File tree

13 files changed

+144
-180
lines changed

13 files changed

+144
-180
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2121
- We restructured the 'File' tab and extracted some parts into the 'Linked files' tab [#6779](https://github.com/JabRef/jabref/pull/6779)
2222
- JabRef now offers journal lists from <https://abbrv.jabref.org>. JabRef the lists which use a dot inside the abbreviations. [#5749](https://github.com/JabRef/jabref/pull/5749)
2323
- We removed two useless preferences in the groups preferences dialog. [#6836](https://github.com/JabRef/jabref/pull/6836)
24+
- Synchronization of SpecialFields to keywords is now disabled by default. [#6621](https://github.com/JabRef/jabref/issues/6621)
2425
- JabRef no longer opens the entry editor with the first entry on startup [6855](https://github.com/JabRef/jabref/issues/6855)
2526

2627
### Fixed

src/main/java/org/jabref/gui/JabRefFrame.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@ private void initDragAndDrop() {
217217
}
218218
});
219219

220-
this.getScene().setOnDragExited(event -> {
221-
tabbedPane.getTabs().remove(dndIndicator);
222-
});
220+
this.getScene().setOnDragExited(event -> tabbedPane.getTabs().remove(dndIndicator));
223221

224222
this.getScene().setOnDragDropped(event -> {
225223
tabbedPane.getTabs().remove(dndIndicator);
@@ -791,7 +789,7 @@ private MenuBar createMenu() {
791789
factory.createMenuItem(StandardActions.MASS_SET_FIELDS, new MassSetFieldsAction(stateManager, dialogService, undoManager))
792790
);
793791

794-
if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
792+
if (Globals.prefs.getSpecialFieldsPreferences().isSpecialFieldsEnabled()) {
795793
edit.getItems().addAll(
796794
new SeparatorMenuItem(),
797795
// ToDo: SpecialField needs the active BasePanel to mark it as changed.
@@ -1032,7 +1030,7 @@ public void addParserResult(ParserResult parserResult, boolean focusPanel) {
10321030
} else {
10331031
// only add tab if DB is not already open
10341032
Optional<BasePanel> panel = getBasePanelList().stream()
1035-
.filter(p -> p.getBibDatabaseContext().getDatabasePath().equals(parserResult.getFile()))
1033+
.filter(p -> p.getBibDatabaseContext().getDatabasePath().equals(parserResult.getPath()))
10361034
.findFirst();
10371035

10381036
if (panel.isPresent()) {
@@ -1091,7 +1089,7 @@ public void updateAllTabTitles() {
10911089
Optional<Path> file = getBasePanelAt(i).getBibDatabaseContext().getDatabasePath();
10921090

10931091
if (file.isPresent()) {
1094-
if (!uniqPath.equals(file.get().getFileName()) && uniqPath.contains(File.separator)) {
1092+
if (!uniqPath.equals(file.get().getFileName().toString()) && uniqPath.contains(File.separator)) {
10951093
// remove filename
10961094
uniqPath = uniqPath.substring(0, uniqPath.lastIndexOf(File.separator));
10971095
tabbedPane.getTabs().get(i).setText(getBasePanelAt(i).getTabTitle() + " \u2014 " + uniqPath);

src/main/java/org/jabref/gui/edit/ManageKeywordsViewModel.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void saveChanges() {
105105
return;
106106
}
107107

108-
if (preferences.isKeywordSyncEnabled() && !keywordsToAdd.isEmpty()) {
108+
if (preferences.getSpecialFieldsPreferences().isKeywordSyncEnabled() && !keywordsToAdd.isEmpty()) {
109109
SpecialFieldsUtils.synchronizeSpecialFields(keywordsToAdd, keywordsToRemove);
110110
}
111111

@@ -125,11 +125,9 @@ private NamedCompound updateKeywords(List<BibEntry> entries, KeywordList keyword
125125

126126
// put keywords back
127127
Optional<FieldChange> change = entry.putKeywords(keywords, preferences.getKeywordDelimiter());
128-
if (change.isPresent()) {
129-
ce.addEdit(new UndoableFieldChange(change.get()));
130-
}
128+
change.ifPresent(fieldChange -> ce.addEdit(new UndoableFieldChange(fieldChange)));
131129

132-
if (preferences.isKeywordSyncEnabled()) {
130+
if (preferences.getSpecialFieldsPreferences().isKeywordSyncEnabled()) {
133131
SpecialFieldsUtils.syncSpecialFieldsFromKeywords(entry, preferences.getKeywordDelimiter());
134132
}
135133
}

src/main/java/org/jabref/gui/maintable/MainTable.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public MainTable(MainTableDataModel model,
107107
panel,
108108
dialogService,
109109
stateManager,
110-
preferencesService))
110+
preferencesService,
111+
Globals.clipboardManager))
111112
.setOnDragDetected(this::handleOnDragDetected)
112113
.setOnDragDropped(this::handleOnDragDropped)
113114
.setOnDragOver(this::handleOnDragOver)

src/main/java/org/jabref/gui/maintable/RightClickMenu.java

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import javafx.scene.control.SeparatorMenuItem;
66

77
import org.jabref.gui.BasePanel;
8+
import org.jabref.gui.ClipBoardManager;
89
import org.jabref.gui.DialogService;
910
import org.jabref.gui.Globals;
1011
import org.jabref.gui.SendAsEMailAction;
@@ -25,18 +26,23 @@
2526
import org.jabref.logic.citationstyle.CitationStylePreviewLayout;
2627
import org.jabref.logic.preview.PreviewLayout;
2728
import org.jabref.model.entry.field.SpecialField;
28-
import org.jabref.preferences.JabRefPreferences;
2929
import org.jabref.preferences.PreferencesService;
3030
import org.jabref.preferences.PreviewPreferences;
3131

3232
public class RightClickMenu {
3333

34-
public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingRepository keyBindingRepository, BasePanel panel, DialogService dialogService, StateManager stateManager, PreferencesService preferencesService) {
34+
public static ContextMenu create(BibEntryTableViewModel entry,
35+
KeyBindingRepository keyBindingRepository,
36+
BasePanel panel,
37+
DialogService dialogService,
38+
StateManager stateManager,
39+
PreferencesService preferencesService,
40+
ClipBoardManager clipBoardManager) {
3541
ContextMenu contextMenu = new ContextMenu();
3642
ActionFactory factory = new ActionFactory(keyBindingRepository);
3743

3844
contextMenu.getItems().add(factory.createMenuItem(StandardActions.COPY, new EditAction(StandardActions.COPY, panel.frame(), stateManager)));
39-
contextMenu.getItems().add(createCopySubMenu(panel, factory, dialogService, stateManager, preferencesService));
45+
contextMenu.getItems().add(createCopySubMenu(panel, factory, dialogService, stateManager, preferencesService, clipBoardManager));
4046
contextMenu.getItems().add(factory.createMenuItem(StandardActions.PASTE, new EditAction(StandardActions.PASTE, panel.frame(), stateManager)));
4147
contextMenu.getItems().add(factory.createMenuItem(StandardActions.CUT, new EditAction(StandardActions.CUT, panel.frame(), stateManager)));
4248
contextMenu.getItems().add(factory.createMenuItem(StandardActions.DELETE_ENTRY, new EditAction(StandardActions.DELETE_ENTRY, panel.frame(), stateManager)));
@@ -47,9 +53,7 @@ public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingReposit
4753

4854
contextMenu.getItems().add(new SeparatorMenuItem());
4955

50-
if (Globals.prefs.getBoolean(JabRefPreferences.SPECIALFIELDSENABLED)) {
51-
// ToDo: SpecialField needs the active BasePanel to mark it as changed.
52-
// Refactor BasePanel, should mark the BibDatabaseContext or the UndoManager as dirty instead!
56+
if (preferencesService.getSpecialFieldsPreferences().isSpecialFieldsEnabled()) {
5357
contextMenu.getItems().add(SpecialFieldMenuItemFactory.createSpecialFieldMenu(SpecialField.RANKING, factory, panel.frame(), dialogService, stateManager));
5458
contextMenu.getItems().add(SpecialFieldMenuItemFactory.getSpecialFieldSingleItem(SpecialField.RELEVANCE, factory, panel.frame(), dialogService, stateManager));
5559
contextMenu.getItems().add(SpecialFieldMenuItemFactory.getSpecialFieldSingleItem(SpecialField.QUALITY, factory, panel.frame(), dialogService, stateManager));
@@ -76,30 +80,35 @@ public static ContextMenu create(BibEntryTableViewModel entry, KeyBindingReposit
7680
return contextMenu;
7781
}
7882

79-
private static Menu createCopySubMenu(BasePanel panel, ActionFactory factory, DialogService dialogService, StateManager stateManager, PreferencesService preferencesService) {
83+
private static Menu createCopySubMenu(BasePanel panel,
84+
ActionFactory factory,
85+
DialogService dialogService,
86+
StateManager stateManager,
87+
PreferencesService preferencesService,
88+
ClipBoardManager clipBoardManager) {
8089
Menu copySpecialMenu = factory.createMenu(StandardActions.COPY_MORE);
81-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
82-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
83-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
84-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
85-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, Globals.clipboardManager, preferencesService)));
90+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_TITLE, new CopyMoreAction(StandardActions.COPY_TITLE, dialogService, stateManager, clipBoardManager, preferencesService)));
91+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY, new CopyMoreAction(StandardActions.COPY_KEY, dialogService, stateManager, clipBoardManager, preferencesService)));
92+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITE_KEY, new CopyMoreAction(StandardActions.COPY_CITE_KEY, dialogService, stateManager, clipBoardManager, preferencesService)));
93+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_TITLE, new CopyMoreAction(StandardActions.COPY_KEY_AND_TITLE, dialogService, stateManager, clipBoardManager, preferencesService)));
94+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_KEY_AND_LINK, new CopyMoreAction(StandardActions.COPY_KEY_AND_LINK, dialogService, stateManager, clipBoardManager, preferencesService)));
8695

8796
// the submenu will behave dependent on what style is currently selected (citation/preview)
8897
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences();
8998
PreviewLayout style = previewPreferences.getCurrentPreviewStyle();
9099
if (style instanceof CitationStylePreviewLayout) {
91-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_HTML, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
100+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_HTML, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, clipBoardManager, previewPreferences)));
92101
Menu copyCitationMenu = factory.createMenu(StandardActions.COPY_CITATION_MORE);
93-
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_TEXT, new CopyCitationAction(CitationStyleOutputFormat.TEXT, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
94-
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_RTF, new CopyCitationAction(CitationStyleOutputFormat.RTF, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
95-
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_ASCII_DOC, new CopyCitationAction(CitationStyleOutputFormat.ASCII_DOC, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
96-
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_XSLFO, new CopyCitationAction(CitationStyleOutputFormat.XSL_FO, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
102+
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_TEXT, new CopyCitationAction(CitationStyleOutputFormat.TEXT, dialogService, stateManager, clipBoardManager, previewPreferences)));
103+
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_RTF, new CopyCitationAction(CitationStyleOutputFormat.RTF, dialogService, stateManager, clipBoardManager, previewPreferences)));
104+
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_ASCII_DOC, new CopyCitationAction(CitationStyleOutputFormat.ASCII_DOC, dialogService, stateManager, clipBoardManager, previewPreferences)));
105+
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_XSLFO, new CopyCitationAction(CitationStyleOutputFormat.XSL_FO, dialogService, stateManager, clipBoardManager, previewPreferences)));
97106
copySpecialMenu.getItems().add(copyCitationMenu);
98107
} else {
99-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, Globals.clipboardManager, previewPreferences)));
108+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_PREVIEW, new CopyCitationAction(CitationStyleOutputFormat.HTML, dialogService, stateManager, clipBoardManager, previewPreferences)));
100109
}
101110

102-
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.EXPORT_TO_CLIPBOARD, new ExportToClipboardAction(panel, dialogService, Globals.exportFactory, Globals.clipboardManager, Globals.TASK_EXECUTOR)));
111+
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.EXPORT_TO_CLIPBOARD, new ExportToClipboardAction(panel, dialogService, Globals.exportFactory, clipBoardManager, Globals.TASK_EXECUTOR)));
103112
return copySpecialMenu;
104113
}
105114
}

src/main/java/org/jabref/gui/preferences/TableTabViewModel.java

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ public void setValues() {
120120
initialSpecialFieldsPreferences = preferences.getSpecialFieldsPreferences();
121121
MainTableNameFormatPreferences initialNameFormatPreferences = preferences.getMainTableNameFormatPreferences();
122122

123-
specialFieldsEnabledProperty.setValue(initialSpecialFieldsPreferences.getSpecialFieldsEnabled());
124-
specialFieldsSyncKeywordsProperty.setValue(initialSpecialFieldsPreferences.getAutoSyncSpecialFieldsToKeyWords());
125-
specialFieldsSerializeProperty.setValue(initialSpecialFieldsPreferences.getSerializeSpecialFields());
123+
specialFieldsEnabledProperty.setValue(initialSpecialFieldsPreferences.isSpecialFieldsEnabled());
124+
specialFieldsSyncKeywordsProperty.setValue(initialSpecialFieldsPreferences.shouldAutoSyncSpecialFieldsToKeyWords());
125+
specialFieldsSerializeProperty.setValue(initialSpecialFieldsPreferences.shouldSerializeSpecialFields());
126126
extraFileColumnsEnabledProperty.setValue(initialMainTablePreferences.getExtraFileColumnsEnabled());
127127
autoResizeColumnsProperty.setValue(initialMainTablePreferences.getResizeColumnsToFit());
128128

@@ -155,30 +155,16 @@ public void setValues() {
155155
}
156156

157157
switch (initialNameFormatPreferences.getDisplayStyle()) {
158-
case NATBIB:
159-
namesNatbibProperty.setValue(true);
160-
break;
161-
case AS_IS:
162-
nameAsIsProperty.setValue(true);
163-
break;
164-
case FIRSTNAME_LASTNAME:
165-
nameFirstLastProperty.setValue(true);
166-
break;
167-
case LASTNAME_FIRSTNAME:
168-
nameLastFirstProperty.setValue(true);
169-
break;
158+
case NATBIB -> namesNatbibProperty.setValue(true);
159+
case AS_IS -> nameAsIsProperty.setValue(true);
160+
case FIRSTNAME_LASTNAME -> nameFirstLastProperty.setValue(true);
161+
case LASTNAME_FIRSTNAME -> nameLastFirstProperty.setValue(true);
170162
}
171163

172164
switch (initialNameFormatPreferences.getAbbreviationStyle()) {
173-
case FULL:
174-
abbreviationEnabledProperty.setValue(true);
175-
break;
176-
case LASTNAME_ONLY:
177-
abbreviationLastNameOnlyProperty.setValue(true);
178-
break;
179-
case NONE:
180-
abbreviationDisabledProperty.setValue(true);
181-
break;
165+
case FULL -> abbreviationEnabledProperty.setValue(true);
166+
case LASTNAME_ONLY -> abbreviationLastNameOnlyProperty.setValue(true);
167+
case NONE -> abbreviationDisabledProperty.setValue(true);
182168
}
183169
}
184170

@@ -268,11 +254,11 @@ public void storeSettings() {
268254
specialFieldsSyncKeywordsProperty.getValue(),
269255
specialFieldsSerializeProperty.getValue());
270256

271-
if (initialSpecialFieldsPreferences.getAutoSyncSpecialFieldsToKeyWords() != newSpecialFieldsPreferences.getAutoSyncSpecialFieldsToKeyWords()) {
257+
if (initialSpecialFieldsPreferences.shouldAutoSyncSpecialFieldsToKeyWords() != newSpecialFieldsPreferences.shouldAutoSyncSpecialFieldsToKeyWords()) {
272258
restartWarnings.add(Localization.lang("Synchronize special fields to keywords"));
273259
}
274260

275-
if (initialSpecialFieldsPreferences.getSerializeSpecialFields() != newSpecialFieldsPreferences.getSerializeSpecialFields()) {
261+
if (initialSpecialFieldsPreferences.shouldSerializeSpecialFields() != newSpecialFieldsPreferences.shouldSerializeSpecialFields()) {
276262
restartWarnings.add(Localization.lang("Serialize special fields"));
277263
}
278264

0 commit comments

Comments
 (0)