public CssLayoutDemo() {
setMargin(true);
setSpacing(true);
setSizeFull();
final FancyCssLayout cssLayout = new FancyCssLayout();
Label todo = new Label(
"FancyCssLayout adds transitions when you add or remove components from it.");
addComponent(todo);
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setWidth("100%");
addComponent(hLayout);
Button addContent = new Button("Add new content item");
hLayout.addComponent(addContent);
CheckBox middleCbox = new CheckBox("add middle");
middleCbox.setImmediate(true);
middleCbox.setValue(addCssMiddle);
hLayout.addComponent(middleCbox);
CheckBox marginCbox = new CheckBox("slide");
marginCbox.setImmediate(true);
marginCbox.setValue(cssLayout
.isTransitionEnabled(FancyTransition.SLIDE));
hLayout.addComponent(marginCbox);
CheckBox styleCbox = new CheckBox("cards");
styleCbox.setImmediate(true);
styleCbox.setValue(boxMode);
hLayout.addComponent(styleCbox);
final Label counterLabel = new Label(getClickCounterCaption());
hLayout.addComponent(counterLabel);
cssLayout.setSizeFull();
addComponent(cssLayout);
setExpandRatio(cssLayout, 1.0f);
for (int i = 0; i < 10; ++i) {
addCssLayoutContent(cssLayout);
}
addContent.addClickListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
addCssLayoutContent(cssLayout);
}
});
middleCbox.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
addCssMiddle = (Boolean) event.getProperty().getValue();
}
});
marginCbox.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
cssLayout.setSlideEnabled((Boolean) event.getProperty()
.getValue());
}
});
styleCbox.addValueChangeListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
boolean value = (Boolean) event.getProperty().getValue();
Iterator<Component> iter = cssLayout.iterator();
while (iter.hasNext()) {
Component component = iter.next();
if (value) {
component.addStyleName("demo-removable-two");
} else {
component.removeStyleName("demo-removable-two");
}
}
boxMode = value;
}
});
cssLayout.addLayoutClickListener(new LayoutClickListener() {
@Override
public void layoutClick(LayoutClickEvent event) {
++clickCounter;
if (event.getChildComponent() == null) {