<commit_before>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2014 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */

package org.geomajas.widget.utility.gwt.client.ribbon;

import org.geomajas.gwt.client.action.toolbar.parameter.ButtonLayoutStyle;
import org.geomajas.widget.utility.common.client.action.RibbonColumnAware;
import org.geomajas.widget.utility.common.client.event.DisabledEvent;
import org.geomajas.widget.utility.common.client.event.EnabledEvent;
import org.geomajas.widget.utility.common.client.event.EnabledHandler;
import org.geomajas.widget.utility.common.client.event.HasEnabledHandlers;
import org.geomajas.widget.utility.common.client.ribbon.RibbonColumn;
import org.geomajas.widget.utility.gwt.client.action.ButtonAction;
import org.geomajas.widget.utility.gwt.client.action.RadioAction;
import org.geomajas.widget.utility.gwt.client.util.GuwLayout;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Cursor;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.SelectionType;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.StatefulCanvas;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.Layout;
import com.smartgwt.client.widgets.layout.VStack;


/**
 * Implementation of the RibbonColumn interface that displays a single button. Instances of this class are initialized
 * using a {@link ButtonAction} that determines the icon, title, tool-tip and click action. If the {@link ButtonAction}
 * implements {@link RibbonColumnAware}, it will be passed a reference to this class. If the {@link ButtonAction}
 * implements {@link HasEnabledHandlers}, the enabled/disabled state of this class will follow the enabled/disabled
 * state of the action.
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class RibbonButton extends StatefulCanvas implements RibbonColumn {

	public static final String PARAMETER_RADIOGROUP = "radioGroup";
	public static final String PARAMETER_SELECTED = "selected";
	public static final String PARAMETER_SHOWDISABLEDICON = "showDisabledIcon";

	private boolean showTitles = true;

	private TitleAlignment titleAlignment;

	private int iconSize;

	private ButtonAction buttonAction;
	private Layout outer;
	private Img icon;
	private StatefulCanvas titleLabel;
	private StatefulCanvas description;

	// ------------------------------------------------------------------------
	// Constructors:
	// ------------------------------------------------------------------------

	/**
	 * Initialize this object using a {@link ButtonAction}. This button will use the icon, title, tool-tip and click
	 * action that this {@link ButtonAction} provides. By default, an icon size of 24px will be used in combination with
	 * a BOTTOM title alignment.
	 * 
	 * @param buttonAction
	 *            The {@link ButtonAction} to use as template.
	 */
	public RibbonButton(final ButtonAction buttonAction) {
		this(buttonAction, 24, TitleAlignment.BOTTOM);
	}

	/**
	 * Initialize this object using a {@link ButtonAction}. This button will use the icon, title, tool-tip and click
	 * action that this {@link ButtonAction} provides.
	 * 
	 * @param buttonAction
	 *            The {@link ButtonAction} to use as template.
	 * @param iconSize
	 *            The size (width & height) for the icon - in pixels.
	 * @param titleAlignment
	 *            The alignment for the title (BOTTOM, RIGHT).
	 */
	public RibbonButton(final ButtonAction buttonAction, int iconSize, TitleAlignment titleAlignment) {
		this.buttonAction = buttonAction;
		this.iconSize = iconSize;
		this.titleAlignment = titleAlignment;

		setCanHover(true);
		setShowHover(true);
		setHoverWrap(false);
		setHoverWidth(1);
		setTooltip(buttonAction.getTooltip());

		setShowRollOver(true);
		setShowDown(true);
		setShowDisabled(true);
		setShowDisabledIcon(false);

		String iconBaseUrl = buttonAction.getIcon();<commit_msg>GWT-597 ribbon column button size from layout class property<commit_after>/*
 * This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
 *
 * Copyright 2008-2014 Geosparc nv, http://www.geosparc.com/, Belgium.
 *
 * The program is available in open source according to the GNU Affero
 * General Public License. All contributions in this program are covered
 * by the Geomajas Contributors License Agreement. For full licensing
 * details, see LICENSE.txt in the project root.
 */

package org.geomajas.widget.utility.gwt.client.ribbon;

import org.geomajas.gwt.client.action.toolbar.parameter.ButtonLayoutStyle;
import org.geomajas.widget.utility.common.client.action.RibbonColumnAware;
import org.geomajas.widget.utility.common.client.event.DisabledEvent;
import org.geomajas.widget.utility.common.client.event.EnabledEvent;
import org.geomajas.widget.utility.common.client.event.EnabledHandler;
import org.geomajas.widget.utility.common.client.event.HasEnabledHandlers;
import org.geomajas.widget.utility.common.client.ribbon.RibbonColumn;
import org.geomajas.widget.utility.gwt.client.action.ButtonAction;
import org.geomajas.widget.utility.gwt.client.action.RadioAction;
import org.geomajas.widget.utility.gwt.client.util.GuwLayout;

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Cursor;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.SelectionType;
import com.smartgwt.client.widgets.Img;
import com.smartgwt.client.widgets.StatefulCanvas;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.Layout;
import com.smartgwt.client.widgets.layout.VStack;


/**
 * Implementation of the RibbonColumn interface that displays a single button. Instances of this class are initialized
 * using a {@link ButtonAction} that determines the icon, title, tool-tip and click action. If the {@link ButtonAction}
 * implements {@link RibbonColumnAware}, it will be passed a reference to this class. If the {@link ButtonAction}
 * implements {@link HasEnabledHandlers}, the enabled/disabled state of this class will follow the enabled/disabled
 * state of the action.
 * 
 * @author <NAME>
 * @author <NAME>
 */
public class RibbonButton extends StatefulCanvas implements RibbonColumn {

	public static final String PARAMETER_RADIOGROUP = "radioGroup";
	public static final String PARAMETER_SELECTED = "selected";
	public static final String PARAMETER_SHOWDISABLEDICON = "showDisabledIcon";

	private boolean showTitles = true;

	private TitleAlignment titleAlignment;

	private int iconSize;

	private ButtonAction buttonAction;
	private Layout outer;
	private Img icon;
	private StatefulCanvas titleLabel;
	private StatefulCanvas description;

	// ------------------------------------------------------------------------
	// Constructors:
	// ------------------------------------------------------------------------

	/**
	 * Initialize this object using a {@link ButtonAction}. This button will use the icon, title, tool-tip and click
	 * action that this {@link ButtonAction} provides. By default, an icon size of 24px will be used in combination with
	 * a BOTTOM title alignment.
	 * 
	 * @param buttonAction
	 *            The {@link ButtonAction} to use as template.
	 */
	public RibbonButton(final ButtonAction buttonAction) {
		this(buttonAction, GuwLayout.ribbonColumnButtonIconSize, TitleAlignment.BOTTOM);
	}

	/**
	 * Initialize this object using a {@link ButtonAction}. This button will use the icon, title, tool-tip and click
	 * action that this {@link ButtonAction} provides.
	 * 
	 * @param buttonAction
	 *            The {@link ButtonAction} to use as template.
	 * @param iconSize
	 *            The size (width & height) for the icon - in pixels.
	 * @param titleAlignment
	 *            The alignment for the title (BOTTOM, RIGHT).
	 */
	public RibbonButton(final ButtonAction buttonAction, int iconSize, TitleAlignment titleAlignment) {
		this.buttonAction = buttonAction;
		this.iconSize = iconSize;
		this.titleAlignment = titleAlignment;

		setCanHover(true);
		setShowHover(true);
		setHoverWrap(false);
		setHoverWidth(1);
		setTooltip(buttonAction.getTooltip());

		setShowRollOver(true);
		setShowDown(true);
		setShowDisabled(true);
		setShowDisabledIcon(false);

		String iconBaseUrl = buttonAction.getIcon();
{'fraction_non_alphanumeric': 0.12104726283577015, 'fraction_numerical': 0.003060183611016661, 'mean_word_length': 3.894065446478092, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2283277', 'n_tokens_mistral': 2610, 'n_tokens_neox': 2450, 'n_words': 713}