package eu.ydp.empiria.player.client.module.colorfill.view;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiTemplate;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;

import eu.ydp.empiria.player.client.module.model.color.ColorModel;
import eu.ydp.empiria.player.client.resources.StyleNameConstants;
import eu.ydp.gwtutil.client.ui.InputInsideButtonHack;

public class PaletteButtonImpl extends Composite implements PaletteButton {

	private static PaletteButtonUiBinder uiBinder = GWT.create(PaletteButtonUiBinder.class);

	@UiTemplate("PaletteButton.ui.xml")
	interface PaletteButtonUiBinder extends UiBinder<Widget, PaletteButtonImpl> {
	}

	@UiField
	FlowPanel container;

	@UiField
	PushButton button;

	@UiField
	FlowPanel description;

	private StyleNameConstants styleNameConstants;

	@Inject
	public PaletteButtonImpl(StyleNameConstants styleNameConstants, InputInsideButtonHack inputInsideButtonHack) {
		initWidget(uiBinder.createAndBindUi(this));
		this.styleNameConstants = styleNameConstants;
		inputInsideButtonHack.activateIfNeededFor(button);
	}

	@Override
	public void setColor(ColorModel color) {
		container.addStyleDependentName(color.toStringRgba());
	}

	@Override
	public void select() {
		container.addStyleName(styleNameConstants.QP_COLORFILL_PALETTE_BUTTON_CONTAINER_SELECTED());
	}

	@Override
	public void deselect() {
		container.removeStyleName(styleNameConstants.QP_COLORFILL_PALETTE_BUTTON_CONTAINER_SELECTED());
	}

	@Override
	public void setDescription(String description) {
		this.description.getElement().setInnerHTML(description);
	}
}

@@ -646,32 +646,32 @@
 ui.Input
-InsideButtonHack
+ToButtonReplacer
 ;%0D%0A%0D%0Apub
@@ -955,22 +955,20 @@
 nImpl%3E %7B
-%0D%0A%09
 %7D%0D%0A
+%09
 %0D%0A%09@UiFi
@@ -1029,18 +1029,19 @@
 utton;%0D%0A
+%09
 %0D%0A
-
 %09@UiFiel
@@ -1068,18 +1068,19 @@
 ption;%0D%0A
+%09
 %0D%0A
-
 %09private
@@ -1120,18 +1120,19 @@
 tants;%0D%0A
+%09
 %0D%0A
-
 %09@Inject
@@ -1207,46 +1207,38 @@
 nput
-InsideButtonHack inputInsideButtonHack
+ToButtonReplacer inputReplacer
 ) %7B%0D
@@ -1345,44 +1345,45 @@
 nput
-InsideButtonHack.activateIfNeededFor
+Replacer.changeInputTypeChildToButton
 (but

Revert "refactor and add condition to hack YPUB-5928"