blob: 19fdf6948a7dcce52bc4dee3d7230b19f8238fce (
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
|
package com.vaadin.tests.components.ui;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.MarginInfo;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.tests.widgetset.TestingWidgetSet;
import com.vaadin.tests.widgetset.server.IdTestLabel;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
@Widgetset(TestingWidgetSet.NAME)
@Theme("tests-tickets")
public class IdOverrideTest extends AbstractReindeerTestUI {
@Override
protected String getTestDescription() {
return "Id shouldn't get overridden unless specifically re-set.<br>"
+ "First two are custom labels with a default id, third is an ordinary label for comparison.";
}
@Override
protected Integer getTicketNumber() {
return 10179;
}
@Override
protected void setup(VaadinRequest request) {
getLayout().setSpacing(true);
getLayout().setMargin(new MarginInfo(true, false, false, false));
final IdTestLabel idTestLabel = new IdTestLabel("default id");
idTestLabel.setSizeUndefined();
addComponent(idTestLabel);
final IdTestLabel idTestLabelWithId = new IdTestLabel("set id");
idTestLabelWithId.setSizeUndefined();
idTestLabelWithId.setId("set10179");
addComponent(idTestLabelWithId);
final Label label = new Label("no id");
label.setSizeUndefined();
addComponent(label);
Button button = new Button();
button.setCaption("Toggle");
button.addClickListener(event -> {
if (idTestLabelWithId.getId() == null) {
idTestLabelWithId.setId("set10179");
idTestLabelWithId.setValue("set id");
idTestLabel.setValue("default id");
label.setValue("no id");
} else {
idTestLabelWithId.setId(null);
idTestLabelWithId.setValue("removed id");
idTestLabel.setValue("still default id");
label.setValue("still no id");
}
});
button.setId("toggle");
addComponent(button);
}
}
|