setTheme("runo");
main = new LegacyWindow("PopupView test");
setMainWindow(main);
VerticalLayout panelLayout = new VerticalLayout();
panelLayout.setMargin(true);
Panel panel = new Panel("PopupTest", panelLayout);
// First test component
final ObjectProperty<String> prop = new ObjectProperty<String>(
"fooTextField");
PopupView.Content content = new PopupView.Content() {
@Override
public String getMinimizedValueAsHTML() {
return String.valueOf(prop.getValue());
}
@Override
public Component getPopupComponent() {
return new TextField("Edit foo", prop);
}
};
PopupView pe = new PopupView(content);
pe.setDescription("Click to edit");
panelLayout.addComponent(pe);
// Second test component
PopupView pe2 = new PopupView("fooLabel", new Label("Foooooooooo..."));
pe2.setDescription("Click to view");
panelLayout.addComponent(pe2);
// Third test component
final ObjectProperty<StringBuffer> prop2 = new ObjectProperty<StringBuffer>(
new StringBuffer("Text for button"));
class myButton extends Button {
public myButton() {
super("Reverse the property");
this.addListener(new Button.ClickListener() {
@Override
public void buttonClick(Button.ClickEvent event) {
StringBuffer getContents = prop2.getValue();
getContents.reverse();
}
});
}
}
VerticalLayout panel2Layout = new VerticalLayout();
panel2Layout.setMargin(true);
final Panel panel2 = new Panel("Editor with a button", panel2Layout);
panel2Layout.addComponent(new myButton());
PopupView.Content content2 = new PopupView.Content() {
@Override
public String getMinimizedValueAsHTML() {
return String.valueOf(prop2.getValue());
}
@Override
public Component getPopupComponent() {
return panel2;
}
};
PopupView p3 = new PopupView(content2);
panelLayout.addComponent(p3);
// Fourth test component
VerticalLayout panel3Layout = new VerticalLayout();
panel3Layout.setMargin(true);
final Panel panel3 = new Panel("Editor popup for a property",
panel3Layout);
TextField tf2 = new TextField("TextField for editing a property");
final ObjectProperty<String> op = new ObjectProperty<String>(
"This is property text.");
tf2.setPropertyDataSource(op);