<commit_before>package de.larmic.butterfaces.component.showcase.comboBox;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;
import javax.faces.view.ViewScoped;
import javax.inject.Named;

import de.larmic.butterfaces.component.partrenderer.StringUtils;
import de.larmic.butterfaces.component.showcase.AbstractInputShowcase;
import de.larmic.butterfaces.component.showcase.example.AbstractCodeExample;
import de.larmic.butterfaces.component.showcase.example.CssCodeExample;
import de.larmic.butterfaces.component.showcase.example.JavaCodeExample;
import de.larmic.butterfaces.component.showcase.example.XhtmlCodeExample;
import de.larmic.butterfaces.component.showcase.type.ComboBoxValueType;

@Named
@ViewScoped
@SuppressWarnings("serial")
public class ComboBoxShowcase extends AbstractInputShowcase implements Serializable {

    private ComboBoxValueType comboBoxValueType = ComboBoxValueType.TEMPLATE;
    private FacetType selectedFacetType = FacetType.NONE;

    private boolean autoFocus;

    private final List<SelectItem> foos = new ArrayList<>();
    private final List<SelectItem> enums = new ArrayList<>();
    private final List<SelectItem> strings = new ArrayList<>();

    private Episode chosenEpisode;

    public ComboBoxShowcase() {
        this.initFoos();
        this.initStrings();
        this.initEnums();
    }

    @Override
    protected Object initValue() {
        return null;
    }

    @Override
    public void buildCodeExamples(final List<AbstractCodeExample> codeExamples) {
        final XhtmlCodeExample xhtmlCodeExample = createXhtmlExample();

        codeExamples.add(xhtmlCodeExample);
        if (this.comboBoxValueType == ComboBoxValueType.TEMPLATE) {
            codeExamples.add(createEpisodeCssCodeExample());
            codeExamples.add(createEpisodeJavaCodeExample());
        }
        generateDemoCSS(codeExamples);
    }

    private JavaCodeExample createEpisodeJavaCodeExample() {
        final JavaCodeExample javaCodeExample = new JavaCodeExample("Episode.java", "episode", "combobox.demo", "Episode", false);

        javaCodeExample.appendInnerContent("    private int numberInSeries;");
        javaCodeExample.appendInnerContent("    private String title;");
        javaCodeExample.appendInnerContent("    private String writtenBy;");
        javaCodeExample.appendInnerContent("    private String originalAirDate;");
        javaCodeExample.appendInnerContent("    private String image;");
        javaCodeExample.appendInnerContent("    // [...] getter + setter");

        return javaCodeExample;
    }

    private CssCodeExample createEpisodeCssCodeExample() {
        final CssCodeExample cssCodeExample = new CssCodeExample();

        cssCodeExample.addCss(".stargateEpisodeItem", "display: flex", "align-items: stretch");<commit_msg>BUT-343 fixed readonly mode on empty combobox<commit_after>package de.larmic.butterfaces.component.showcase.comboBox;

import de.larmic.butterfaces.component.partrenderer.StringUtils;
import de.larmic.butterfaces.component.showcase.AbstractInputShowcase;
import de.larmic.butterfaces.component.showcase.example.AbstractCodeExample;
import de.larmic.butterfaces.component.showcase.example.CssCodeExample;
import de.larmic.butterfaces.component.showcase.example.JavaCodeExample;
import de.larmic.butterfaces.component.showcase.example.XhtmlCodeExample;
import de.larmic.butterfaces.component.showcase.type.ComboBoxValueType;

import javax.faces.model.SelectItem;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Named
@ViewScoped
@SuppressWarnings("serial")
public class ComboBoxShowcase extends AbstractInputShowcase implements Serializable {

    private ComboBoxValueType comboBoxValueType = ComboBoxValueType.TEMPLATE;
    private FacetType selectedFacetType = FacetType.NONE;

    private boolean autoFocus;

    private final List<SelectItem> foos = new ArrayList<>();
    private final List<SelectItem> enums = new ArrayList<>();
    private final List<SelectItem> strings = new ArrayList<>();

    private Episode chosenEpisode;

    public ComboBoxShowcase() {
        this.initFoos();
        this.initStrings();
        this.initEnums();
    }

    @Override
    protected Object initValue() {
        return null;
    }

    @Override
    public void buildCodeExamples(final List<AbstractCodeExample> codeExamples) {
        final XhtmlCodeExample xhtmlCodeExample = createXhtmlExample();

        codeExamples.add(xhtmlCodeExample);
        if (this.comboBoxValueType == ComboBoxValueType.TEMPLATE) {
            codeExamples.add(createEpisodeJavaCodeExample());
            codeExamples.add(createEpisodeCssCodeExample());
        }
        generateDemoCSS(codeExamples);
    }

    private JavaCodeExample createEpisodeJavaCodeExample() {
        final JavaCodeExample javaCodeExample = new JavaCodeExample("Episode.java", "episode", "combobox.demo", "Episode", false);

        javaCodeExample.appendInnerContent("    private int numberInSeries;");
        javaCodeExample.appendInnerContent("    private String title;");
        javaCodeExample.appendInnerContent("    private String writtenBy;");
        javaCodeExample.appendInnerContent("    private String originalAirDate;");
        javaCodeExample.appendInnerContent("    private String image;");
        javaCodeExample.appendInnerContent("    // [...] getter + setter");

        return javaCodeExample;
    }

    private CssCodeExample createEpisodeCssCodeExample() {
        final CssCodeExample cssCodeExample = new CssCodeExample();

        cssCodeExample.addCss(".stargateEpisodeItem", "display: flex", "align-items: stretch");
{'fraction_non_alphanumeric': 0.09399342219144885, 'fraction_numerical': 0.0005193006750908776, 'mean_word_length': 4.325345622119816, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 18, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1570977', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1558, 'n_words': 301}