<commit_before>package com.izforge.izpack.installer.container.impl;

import com.izforge.izpack.api.data.AutomatedInstallData;
import com.izforge.izpack.api.data.ResourceManager;
import com.izforge.izpack.api.exception.ResourceNotFoundException;
import com.izforge.izpack.api.substitutor.VariableSubstitutor;
import com.izforge.izpack.core.container.AbstractChildContainer;
import com.izforge.izpack.installer.base.InstallerFrame;
import com.izforge.izpack.installer.container.IInstallerContainer;
import com.izforge.izpack.installer.language.LanguageDialog;
import com.izforge.izpack.installer.manager.PanelManager;
import com.izforge.izpack.installer.unpacker.IUnpacker;
import org.picocontainer.parameters.ComponentParameter;
import org.picocontainer.parameters.ConstantParameter;

import javax.swing.*;
import java.awt.*;

/**
 * Container for panel level component
 */
public class InstallerContainer extends AbstractChildContainer implements IInstallerContainer
{

    public InstallerContainer(ApplicationContainer parent) throws ClassNotFoundException
    {
        super(parent);
        initBindings();
    }

    public void initBindings() throws ClassNotFoundException
    {
        pico
                .addComponent(IInstallerContainer.class, this)
                .addComponent(PanelManager.class)
                ;
        addVariablerComponent();
    }

    private void addVariablerComponent() throws ClassNotFoundException
    {
        AutomatedInstallData installdata = pico.getComponent(AutomatedInstallData.class);
        VariableSubstitutor substitutor = pico.getComponent(VariableSubstitutor.class);
        String unpackerclassname = installdata.getInfo().getUnpackerClassName();
        Class<IUnpacker> unpackerclass = (Class<IUnpacker>) Class.forName(unpackerclassname);
        pico
                .addComponent(IUnpacker.class, unpackerclass)
                .addComponent(InstallerFrame.class, InstallerFrame.class,
                        new ConstantParameter(getTitle(installdata, substitutor)),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter()
                )
                .addComponent(LanguageDialog.class, LanguageDialog.class,
                        new ConstantParameter(initFrame()),
                        new ComponentParameter(),
                        new ComponentParameter(),
                        new ComponentParameter()
                );
    }


    private JFrame initFrame()
    {
        ResourceManager resourceManager = pico.getComponent(ResourceManager.class);
        // Dummy Frame
        JFrame frame = new JFrame();
        ImageIcon imageIcon = null;
        try
        {
            imageIcon = resourceManager.getImageIconResource("JFrameIcon");
        }
        catch (ResourceNotFoundException e)
        {
            imageIcon = new ImageIcon(this.getClass().getResource("/img/JFrameIcon.png"));
        }
        frame.setIconImage(imageIcon.getImage());

        Dimension frameSize = frame.getSize();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                (screenSize.height - frameSize.height) / 2 - 10);
        return frame;
    }

    private String getTitle(AutomatedInstallData automatedInstallData, VariableSubstitutor vs)
    {
        // Use a alternate message if defined.
        final String key = "installer.reversetitle";
        String message = automatedInstallData.getLangpack().getString(key);
        // message equal to key -> no message defined.
        if (message.indexOf(key) > -1)
        {
            return automatedInstallData.getLangpack().getString("installer.title")
                    + automatedInstallData.getInfo().getAppName();
        }
        else
        { // Attention! The alternate message has to contain the whole message including
            // $APP_NAME and may be $APP_VER.
            return vs.substitute(message);
        }
    }


}
<commit_msg>Use of configuration name instead of constant parameter for installer container<commit_after>package com.izforge.izpack.installer.container.impl;

import com.izforge.izpack.api.data.AutomatedInstallData;
import com.izforge.izpack.api.data.ResourceManager;
import com.izforge.izpack.api.exception.ResourceNotFoundException;
import com.izforge.izpack.api.substitutor.VariableSubstitutor;
import com.izforge.izpack.core.container.AbstractChildContainer;
import com.izforge.izpack.installer.base.InstallerFrame;
import com.izforge.izpack.installer.container.IInstallerContainer;
import com.izforge.izpack.installer.language.LanguageDialog;
import com.izforge.izpack.installer.manager.PanelManager;
import com.izforge.izpack.installer.unpacker.IUnpacker;
import org.picocontainer.Characteristics;

import javax.swing.*;
import java.awt.*;

/**
 * Container for panel level component
 */
public class InstallerContainer extends AbstractChildContainer implements IInstallerContainer
{

    public InstallerContainer(ApplicationContainer parent) throws ClassNotFoundException
    {
        super(parent);
        initBindings();
    }

    public void initBindings() throws ClassNotFoundException
    {
        pico.addComponent(IInstallerContainer.class, this)
                .addComponent(PanelManager.class);

        AutomatedInstallData installdata = pico.getComponent(AutomatedInstallData.class);
        VariableSubstitutor substitutor = pico.getComponent(VariableSubstitutor.class);
        String unpackerclassname = installdata.getInfo().getUnpackerClassName();
        Class<IUnpacker> unpackerclass = (Class<IUnpacker>) Class.forName(unpackerclassname);
        pico
                // Configuration of title parameter in InstallerFrame
                .addConfig("title", getTitle(installdata, substitutor))
                        // Configuration of frame parameter in languageDialog
                .addConfig("frame", initFrame());
        pico
                .addComponent(IUnpacker.class, unpackerclass)
                .as(Characteristics.USE_NAMES).addComponent(InstallerFrame.class)
                .as(Characteristics.USE_NAMES).addComponent(LanguageDialog.class);
    }


    private JFrame initFrame()
    {
        ResourceManager resourceManager = pico.getComponent(ResourceManager.class);
        // Dummy Frame
        JFrame frame = new JFrame();
        ImageIcon imageIcon = null;
        try
        {
            imageIcon = resourceManager.getImageIconResource("JFrameIcon");
        }
        catch (ResourceNotFoundException e)
        {
            imageIcon = new ImageIcon(this.getClass().getResource("/img/JFrameIcon.png"));
        }
        frame.setIconImage(imageIcon.getImage());

        Dimension frameSize = frame.getSize();
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((screenSize.width - frameSize.width) / 2,
                (screenSize.height - frameSize.height) / 2 - 10);
        return frame;
    }

    private String getTitle(AutomatedInstallData automatedInstallData, VariableSubstitutor vs)
    {
        // Use a alternate message if defined.
        final String key = "installer.reversetitle";
        String message = automatedInstallData.getLangpack().getString(key);
        // message equal to key -> no message defined.
        if (message.indexOf(key) > -1)
        {
            return automatedInstallData.getLangpack().getString("installer.title")
                    + automatedInstallData.getInfo().getAppName();
        }
        else
        { // Attention! The alternate message has to contain the whole message including
            // $APP_NAME and may be $APP_VER.
            return vs.substitute(message);
        }
    }


}

{'fraction_non_alphanumeric': 0.08717125571058155, 'fraction_numerical': 0.0012347203358439314, 'mean_word_length': 2.655234657039711, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '3408497', 'n_tokens_mistral': 2122, 'n_tokens_neox': 2016, 'n_words': 394}