Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into convertSearchWorker
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Siedlerchr committed May 6, 2019
2 parents d99edc7 + c168c49 commit 84758a7
Show file tree
Hide file tree
Showing 21 changed files with 585 additions and 197 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
}

plugins {
id 'com.gradle.build-scan' version '2.2.1'
id 'com.gradle.build-scan' version '2.3'
id 'com.install4j.gradle' version '7.0.11'
id 'com.github.johnrengelman.shadow' version '5.0.0'
id "com.simonharrer.modernizer" version '1.6.0-1'
Expand Down
29 changes: 11 additions & 18 deletions src/main/java/org/jabref/gui/BasePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
import org.jabref.gui.maintable.MainTableDataModel;
import org.jabref.gui.mergeentries.MergeEntriesAction;
import org.jabref.gui.mergeentries.MergeWithFetchedEntryAction;
import org.jabref.gui.preview.CitationStyleToClipboardWorker;
import org.jabref.gui.preview.PreviewPanel;
import org.jabref.gui.specialfields.SpecialFieldDatabaseChangeListener;
import org.jabref.gui.specialfields.SpecialFieldValueViewModel;
import org.jabref.gui.specialfields.SpecialFieldViewModel;
Expand All @@ -67,7 +69,6 @@
import org.jabref.gui.undo.UndoableInsertEntry;
import org.jabref.gui.undo.UndoableRemoveEntry;
import org.jabref.gui.util.DefaultTaskExecutor;
import org.jabref.gui.worker.CitationStyleToClipboardWorker;
import org.jabref.gui.worker.SendAsEMailAction;
import org.jabref.logic.citationstyle.CitationStyleCache;
import org.jabref.logic.citationstyle.CitationStyleOutputFormat;
Expand Down Expand Up @@ -130,30 +131,25 @@ public class BasePanel extends StackPane {
private final ExternalFileTypes externalFileTypes;

private final EntryEditor entryEditor;
private final DialogService dialogService;
private MainTable mainTable;
// To contain instantiated entry editors. This is to save time
// As most enums, this must not be null
private BasePanelMode mode = BasePanelMode.SHOWING_NOTHING;
private SplitPane splitPane;
private DatabaseChangePane changePane;
private boolean saving;

// AutoCompleter used in the search bar
private PersonNameSuggestionProvider searchAutoCompleter;
private boolean baseChanged;
private boolean nonUndoableChange;
// Used to track whether the base has changed since last save.
private BibEntry showing;

private SuggestionProviders suggestionProviders;

@SuppressWarnings({"FieldCanBeLocal", "unused"}) private Subscription dividerPositionSubscription;

// the query the user searches when this BasePanel is active
private Optional<SearchQuery> currentSearchQuery = Optional.empty();

private Optional<DatabaseChangeMonitor> changeMonitor = Optional.empty();
private final DialogService dialogService;

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

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

this.preview = new PreviewPanel(this, getBibDatabaseContext(), preferences.getKeyBindings(), preferences.getPreviewPreferences(), dialogService, externalFileTypes);
this.preview = new PreviewPanel(getBibDatabaseContext(), this, dialogService, externalFileTypes, Globals.getKeyPrefs(), preferences.getPreviewPreferences());
frame().getGlobalSearchBar().getSearchQueryHighlightObservable().addSearchListener(preview);
}

@Subscribe
Expand Down Expand Up @@ -953,7 +950,7 @@ public void entryEditorClosing(EntryEditor editor) {
*/
public void ensureNotShowingBottomPanel(BibEntry entry) {
if (((mode == BasePanelMode.SHOWING_EDITOR) && (entryEditor.getEntry() == entry))
|| ((mode == BasePanelMode.SHOWING_PREVIEW) && (preview.getEntry() == entry))) {
|| ((mode == BasePanelMode.SHOWING_PREVIEW))) {
closeBottomPane();
}
}
Expand Down Expand Up @@ -1139,10 +1136,6 @@ public CitationStyleCache getCitationStyleCache() {
return citationStyleCache;
}

public PreviewPanel getPreviewPanel() {
return preview;
}

public FileAnnotationCache getAnnotationCache() {
return annotationCache;
}
Expand Down Expand Up @@ -1172,6 +1165,11 @@ public void cut() {
mainTable.cut();
}

@Subscribe
public void listen(EntryChangedEvent entryChangedEvent) {
this.markBaseChanged();
}

private static class SearchAndOpenFile {

private final BibEntry entry;
Expand Down Expand Up @@ -1280,11 +1278,6 @@ public void listen(EntryRemovedEvent removedEntryEvent) {
}
}

@Subscribe
public void listen(EntryChangedEvent entryChangedEvent) {
this.markBaseChanged();
}

private class UndoAction implements BaseAction {

@Override
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/org/jabref/gui/EntryContainer.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ public void init() {
}
globalSearchBar.setSearchTerm(content);

currentBasePanel.getPreviewPanel().updateLayout(Globals.prefs.getPreviewPreferences());

// groupSidePane.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(GroupSidePane.class));
//previewToggle.setSelected(Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled());
//generalFetcher.getToggleCommand().setSelected(sidePaneManager.isComponentVisible(WebSearchPane.class));
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/org/jabref/gui/collab/EntryAddChangeViewModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import javafx.scene.Node;

import org.jabref.Globals;
import org.jabref.JabRefGUI;
import org.jabref.gui.PreviewPanel;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.preview.PreviewViewer;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableInsertEntry;
import org.jabref.logic.l10n.Localization;
Expand All @@ -29,8 +27,8 @@ public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {

@Override
public Node description() {
PreviewPanel previewPanel = new PreviewPanel(null, new BibDatabaseContext(), Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), JabRefGUI.getMainFrame().getDialogService(), ExternalFileTypes.getInstance());
previewPanel.setEntry(diskEntry);
return previewPanel;
PreviewViewer previewViewer = new PreviewViewer(new BibDatabaseContext(), JabRefGUI.getMainFrame().getDialogService());
previewViewer.setEntry(diskEntry);
return previewViewer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import javafx.scene.Node;

import org.jabref.Globals;
import org.jabref.JabRefGUI;
import org.jabref.gui.PreviewPanel;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.preview.PreviewViewer;
import org.jabref.gui.undo.NamedCompound;
import org.jabref.gui.undo.UndoableRemoveEntry;
import org.jabref.logic.bibtex.DuplicateCheck;
Expand Down Expand Up @@ -46,8 +44,8 @@ public void makeChange(BibDatabaseContext database, NamedCompound undoEdit) {

@Override
public Node description() {
PreviewPanel previewPanel = new PreviewPanel(null, new BibDatabaseContext(), Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), JabRefGUI.getMainFrame().getDialogService(), ExternalFileTypes.getInstance());
previewPanel.setEntry(memEntry);
return previewPanel;
PreviewViewer previewViewer = new PreviewViewer(new BibDatabaseContext(), JabRefGUI.getMainFrame().getDialogService());
previewViewer.setEntry(memEntry);
return previewViewer;
}
}
7 changes: 4 additions & 3 deletions src/main/java/org/jabref/gui/maintable/RightClickMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import org.jabref.gui.menus.ChangeEntryTypeMenu;
import org.jabref.gui.mergeentries.FetchAndMergeEntry;
import org.jabref.gui.specialfields.SpecialFieldMenuItemFactory;
import org.jabref.logic.citationstyle.CitationStyle;
import org.jabref.logic.citationstyle.CitationStylePreviewLayout;
import org.jabref.logic.citationstyle.PreviewLayout;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.specialfields.SpecialField;
Expand Down Expand Up @@ -127,8 +128,8 @@ private static Menu createCopySubMenu(BasePanel panel, ActionFactory factory, Di

// the submenu will behave dependent on what style is currently selected (citation/preview)
PreviewPreferences previewPreferences = Globals.prefs.getPreviewPreferences();
String style = previewPreferences.getPreviewCycle().get(previewPreferences.getPreviewCyclePosition());
if (CitationStyle.isCitationStyleFile(style)) {
PreviewLayout style = previewPreferences.getCurrentPreviewStyle();
if (style instanceof CitationStylePreviewLayout) {
copySpecialMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_HTML, new OldCommandWrapper(Actions.COPY_CITATION_HTML, panel)));
Menu copyCitationMenu = factory.createMenu(StandardActions.COPY_CITATION_MORE);
copyCitationMenu.getItems().add(factory.createMenuItem(StandardActions.COPY_CITATION_TEXT, new OldCommandWrapper(Actions.COPY_CITATION_TEXT, panel)));
Expand Down
25 changes: 10 additions & 15 deletions src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import javafx.scene.layout.VBox;

import org.jabref.gui.DialogService;
import org.jabref.gui.PreviewPanel;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.icon.IconTheme;
import org.jabref.gui.preview.PreviewViewer;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ValueTableCellFactory;
import org.jabref.gui.util.ViewModelTableRowFactory;
import org.jabref.logic.citationstyle.TextBasedPreviewLayout;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OOBibStyle;
import org.jabref.logic.openoffice.StyleLoader;
Expand All @@ -43,8 +43,8 @@ public class StyleSelectDialogView extends BaseDialog<OOBibStyle> {
@Inject private PreferencesService preferencesService;
@Inject private DialogService dialogService;
private StyleSelectDialogViewModel viewModel;
private PreviewPanel previewArticle;
private PreviewPanel previewBook;
private PreviewViewer previewArticle;
private PreviewViewer previewBook;

public StyleSelectDialogView(StyleLoader loader) {

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

@FXML
private void initialize() {

viewModel = new StyleSelectDialogViewModel(dialogService, loader, preferencesService);

previewArticle = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
previewArticle = new PreviewViewer(new BibDatabaseContext(), dialogService);
previewArticle.setEntry(TestEntry.getTestEntry());
vbox.getChildren().add(previewArticle);

previewBook = new PreviewPanel(null, new BibDatabaseContext(), preferencesService.getKeyBindingRepository(), preferencesService.getPreviewPreferences(), dialogService, ExternalFileTypes.getInstance());
previewBook = new PreviewViewer(new BibDatabaseContext(), dialogService);
previewBook.setEntry(TestEntry.getTestEntryBook());
vbox.getChildren().add(previewBook);

Expand All @@ -89,12 +88,8 @@ private void initialize() {
}
return null;
})
.withOnMouseClickedEvent(item -> {
return evt -> viewModel.deleteStyle();
})
.withTooltip(item -> {
return Localization.lang("Remove style");
})
.withOnMouseClickedEvent(item -> evt -> viewModel.deleteStyle())
.withTooltip(item -> Localization.lang("Remove style"))
.install(colDeleteIcon);

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

EasyBind.subscribe(viewModel.selectedItemProperty(), style -> {
tvStyles.getSelectionModel().select(style);
previewArticle.setLayout(style.getStyle().getReferenceFormat("default"));
previewBook.setLayout(style.getStyle().getReferenceFormat("default"));
previewArticle.setLayout(new TextBasedPreviewLayout(style.getStyle().getReferenceFormat("default")));
previewBook.setLayout(new TextBasedPreviewLayout(style.getStyle().getReferenceFormat("default")));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.jabref.gui.DialogService;
import org.jabref.gui.GUIGlobals;
import org.jabref.gui.JabRefFrame;
import org.jabref.gui.externalfiletype.ExternalFileTypes;
import org.jabref.gui.util.BaseDialog;
import org.jabref.gui.util.ControlHelper;
import org.jabref.gui.util.FileDialogConfiguration;
Expand Down Expand Up @@ -86,7 +85,7 @@ public PreferencesDialog(JabRefFrame parent, TaskExecutor taskExecutor) {
preferenceTabs.add(new FileTab(dialogService, prefs));
preferenceTabs.add(new TablePrefsTab(prefs));
preferenceTabs.add(new TableColumnsTab(prefs, frame));
preferenceTabs.add(new PreviewPrefsTab(dialogService, ExternalFileTypes.getInstance(), taskExecutor));
preferenceTabs.add(new PreviewPreferencesTab(dialogService, taskExecutor));
preferenceTabs.add(new ExternalTab(frame, this, prefs));
preferenceTabs.add(new GroupsPrefsTab(prefs));
preferenceTabs.add(new EntryEditorPrefsTab(prefs));
Expand Down
Loading

0 comments on commit 84758a7

Please sign in to comment.