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

Rework preview logic. Fixes #4923 #4951

Merged
merged 4 commits into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 10 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,7 @@ 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);
}

Expand Down Expand Up @@ -954,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 @@ -1140,10 +1136,6 @@ public CitationStyleCache getCitationStyleCache() {
return citationStyleCache;
}

public PreviewPanel getPreviewPanel() {
return preview;
}

public FileAnnotationCache getAnnotationCache() {
return annotationCache;
}
Expand Down Expand Up @@ -1173,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 @@ -1281,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
Loading