blob: ce260f108de656c87a13ab76804cac8597d8e437 (
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
|
/*
* Copyright 2000-2014 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.vaadin.tests.widgetset.server.grid;
import java.util.Arrays;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.tests.widgetset.TestingWidgetSet;
import com.vaadin.tests.widgetset.client.grid.GridClientColumnRendererConnector.Renderers;
import com.vaadin.tests.widgetset.client.grid.GridClientColumnRendererRpc;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeButton;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@Widgetset(TestingWidgetSet.NAME)
public class GridClientColumnRenderers extends UI {
/**
* Controls the grid on the client side
*/
public static class GridController extends AbstractComponent {
private GridClientColumnRendererRpc rpc() {
return getRpcProxy(GridClientColumnRendererRpc.class);
}
/**
* Adds a new column with a renderer to the grid.
*/
public void addColumn(Renderers renderer) {
rpc().addColumn(renderer);
}
/**
* Tests detaching and attaching grid
*/
public void detachAttach() {
rpc().detachAttach();
}
/**
* @since
*/
public void triggerClientSorting() {
rpc().triggerClientSorting();
}
/**
* @since
*/
public void triggerClientSortingTest() {
rpc().triggerClientSortingTest();
}
/**
* @since
*/
public void shuffle() {
rpc().shuffle();
}
}
@Override
protected void init(VaadinRequest request) {
final GridController controller = new GridController();
final CssLayout controls = new CssLayout();
final VerticalLayout content = new VerticalLayout();
content.addComponent(controller);
content.addComponent(controls);
setContent(content);
final NativeSelect select = new NativeSelect(
"Add Column with Renderer", Arrays.asList(Renderers.values()));
select.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
for (Renderers renderer : Renderers.values()) {
select.setItemCaption(renderer, renderer.toString());
}
select.setValue(Renderers.TEXT_RENDERER);
select.setNullSelectionAllowed(false);
controls.addComponent(select);
NativeButton addColumnBtn = new NativeButton("Add");
addColumnBtn.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
Renderers renderer = (Renderers) select.getValue();
controller.addColumn(renderer);
}
});
controls.addComponent(addColumnBtn);
NativeButton detachAttachBtn = new NativeButton("DetachAttach");
detachAttachBtn.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
controller.detachAttach();
}
});
controls.addComponent(detachAttachBtn);
NativeButton shuffleButton = new NativeButton("Shuffle");
shuffleButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
controller.shuffle();
}
});
controls.addComponent(shuffleButton);
NativeButton sortButton = new NativeButton("Trigger sorting event");
sortButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
controller.triggerClientSorting();
}
});
controls.addComponent(sortButton);
NativeButton testSortingButton = new NativeButton("Test sorting");
testSortingButton.addClickListener(new ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
controller.triggerClientSortingTest();
}
});
controls.addComponent(testSortingButton);
Label console = new Label();
console.setContentMode(ContentMode.HTML);
console.setId("testDebugConsole");
content.addComponent(console);
}
}
|