Skip to content

Commit 84758a7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into convertSearchWorker
* upstream/master: Bump com.gradle.build-scan from 2.2.1 to 2.3 (#4957) Rework preview logic. Fixes #4923 (#4951) # Conflicts: # src/main/java/org/jabref/gui/BasePanel.java # src/main/java/org/jabref/gui/PreviewPanel.java
2 parents d99edc7 + c168c49 commit 84758a7

21 files changed

+585
-197
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ buildscript {
1616
}
1717

1818
plugins {
19-
id 'com.gradle.build-scan' version '2.2.1'
19+
id 'com.gradle.build-scan' version '2.3'
2020
id 'com.install4j.gradle' version '7.0.11'
2121
id 'com.github.johnrengelman.shadow' version '5.0.0'
2222
id "com.simonharrer.modernizer" version '1.6.0-1'

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

+11-18
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
import org.jabref.gui.maintable.MainTableDataModel;
5959
import org.jabref.gui.mergeentries.MergeEntriesAction;
6060
import org.jabref.gui.mergeentries.MergeWithFetchedEntryAction;
61+
import org.jabref.gui.preview.CitationStyleToClipboardWorker;
62+
import org.jabref.gui.preview.PreviewPanel;
6163
import org.jabref.gui.specialfields.SpecialFieldDatabaseChangeListener;
6264
import org.jabref.gui.specialfields.SpecialFieldValueViewModel;
6365
import org.jabref.gui.specialfields.SpecialFieldViewModel;
@@ -67,7 +69,6 @@
6769
import org.jabref.gui.undo.UndoableInsertEntry;
6870
import org.jabref.gui.undo.UndoableRemoveEntry;
6971
import org.jabref.gui.util.DefaultTaskExecutor;
70-
import org.jabref.gui.worker.CitationStyleToClipboardWorker;
7172
import org.jabref.gui.worker.SendAsEMailAction;
7273
import org.jabref.logic.citationstyle.CitationStyleCache;
7374
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
@@ -130,30 +131,25 @@ public class BasePanel extends StackPane {
130131
private final ExternalFileTypes externalFileTypes;
131132

132133
private final EntryEditor entryEditor;
134+
private final DialogService dialogService;
133135
private MainTable mainTable;
134136
// To contain instantiated entry editors. This is to save time
135137
// As most enums, this must not be null
136138
private BasePanelMode mode = BasePanelMode.SHOWING_NOTHING;
137139
private SplitPane splitPane;
138140
private DatabaseChangePane changePane;
139141
private boolean saving;
140-
141142
// AutoCompleter used in the search bar
142143
private PersonNameSuggestionProvider searchAutoCompleter;
143144
private boolean baseChanged;
144145
private boolean nonUndoableChange;
145146
// Used to track whether the base has changed since last save.
146147
private BibEntry showing;
147-
148148
private SuggestionProviders suggestionProviders;
149-
150149
@SuppressWarnings({"FieldCanBeLocal", "unused"}) private Subscription dividerPositionSubscription;
151-
152150
// the query the user searches when this BasePanel is active
153151
private Optional<SearchQuery> currentSearchQuery = Optional.empty();
154-
155152
private Optional<DatabaseChangeMonitor> changeMonitor = Optional.empty();
156-
private final DialogService dialogService;
157153

158154
public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabaseContext bibDatabaseContext, ExternalFileTypes externalFileTypes) {
159155
this.preferences = Objects.requireNonNull(preferences);
@@ -188,7 +184,8 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas
188184

189185
this.entryEditor = new EntryEditor(this, preferences.getEntryEditorPreferences(), Globals.getFileUpdateMonitor(), dialogService, externalFileTypes, Globals.TASK_EXECUTOR);
190186

191-
this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService, externalFileTypes);
187+
this.preview = new PreviewPanel(getBibDatabaseContext(), this, dialogService, externalFileTypes, Globals.getKeyPrefs(), preferences.getPreviewPreferences());
188+
frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview);
192189
}
193190

194191
@Subscribe
@@ -953,7 +950,7 @@ public void entryEditorClosing(EntryEditor editor) {
953950
*/
954951
public void ensureNotShowingBottomPanel(BibEntry entry) {
955952
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry))
956-
|| ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) {
953+
|| ((mode == BasePanelMode.SHOWING_PREVIEW))) {
957954
closeBottomPane();
958955
}
959956
}
@@ -1139,10 +1136,6 @@ public CitationStyleCache getCitationStyleCache() {
11391136
return citationStyleCache;
11401137
}
11411138

1142-
public PreviewPanel getPreviewPanel() {
1143-
return preview;
1144-
}
1145-
11461139
public FileAnnotationCache getAnnotationCache() {
11471140
return annotationCache;
11481141
}
@@ -1172,6 +1165,11 @@ public void cut() {
11721165
mainTable.cut();
11731166
}
11741167

