Move initialize JavaFx platform to a single place in the Core Installer, and let the plafform exit implicitely.

This commit is contained in:
adam-m 2013-03-21 11:25:56 -04:00
parent 2205b3bfdb
commit dc702afa50
3 changed files with 17 additions and 19 deletions

View File

@ -107,15 +107,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
private void customizeComponents() { private void customizeComponents() {
inImageMode = false; 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: "); logger.log(Level.INFO, "Supported image formats by javafx image viewer: ");
//initialize supported image types //initialize supported image types
//TODO use mime-types instead once we have support //TODO use mime-types instead once we have support
String[] fxSupportedImagesSuffixes = ImageIO.getReaderFileSuffixes(); String[] fxSupportedImagesSuffixes = ImageIO.getReaderFileSuffixes();

View File

@ -18,9 +18,11 @@
*/ */
package org.sleuthkit.autopsy.corecomponents; package org.sleuthkit.autopsy.corecomponents;
import com.sun.javafx.application.PlatformImpl;
import java.awt.Color; import java.awt.Color;
import java.awt.Insets; import java.awt.Insets;
import java.util.logging.Level; import java.util.logging.Level;
import javafx.application.Platform;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.UIManager; import javax.swing.UIManager;
@ -37,33 +39,39 @@ import org.sleuthkit.autopsy.casemodule.Case;
public class Installer extends ModuleInstall { public class Installer extends ModuleInstall {
private static Installer instance; private static Installer instance;
Logger logger = Logger.getLogger(Installer.class.getName());
public synchronized static Installer getDefault() { public synchronized static Installer getDefault() {
if (instance == null) { if (instance == null) {
instance = new Installer(); instance = new Installer();
} }
return instance; return instance;
} }
private Installer() { private Installer() {
super(); super();
} }
@Override @Override
public void restored() { public void restored() {
WindowManager.getDefault().invokeWhenUIReady(new Runnable() { WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
@Override @Override
public void run() { public void run() {
Case.invokeStartupDialog(); // bring up the startup dialog 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(); //setupLAF();
UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI"); UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder()); 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()); Logger logger = Logger.getLogger(Installer.class.getName());
//use Nimbus if available //use Nimbus if available
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels() ) { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) { if ("Nimbus".equals(info.getName())) {
try { try {
UIManager.setLookAndFeel(info.getClassName()); UIManager.setLookAndFeel(info.getClassName());

View File

@ -198,7 +198,7 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar,
//JavaFX thread //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. //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. //Components can be declared whenever, but initialization and manipulation must take place here.
PlatformImpl.startup(new Runnable() { PlatformImpl.runLater(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
@ -1059,8 +1059,6 @@ public class Timeline extends CallableSystemAction implements Presenter.Toolbar,
return; return;
} }
Platform.setImplicitExit(false);
// listen for case changes (specifically images being added). // listen for case changes (specifically images being added).
if (Case.isCaseOpen() && !listeningToAddImage) { if (Case.isCaseOpen() && !listeningToAddImage) {
Case.addPropertyChangeListener(this); Case.addPropertyChangeListener(this);