blob: eb2bf05cf4ff1bb22e096a5d2af7212c4a36edbb (
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
|
package com.vaadin.tests.layouts.layouttester;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.v7.ui.Table;
import com.vaadin.v7.ui.TextField;
public class BaseAddReplaceMove extends BaseLayoutTestUI {
/**
* @param layoutClass
*/
public BaseAddReplaceMove(Class<? extends AbstractLayout> layoutClass) {
super(layoutClass);
}
@Override
protected void setup(VaadinRequest request) {
init();
buildLayout();
super.setup(request);
}
private void buildLayout() {
// Set undefined height to avoid expanding
l2.setHeight(null);
// extra layout from which components will be moved
final HorizontalLayout source = new HorizontalLayout();
Label label1 = new Label("OTHER LABEL 1");
label1.setWidth("100%"); // Only to make test backwards compatible
source.addComponent(label1);
Label label2 = new Label("OTHER LABEL 2");
label2.setWidth("100%"); // Only to make test backwards compatible
source.addComponent(label2);
final AbstractComponent c1 = new Label("<b>LABEL</b>",
ContentMode.HTML);
final AbstractComponent c2 = new Label("<b>LABEL</b>",
ContentMode.HTML);
final AbstractComponent c3 = new Table("TABLE");
c3.setHeight("100px");
c3.setWidth("100%");
final Button btnAdd = new Button("Test add");
final Button btnReplace = new Button("Test replace");
final Button btnMove = new Button("Test move");
final Button btnRemove = new Button("Test remove");
l1.addComponent(btnAdd);
l1.addComponent(btnReplace);
l1.addComponent(btnMove);
l1.addComponent(btnRemove);
btnAdd.addClickListener(event -> l2.addComponent(new TextField()));
btnReplace.addClickListener(event -> l2.replaceComponent(c1, c3));
btnMove.addClickListener(event -> l2.moveComponentsFrom(source));
btnRemove.addClickListener(event -> {
l2.removeComponent(c1);
l2.removeComponent(c2);
});
l2.addComponent(c1);
l2.addComponent(c2);
l2.addComponent(c3);
}
}
|