From dc702afa50ca801c5f6843c34f18b0bcd71262d6 Mon Sep 17 00:00:00 2001 From: adam-m Date: Thu, 21 Mar 2013 11:25:56 -0400 Subject: [PATCH] Move initialize JavaFx platform to a single place in the Core Installer, and let the plafform exit implicitely. --- .../DataContentViewerMedia.java | 8 ------- .../autopsy/corecomponents/Installer.java | 24 ++++++++++++------- .../sleuthkit/autopsy/timeline/Timeline.java | 4 +--- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java index 1770adef7a..e49dd6da87 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/DataContentViewerMedia.java @@ -107,15 +107,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo private void customizeComponents() { inImageMode = false; - Platform.setImplicitExit(false); - PlatformImpl.startup(new Runnable() { - @Override - public void run() { - logger.log(Level.INFO, "Initializing JavaFX for image viewing"); - } - }); logger.log(Level.INFO, "Supported image formats by javafx image viewer: "); - //initialize supported image types //TODO use mime-types instead once we have support String[] fxSupportedImagesSuffixes = ImageIO.getReaderFileSuffixes(); diff --git a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java index 969341b2ce..d77cea5ada 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponents/Installer.java @@ -18,9 +18,11 @@ */ package org.sleuthkit.autopsy.corecomponents; +import com.sun.javafx.application.PlatformImpl; import java.awt.Color; import java.awt.Insets; import java.util.logging.Level; +import javafx.application.Platform; import org.sleuthkit.autopsy.coreutils.Logger; import javax.swing.BorderFactory; import javax.swing.UIManager; @@ -37,33 +39,39 @@ import org.sleuthkit.autopsy.casemodule.Case; public class Installer extends ModuleInstall { private static Installer instance; - + Logger logger = Logger.getLogger(Installer.class.getName()); + public synchronized static Installer getDefault() { if (instance == null) { instance = new Installer(); } return instance; } - + private Installer() { super(); } - - @Override public void restored() { WindowManager.getDefault().invokeWhenUIReady(new Runnable() { - @Override public void run() { Case.invokeStartupDialog(); // bring up the startup dialog - + + //initialize java fx + Platform.setImplicitExit(true); + PlatformImpl.startup(new Runnable() { + @Override + public void run() { + logger.log(Level.INFO, "Initializing JavaFX for image viewing"); + } + }); + } }); - Logger logger = Logger.getLogger(Installer.class.getName()); //setupLAF(); UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI"); UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder()); @@ -80,7 +88,7 @@ public class Installer extends ModuleInstall { Logger logger = Logger.getLogger(Installer.class.getName()); //use Nimbus if available - for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels() ) { + for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { try { UIManager.setLookAndFeel(info.getClassName()); diff --git a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java index de787aec28..ef98488038 100644 --- a/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java +++ b/Timeline/src/org/sleuthkit/autopsy/timeline/Timeline.java @@ -198,7 +198,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, //JavaFX thread //JavaFX components MUST be run in the JavaFX thread, otherwise massive amounts of exceptions will be thrown and caught. Liable to freeze up and crash. //Components can be declared whenever, but initialization and manipulation must take place here. - PlatformImpl.startup(new Runnable() { + PlatformImpl.runLater(new Runnable() { @Override public void run() { try { @@ -1059,8 +1059,6 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar, return; } - Platform.setImplicitExit(false); - // listen for case changes (specifically images being added). if (Case.isCaseOpen() && !listeningToAddImage) { Case.addPropertyChangeListener(this);