1168+
@Subscribe
1169+
public void listen(EntryChangedEvent entryChangedEvent) {
1170+
this.markBaseChanged();
1171+
}
1172+
11751173
private static class SearchAndOpenFile {
11761174

11771175
private final BibEntry entry;
@@ -1280,11 +1278,6 @@ public void listen(EntryRemovedEvent removedEntryEvent) {
12801278
}
12811279
}
12821280

1283-
@Subscribe
1284-
public void listen(EntryChangedEvent entryChangedEvent) {
1285-
this.markBaseChanged();
1286-
}
1287-
12881281
private class UndoAction implements BaseAction {
12891282

12901283
@Override

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

-12
This file was deleted.

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

-2
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,6 @@ public void init() {
232232
}
233233
globalSearchBar.setSearchTerm(content);
234234

235-
currentBasePanel.getPreviewPanel().updateLayout(Globals.prefs.getPreviewPreferences());
236-
237235
// groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class));
238236
//previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled());
239237
//generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class));

src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import javafx.scene.Node;
44

5-
import org.jabref.Globals;
65
import org.jabref.JabRefGUI;
7-
import org.jabref.gui.PreviewPanel;
8-
import org.jabref.gui.externalfiletype.ExternalFileTypes;
6+
import org.jabref.gui.preview.PreviewViewer;
97
import org.jabref.gui.undo.NamedCompound;
108
import org.jabref.gui.undo.UndoableInsertEntry;
119
import org.jabref.logic.l10n.Localization;
@@ -29,8 +27,8 @@ public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {
2927

3028
@Override
3129
public Node description() {
32-
PreviewPanel previewPanel = new PreviewPanel(null, new BibDatabaseContext(), Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), JabRefGUI.getMainFrame().getDialogService(), ExternalFileTypes.getInstance());
33-
previewPanel.setEntry(diskEntry);
34-
return previewPanel;
30+
PreviewViewer previewViewer = new PreviewViewer(new BibDatabaseContext(), JabRefGUI.getMainFrame().getDialogService());
31+
previewViewer.setEntry(diskEntry);
32+
return previewViewer;
3533
}
3634
}

src/main/java/org/jabref/gui/collab/EntryDeleteChangeViewModel.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import javafx.scene.Node;
44

5-
import org.jabref.Globals;
65
import org.jabref.JabRefGUI;
7-
import org.jabref.gui.PreviewPanel;
8-
import org.jabref.gui.externalfiletype.ExternalFileTypes;
6+
import org.jabref.gui.preview.PreviewViewer;
97
import org.jabref.gui.undo.NamedCompound;
108
import org.jabref.gui.undo.UndoableRemoveEntry;
119
import org.jabref.logic.bibtex.DuplicateCheck;
@@ -46,8 +44,8 @@ public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {
4644

4745
@Override
4846
public Node description() {
49-
PreviewPanel previewPanel = new PreviewPanel(null, new BibDatabaseContext(), Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), JabRefGUI.getMainFrame().getDialogService(), ExternalFileTypes.getInstance());
50-
previewPanel.setEntry(memEntry);
51-
return previewPanel;
47+
PreviewViewer previewViewer = new PreviewViewer(new BibDatabaseContext(), JabRefGUI.getMainFrame().getDialogService());
48+
previewViewer.setEntry(memEntry);
49+
return previewViewer;
5250
}
5351
}

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import org.jabref.gui.menus.ChangeEntryTypeMenu;
2121
import org.jabref.gui.mergeentries.FetchAndMergeEntry;
2222
import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory;
23-
import org.jabref.logic.citationstyle.CitationStyle;
23+
import org.jabref.logic.citationstyle.CitationStylePreviewLayout;
24+
import org.jabref.logic.citationstyle.PreviewLayout;
2425
import org.jabref.model.entry.BibEntry;
2526
import org.jabref.model.entry.FieldName;
2627
import org.jabref.model.entry.specialfields.SpecialField;
@@ -127,8 +128,8 @@ private static Menu createCopySubMenu(BasePanel panel, ActionFactory factory, Di
127128

128129
// the submenu will behave dependent on what style is currently selected (citation/preview)
129130
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences();
130-
String style = previewPreferences.getPreviewCycle().get(previewPreferences.getPreviewCyclePosition());
131-
if (CitationStyle.isCitationStyleFile(style)) {
131+
PreviewLayout style = previewPreferences.getCurrentPreviewStyle();
132+
if (style instanceof CitationStylePreviewLayout) {
132133
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_HTML, new OldCommandWrapper(Actions.COPY_CITATION_HTML, panel)));
133134
Menu copyCitationMenu = factory.createMenu(StandardActions.COPY_CITATION_MORE);
134135
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_TEXT, new OldCommandWrapper(Actions.COPY_CITATION_TEXT, panel)));

