<commit_before>/*
 * Copyright 2000,2005 wingS development team.
 *
 * This file is part of wingS (http://wingsframework.org).
 *
 * wingS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * Please see COPYING for the complete licence.
 */
package org.wings;


import org.wings.plaf.ButtonCG;
import org.wings.plaf.CheckBoxCG;
import org.wings.plaf.ClickableCG;
import org.wings.plaf.RadioButtonCG;
import org.wings.plaf.ToggleButtonCG;
import org.wings.style.Selector;
import org.wings.style.CSSStyleSheet;
import org.wings.style.CSSAttributeSet;
import org.wings.style.CSSProperty;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * Base class for elements with icon and text like {@link SAbstractButton} and {@link SClickable}.
 *
 * It supports 7 different icon states.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public abstract class SAbstractIconTextCompound
        extends SComponent
        implements ItemSelectable {
    public static final int ICON_COUNT = 7;
    public static final int DISABLED_ICON = 0;
    public static final int DISABLED_SELECTED_ICON = 1;
    public static final int ENABLED_ICON = 2;
    public static final int SELECTED_ICON = 3;
    public static final int ROLLOVER_ICON = 4;
    public static final int ROLLOVER_SELECTED_ICON = 5;
    public static final int PRESSED_ICON = 6;

    /**
     * A Pseudo selector for buttons in selected state
     * Refer to {@link SComponent#setAttribute(org.wings.style.Selector, org.wings.style.CSSProperty, String)}
     */
    public static final Selector SELECTOR_SELECTED = new Selector("selected");

    private SButtonModel model;

    /**
     * The button model's <code>changeListener</code>.
     */
    protected ChangeListener changeListener = null;

    protected transient ChangeEvent changeEvent = null;

    /**
     * the text the button is showing
     */
    private String text;

    /**
     * The icon to be displayed
     */
    private SIcon icon;

    private SIcon disabledIcon;

    private SIcon selectedIcon;

    private SIcon pressedIcon;

    private SIcon disabledSelectedIcon;

    private SIcon rolloverIcon;

    private SIcon rolloverSelectedIcon;

    private int verticalTextPosition = SConstants.CENTER;

    private int horizontalTextPosition = SConstants.RIGHT;

    private int iconTextGap = 4;

    private boolean delayEvents = false;
    private boolean delayedEvent = false;

    /**
     * Create a button with given text.
     *
     * @param text the button text
     */
    public SAbstractIconTextCompound(String text) {
        setText(text);
        model = new SDefaultButtonModel();
    }

    /**
     * Creates a new submit button
     */
    public SAbstractIconTextCompound() {
        this(null);<commit_msg>o don't set empty text<commit_after>/*
 * Copyright 2000,2005 wingS development team.
 *
 * This file is part of wingS (http://wingsframework.org).
 *
 * wingS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1
 * of the License, or (at your option) any later version.
 *
 * Please see COPYING for the complete licence.
 */
package org.wings;


import org.wings.plaf.ButtonCG;
import org.wings.plaf.CheckBoxCG;
import org.wings.plaf.ClickableCG;
import org.wings.plaf.RadioButtonCG;
import org.wings.plaf.ToggleButtonCG;
import org.wings.style.Selector;
import org.wings.style.CSSStyleSheet;
import org.wings.style.CSSAttributeSet;
import org.wings.style.CSSProperty;

import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.EventListenerList;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;

/**
 * Base class for elements with icon and text like {@link SAbstractButton} and {@link SClickable}.
 *
 * It supports 7 different icon states.
 *
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 */
public abstract class SAbstractIconTextCompound
        extends SComponent
        implements ItemSelectable {
    public static final int ICON_COUNT = 7;
    public static final int DISABLED_ICON = 0;
    public static final int DISABLED_SELECTED_ICON = 1;
    public static final int ENABLED_ICON = 2;
    public static final int SELECTED_ICON = 3;
    public static final int ROLLOVER_ICON = 4;
    public static final int ROLLOVER_SELECTED_ICON = 5;
    public static final int PRESSED_ICON = 6;

    /**
     * A Pseudo selector for buttons in selected state
     * Refer to {@link SComponent#setAttribute(org.wings.style.Selector, org.wings.style.CSSProperty, String)}
     */
    public static final Selector SELECTOR_SELECTED = new Selector("selected");

    private SButtonModel model;

    /**
     * The button model's <code>changeListener</code>.
     */
    protected ChangeListener changeListener = null;

    protected transient ChangeEvent changeEvent = null;

    /**
     * the text the button is showing
     */
    private String text;

    /**
     * The icon to be displayed
     */
    private SIcon icon;

    private SIcon disabledIcon;

    private SIcon selectedIcon;

    private SIcon pressedIcon;

    private SIcon disabledSelectedIcon;

    private SIcon rolloverIcon;

    private SIcon rolloverSelectedIcon;

    private int verticalTextPosition = SConstants.CENTER;

    private int horizontalTextPosition = SConstants.RIGHT;

    private int iconTextGap = 4;

    private boolean delayEvents = false;
    private boolean delayedEvent = false;

    /**
     * Create a button with given text.
     *
     * @param text the button text
     */
    public SAbstractIconTextCompound(String text) {
        setText(text);
        model = new SDefaultButtonModel();
    }

    /**
     * Creates a new submit button
     */
    public SAbstractIconTextCompound() {
        model = new SDefaultButtonModel();
{'fraction_non_alphanumeric': 0.08189929891650732, 'fraction_numerical': 0.006373486297004461, 'mean_word_length': 3.3170563961485557, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '10771', 'n_tokens_mistral': 1849, 'n_tokens_neox': 1767, 'n_words': 585}