<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.sparkimpl.plugin.viewer;

import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.PluginManager;
import org.jivesoftware.spark.component.RolloverButton;
import org.jivesoftware.spark.plugin.PublicPlugin;
import org.jivesoftware.spark.util.BrowserLauncher;
import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class SparkPlugUI extends JPanel {
    private PublicPlugin plugin;
    private final JButton installButton = new JButton();
    private JLabel imageIcon = new JLabel();

    public SparkPlugUI(PublicPlugin plugin) {
        this.plugin = plugin;

        setLayout(new GridBagLayout());
        setBackground(Color.white);

        JLabel titleLabel = new JLabel();
        JLabel versionLabel = new JLabel();
        JLabel descriptionLabel = new JLabel();


        if (getFilename() != null) {
            URL url = null;
            try {
                url = new URL("http://www.igniterealtime.org/updater/sparkplugs?filename=" + getFilename());
                Image image = ImageIO.read(url);
                ImageIcon icon = new ImageIcon(image);
                imageIcon.setIcon(icon);
                if (icon.getIconWidth() == -1) {
                    imageIcon.setIcon(SparkRes.getImageIcon(SparkRes.PLUGIN_IMAGE));
                }
            }
            catch (Exception e) {
                Log.error("Unable to find image for " + url, e);
            }
        }
        else {
            imageIcon.setIcon(SparkRes.getImageIcon(SparkRes.PLUGIN_IMAGE));
        }

        add(imageIcon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));

        add(titleLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
        titleLabel.setFont(new Font("dialog", Font.BOLD, 11));
        titleLabel.setForeground(new Color(80, 93, 198));

        add(versionLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

        titleLabel.setText(plugin.getName());
        versionLabel.setText(plugin.getVersion() + " by " + plugin.getAuthor());
        descriptionLabel.setText(plugin.getDescription());


        add(installButton, new GridBagConstraints(4, 0, 1, 2, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));

<commit_msg>SPARK-652 Sparkplug strack trace.<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.sparkimpl.plugin.viewer;

import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.spark.PluginManager;
import org.jivesoftware.spark.component.RolloverButton;
import org.jivesoftware.spark.plugin.PublicPlugin;
import org.jivesoftware.spark.util.BrowserLauncher;
import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log;

import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

public class SparkPlugUI extends JPanel {
    private PublicPlugin plugin;
    private final JButton installButton = new JButton();
    private JLabel imageIcon = new JLabel();

    public SparkPlugUI(PublicPlugin plugin) {
        this.plugin = plugin;

        setLayout(new GridBagLayout());
        setBackground(Color.white);

        JLabel titleLabel = new JLabel();
        JLabel versionLabel = new JLabel();
        JLabel descriptionLabel = new JLabel();


        if (getFilename() != null) {
            URL url = null;
            try {
                url = new URL("http://www.igniterealtime.org/updater/sparkplugs?filename=" + getFilename());
                final Image pluginImage = ImageIO.read(url);

                // In some cases, people are not supplying icons. This case needs to be handled.
                if (pluginImage != null) {
                    ImageIcon pluginIcon = new ImageIcon(pluginImage);
                    imageIcon.setIcon(pluginIcon);
                    if (pluginIcon.getIconWidth() == -1) {
                        imageIcon.setIcon(SparkRes.getImageIcon(SparkRes.PLUGIN_IMAGE));
                    }
                }
            }
            catch (Exception e) {
                Log.debug("Unable to find image for " + url);
            }
        }
        else {
            imageIcon.setIcon(SparkRes.getImageIcon(SparkRes.PLUGIN_IMAGE));
        }

        add(imageIcon, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));

        add(titleLabel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
        titleLabel.setFont(new Font("dialog", Font.BOLD, 11));
        titleLabel.setForeground(new Color(80, 93, 198));

        add(versionLabel, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

        titleLabel.setText(plugin.getName());
        versionLabel.setText(plugin.getVersion() + " by " + plugin.getAuthor());
        descriptionLabel.setText(plugin.getDescription());


        add(installButton, new GridBagConstraints(4, 0, 1, 2, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));


{'fraction_non_alphanumeric': 0.11632216678545973, 'fraction_numerical': 0.020384889522451887, 'mean_word_length': 3.0766995932597325, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5936473', 'n_tokens_mistral': 2292, 'n_tokens_neox': 2109, 'n_words': 513}