aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/themes/valo/TextFields.java
blob: 20383d798cbb51a1f29e05d79ad35b33917d54e7 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
package com.vaadin.tests.themes.valo;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.UserError;
import com.vaadin.ui.Button;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;

public class TextFields extends VerticalLayout implements View {
    private TestIcon testIcon = new TestIcon(140);

    public TextFields() {
        setSpacing(false);

        Label h1 = new Label("Text Fields");
        h1.addStyleName(ValoTheme.LABEL_H1);
        addComponent(h1);

        HorizontalLayout row = new HorizontalLayout();
        row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
        addComponent(row);

        TextField tf = new TextField("Normal");
        tf.setPlaceholder("First name");
        tf.setIcon(testIcon.get());
        row.addComponent(tf);

        tf = new TextField("Custom color");
        tf.setPlaceholder("Email");
        tf.addStyleName("color1");
        row.addComponent(tf);

        tf = new TextField("User Color");
        tf.setPlaceholder("Gender");
        tf.addStyleName("color2");
        row.addComponent(tf);

        tf = new TextField("Themed");
        tf.setPlaceholder("Age");
        tf.addStyleName("color3");
        row.addComponent(tf);

        tf = new TextField("Error");
        tf.setValue("Something’s wrong");
        tf.setComponentError(new UserError("Fix it, now!"));
        row.addComponent(tf);

        tf = new TextField("Error, borderless");
        tf.setValue("Something’s wrong");
        tf.setComponentError(new UserError("Fix it, now!"));
        tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
        row.addComponent(tf);

        tf = new TextField("Read-only");
        tf.setPlaceholder("Nationality");
        tf.setValue("Finnish");
        tf.setReadOnly(true);
        row.addComponent(tf);

        tf = new TextField("Small");
        tf.setValue("Field value");
        tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        row.addComponent(tf);

        tf = new TextField("Large");
        tf.setValue("Field value");
        tf.addStyleName(ValoTheme.TEXTFIELD_LARGE);
        tf.setIcon(testIcon.get(true));
        row.addComponent(tf);

        tf = new TextField("Icon inside");
        tf.setPlaceholder("Ooh, an icon");
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get());
        row.addComponent(tf);

        tf = new TextField("Large, Icon inside");
        tf.setPlaceholder("Ooh, an icon");
        tf.addStyleName(ValoTheme.TEXTFIELD_LARGE);
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get());
        row.addComponent(tf);

        tf = new TextField("Small, Icon inside");
        tf.setPlaceholder("Ooh, an icon");
        tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get());
        row.addComponent(tf);

        tf = new TextField("16px supported by default");
        tf.setPlaceholder("Image icon");
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get(true, 16));
        row.addComponent(tf);

        tf = new TextField();
        tf.setValue("Font, no caption");
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get());
        row.addComponent(tf);

        tf = new TextField();
        tf.setValue("Image, no caption");
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get(true, 16));
        row.addComponent(tf);

        CssLayout group = new CssLayout();
        group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
        row.addComponent(group);

        tf = new TextField();
        tf.setPlaceholder("Grouped with a button");
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.setIcon(testIcon.get());
        tf.setWidth("260px");
        group.addComponent(tf);

        Button button = new Button("Do It");
        // button.addStyleName(ValoTheme.BUTTON_PRIMARY);
        group.addComponent(button);

        tf = new TextField("Borderless");
        tf.setPlaceholder("Write here…");
        tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
        tf.setIcon(testIcon.get());
        row.addComponent(tf);

        tf = new TextField("Right-aligned");
        tf.setValue("1,234");
        tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
        row.addComponent(tf);

        tf = new TextField("Centered");
        tf.setPlaceholder("Guess what?");
        tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_CENTER);
        row.addComponent(tf);

        PasswordField pwf = new PasswordField("Password");
        pwf.setPlaceholder("Secret words");
        pwf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        pwf.setIcon(FontAwesome.LOCK);
        row.addComponent(pwf);

        pwf = new PasswordField("Password, right-aligned");
        pwf.setPlaceholder("Secret words");
        pwf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        pwf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
        pwf.setIcon(FontAwesome.LOCK);
        row.addComponent(pwf);

        pwf = new PasswordField("Password, centered");
        pwf.setPlaceholder("Secret words");
        pwf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
        pwf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_CENTER);
        pwf.setIcon(FontAwesome.LOCK);
        row.addComponent(pwf);

        tf = new TextField("Tiny");
        tf.setValue("Field value");
        tf.addStyleName(ValoTheme.TEXTFIELD_TINY);
        row.addComponent(tf);

        tf = new TextField("Huge");
        tf.setValue("Field value");
        tf.addStyleName(ValoTheme.TEXTFIELD_HUGE);
        row.addComponent(tf);

        h1 = new Label("Text Areas");
        h1.addStyleName(ValoTheme.LABEL_H1);
        addComponent(h1);

        row = new HorizontalLayout();
        row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
        addComponent(row);

        TextArea ta = new TextArea("Normal");
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        ta = new TextArea("Inline icon");
        ta.setPlaceholder("Inline icon not really working");
        ta.addStyleName("inline-icon");
        ta.setIcon(testIcon.get());
        row.addComponent(ta);

        ta = new TextArea("Custom color");
        ta.addStyleName("color1");
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        ta = new TextArea("Custom color, read-only");
        ta.addStyleName("color2");
        ta.setValue("Field value, spanning multiple lines of text");
        ta.setReadOnly(true);
        row.addComponent(ta);

        ta = new TextArea("Custom color");
        ta.addStyleName("color3");
        ta.setValue("Field value, spanning multiple lines of text");
        row.addComponent(ta);

        ta = new TextArea("Small");
        ta.addStyleName(ValoTheme.TEXTAREA_SMALL);
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        ta = new TextArea("Large");
        ta.addStyleName(ValoTheme.TEXTAREA_LARGE);
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        ta = new TextArea("Borderless");
        ta.addStyleName(ValoTheme.TEXTAREA_BORDERLESS);
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        ta = new TextArea("Right-aligned");
        ta.addStyleName(ValoTheme.TEXTAREA_ALIGN_RIGHT);
        ta.setValue("Field value, spanning multiple lines of text");
        row.addComponent(ta);

        ta = new TextArea("Centered");
        ta.addStyleName(ValoTheme.TEXTAREA_ALIGN_CENTER);
        ta.setValue("Field value, spanning multiple lines of text");
        row.addComponent(ta);

        ta = new TextArea("Tiny");
        ta.addStyleName(ValoTheme.TEXTAREA_TINY);
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        ta = new TextArea("Huge");
        ta.addStyleName(ValoTheme.TEXTAREA_HUGE);
        ta.setPlaceholder("Write your comment…");
        row.addComponent(ta);

        RichTextArea rta = new RichTextArea();
        rta.setValue("<b>Some</b> <i>rich</i> content");
        row.addComponent(rta);

        rta = new RichTextArea("Read-only");
        rta.setValue("<b>Some</b> <i>rich</i> content");
        rta.setReadOnly(true);
        row.addComponent(rta);
    }

    @Override
    public void enter(ViewChangeEvent event) {
        // TODO Auto-generated method stub

    }

}