@param controller Window context. @return main window instance.
(GuiController controller)
| 253 | * @return main window instance. |
| 254 | */ |
| 255 | public static MainWindow get(GuiController controller) { |
| 256 | if (window == null) { |
| 257 | MainWindow app = window = new MainWindow(controller); |
| 258 | VMUtil.tkIint(); |
| 259 | Platform.runLater(() -> { |
| 260 | Stage stage = new Stage(); |
| 261 | try { |
| 262 | // When Recaf is run as an agent on Java 11+ then there is some additional weird classloader logic |
| 263 | // with modules where it cannot resolve paths to resources. We can simply set the classloader here |
| 264 | // to point it to whatever classloader has loaded Recaf. |
| 265 | if (VMUtil.getVmVersion() >= 11 && InstrumentationResource.isActive() && |
| 266 | Thread.currentThread().getContextClassLoader() == null) { |
| 267 | Thread.currentThread().setContextClassLoader(Recaf.class.getClassLoader()); |
| 268 | } |
| 269 | // Initialize the JFX app once things are configured. |
| 270 | app.init(); |
| 271 | app.start(stage); |
| 272 | } catch (Exception ex) { |
| 273 | throw new RuntimeException(ex); |
| 274 | } |
| 275 | // Disable CSS logger, it complains a lot about non-issues |
| 276 | try { |
| 277 | ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class) |
| 278 | .setLoggerLevel("javafx.css", "OFF"); |
| 279 | } catch (IllegalArgumentException ignored) { |
| 280 | // Expected: logger may not exist |
| 281 | } |
| 282 | }); |
| 283 | } |
| 284 | return window; |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Clear open tabs and remove the current workspace navigator. |