componentChooser.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
final Window chooser = new Window("Choose component",
layout);
layout.setSizeUndefined();
chooser.setModal(true);
NativeSelect select = new NativeSelect(
"Choose component to edit");
select.setNullSelectionAllowed(false);
IndexedContainer container = new IndexedContainer();
container.addContainerProperty("caption", String.class, "");
Iterator<Component> componentIterator = l
.getComponentIterator();
while (componentIterator.hasNext()) {
AbstractComponent next = (AbstractComponent) componentIterator
.next();
Item item = container.addItem(next);
String caption = next.getClass().getSimpleName();
caption += "; cap: " + next.getCaption() + "; debugid"
+ getId();
if (next instanceof Property) {
caption += " value:"
+ ((Property<?>) next).getValue();
}
item.getItemProperty("caption").setValue(caption);
}
select.setContainerDataSource(container);
select.setItemCaptionPropertyId("caption");
select.setImmediate(true);
select.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
editcomponent((Component) event.getProperty()
.getValue());
getMainWindow().removeWindow(chooser);
}
});
layout.addComponent(select);
getMainWindow().addWindow(chooser);
}
});
addComponent(componentChooser);
Button addComp = new Button("add component");
addComp.addListener(new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
final Window chooser = new Window(
"Choose component type to add", layout);
layout.setSizeUndefined();
chooser.setModal(true);
NativeSelect select = new NativeSelect(
"Choose component to edit");
select.setNullSelectionAllowed(false);