blob: 9c03a2149b9d88f9809543b0c2ecd444042be629 (
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
package com.vaadin.tests.tickets;
import java.util.Random;
import com.vaadin.Application;
import com.vaadin.data.Property.ValueChangeEvent;
import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.UserError;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI.LegacyWindow;
import com.vaadin.ui.VerticalLayout;
public class Ticket2029 extends Application {
int COMPONENTS;
int DIM1, DIM2;
Random r = new Random();
@Override
public void init() {
COMPONENTS = 5;
DIM1 = 504;
DIM2 = 100;
LegacyWindow w = new LegacyWindow(getClass().getSimpleName());
setMainWindow(w);
// setTheme("tests-tickets");
Panel p = createPanel();
w.getContent().addComponent(p);
// w.getLayout().addComponent(createGLPanel());
w.getContent().addComponent(createPanelV());
}
private Panel createPanel() {
Panel p = new Panel(DIM1 + "x" + DIM2 + " OrderedLayout");
p.setWidth(DIM1 + "px");
p.setHeight(DIM2 + "px");
HorizontalLayout layout = new HorizontalLayout();
p.setContent(layout);
p.getContent().setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextField tf = new TextField();
if (r.nextBoolean()) {
tf.setCaption("Caption");
}
if (r.nextBoolean()) {
tf.setRequired(true);
}
if (r.nextBoolean()) {
tf.setComponentError(new UserError("Error"));
}
tf.setWidth("100%");
layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
p.addComponent(tf);
}
return p;
}
@SuppressWarnings("unused")
private Panel createGLPanel() {
Panel p = new Panel("" + DIM1 + "x" + DIM2 + " GridLayout");
p.setWidth("" + DIM1 + "px");
p.setHeight("" + DIM2 + "px");
GridLayout layout = new GridLayout(COMPONENTS, 1);
p.setContent(layout);
p.getContent().setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextField tf = new TextField();
tf.setImmediate(true);
tf.addListener(new ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
Component c = ((Component) event.getProperty());
c.setCaption("askfdj");
}
});
if (r.nextBoolean()) {
tf.setCaption("Caption");
}
if (r.nextBoolean()) {
tf.setRequired(true);
}
if (r.nextBoolean()) {
tf.setComponentError(new UserError("Error"));
}
tf.setWidth("100%");
layout.setComponentAlignment(tf, Alignment.MIDDLE_LEFT);
p.addComponent(tf);
}
return p;
}
private Panel createPanelV() {
Panel p = new Panel("" + DIM1 + "x" + DIM2 + " OrderedLayout");
p.setWidth("" + DIM2 + "px");
p.setHeight("" + DIM1 + "px");
VerticalLayout layout = new VerticalLayout();
p.setContent(layout);
p.getContent().setSizeFull();
for (int i = 0; i < COMPONENTS; i++) {
TextArea tf = new TextArea();
if (r.nextBoolean()) {
tf.setCaption("Caption");
}
if (r.nextBoolean()) {
tf.setRequired(true);
}
if (r.nextBoolean()) {
tf.setComponentError(new UserError("Error"));
}
tf.setRows(2);
tf.setSizeFull();
layout.setComponentAlignment(tf, Alignment.BOTTOM_LEFT);
p.addComponent(tf);
}
return p;
}
}
|