10
10
import javafx .stage .Stage ;
11
11
12
12
import org .jabref .gui .BasePanel ;
13
- import org .jabref .gui .DialogService ;
14
- import org .jabref .gui .FXDialogService ;
15
13
import org .jabref .gui .GUIGlobals ;
16
14
import org .jabref .gui .JabRefFrame ;
17
15
import org .jabref .gui .dialogs .BackupUIManager ;
@@ -43,14 +41,13 @@ public class JabRefGUI {
43
41
private final boolean isBlank ;
44
42
private final List <ParserResult > failed = new ArrayList <>();
45
43
private final List <ParserResult > toOpenTab = new ArrayList <>();
46
- private final DialogService dialogService ;
47
44
48
45
private final String focusedFile ;
49
46
50
47
public JabRefGUI (Stage mainStage , List <ParserResult > argsDatabases , boolean isBlank ) {
51
48
this .bibDatabases = argsDatabases ;
52
49
this .isBlank = isBlank ;
53
- this . dialogService = new FXDialogService (mainStage );
50
+ mainFrame = new JabRefFrame (mainStage );
54
51
55
52
// passed file (we take the first one) should be focused
56
53
focusedFile = argsDatabases .stream ()
@@ -60,7 +57,7 @@ public JabRefGUI(Stage mainStage, List<ParserResult> argsDatabases, boolean isBl
60
57
.orElse (Globals .prefs .get (JabRefPreferences .LAST_FOCUSED ));
61
58
62
59
openWindow (mainStage );
63
- new VersionWorker (Globals .BUILD_INFO .getVersion (), Globals .prefs .getVersionPreferences ().getIgnoredVersion (), JabRefGUI . getMainFrame () .getDialogService (), Globals .TASK_EXECUTOR )
60
+ new VersionWorker (Globals .BUILD_INFO .getVersion (), Globals .prefs .getVersionPreferences ().getIgnoredVersion (), mainFrame .getDialogService (), Globals .TASK_EXECUTOR )
64
61
.checkForNewVersionAsync (false );
65
62
}
66
63
@@ -75,7 +72,7 @@ private void openWindow(Stage mainStage) {
75
72
GUIGlobals .init ();
76
73
77
74
LOGGER .debug ("Initializing frame" );
78
- JabRefGUI . mainFrame = new JabRefFrame ( mainStage );
75
+ mainFrame . init ( );
79
76
80
77
// Add all bibDatabases databases to the frame:
81
78
boolean first = false ;
@@ -99,7 +96,7 @@ private void openWindow(Stage mainStage) {
99
96
pr .getDatabase ().clearSharedDatabaseID ();
100
97
101
98
LOGGER .error ("Connection error" , e );
102
- dialogService .showErrorDialogAndWait (
99
+ mainFrame . getDialogService () .showErrorDialogAndWait (
103
100
Localization .lang ("Connection error" ),
104
101
Localization .lang ("A local copy will be opened." ),
105
102
e );
@@ -110,15 +107,15 @@ private void openWindow(Stage mainStage) {
110
107
// add them to the list
111
108
toOpenTab .add (pr );
112
109
} else {
113
- JabRefGUI . getMainFrame () .addParserResult (pr , first );
110
+ mainFrame .addParserResult (pr , first );
114
111
first = false ;
115
112
}
116
113
}
117
114
}
118
115
119
116
// finally add things to the currently opened tab
120
117
for (ParserResult pr : toOpenTab ) {
121
- JabRefGUI . getMainFrame () .addParserResult (pr , first );
118
+ mainFrame .addParserResult (pr , first );
122
119
first = false ;
123
120
}
124
121
@@ -158,14 +155,14 @@ private void openWindow(Stage mainStage) {
158
155
String message = Localization .lang ("Error opening file '%0'." , pr .getFile ().get ().getName ()) + "\n "
159
156
+ pr .getErrorMessage ();
160
157
161
- dialogService .showErrorDialogAndWait (Localization .lang ("Error opening file" ), message );
158
+ mainFrame . getDialogService () .showErrorDialogAndWait (Localization .lang ("Error opening file" ), message );
162
159
163
160
}
164
161
165
162
// Display warnings, if any
166
163
int tabNumber = 0 ;
167
164
for (ParserResult pr : bibDatabases ) {
168
- ParserResultWarningDialog .showParserResultWarningDialog (pr , JabRefGUI . getMainFrame () , tabNumber ++);
165
+ ParserResultWarningDialog .showParserResultWarningDialog (pr , mainFrame , tabNumber ++);
169
166
}
170
167
171
168
// After adding the databases, go through each and see if
@@ -177,9 +174,9 @@ private void openWindow(Stage mainStage) {
177
174
// This is because importToOpen might have been used, which adds to
178
175
// loadedDatabases, but not to getBasePanelCount()
179
176
180
- for (int i = 0 ; (i < bibDatabases .size ()) && (i < JabRefGUI . getMainFrame () .getBasePanelCount ()); i ++) {
177
+ for (int i = 0 ; (i < bibDatabases .size ()) && (i < mainFrame .getBasePanelCount ()); i ++) {
181
178
ParserResult pr = bibDatabases .get (i );
182
- BasePanel panel = JabRefGUI . getMainFrame () .getBasePanelAt (i );
179
+ BasePanel panel = mainFrame .getBasePanelAt (i );
183
180
OpenDatabaseAction .performPostOpenActions (panel , pr );
184
181
}
185
182
@@ -209,7 +206,7 @@ private void openLastEditedDatabases() {
209
206
}
210
207
211
208
if (BackupManager .checkForBackupFile (dbFile .toPath ())) {
212
- BackupUIManager .showRestoreBackupDialog (dialogService , dbFile .toPath ());
209
+ BackupUIManager .showRestoreBackupDialog (mainFrame . getDialogService () , dbFile .toPath ());
213
210
}
214
211
215
212
ParserResult parsedDatabase = OpenDatabase .loadDatabase (fileName ,
0 commit comments