layout.addComponent(new Label("Layout"));
ArrayList<String> sizes = new ArrayList<String>();
sizes.addAll(Arrays.asList("100px", "30em", "100%"));
final NativeSelect width = new NativeSelect(null, sizes);
width.setImmediate(true);
width.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (width.getValue() != null) {
l.setWidth(width.getValue().toString());
} else {
l.setWidth(null);
}
}
});
layout.addComponent(width);
layout.addComponent(new Label("×", ContentMode.HTML));
final NativeSelect height = new NativeSelect(null, sizes);
height.setImmediate(true);
height.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (height.getValue() != null) {
l.setHeight(height.getValue().toString());
} else {
l.setHeight(null);
}
}
});
layout.addComponent(height);
final CheckBox margin = new CheckBox("Margin", false);
margin.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
l.setMargin(margin.getValue().booleanValue());
}
});
margin.setImmediate(true);
layout.addComponent(margin);
layout.addComponent(margin);
final CheckBox spacing = new CheckBox("Spacing", false);
spacing.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
l.setSpacing(spacing.getValue().booleanValue());
}
});
spacing.setImmediate(true);
layout.addComponent(spacing);
// Cell controls
HorizontalLayout cell = new HorizontalLayout();
cell.addStyleName("fieldset");
cell.setSpacing(true);
controls.addComponent(cell);
cell.addComponent(new Label("Cell"));
ArrayList<Alignment> alignments = new ArrayList<Alignment>();
alignments.addAll(Arrays.asList(Alignment.TOP_LEFT,
Alignment.MIDDLE_LEFT, Alignment.BOTTOM_LEFT,
Alignment.TOP_CENTER, Alignment.MIDDLE_CENTER,
Alignment.BOTTOM_CENTER, Alignment.TOP_RIGHT,
Alignment.MIDDLE_RIGHT, Alignment.BOTTOM_RIGHT));
align = new NativeSelect(null, alignments);
for (Alignment a : alignments) {
align.setItemCaption(a,
a.getVerticalAlignment() + "-" + a.getHorizontalAlignment());
}
align.setImmediate(true);
align.setEnabled(false);
align.setNullSelectionAllowed(false);
align.select(Alignment.TOP_LEFT);
align.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (target == null) {
return;
}
l.setComponentAlignment(target, ((Alignment) align.getValue()));
}
});
cell.addComponent(align);
expand = new CheckBox("Expand");
expand.setImmediate(true);
expand.setEnabled(false);
expand.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (target != null) {
l.setExpandRatio(target, expand.getValue() ? 1 : 0);
}
}
});
cell.addComponent(expand);
// Component controls
HorizontalLayout component = new HorizontalLayout();
component.addStyleName("fieldset");
component.setSpacing(true);
root.addComponent(component);
component.addComponent(new Label("Component"));
sizes = new ArrayList<String>();
sizes.addAll(Arrays.asList("50px", "200px", "10em", "50%", "100%"));
componentWidth = new NativeSelect(null, sizes);
componentWidth.setImmediate(true);
componentWidth.setEnabled(false);
componentWidth.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (target == null) {
return;
}
if (componentWidth.getValue() != null) {
target.setWidth(componentWidth.getValue().toString());
} else {
target.setWidth(null);
}
}
});
component.addComponent(componentWidth);
component.addComponent(new Label("×", ContentMode.HTML));
componentHeight = new NativeSelect(null, sizes);
componentHeight.setImmediate(true);
componentHeight.setEnabled(false);
componentHeight.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (componentHeight.getValue() != null) {
target.setHeight(componentHeight.getValue().toString());
} else {
target.setHeight(null);
}
}
});
component.addComponent(componentHeight);
componentCaption = new NativeSelect("Caption", Arrays.asList("Short",
"Slightly Longer Caption"));
componentCaption.setImmediate(true);
componentCaption.setEnabled(false);
componentCaption.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
if (componentCaption.getValue() != null) {
target.setCaption(componentCaption.getValue().toString());
} else {
target.setCaption(null);
}
}
});
component.addComponent(componentCaption);
componentIcon = new NativeSelect("Icon", Arrays.asList(
"../runo/icons/16/folder.png", "../runo/icons/32/document.png"));
componentIcon.setImmediate(true);
componentIcon.setEnabled(false);
componentIcon.addListener(new ValueChangeListener() {
@Override