<commit_before>/**
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Lesser Public License (LGPL),
 * a copy of which is included in this distribution.
 */

package org.jivesoftware;

import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.settings.JiveInfo;

import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import java.io.File;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

/**
 * In many cases, you will need to know the structure of the Spark installation, such as the directory structures, what
 * type of system Spark is running on, and also the arguments which were passed into Spark on startup. The <code>Spark</code>
 * class provides some simple static calls to retrieve this information.
 *
 * @version 1.0, 11/17/2005
 */
public final class Spark {

    private static final String USER_HOME = System.getProperties().getProperty("user.home");
    private static String argument;

    private static File RESOURCE_DIRECTORY;
    private static File BIN_DIRECTORY;
    private static File LOG_DIRECTORY;


    /**
     * Private constructor that invokes the LoginDialog and
     * the Spark Main Application.
     */
    private Spark() {
        final LoginDialog dialog = new LoginDialog();
        dialog.invoke(new JFrame());
    }

    /**
     * Invocation method.
     *
     * @param args - Will receive arguments from Java Web Start.
     */
    public static void main(final String[] args) {
        /*
        * EnhancedDebuggerWindow.PERSISTED_DEBUGGER = true;
        * EnhancedDebuggerWindow.MAX_TABLE_ROWS = 10;
        * XMPPConnection.DEBUG_ENABLED = true;
        */

        String current = System.getProperty("java.library.path");
        String classPath = System.getProperty("java.class.path");

        // Set UIManager properties for JTree
        System.setProperty("apple.laf.useScreenMenuBar", "true");

        /** Update Library Path **/
        StringBuffer buf = new StringBuffer();
        buf.append(current);
        buf.append(";");


        final String workingDirectory = System.getProperty("appdir");
        if (workingDirectory == null) {
            RESOURCE_DIRECTORY = new File(USER_HOME, "/Spark/resources").getAbsoluteFile();
            BIN_DIRECTORY = new File(USER_HOME, "/Spark/bin").getAbsoluteFile();
            LOG_DIRECTORY = new File(USER_HOME, "/Spark/logs").getAbsoluteFile();
            RESOURCE_DIRECTORY.mkdirs();
            LOG_DIRECTORY.mkdirs();
            if (!RESOURCE_DIRECTORY.exists() || !LOG_DIRECTORY.exists()) {
                JOptionPane.showMessageDialog(new JFrame(), "Unable to create directories necessary for runtime.", "Spark Error", JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
        }
        // This is the Spark.exe or Spark.dmg installed executable.

        else {
            // This is the installed executable.
            File workingDir = new File(workingDirectory);

            RESOURCE_DIRECTORY = new File(workingDir, "resources").getAbsoluteFile();
            BIN_DIRECTORY = new File(workingDir, "bin").getAbsoluteFile();
            LOG_DIRECTORY = new File(workingDir, "logs").getAbsoluteFile();
            LOG_DIRECTORY.mkdirs();
            try {
                buf.append(RESOURCE_DIRECTORY.getCanonicalPath()).append(";");
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }


        buf.append(classPath);

        // Update System Properties
        System.setProperty("java.library.path", buf.toString());


        System.setProperty("sun.java2d.noddraw", "true");

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                // Start Application
                new Spark();<commit_msg>fix mac build.<commit_after>/**
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2006 <NAME>. All rights reserved.
 *
 * This software is published under the terms of the GNU Lesser Public License (LGPL),
 * a copy of which is included in this distribution.
 */

package org.jivesoftware;

import org.jivesoftware.resource.Default;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.util.log.Log;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;
import java.io.File;
import java.io.IOException;

/**
 * In many cases, you will need to know the structure of the Spark installation, such as the directory structures, what
 * type of system Spark is running on, and also the arguments which were passed into Spark on startup. The <code>Spark</code>
 * class provides some simple static calls to retrieve this information.
 *
 * @version 1.0, 11/17/2005
 */
public final class Spark {

    private static final String USER_HOME = System.getProperties().getProperty("user.home");
    private static String argument;

    private static File RESOURCE_DIRECTORY;
    private static File BIN_DIRECTORY;
    private static File LOG_DIRECTORY;


    /**
     * Private constructor that invokes the LoginDialog and
     * the Spark Main Application.
     */
    private Spark() {
        final LoginDialog dialog = new LoginDialog();
        dialog.invoke(new JFrame());
    }

    /**
     * Invocation method.
     *
     * @param args - Will receive arguments from Java Web Start.
     */
    public static void main(final String[] args) {
        /*
        * EnhancedDebuggerWindow.PERSISTED_DEBUGGER = true;
        * EnhancedDebuggerWindow.MAX_TABLE_ROWS = 10;
        * XMPPConnection.DEBUG_ENABLED = true;
        */

        String current = System.getProperty("java.library.path");
        String classPath = System.getProperty("java.class.path");

        // Set UIManager properties for JTree
        System.setProperty("apple.laf.useScreenMenuBar", "true");

        /** Update Library Path **/
        StringBuffer buf = new StringBuffer();
        buf.append(current);
        buf.append(";");


        final String workingDirectory = System.getProperty("appdir");
        if (workingDirectory == null) {
            RESOURCE_DIRECTORY = new File(USER_HOME, "/Spark/resources").getAbsoluteFile();
            BIN_DIRECTORY = new File(USER_HOME, "/Spark/bin").getAbsoluteFile();
            LOG_DIRECTORY = new File(USER_HOME, "/Spark/logs").getAbsoluteFile();
            RESOURCE_DIRECTORY.mkdirs();
            LOG_DIRECTORY.mkdirs();
            if (!RESOURCE_DIRECTORY.exists() || !LOG_DIRECTORY.exists()) {
                JOptionPane.showMessageDialog(new JFrame(), "Unable to create directories necessary for runtime.", "Spark Error", JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
        }
        // This is the Spark.exe or Spark.dmg installed executable.

        else {
            // This is the installed executable.
            File workingDir = new File(workingDirectory);

            RESOURCE_DIRECTORY = new File(workingDir, "resources").getAbsoluteFile();
            BIN_DIRECTORY = new File(workingDir, "bin").getAbsoluteFile();

            if (!Spark.isWindows()) {
                LOG_DIRECTORY = new File(USER_HOME, "/Spark/logs").getAbsoluteFile();
            }
            else {
                LOG_DIRECTORY = new File(workingDir, "logs").getAbsoluteFile();
            }
            LOG_DIRECTORY.mkdirs();
            try {
                buf.append(RESOURCE_DIRECTORY.getCanonicalPath()).append(";");
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }


        buf.append(classPath);

        // Update System Properties
        System.setProperty("java.library.path", buf.toString());


        System.setProperty("sun.java2d.noddraw", "true");

        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                // Start Application
                new Spark();
{'fraction_non_alphanumeric': 0.10603334532805565, 'fraction_numerical': 0.004318100035984167, 'mean_word_length': 2.5571672354948807, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6328049', 'n_tokens_mistral': 2315, 'n_tokens_neox': 2212, 'n_words': 603}