blob: dd95ff68423fe7c6b4a227d6004f0517eb92e17d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
package com.vaadin.tests.components;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Layout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout;
public class CustomComponentwithUndefinedSize extends TestBase {
@Override
protected String getDescription() {
return "A custom component with no size definition should not prevent scrollbars from being shown when its contents is larger than its parent";
}
@Override
protected Integer getTicketNumber() {
return 2459;
}
@Override
protected void setup() {
TabSheet tabs = new TabSheet();
tabs.setSizeFull();
MyCustomComponent mcc = new MyCustomComponent();
mcc.setSizeUndefined();
// Doesn't work
tabs.addTab(mcc, "Doesn't work (CustomComponent)", null);
// Works:
tabs.addTab(mcc.buildLayout(),
"Works (no CustomComponent, same layout)", null);
addComponent(tabs);
getLayout().setSizeFull();
}
private int step = 0;
public class MyCustomComponent extends CustomComponent {
public MyCustomComponent() {
setCompositionRoot(buildLayout());
}
public Layout buildLayout() {
VerticalLayout layout = new VerticalLayout();
VerticalLayout panelLayout = new VerticalLayout();
panelLayout.setMargin(true);
final Panel widePanel = new Panel("too big", panelLayout);
widePanel.setSizeUndefined();
widePanel.setWidth("2000px");
widePanel.setHeight("200px");
layout.addComponent(widePanel);
Button button = new Button("Change panel size",
new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
switch (step++ % 4) {
case 0:
widePanel.setWidth("200px");
break;
case 1:
widePanel.setHeight("2000px");
break;
case 2:
widePanel.setWidth("2000px");
break;
case 3:
widePanel.setHeight("200px");
break;
}
}
});
panelLayout.addComponent(button);
layout.setSizeUndefined();
return layout;
}
}
}
|