blob: 0f52424eef1f7c9192aefaaff91497018515478a (
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
|
package com.vaadin.tests.components.table;
import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractTestUIWithLog;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Label;
import com.vaadin.v7.data.util.IndexedContainer;
import com.vaadin.v7.ui.Table;
public class TableParentEnabledStateChange extends AbstractTestUIWithLog {
private Button toggle;
@Override
protected void setup(VaadinRequest request) {
addComponent(new Label(
"Toggling the enabled state of the custom component will break the selectability of the row in the table. "));
final MyCustomComponent customComponent = new MyCustomComponent();
toggle = new Button(
"Toggle enabled state ; " + customComponent.isEnabled());
toggle.addClickListener(event -> {
customComponent.setEnabled(!customComponent.isEnabled());
toggle.setCaption(
"Toggle enabled state ; " + customComponent.isEnabled());
});
addComponent(toggle);
addComponent(customComponent);
}
class MyCustomComponent extends CustomComponent {
private static final long serialVersionUID = 1L;
private FormLayout root;
private Table table;
private Button toggle;
public MyCustomComponent() {
root = new FormLayout();
setCompositionRoot(root);
setWidth("300px");
setHeight("300px");
table = new Table();
table.setWidth("200px");
table.setHeight("150px");
table.setSelectable(true);
IndexedContainer container = new IndexedContainer();
container.addContainerProperty("name", String.class,
"Select this item");
container.addItem(1);
table.setContainerDataSource(container);
root.addComponent(table);
}
}
}
|