53
53
import org .jabref .gui .mergeentries .MergeEntriesAction ;
54
54
import org .jabref .gui .mergeentries .MergeWithFetchedEntryAction ;
55
55
import org .jabref .gui .preview .CitationStyleToClipboardWorker ;
56
- import org .jabref .gui .preview .PreviewPanel ;
57
56
import org .jabref .gui .specialfields .SpecialFieldDatabaseChangeListener ;
58
57
import org .jabref .gui .specialfields .SpecialFieldValueViewModel ;
59
58
import org .jabref .gui .specialfields .SpecialFieldViewModel ;
@@ -122,7 +121,6 @@ public class BasePanel extends StackPane {
122
121
// Keeps track of the string dialog if it is open.
123
122
private final Map <Actions , BaseAction > actions = new HashMap <>();
124
123
private final SidePaneManager sidePaneManager ;
125
- private final PreviewPanel preview ;
126
124
private final BasePanelPreferences preferences ;
127
125
private final ExternalFileTypes externalFileTypes ;
128
126
@@ -179,8 +177,6 @@ public BasePanel(JabRefFrame frame, BasePanelPreferences preferences, BibDatabas
179
177
this .getDatabase ().registerListener (new UpdateTimestampListener (Globals .prefs ));
180
178
181
179
this .entryEditor = new EntryEditor (this , externalFileTypes );
182
-
183
- this .preview = new PreviewPanel (getBibDatabaseContext (), this , dialogService , externalFileTypes , Globals .getKeyPrefs (), preferences .getPreviewPreferences ());
184
180
}
185
181
186
182
@ Subscribe
@@ -263,8 +259,6 @@ private void setupActions() {
263
259
// The action for copying selected entries.
264
260
actions .put (Actions .COPY , this ::copy );
265
261
266
- actions .put (Actions .PRINT_PREVIEW , new PrintPreviewAction ());
267
-
268
262
actions .put (Actions .CUT , this ::cut );
269
263
270
264
actions .put (Actions .DELETE , () -> delete (false ));
@@ -358,19 +352,6 @@ private void setupActions() {
358
352
new SpecialFieldViewModel (SpecialField .READ_STATUS , undoManager ).getSpecialFieldAction (status , this .frame ));
359
353
}
360
354
361
- actions .put (Actions .TOGGLE_PREVIEW , () -> {
362
- PreviewPreferences previewPreferences = Globals .prefs .getPreviewPreferences ();
363
- boolean enabled = !previewPreferences .isPreviewPanelEnabled ();
364
- PreviewPreferences newPreviewPreferences = previewPreferences .getBuilder ()
365
- .withPreviewPanelEnabled (enabled )
366
- .build ();
367
- Globals .prefs .storePreviewPreferences (newPreviewPreferences );
368
- setPreviewActive (enabled );
369
- });
370
-
371
- actions .put (Actions .NEXT_PREVIEW_STYLE , this ::nextPreviewStyle );
372
- actions .put (Actions .PREVIOUS_PREVIEW_STYLE , this ::previousPreviewStyle );
373
-
374
355
actions .put (Actions .SEND_AS_EMAIL , new SendAsEMailAction (frame ));
375
356
376
357
actions .put (Actions .WRITE_XMP , new WriteXMPAction (this )::execute );
@@ -679,7 +660,6 @@ private void createMainTable() {
679
660
.stream ()
680
661
.findFirst ()
681
662
.ifPresent (entry -> {
682
- preview .setEntry (entry );
683
663
entryEditor .setEntry (entry );
684
664
}));
685
665
@@ -816,9 +796,7 @@ private void instantiateSearchAutoCompleter() {
816
796
}
817
797
818
798
private void adjustSplitter () {
819
- if (mode == BasePanelMode .SHOWING_PREVIEW ) {
820
- splitPane .setDividerPositions (Globals .prefs .getPreviewPreferences ().getPreviewPanelDividerPosition ().doubleValue ());
821
- } else if (mode == BasePanelMode .SHOWING_EDITOR ) {
799
+ if (mode == BasePanelMode .SHOWING_EDITOR ) {
822
800
splitPane .setDividerPositions (preferences .getEntryEditorDividerPosition ());
823
801
}
824
802
}
@@ -844,17 +822,11 @@ public void showAndEdit(BibEntry entry) {
844
822
}
845
823
846
824
private void showBottomPane (BasePanelMode newMode ) {
847
- Node pane ;
848
- switch (newMode ) {
849
- case SHOWING_PREVIEW :
850
- pane = preview ;
851
- break ;
852
- case SHOWING_EDITOR :
853
- pane = entryEditor ;
854
- break ;
855
- default :
856
- throw new UnsupportedOperationException ("new mode not recognized: " + newMode .name ());
825
+ if (newMode != BasePanelMode .SHOWING_EDITOR ) {
826
+ throw new UnsupportedOperationException ("new mode not recognized: " + newMode .name ());
857
827
}
828
+ Node pane = entryEditor ;
829
+
858
830
if (splitPane .getItems ().size () == 2 ) {
859
831
splitPane .getItems ().set (1 , pane );
860
832
} else {
@@ -870,23 +842,6 @@ private void showAndEdit() {
870
842
}
871
843
}
872
844
873
- /**
874
- * Sets the given preview panel as the bottom component in the split panel. Updates the mode to SHOWING_PREVIEW.
875
- *
876
- * @param entry The entry to show in the preview.
877
- */
878
- private void showPreview (BibEntry entry ) {
879
- showBottomPane (BasePanelMode .SHOWING_PREVIEW );
880
-
881
- preview .setEntry (entry );
882
- }
883
-
884
- private void showPreview () {
885
- if (!mainTable .getSelectedEntries ().isEmpty ()) {
886
- showPreview (mainTable .getSelectedEntries ().get (0 ));
887
- }
888
- }
889
-
890
845
public void nextPreviewStyle () {
891
846
cyclePreview (Globals .prefs .getPreviewPreferences ().getPreviewCyclePosition () + 1 );
892
847
}
@@ -901,16 +856,15 @@ private void cyclePreview(int newPosition) {
901
856
.withPreviewCyclePosition (newPosition )
902
857
.build ();
903
858
Globals .prefs .storePreviewPreferences (previewPreferences );
904
-
905
- preview .updateLayout (previewPreferences );
859
+ entryEditor .updatePreviewInTabs (previewPreferences );
906
860
}
907
861
908
862
/**
909
863
* Removes the bottom component.
910
864
*/
911
865
public void closeBottomPane () {
912
866
mode = BasePanelMode .SHOWING_NOTHING ;
913
- splitPane .getItems ().removeAll (entryEditor , preview );
867
+ splitPane .getItems ().remove (entryEditor );
914
868
}
915
869
916
870
/**
@@ -932,23 +886,17 @@ public void selectNextEntry() {
932
886
/**
933
887
* This method is called from an EntryEditor when it should be closed. We relay to the selection listener, which
934
888
* takes care of the rest.
935
- *
936
- * @param editor The entry editor to close.
937
889
*/
938
- public void entryEditorClosing (EntryEditor editor ) {
939
- if (Globals .prefs .getPreviewPreferences ().isPreviewPanelEnabled ()) {
940
- showPreview (editor .getEntry ());
941
- } else {
942
- closeBottomPane ();
943
- }
890
+ public void entryEditorClosing () {
891
+ closeBottomPane ();
944
892
mainTable .requestFocus ();
945
893
}
946
894
947
895
/**
948
- * Closes the entry editor or preview panel if it is showing the given entry.
896
+ * Closes the entry editor if it is showing the given entry.
949
897
*/
950
- public void ensureNotShowingBottomPanel (BibEntry entry ) {
951
- if (((mode == BasePanelMode .SHOWING_EDITOR ) && (entryEditor .getEntry () == entry )) || (( mode == BasePanelMode . SHOWING_PREVIEW )) ) {
898
+ private void ensureNotShowingBottomPanel (BibEntry entry ) {
899
+ if (((mode == BasePanelMode .SHOWING_EDITOR ) && (entryEditor .getEntry () == entry ))) {
952
900
closeBottomPane ();
953
901
}
954
902
}
@@ -996,7 +944,7 @@ public BibDatabase getDatabase() {
996
944
return bibDatabaseContext .getDatabase ();
997
945
}
998
946
999
- public boolean showDeleteConfirmationDialog (int numberOfEntries ) {
947
+ private boolean showDeleteConfirmationDialog (int numberOfEntries ) {
1000
948
if (Globals .prefs .getBoolean (JabRefPreferences .CONFIRM_DELETE )) {
1001
949
String title = Localization .lang ("Delete entry" );
1002
950
String message = Localization .lang ("Really delete the selected entry?" );
@@ -1029,13 +977,7 @@ private void saveDividerLocation(Number position) {
1029
977
return ;
1030
978
}
1031
979
1032
- if (mode == BasePanelMode .SHOWING_PREVIEW ) {
1033
- PreviewPreferences previewPreferences = Globals .prefs .getPreviewPreferences ()
1034
- .getBuilder ()
1035
- .withPreviewPanelDividerPosition (position )
1036
- .build ();
1037
- Globals .prefs .storePreviewPreferences (previewPreferences );
1038
- } else if (mode == BasePanelMode .SHOWING_EDITOR ) {
980
+ if (mode == BasePanelMode .SHOWING_EDITOR ) {
1039
981
preferences .setEntryEditorDividerPosition (position .doubleValue ());
1040
982
}
1041
983
}
@@ -1093,14 +1035,6 @@ public String formatOutputMessage(String start, int count) {
1093
1035
return String .format ("%s %d %s." , start , count , (count > 1 ? Localization .lang ("entries" ) : Localization .lang ("entry" )));
1094
1036
}
1095
1037
1096
- private void setPreviewActive (boolean enabled ) {
1097
- if (enabled ) {
1098
- showPreview ();
1099
- } else {
1100
- preview .close ();
1101
- }
1102
- }
1103
-
1104
1038
public CountingUndoManager getUndoManager () {
1105
1039
return undoManager ;
1106
1040
}
@@ -1353,13 +1287,4 @@ public void action() {
1353
1287
markChangedOrUnChanged ();
1354
1288
}
1355
1289
}
1356
-
1357
- private class PrintPreviewAction implements BaseAction {
1358
-
1359
- @ Override
1360
- public void action () {
1361
- showPreview ();
1362
- preview .print ();
1363
- }
1364
- }
1365
1290
}
0 commit comments