src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java

+10-15
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
import javafx.scene.layout.VBox;
1313

1414
import org.jabref.gui.DialogService;
15-
import org.jabref.gui.PreviewPanel;
16-
import org.jabref.gui.externalfiletype.ExternalFileTypes;
1715
import org.jabref.gui.icon.IconTheme;
16+
import org.jabref.gui.preview.PreviewViewer;
1817
import org.jabref.gui.util.BaseDialog;
1918
import org.jabref.gui.util.ValueTableCellFactory;
2019
import org.jabref.gui.util.ViewModelTableRowFactory;
20+
import org.jabref.logic.citationstyle.TextBasedPreviewLayout;
2121
import org.jabref.logic.l10n.Localization;
2222
import org.jabref.logic.openoffice.OOBibStyle;
2323
import org.jabref.logic.openoffice.StyleLoader;
@@ -43,8 +43,8 @@ public class StyleSelectDialogView extends BaseDialog<OOBibStyle> {
4343
@Inject private PreferencesService preferencesService;
4444
@Inject private DialogService dialogService;
4545
private StyleSelectDialogViewModel viewModel;
46-
private PreviewPanel previewArticle;
47-
private PreviewPanel previewBook;
46+
private PreviewViewer previewArticle;
47+
private PreviewViewer previewBook;
4848

4949
public StyleSelectDialogView(StyleLoader loader) {
5050

@@ -66,14 +66,13 @@ public StyleSelectDialogView(StyleLoader loader) {
6666

6767
@FXML
6868
private void initialize() {
69-
7069
viewModel = new StyleSelectDialogViewModel(dialogService, loader, preferencesService);
7170

72-
previewArticle = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
71+
previewArticle = new PreviewViewer(new BibDatabaseContext(), dialogService);
7372
previewArticle.setEntry(TestEntry.getTestEntry());
7473
vbox.getChildren().add(previewArticle);
7574

76-
previewBook = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
75+
previewBook = new PreviewViewer(new BibDatabaseContext(), dialogService);
7776
previewBook.setEntry(TestEntry.getTestEntryBook());
7877
vbox.getChildren().add(previewBook);
7978

@@ -89,12 +88,8 @@ private void initialize() {
8988
}
9089
return null;
9190
})
92-
.withOnMouseClickedEvent(item -> {
93-
return evt -> viewModel.deleteStyle();
94-
})
95-
.withTooltip(item -> {
96-
return Localization.lang("Remove style");
97-
})
91+
.withOnMouseClickedEvent(item -> evt -> viewModel.deleteStyle())
92+
.withTooltip(item -> Localization.lang("Remove style"))
9893
.install(colDeleteIcon);
9994

10095
edit.setOnAction(e -> viewModel.editStyle());
@@ -122,8 +117,8 @@ private void initialize() {
122117

123118
EasyBind.subscribe(viewModel.selectedItemProperty(), style -> {
124119
tvStyles.getSelectionModel().select(style);
125-
previewArticle.setLayout(style.getStyle().getReferenceFormat("default"));
126-
previewBook.setLayout(style.getStyle().getReferenceFormat("default"));
120+
previewArticle.setLayout(new TextBasedPreviewLayout(style.getStyle().getReferenceFormat("default")));
121+
previewBook.setLayout(new TextBasedPreviewLayout(style.getStyle().getReferenceFormat("default")));
127122
});
128123
}
129124

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.jabref.gui.DialogService;
2525
import org.jabref.gui.GUIGlobals;
2626
import org.jabref.gui.JabRefFrame;
27-
import org.jabref.gui.externalfiletype.ExternalFileTypes;
2827
import org.jabref.gui.util.BaseDialog;
2928
import org.jabref.gui.util.ControlHelper;
3029
import org.jabref.gui.util.FileDialogConfiguration;
@@ -86,7 +85,7 @@ public PreferencesDialog(JabRefFrame parent, TaskExecutor taskExecutor) {
8685
preferenceTabs.add(new FileTab(dialogService, prefs));
8786
preferenceTabs.add(new TablePrefsTab(prefs));
8887
preferenceTabs.add(new TableColumnsTab(prefs, frame));
89-
preferenceTabs.add(new PreviewPrefsTab(dialogService, ExternalFileTypes.getInstance(), taskExecutor));
88+
preferenceTabs.add(new PreviewPreferencesTab(dialogService, taskExecutor));
9089
preferenceTabs.add(new ExternalTab(frame, this, prefs));
9190
preferenceTabs.add(new GroupsPrefsTab(prefs));
9291
preferenceTabs.add(new EntryEditorPrefsTab(prefs));

0 commit comments

Comments
 (0)