Skip to content

Commit ed6bf99

Browse files
authored
Hotfix for CAYW in GUI (#13470)
1 parent 89ee3a5 commit ed6bf99

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

jabsrv/src/main/java/org/jabref/http/server/cayw/CAYWResource.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jabref.http.server.cayw.format.FormatterService;
2222
import org.jabref.http.server.cayw.gui.CAYWEntry;
2323
import org.jabref.http.server.cayw.gui.SearchDialog;
24+
import org.jabref.http.server.services.ContextsToServe;
2425
import org.jabref.logic.importer.fileformat.BibtexImporter;
2526
import org.jabref.logic.preferences.CliPreferences;
2627
import org.jabref.model.database.BibDatabase;
@@ -29,7 +30,6 @@
2930
import org.jabref.model.entry.field.StandardField;
3031
import org.jabref.model.util.DummyFileUpdateMonitor;
3132

32-
import com.google.gson.Gson;
3333
import jakarta.inject.Inject;
3434
import jakarta.ws.rs.BeanParam;
3535
import jakarta.ws.rs.GET;
@@ -52,10 +52,10 @@ public class CAYWResource {
5252
private CliPreferences preferences;
5353

5454
@Inject
55-
private Gson gson;
55+
private FormatterService formatterService;
5656

5757
@Inject
58-
private FormatterService formatterService;
58+
private ContextsToServe contextsToServe;
5959

6060
@GET
6161
@Produces(MediaType.TEXT_PLAIN)
@@ -166,6 +166,12 @@ private BibDatabaseContext getDatabaseContextFromStream(InputStream inputStream)
166166
private synchronized void initializeGUI() {
167167
// TODO: Implement a better way to handle the window popup since this is a bit hacky.
168168
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.");
169175
CountDownLatch latch = new CountDownLatch(1);
170176
Platform.startup(() -> {
171177
Platform.setImplicitExit(false);

0 commit comments

Comments
 (0)