package eu.ydp.empiria.player.client.components;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseOutEvent;
import com.google.gwt.event.dom.client.MouseOutHandler;
import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.Widget;

public class ExListBoxOption {

	protected Widget baseBody;
	protected Widget popupBody;
	protected Panel popupPanel;
	protected Widget popupButton;
	
	public ExListBoxOption(Widget baseBody, Widget popupBody){
		this.baseBody = baseBody;
		this.popupBody = popupBody;
		
		popupButton = new PushButton();
		popupButton.setStyleName("qp-exlistbox-popup-option-button");				
		
		popupPanel = new FlowPanel();
		popupPanel.setStyleName("qp-exlistbox-popup-option-panel");
		popupPanel.addDomHandler(new MouseOverHandler() {
			
			@Override
			public void onMouseOver(MouseOverEvent arg0) {
				popupPanel.setStyleName("qp-exlistbox-popup-option-panel-over");				
			}
		}, MouseOverEvent.getType());
		popupPanel.addDomHandler(new MouseOutHandler() {
			
			@Override
			public void onMouseOut(MouseOutEvent arg0) {
				popupPanel.setStyleName("qp-exlistbox-popup-option-panel");
				
			}
		}, MouseOutEvent.getType());
		popupPanel.addDomHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent arg0) {
				popupPanel.setStyleName("qp-exlistbox-popup-option-panel");
			}
		}, ClickEvent.getType());
		popupPanel.add(popupBody);
		popupPanel.add(popupButton);
		
	}
	
	public Widget getPopupBody(){
		return popupPanel;
	}
	
	public Widget getBaseBody(){
		return baseBody;
	}
		
	public void setSelected(boolean sel){
		if (sel)
			popupButton.setStyleName("qp-exlistbox-popup-option-button-selected");
		else
			popupButton.setStyleName("qp-exlistbox-popup-option-button");
	}
}

@@ -723,24 +723,99 @@
 Button;%0D%0A%09%0D%0A
+%09protected boolean selected = false;%0D%0A%09protected boolean over = false;%0D%0A%09%0D%0A
 %09public ExLi
@@ -1262,70 +1262,20 @@
 %09%09%09%09
-popupPanel.setStyleName(%22qp-exlistbox-popup-option-panel-over%22
+setOver(true
 );%09%09
@@ -1445,65 +1445,21 @@
 %09%09%09%09
-popupPanel.setStyleName(%22qp-exlistbox-popup-option-panel%22
+setOver(false
 );%0D%0A
@@ -1621,65 +1621,21 @@
 %09%09%09%09
-popupPanel.setStyleName(%22qp-exlistbox-popup-option-panel%22
+setOver(false
 );%0D%0A
@@ -1863,60 +1863,443 @@
 %7D%0D%0A%09
-%09%0D%0A%09public void setSelected(boolean sel)%7B%0D%0A%09%09if (sel
+%0D%0A%09protected void setOver(boolean ov)%7B%0D%0A%09%09over = ov;%0D%0A%09%09updateStyle();%0D%0A%09%7D%0D%0A%09%09%0D%0A%09public void setSelected(boolean sel)%7B%0D%0A%09%09selected = sel;%0D%0A%09%09updateStyle();%0D%0A%09%7D%0D%0A%09%0D%0A%09protected void updateStyle()%7B%0D%0A%09%09String selectedPart = %22%22;%0D%0A%09%09if (selected)%0D%0A%09%09%09selectedPart = %22-selected%22;%0D%0A%09%09String overPart = %22%22;%0D%0A%09%09if (over)%0D%0A%09%09%09overPart = %22-over%22;%0D%0A%09%09popupPanel.setStyleName(%22qp-exlistbox-popup-option-panel%22+selectedPart+overPart);%0D%0A%09%09if (selected
 )%0D%0A%09

change styles in ExListBoxOption task#54395