21
21
import org .jabref .http .server .cayw .format .FormatterService ;
22
22
import org .jabref .http .server .cayw .gui .CAYWEntry ;
23
23
import org .jabref .http .server .cayw .gui .SearchDialog ;
24
+ import org .jabref .http .server .services .ContextsToServe ;
24
25
import org .jabref .logic .importer .fileformat .BibtexImporter ;
25
26
import org .jabref .logic .preferences .CliPreferences ;
26
27
import org .jabref .model .database .BibDatabase ;
29
30
import org .jabref .model .entry .field .StandardField ;
30
31
import org .jabref .model .util .DummyFileUpdateMonitor ;
31
32
32
- import com .google .gson .Gson ;
33
33
import jakarta .inject .Inject ;
34
34
import jakarta .ws .rs .BeanParam ;
35
35
import jakarta .ws .rs .GET ;
@@ -52,10 +52,10 @@ public class CAYWResource {
52
52
private CliPreferences preferences ;
53
53
54
54
@ Inject
55
- private Gson gson ;
55
+ private FormatterService formatterService ;
56
56
57
57
@ Inject
58
- private FormatterService formatterService ;
58
+ private ContextsToServe contextsToServe ;
59
59
60
60
@ GET
61
61
@ Produces (MediaType .TEXT_PLAIN )
@@ -166,6 +166,12 @@ private BibDatabaseContext getDatabaseContextFromStream(InputStream inputStream)
166
166
private synchronized void initializeGUI () {
167
167
// TODO: Implement a better way to handle the window popup since this is a bit hacky.
168
168
if (!initialized ) {
169
+ if (!contextsToServe .getContextsToServe ().isEmpty ()) {
170
+ LOGGER .debug ("Running inside JabRef UI, no need to initialize JavaFX for CAYW resource." );
171
+ initialized = true ;
172
+ return ;
173
+ }
174
+ LOGGER .debug ("Initializing JavaFX for CAYW resource." );
169
175
CountDownLatch latch = new CountDownLatch (1 );
170
176
Platform .startup (() -> {
171
177
Platform .setImplicitExit (false );
0 commit comments