package de.mhus.examples.vaadin.addon.ports;

import java.util.Arrays;

import org.vaadin.miki.flatselect.FlatSelect;

import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Notification;
import com.vaadin.ui.Panel;
import com.vaadin.ui.VerticalLayout;

public class FlatSelectTab extends VerticalLayout implements Component {

	public FlatSelectTab() {
        // Initialize our new UI component
		setSizeFull();
//		addStyleName("flatselect");
		{
			HorizontalLayout container = new HorizontalLayout();
	        final FlatSelect component = new FlatSelect("Pick one", Arrays.asList("options", "available", "in", "flat", "select", "are", "plenty"));
	        container.addStyleName("flatlabel");
	        container.addStyleName("flatleft");
	        container.addStyleName("flatselectable");
	        component.setOptionsPerRow(2);
	        component.setOptionsWidth("200px");
	
	        component.addValueChangeListener(e -> component.setCaption(component.getItemCaption(e.getProperty().getValue())));
	
	        // Show it in the middle of the screen
	        final VerticalLayout layout = new VerticalLayout();
	        layout.setStyleName("demoContentLayout");
	        layout.setSizeFull();
	        layout.addComponent(component);
	        layout.setComponentAlignment(component, Alignment.MIDDLE_CENTER);
	        container.addComponent(layout);
	        addComponent(container);
		}
		{
			HorizontalLayout container = new HorizontalLayout();
	        final FlatSelect component = new FlatSelect("Pick one", Arrays.asList("options", "available", "in", "flat", "select", "are", "plenty"));
	        container.addStyleName("flatselectable");
	        component.setOptionsPerRow(2);
	        component.setOptionsWidth("200px");
	
	        component.addValueChangeListener(e -> component.setCaption(component.getItemCaption(e.getProperty().getValue())));
	
	        // Show it in the middle of the screen
	        final VerticalLayout layout = new VerticalLayout();
	        layout.setStyleName("demoContentLayout");
	        layout.setSizeFull();
	        layout.addComponent(component);
	        layout.setComponentAlignment(component, Alignment.MIDDLE_CENTER);
	        container.addComponent(layout);
	        addComponent(container);
		}
		{
			HorizontalLayout container = new HorizontalLayout();
	        final FlatSelect component = new FlatSelect("Pick one", Arrays.asList("options", "available", "in", "flat", "select", "are", "plenty"));
	        container.addStyleName("flatselect");
	        container.addStyleName("flatleft");
	        container.addStyleName("flatselectable");
	        component.setOptionsPerRow(2);
	        component.setOptionsWidth("200px");
	
	        component.addValueChangeListener(e -> Notification.show("Click " + e.getProperty().getValue() ) );
	
	        // Show it in the middle of the screen
	        final VerticalLayout layout = new VerticalLayout();
	        layout.setStyleName("demoContentLayout");
	        layout.setSizeFull();
	        layout.addComponent(component);
	        layout.setComponentAlignment(component, Alignment.MIDDLE_CENTER);
	        container.addComponent(layout);
	        addComponent(container);
		}
	}
}

@@ -140,24 +140,53 @@
 .Alignment;%0A
+import com.vaadin.ui.Button;%0A
 import com.v
@@ -201,24 +201,24 @@
 .Component;%0A
-
 import com.v
@@ -343,16 +343,56 @@
 lLayout;
+%0Aimport com.vaadin.ui.Button.ClickEvent;
 %0A%0Apublic
@@ -1512,32 +1512,97 @@
 ent(container);%0A
+%09        %0A%09        container.addComponent(new Button(%22Button%22));%0A
 %09%09%7D%0A%09%09%7B%0A%09%09%09Horiz
@@ -2436,24 +2436,80 @@
 (container);
+%0A%0A%09        container.addComponent(new Button(%22Button%22));
 %0A%09%09%7D%0A%09%09%7B%0A%09%09%09
@@ -3004,20 +3004,22 @@
 .show(%22C
-lick
+hanged
  %22 + e.g
@@ -3389,32 +3389,32 @@
 ponent(layout);%0A
-
 %09        addComp
@@ -3431,16 +3431,261 @@
 ainer);%0A
+%0A%09        container.addComponent(new Button(%22Button%22));%0A%09        %0A%09        component.addClickListener(new Button.ClickListener() %7B%0A%09%09%09%09%0A%09%09%09%09@Override%0A%09%09%09%09public void buttonClick(ClickEvent event) %7B%0A%09%09%09%09%09Notification.show(%22Click%22);%0A%09%09%09%09%7D%0A%09%09%09%7D);%0A%0A
 %09%09%7D%0A%09%7D%0A%7D

add click event