<commit_before>/*
 * Autopsy Forensic Browser
 *
 * Copyright 2011 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
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;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI;
import org.openide.modules.ModuleInstall;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;

/**
 * Manages this module's lifecycle. Opens the startup dialog during startup.
 */
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");
                    }
                });

            }
        });

        //setupLAF();
        UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
        UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
        UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
    }

    private void setupLAF() {

        //TODO apply custom skinning 
        //UIManager.put("nimbusBase", new Color());
        //UIManager.put("nimbusBlueGrey", new Color());
        //UIManager.put("control", new Color());


        Logger logger = Logger.getLogger(Installer.class.getName());
        //use Nimbus if available
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                try {
                    UIManager.setLookAndFeel(info.getClassName());
                } catch (ClassNotFoundException ex) {<commit_msg>better tear down of javafx platform on app exit<commit_after>/*
 * Autopsy Forensic Browser
 *
 * Copyright 2011 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
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;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;
import org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI;
import org.openide.modules.ModuleInstall;
import org.openide.windows.WindowManager;
import org.sleuthkit.autopsy.casemodule.Case;

/**
 * Manages this module's lifecycle. Opens the startup dialog during startup.
 */
public class Installer extends ModuleInstall {

    private static Installer instance;
    private static final Logger logger = Logger.getLogger(Installer.class.getName());
    private volatile boolean javaFxInit = true;

    public synchronized static Installer getDefault() {
        if (instance == null) {
            instance = new Installer();
        }
        return instance;
    }

    private Installer() {
        super();
        javaFxInit = true;
    }

    @Override
    public void restored() {

        WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
            @Override
            public void run() {
                Case.invokeStartupDialog(); // bring up the startup dialog

                //initialize java fx if exists
                try {
                    Platform.setImplicitExit(false);
                    PlatformImpl.startup(new Runnable() {
                        @Override
                        public void run() {
                            logger.log(Level.INFO, "Initializing JavaFX for image viewing");
                        }
                    });
                } catch (Exception e) {
                    //in case javafx not present
                    javaFxInit = false;
                    
                }

            }
        });

        //setupLAF();
        UIManager.put("ViewTabDisplayerUI", "org.sleuthkit.autopsy.corecomponents.NoTabsTabDisplayerUI");
        UIManager.put(DefaultTabbedContainerUI.KEY_VIEW_CONTENT_BORDER, BorderFactory.createEmptyBorder());
        UIManager.put("TabbedPane.contentBorderInsets", new Insets(0, 0, 0, 0));
    }

    @Override
    public void uninstalled() {
        super.uninstalled();

        //exit JavaFx plat
        if (javaFxInit) {
            Platform.exit();
        }
        

    }

    private void setupLAF() {

        //TODO apply custom skinning 
        //UIManager.put("nimbusBase", new Color());
        //UIManager.put("nimbusBlueGrey", new Color());
        //UIManager.put("control", new Color());


        Logger logger = Logger.getLogger(Installer.class.getName());
        //use Nimbus if available
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                try {
                    UIManager.setLookAndFeel(info.getClassName());
                } catch (ClassNotFoundException ex) {
{'fraction_non_alphanumeric': 0.0956025605343724, 'fraction_numerical': 0.003339827442248817, 'mean_word_length': 2.507564665690581, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6539099', 'n_tokens_mistral': 1959, 'n_tokens_neox': 1909, 'n_words': 518}