Lots of Content ...
", ContentMode.HTML));
208 |
209 | mainLayout.addComponent(middleContent);
210 | mainLayout.setExpandRatio(middleContent, 1);
211 | setContent(mainLayout);
212 | }
213 | ```
214 | 
215 |
216 | The Layouting of the SliderPanel is not made absolute because of the possibility to use it also within the layout:
217 |
218 | 
219 |
220 |
221 | The MIT License (MIT)
222 | -------------------------
223 |
224 | Copyright (c) 2017 rocketbase.io
225 |
226 | Permission is hereby granted, free of charge, to any person obtaining a copy
227 | of this software and associated documentation files (the "Software"), to deal
228 | in the Software without restriction, including without limitation the rights
229 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
230 | copies of the Software, and to permit persons to whom the Software is
231 | furnished to do so, subject to the following conditions:
232 |
233 | The above copyright notice and this permission notice shall be included in all
234 | copies or substantial portions of the Software.
235 |
236 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
237 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
238 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
239 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
240 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
241 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
242 | SOFTWARE.
243 |
244 |
--------------------------------------------------------------------------------
/vaadin-sliderpanel/src/main/java/org/vaadin/sliderpanel/SliderPanel.java:
--------------------------------------------------------------------------------
1 | package org.vaadin.sliderpanel;
2 |
3 | import com.vaadin.shared.Registration;
4 | import com.vaadin.ui.AbstractSingleComponentContainer;
5 | import com.vaadin.ui.Component;
6 | import com.vaadin.util.ReflectTools;
7 | import org.vaadin.sliderpanel.client.*;
8 |
9 | import java.io.Serializable;
10 | import java.lang.reflect.Method;
11 |
12 | /**
13 | * Vaadin SliderPanel
14 | *
15 | * @author Marten Prieß (http://www.non-rocket-science.com)
16 | * @version 1.0
17 | */
18 | public class SliderPanel extends AbstractSingleComponentContainer {
19 |
20 |
21 | private final SliderPanelServerRpc rpc = new SliderPanelServerRpc() {
22 |
23 | @Override
24 | public void clicked(final boolean visible) {
25 | getState().expand = visible;
26 | SliderPanel.this.fireEvent(new SliderPanelToggleEvent(SliderPanel.this, visible));
27 | }
28 | };
29 |
30 | /**
31 | * {@link SliderPanelBuilder} simplify the configuration of the {@link SliderPanel} grid = new Grid(Inhabitants.class);
204 | grid.setSizeFull();
205 |
206 | // init Container
207 | grid.setItems(DummyDataGen.genInhabitants(100));
208 | grid.setColumnOrder("id", "gender", "name", "bodySize", "birthday", "onFacebook");
209 |
210 | return grid;
211 | }
212 |
213 | private Component genInfo() {
214 | VerticalLayout info = new VerticalLayout();
215 | info.setMargin(true);
216 | info.setWidth("320px");
217 | info.setHeight("100%");
218 | info.addStyleName("black-bg");
219 |
220 | Label details = new Label("Vaadin SliderPanel
"
221 | + "Developed by Marten Prieß
"
222 | + "www.rocketbase.io
"
223 | + "
Sample & Sourcecode:
github.com
"
224 | + "Vaadin Addon-Site:
vaadin.com
", ContentMode.HTML);
225 | details.setSizeFull();
226 | info.addComponentsAndExpand(details);
227 | info.addComponent(new Label("Version: " + buildVersion + "
", ContentMode.HTML));
228 |
229 | return info;
230 | }
231 |
232 | private VerticalLayout dummyContent(final String title, final int length) {
233 | String text = "";
234 | for (int x = 0; x <= length; x++) {
235 | text += LOREM_IPSUM + " ";
236 | }
237 | Label htmlDummy = new Label(String.format("%s
%s", title, text.trim()), ContentMode.HTML);
238 | VerticalLayout component = new VerticalLayout(htmlDummy);
239 | component.setExpandRatio(htmlDummy, 1);
240 | component.addComponent(new Button(title, new Button.ClickListener() {
241 | @Override
242 | public void buttonClick(final ClickEvent event) {
243 | Notification.show("clicked: " + title, Type.HUMANIZED_MESSAGE);
244 | }
245 | }));
246 | component.setMargin(true);
247 | component.setSpacing(true);
248 | return component;
249 | }
250 | }
251 |
--------------------------------------------------------------------------------
/vaadin-sliderpanel/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 4.0.0
5 | org.vaadin.addons
6 | vaadin-sliderpanel
7 | 2.2.2-SNAPSHOT
8 | jar
9 |
10 | SliderPanel
11 | SlidingPanel that allows to collapse and expand. Lays of rest of the content
12 | https://github.com/melistik/vaadin-sliderpanel
13 |
14 |
15 |
16 | Marten Prieß
17 | marten@rocketbase.io
18 | rocketbase.io software productions
19 | http://www.rocketbase.io
20 |
21 |
22 |
23 |
24 | 8.0.0
25 | 1.8
26 | 1.8
27 | UTF-8
28 | false
29 |
30 |
31 | ${project.version}
32 | SliderPanel
33 | Marten Prieß
34 | The MIT License (MIT)
35 | ${project.artifactId}-${project.version}.jar
36 |
37 |
38 |
39 |
40 | The MIT License (MIT)
41 | http://opensource.org/licenses/MIT
42 |
43 |
44 |
45 |
46 |
47 | com.vaadin
48 | vaadin-client
49 | ${vaadin.version}
50 | provided
51 |
52 |
53 | com.vaadin
54 | vaadin-client-compiler
55 | ${vaadin.version}
56 | provided
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | src/main/java
65 |
66 |
67 | src/main/resources
68 |
69 |
70 |
71 |
72 |
73 | org.apache.maven.plugins
74 | maven-compiler-plugin
75 | 3.6.1
76 |
77 | ${project.encoding}
78 | ${project.source.version}
79 | ${project.target.version}
80 |
81 |
82 |
83 |
84 | org.codehaus.mojo
85 | exec-maven-plugin
86 | 1.5.0
87 |
88 |
89 | stylesheet
90 | compile
91 |
92 | java
93 |
94 |
95 | true
96 | true
97 |
98 | com.vaadin
99 | vaadin-sass-compiler
100 |
101 | com.vaadin.sass.SassCompiler
102 |
103 | ${basedir}/src/main/resources/org/vaadin/sliderpanel/sliderpanel.scss
104 | ${basedir}/src/main/resources/org/vaadin/sliderpanel/public/sliderpanel/sliderpanel.css
105 |
106 |
107 |
108 |
109 |
110 |
111 | com.vaadin
112 | vaadin-sass-compiler
113 | 0.9.13
114 |
115 |
116 |
117 |
118 |
119 | org.apache.felix
120 | maven-bundle-plugin
121 | 3.2.0
122 | true
123 |
124 |
125 | default-bundle
126 | process-classes
127 |
128 | manifest
129 |
130 |
131 | true
132 |
133 | *
134 | org.vaadin.sliderpanel.*
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 | org.apache.maven.plugins
143 | maven-jar-plugin
144 | 3.0.2
145 |
146 |
147 | ${project.build.outputDirectory}/META-INF/MANIFEST.MF
148 | true
149 |
150 | true
151 |
152 |
153 |
154 | 1
155 | ${Vaadin-License-Title}
156 | org.vaadin.sliderpanel.WidgetSet
157 |
158 |
159 |
160 |
161 |
162 |
163 | org.apache.maven.plugins
164 | maven-source-plugin
165 | 3.0.1
166 |
167 |
168 | attach-sources
169 |
170 | jar
171 |
172 |
173 |
174 |
175 |
176 |
177 | org.apache.maven.plugins
178 | maven-assembly-plugin
179 | 3.0.0
180 |
181 | false
182 |
183 | assembly/assembly.xml
184 |
185 |
186 |
187 |
188 |
189 | single
190 |
191 | package
192 |
193 |
194 |
195 |
196 |
197 |
198 | org.apache.maven.plugins
199 | maven-javadoc-plugin
200 | 2.10.4
201 |
202 |
203 | attach-javadocs
204 |
205 | jar
206 |
207 |
208 | -Xdoclint:none
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
218 |
219 | org.eclipse.m2e
220 | lifecycle-mapping
221 | 1.0.0
222 |
223 |
224 |
225 |
226 |
227 |
228 | org.jasig.maven
229 |
230 |
231 | sass-maven-plugin
232 |
233 |
234 | [1.1.1,)
235 |
236 |
237 |
238 | update-stylesheets
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 | org.codehaus.mojo
250 |
251 |
252 | exec-maven-plugin
253 |
254 |
255 | [1.4.0,)
256 |
257 |
258 | java
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
--------------------------------------------------------------------------------
/vaadin-sliderpanel-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | vaadin-sliderpanel-root
5 | org.vaadin.addons
6 | 2.2.2-SNAPSHOT
7 |
8 |
9 | 4.0.0
10 | vaadin-sliderpanel-demo
11 |
12 |
13 |
14 | Marten Prieß
15 | marten@rocketbase.io
16 | rocketbase.io software productions
17 | http://www.rocketbase.io
18 |
19 |
20 |
21 |
22 |
23 | org.vaadin.sliderpanel.demo.Application
24 | 1.5.1.RELEASE
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | com.vaadin
33 | vaadin-bom
34 | ${vaadin.version}
35 | pom
36 | import
37 |
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-dependencies
42 | ${spring.boot.version}
43 | pom
44 | import
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | com.vaadin
53 | vaadin-spring-boot-starter
54 | 2.0.0
55 |
56 |
57 |
58 | org.vaadin.addons
59 | vaadin-sliderpanel
60 | ${version}
61 |
62 |
63 |
64 | com.vaadin
65 | vaadin-client
66 | provided
67 |
68 |
69 | com.vaadin
70 | vaadin-client-compiler
71 | provided
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | ${basedir}/src/main/resources
80 | true
81 |
82 | **/application.yml
83 | **/application.properties
84 |
85 |
86 |
87 | ${basedir}/src/main/resources
88 |
89 | **/application.yml
90 | **/application.properties
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | org.apache.maven.plugins
99 | maven-compiler-plugin
100 | 3.0
101 |
102 | 1.8
103 | 1.8
104 |
105 |
106 |
107 |
108 | org.apache.maven.plugins
109 | maven-dependency-plugin
110 |
111 |
112 | unpack
113 | generate-sources
114 |
115 | unpack
116 |
117 |
118 |
119 |
120 | org.vaadin.addons
121 | vaadin-sliderpanel
122 | ${version}
123 | jar
124 | **/sliderpanel/components/*.scss
125 | ${basedir}/src/main/resources
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 | org.codehaus.mojo
135 | exec-maven-plugin
136 | 1.5.0
137 |
138 |
139 | stylesheet
140 | compile
141 |
142 | java
143 |
144 |
145 | true
146 | true
147 |
148 | com.vaadin
149 | vaadin-sass-compiler
150 |
151 | com.vaadin.sass.SassCompiler
152 |
153 | ${basedir}/src/main/resources/org/vaadin/sliderpanel/demo/demo.scss
154 | ${basedir}/src/main/resources/org/vaadin/sliderpanel/demo/demo.css
155 |
156 |
157 |
158 |
159 |
160 |
161 | com.vaadin
162 | vaadin-sass-compiler
163 | 0.9.13
164 |
165 |
166 |
167 |
168 |
169 | com.vaadin
170 | vaadin-maven-plugin
171 | ${vaadin.version}
172 |
173 | -Xmx1g -Xss1024k
174 | ${project.build.outputDirectory}/VAADIN/widgetsets
175 | ${project.build.outputDirectory}/VAADIN/widgetsets
176 | true
177 |
178 | true
179 | ${project.build.directory}/gwtdirt
180 | false
181 |
182 | true
183 |
184 | ${project.build.directory}/gwt-deploy
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 | clean
194 | resources
195 | update-widgetset
196 | compile
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 | org.apache.maven.plugins
205 | maven-jar-plugin
206 |
207 |
208 |
209 | ${start-class}
210 |
211 |
212 |
213 |
214 |
215 | org.springframework.boot
216 | spring-boot-maven-plugin
217 | ${spring.boot.version}
218 |
219 |
220 |
221 | repackage
222 |
223 |
224 |
225 |
226 | ${start-class}
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
236 |
237 |
238 | org.eclipse.m2e
239 | lifecycle-mapping
240 | 1.0.0
241 |
242 |
243 |
244 |
245 |
246 | com.vaadin
247 |
248 | vaadin-maven-plugin
249 |
250 | [7.1.11,)
251 |
252 | resources
253 | update-widgetset
254 | compile
255 | compile-theme
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 | org.apache.maven.plugins
266 |
267 |
268 | maven-dependency-plugin
269 |
270 |
271 | [2.8,)
272 |
273 |
274 | unpack
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 | org.codehaus.mojo
285 |
286 |
287 | exec-maven-plugin
288 |
289 |
290 | [1.5.0,)
291 |
292 |
293 | java
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
--------------------------------------------------------------------------------
/assets/sliderpanel-layouting.json:
--------------------------------------------------------------------------------
1 | {
2 | "mockup":{
3 | "controls":{
4 | "control":[
5 | {
6 | "ID":"0",
7 | "h":"600",
8 | "measuredH":"400",
9 | "measuredW":"450",
10 | "properties":{
11 | "text":"Sliderpanel\nhttp://localhost:8080/vaadin-sliderpanel"
12 | },
13 | "typeID":"BrowserWindow",
14 | "w":"800",
15 | "x":"98",
16 | "y":"61",
17 | "zOrder":"0"
18 | },
19 | {
20 | "ID":"1",
21 | "h":"31",
22 | "measuredH":"70",
23 | "measuredW":"100",
24 | "properties":{
25 | "color":"13421772"
26 | },
27 | "typeID":"Canvas",
28 | "w":"785",
29 | "x":"105",
30 | "y":"141",
31 | "zOrder":"1"
32 | },
33 | {
34 | "ID":"2",
35 | "h":"31",
36 | "measuredH":"70",
37 | "measuredW":"100",
38 | "properties":{
39 | "color":"13421772"
40 | },
41 | "typeID":"Canvas",
42 | "w":"785",
43 | "x":"105",
44 | "y":"619",
45 | "zOrder":"2"
46 | },
47 | {
48 | "ID":"4",
49 | "measuredH":"21",
50 | "measuredW":"94",
51 | "properties":{
52 | "text":"SliderMode.TOP"
53 | },
54 | "typeID":"Label",
55 | "x":"451",
56 | "y":"146",
57 | "zOrder":"3"
58 | },
59 | {
60 | "ID":"5",
61 | "measuredH":"21",
62 | "measuredW":"122",
63 | "properties":{
64 | "text":"SliderMode.BOTTOM"
65 | },
66 | "typeID":"Label",
67 | "x":"437",
68 | "y":"624",
69 | "zOrder":"4"
70 | },
71 | {
72 | "ID":"6",
73 | "h":"435",
74 | "measuredH":"70",
75 | "measuredW":"100",
76 | "properties":{
77 | "color":"13421772"
78 | },
79 | "typeID":"Canvas",
80 | "w":"31",
81 | "x":"105",
82 | "y":"178",
83 | "zOrder":"5"
84 | },
85 | {
86 | "ID":"7",
87 | "h":"435",
88 | "measuredH":"70",
89 | "measuredW":"100",
90 | "properties":{
91 | "color":"13421772"
92 | },
93 | "typeID":"Canvas",
94 | "w":"31",
95 | "x":"859",
96 | "y":"178",
97 | "zOrder":"6"
98 | },
99 | {
100 | "ID":"8",
101 | "measuredH":"101",
102 | "measuredW":"21",
103 | "properties":{
104 | "text":"SliderMode.LEFT",
105 | "textOrientation":"up"
106 | },
107 | "typeID":"Label",
108 | "x":"112",
109 | "y":"345",
110 | "zOrder":"7"
111 | },
112 | {
113 | "ID":"9",
114 | "measuredH":"109",
115 | "measuredW":"21",
116 | "properties":{
117 | "text":"SliderMode.RIGHT",
118 | "textOrientation":"down"
119 | },
120 | "typeID":"Label",
121 | "x":"861",
122 | "y":"341",
123 | "zOrder":"8"
124 | },
125 | {
126 | "ID":"10",
127 | "measuredH":"32",
128 | "measuredW":"32",
129 | "properties":{
130 | "icon":{
131 | "ID":"arrow-circle-down",
132 | "name":"Arrow Circle Down",
133 | "size":"medium"
134 | }
135 | },
136 | "typeID":"Icon",
137 | "x":"792",
138 | "y":"140",
139 | "zOrder":"9"
140 | },
141 | {
142 | "ID":"11",
143 | "measuredH":"32",
144 | "measuredW":"32",
145 | "properties":{
146 | "icon":{
147 | "ID":"arrow-circle-down",
148 | "name":"Arrow Circle Down",
149 | "size":"medium"
150 | },
151 | "rotation":"90"
152 | },
153 | "typeID":"Icon",
154 | "x":"105",
155 | "y":"542",
156 | "zOrder":"10"
157 | },
158 | {
159 | "ID":"12",
160 | "measuredH":"32",
161 | "measuredW":"32",
162 | "properties":{
163 | "icon":{
164 | "ID":"arrow-circle-down",
165 | "name":"Arrow Circle Down",
166 | "size":"medium"
167 | },
168 | "rotation":"180"
169 | },
170 | "typeID":"Icon",
171 | "x":"792",
172 | "y":"618",
173 | "zOrder":"11"
174 | },
175 | {
176 | "ID":"13",
177 | "measuredH":"32",
178 | "measuredW":"32",
179 | "properties":{
180 | "icon":{
181 | "ID":"arrow-circle-down",
182 | "name":"Arrow Circle Down",
183 | "size":"medium"
184 | },
185 | "rotation":"270"
186 | },
187 | "typeID":"Icon",
188 | "x":"858",
189 | "y":"224",
190 | "zOrder":"12"
191 | },
192 | {
193 | "ID":"14",
194 | "h":"349",
195 | "measuredH":"70",
196 | "measuredW":"100",
197 | "properties":{
198 | "backgroundAlpha":"0.25",
199 | "borderColor":"13369344",
200 | "borderStyle":"square",
201 | "color":"15374745"
202 | },
203 | "typeID":"Canvas",
204 | "w":"526",
205 | "x":"235",
206 | "y":"221",
207 | "zOrder":"13"
208 | },
209 | {
210 | "ID":"15",
211 | "measuredH":"21",
212 | "measuredW":"88",
213 | "properties":{
214 | "color":"13369344",
215 | "text":"Vertical Layout"
216 | },
217 | "typeID":"Label",
218 | "x":"235",
219 | "y":"203",
220 | "zOrder":"14"
221 | },
222 | {
223 | "ID":"16",
224 | "h":"33",
225 | "measuredH":"70",
226 | "measuredW":"100",
227 | "properties":{
228 | "backgroundAlpha":"0.25",
229 | "borderColor":"13369344",
230 | "borderStyle":"square",
231 | "color":"15374745"
232 | },
233 | "typeID":"Canvas",
234 | "w":"511",
235 | "x":"241",
236 | "y":"232",
237 | "zOrder":"15"
238 | },
239 | {
240 | "ID":"17",
241 | "h":"246",
242 | "measuredH":"70",
243 | "measuredW":"100",
244 | "properties":{
245 | "backgroundAlpha":"0.25",
246 | "borderColor":"13369344",
247 | "borderStyle":"square",
248 | "color":"15374745"
249 | },
250 | "typeID":"Canvas",
251 | "w":"511",
252 | "x":"241",
253 | "y":"272",
254 | "zOrder":"16"
255 | },
256 | {
257 | "ID":"18",
258 | "h":"33",
259 | "measuredH":"70",
260 | "measuredW":"100",
261 | "properties":{
262 | "backgroundAlpha":"0.25",
263 | "borderColor":"13369344",
264 | "borderStyle":"square",
265 | "color":"15374745"
266 | },
267 | "typeID":"Canvas",
268 | "w":"511",
269 | "x":"241",
270 | "y":"526",
271 | "zOrder":"17"
272 | },
273 | {
274 | "ID":"19",
275 | "h":"23",
276 | "measuredH":"70",
277 | "measuredW":"100",
278 | "properties":{
279 | "color":"13421772"
280 | },
281 | "typeID":"Canvas",
282 | "w":"467",
283 | "x":"265",
284 | "y":"237",
285 | "zOrder":"18"
286 | },
287 | {
288 | "ID":"20",
289 | "measuredH":"21",
290 | "measuredW":"94",
291 | "properties":{
292 | "text":"SliderMode.TOP"
293 | },
294 | "typeID":"Label",
295 | "x":"451",
296 | "y":"238",
297 | "zOrder":"19"
298 | },
299 | {
300 | "ID":"21",
301 | "h":"77",
302 | "measuredH":"100",
303 | "measuredW":"150",
304 | "properties":{
305 | "curvature":"-1",
306 | "direction":"bottom",
307 | "rightArrow":"false"
308 | },
309 | "typeID":"Arrow",
310 | "w":"212",
311 | "x":"580",
312 | "y":"256",
313 | "zOrder":"30"
314 | },
315 | {
316 | "ID":"22",
317 | "h":"46",
318 | "measuredH":"123",
319 | "measuredW":"109",
320 | "properties":{
321 | "text":"setExpandRatio(1)"
322 | },
323 | "typeID":"StickyNote",
324 | "w":"138",
325 | "x":"761",
326 | "y":"251",
327 | "zOrder":"20"
328 | },
329 | {
330 | "ID":"23",
331 | "h":"25",
332 | "measuredH":"100",
333 | "measuredW":"150",
334 | "properties":{
335 | "curvature":"-1",
336 | "direction":"bottom",
337 | "rightArrow":"false"
338 | },
339 | "typeID":"Arrow",
340 | "w":"157",
341 | "x":"323",
342 | "y":"187",
343 | "zOrder":"22"
344 | },
345 | {
346 | "ID":"24",
347 | "h":"46",
348 | "measuredH":"123",
349 | "measuredW":"109",
350 | "properties":{
351 | "text":"setSizeFull()"
352 | },
353 | "typeID":"StickyNote",
354 | "w":"138",
355 | "x":"461",
356 | "y":"176",
357 | "zOrder":"21"
358 | },
359 | {
360 | "ID":"25",
361 | "h":"210",
362 | "measuredH":"70",
363 | "measuredW":"100",
364 | "properties":{
365 | "backgroundAlpha":"0.75",
366 | "borderColor":"5865130",
367 | "borderStyle":"square",
368 | "color":"10470904"
369 | },
370 | "typeID":"Canvas",
371 | "w":"481",
372 | "x":"258",
373 | "y":"298",
374 | "zOrder":"23"
375 | },
376 | {
377 | "ID":"26",
378 | "measuredH":"21",
379 | "measuredW":"102",
380 | "properties":{
381 | "color":"2848996",
382 | "text":"Horizontal Layout"
383 | },
384 | "typeID":"Label",
385 | "x":"258",
386 | "y":"277",
387 | "zOrder":"24"
388 | },
389 | {
390 | "ID":"27",
391 | "h":"191",
392 | "measuredH":"70",
393 | "measuredW":"100",
394 | "properties":{
395 | "color":"13421772"
396 | },
397 | "typeID":"Canvas",
398 | "w":"31",
399 | "x":"265",
400 | "y":"308",
401 | "zOrder":"25"
402 | },
403 | {
404 | "ID":"28",
405 | "measuredH":"101",
406 | "measuredW":"21",
407 | "properties":{
408 | "text":"SliderMode.LEFT",
409 | "textOrientation":"up"
410 | },
411 | "typeID":"Label",
412 | "x":"271",
413 | "y":"353",
414 | "zOrder":"26"
415 | },
416 | {
417 | "ID":"29",
418 | "h":"191",
419 | "measuredH":"70",
420 | "measuredW":"100",
421 | "properties":{
422 | "color":"13421772"
423 | },
424 | "typeID":"Canvas",
425 | "w":"31",
426 | "x":"701",
427 | "y":"308",
428 | "zOrder":"27"
429 | },
430 | {
431 | "ID":"30",
432 | "measuredH":"109",
433 | "measuredW":"21",
434 | "properties":{
435 | "text":"SliderMode.RIGHT",
436 | "textOrientation":"down"
437 | },
438 | "typeID":"Label",
439 | "w":"21",
440 | "x":"704",
441 | "y":"349",
442 | "zOrder":"28"
443 | },
444 | {
445 | "ID":"31",
446 | "h":"191",
447 | "measuredH":"70",
448 | "measuredW":"100",
449 | "properties":{
450 | "backgroundAlpha":"0.5",
451 | "borderColor":"13421772",
452 | "borderStyle":"roundedDotted",
453 | "color":"16777215"
454 | },
455 | "typeID":"Canvas",
456 | "w":"390",
457 | "x":"303",
458 | "y":"308",
459 | "zOrder":"29"
460 | },
461 | {
462 | "ID":"32",
463 | "h":"37",
464 | "measuredH":"100",
465 | "measuredW":"150",
466 | "properties":{
467 | "curvature":"-1",
468 | "direction":"bottom",
469 | "rightArrow":"false"
470 | },
471 | "typeID":"Arrow",
472 | "w":"425",
473 | "x":"367",
474 | "y":"256",
475 | "zOrder":"31"
476 | },
477 | {
478 | "ID":"33",
479 | "measuredH":"43",
480 | "measuredW":"267",
481 | "properties":{
482 | "color":"16777215",
483 | "text":"middle content"
484 | },
485 | "typeID":"Title",
486 | "x":"367",
487 | "y":"382",
488 | "zOrder":"32"
489 | },
490 | {
491 | "ID":"34",
492 | "h":"23",
493 | "measuredH":"70",
494 | "measuredW":"100",
495 | "properties":{
496 | "color":"13421772"
497 | },
498 | "typeID":"Canvas",
499 | "w":"467",
500 | "x":"265",
501 | "y":"531",
502 | "zOrder":"33"
503 | },
504 | {
505 | "ID":"35",
506 | "measuredH":"21",
507 | "measuredW":"122",
508 | "properties":{
509 | "text":"SliderMode.BOTTOM"
510 | },
511 | "typeID":"Label",
512 | "x":"437",
513 | "y":"532",
514 | "zOrder":"34"
515 | }
516 | ]
517 | },
518 | "measuredH":"661",
519 | "measuredW":"899",
520 | "mockupH":"600",
521 | "mockupW":"801",
522 | "version":"1.0"
523 | }
524 | }
--------------------------------------------------------------------------------
/vaadin-sliderpanel/src/main/java/org/vaadin/sliderpanel/client/VSliderPanel.java:
--------------------------------------------------------------------------------
1 | package org.vaadin.sliderpanel.client;
2 |
3 | import org.vaadin.sliderpanel.SliderPanel;
4 |
5 | import com.google.gwt.animation.client.Animation;
6 | import com.google.gwt.dom.client.DivElement;
7 | import com.google.gwt.dom.client.Document;
8 | import com.google.gwt.dom.client.Element;
9 | import com.google.gwt.dom.client.EventTarget;
10 | import com.google.gwt.dom.client.NativeEvent;
11 | import com.google.gwt.dom.client.Style;
12 | import com.google.gwt.dom.client.Style.Display;
13 | import com.google.gwt.dom.client.Style.Position;
14 | import com.google.gwt.safehtml.shared.SafeHtmlUtils;
15 | import com.google.gwt.user.client.DOM;
16 | import com.google.gwt.user.client.Event;
17 | import com.google.gwt.user.client.Event.NativePreviewEvent;
18 | import com.google.gwt.user.client.Event.NativePreviewHandler;
19 | import com.google.gwt.user.client.Timer;
20 | import com.google.gwt.user.client.ui.SimplePanel;
21 |
22 | /**
23 | * the main gwt implementation of the {@link SliderPanel}
24 | *
25 | * @author Marten Prieß (http://www.non-rocket-science.com)
26 | * @version 1.0
27 | */
28 | public class VSliderPanel extends SimplePanel implements NativePreviewHandler {
29 |
30 | public static final String CLASSNAME = "v-sliderpanel";
31 |
32 | private String wrapperBaseClassName = "", tabBaseClassName = "";
33 |
34 | private final DivElement wrapperNode, contentNode, navigationElem, captionNode, tabElem;
35 |
36 | private boolean initialized = false;
37 |
38 | private boolean expand = false;
39 |
40 | private boolean flowInContent = false;
41 |
42 | private int animationDuration;
43 |
44 | private Integer componentSize = null;
45 |
46 | private SliderMode mode = null;
47 |
48 | private final SliderTabPosition tabPosition = null;
49 |
50 | private int tabSize;
51 |
52 | private final SliderAnimation slideAnimation = new SliderAnimation();
53 |
54 | private ToggleListener listener;
55 |
56 | private boolean autoCollapseSlider = false;
57 |
58 | private boolean enabled = true;
59 |
60 | public VSliderPanel() {
61 | super();
62 | // main wrapper of the component
63 | this.wrapperNode = Document.get()
64 | .createDivElement();
65 | this.wrapperNode.setClassName(VSliderPanel.CLASSNAME + "-wrapper");
66 | getElement().appendChild(this.wrapperNode);
67 |
68 | // container that holds the content
69 | this.contentNode = Document.get()
70 | .createDivElement();
71 | this.contentNode.setClassName(VSliderPanel.CLASSNAME + "-content");
72 | this.contentNode.getStyle()
73 | .setDisplay(Display.BLOCK);
74 | this.wrapperNode.appendChild(this.contentNode);
75 |
76 | // wrapper for collapsed content line, tab with caption and icon
77 | this.navigationElem = Document.get()
78 | .createDivElement();
79 | this.navigationElem.setClassName(VSliderPanel.CLASSNAME + "-navigator");
80 |
81 | this.tabElem = Document.get()
82 | .createDivElement();
83 | this.tabElem.setClassName(VSliderPanel.CLASSNAME + "-tab");
84 | this.navigationElem.appendChild(this.tabElem);
85 |
86 | this.captionNode = Document.get()
87 | .createDivElement();
88 | this.captionNode.setClassName(VSliderPanel.CLASSNAME + "-caption");
89 | this.tabElem.appendChild(this.captionNode);
90 |
91 | DivElement toggleLabel = Document.get()
92 | .createDivElement();
93 | toggleLabel.setClassName(VSliderPanel.CLASSNAME + "-icon");
94 | this.tabElem.appendChild(toggleLabel);
95 |
96 | DOM.sinkEvents(this.tabElem, Event.ONCLICK);
97 | this.wrapperNode.appendChild(this.navigationElem);
98 |
99 | Event.addNativePreviewHandler(this);
100 | }
101 |
102 | private void setMode(final SliderMode sliderMode, final boolean flowInContent) {
103 | if (this.mode == null) {
104 | this.mode = sliderMode;
105 | this.flowInContent = flowInContent;
106 | this.wrapperNode.addClassName("mode-" + this.mode.name()
107 | .toLowerCase());
108 | this.wrapperNode.addClassName("layout-" + (this.mode.isVertical() ? "vertical" : "horizontal"));
109 |
110 | if (flowInContent) {
111 | this.wrapperNode.addClassName("flow-in-content");
112 | }
113 |
114 | this.wrapperBaseClassName = this.wrapperNode.getClassName();
115 |
116 | if (this.mode.equals(SliderMode.BOTTOM) || this.mode.equals(SliderMode.LEFT)) {
117 | // rearrange order contentNode after navigationElem
118 | this.wrapperNode.removeChild(this.contentNode);
119 | this.wrapperNode.appendChild(this.contentNode);
120 | }
121 | }
122 | }
123 |
124 | private void setTabPosition(final SliderTabPosition tabPosition) {
125 | if (this.tabPosition != null) {
126 | this.tabElem.removeClassName("tab-" + tabPosition.name()
127 | .toLowerCase());
128 | }
129 | this.tabElem.addClassName("tab-" + tabPosition.name()
130 | .toLowerCase());
131 | this.tabBaseClassName = this.tabElem.getClassName();
132 | }
133 |
134 | public void configure(final SliderMode sliderMode, final boolean flowInContent, final SliderTabPosition tabPosition, final Integer pixel) {
135 | if (!this.initialized) {
136 | setMode(sliderMode, flowInContent);
137 | setTabPosition(tabPosition);
138 | if (pixel > 0) {
139 | this.componentSize = pixel;
140 | }
141 | this.initialized = true;
142 | }
143 | }
144 |
145 | public void setFixedContentSize(final int pixel) {
146 | this.componentSize = pixel;
147 | }
148 |
149 | public void initialize(final boolean expand, final int tabSize) {
150 | this.expand = expand;
151 | this.tabSize = tabSize;
152 | animateTo(expand, 0, false);
153 | }
154 |
155 | public void setCaption(final String caption, final boolean captionAsHtml) {
156 | String captionContent = caption != null ? caption : "";
157 | if (!captionAsHtml) {
158 | captionContent = SafeHtmlUtils.htmlEscape(captionContent);
159 | }
160 | this.captionNode.setInnerHTML(captionContent);
161 | }
162 |
163 | public void setExpand(final boolean expand, final boolean animated) {
164 | if (!isEnabled()) {
165 | return;
166 | }
167 | animateTo(expand, animated ? this.animationDuration : 0, true);
168 | }
169 |
170 | public void setAnimationDuration(final int animationDuration) {
171 | this.animationDuration = animationDuration;
172 | }
173 |
174 | public void setAutoCollapseSlider(boolean autoCollapseSlider) {
175 | this.autoCollapseSlider = autoCollapseSlider;
176 | }
177 |
178 | public void setZIndex(int zIndex) {
179 | this.contentNode.getStyle().setZIndex(zIndex);
180 | this.navigationElem.getStyle().setZIndex(zIndex+1);
181 | this.wrapperNode.getStyle().setZIndex(zIndex);
182 | }
183 |
184 | /**
185 | * handel the closed/open className on the TabElement
186 | */
187 | private void updateTabElemClassName() {
188 | if (this.expand) {
189 | this.tabElem.removeClassName("closed");
190 | this.tabElem.addClassName("open");
191 | }
192 | else {
193 | this.tabElem.removeClassName("open");
194 | this.tabElem.addClassName("closed");
195 | }
196 | }
197 |
198 | @Override
199 | public void onBrowserEvent(final Event event) {
200 | if (!isEnabled()) {
201 | return;
202 | }
203 | if (event != null && (event.getTypeInt() == Event.ONCLICK)) {
204 | animateTo(!this.expand, this.animationDuration, true);
205 | }
206 | super.onBrowserEvent(event);
207 | }
208 |
209 | /**
210 | * used to log in javascript console
211 | *
212 | * @param message info to get logged
213 | */
214 | native void consoleLog(final String message) /*-{
215 | console.log( message );
216 | }-*/;
217 |
218 | @SuppressWarnings("deprecation")
219 | @Override
220 | protected com.google.gwt.user.client.Element getContainerElement() {
221 | return DOM.asOld(this.contentNode);
222 | }
223 |
224 | public void setToggleListener(final ToggleListener toggleListener) {
225 | this.listener = toggleListener;
226 | }
227 |
228 | private class SliderAnimation extends Animation {
229 | private boolean animateToExpand = false;
230 |
231 | private boolean fireToggleEvent = true;
232 |
233 | public void setAnimateToExpand(final boolean expand, final boolean fireToggleEvent) {
234 | this.animateToExpand = expand;
235 | this.fireToggleEvent = fireToggleEvent;
236 | }
237 |
238 | private void changeSize(final double size) {
239 | if (VSliderPanel.this.mode.isVertical()) {
240 | if (VSliderPanel.this.mode.equals(SliderMode.RIGHT)) {
241 | VSliderPanel.this.contentNode.getStyle()
242 | .setWidth(size, Style.Unit.PX);
243 |
244 | if (VSliderPanel.this.flowInContent) {
245 | // new
246 | VSliderPanel.this.navigationElem.getStyle()
247 | .setLeft(-1 * (size + VSliderPanel.this.tabSize), Style.Unit.PX);
248 | VSliderPanel.this.contentNode.getStyle()
249 | .setLeft(-1 * size, Style.Unit.PX);
250 | }
251 | else {
252 | VSliderPanel.this.navigationElem.getStyle()
253 | .setLeft(-1 * size, Style.Unit.PX);
254 | VSliderPanel.this.contentNode.getStyle()
255 | .setLeft(-1 * size + VSliderPanel.this.tabSize, Style.Unit.PX);
256 | }
257 | }
258 | else {
259 | VSliderPanel.this.contentNode.getStyle()
260 | .setWidth(VSliderPanel.this.componentSize, Style.Unit.PX);
261 | VSliderPanel.this.contentNode.getStyle().setWidth(size, Style.Unit.PX);
262 | VSliderPanel.this.contentNode.getFirstChildElement().getStyle().setPosition(Position.ABSOLUTE);
263 | VSliderPanel.this.contentNode.getFirstChildElement().getStyle().setLeft(-1 * (VSliderPanel.this.componentSize - size), Style.Unit.PX);
264 |
265 |
266 | if (VSliderPanel.this.flowInContent) {
267 | VSliderPanel.this.navigationElem.getStyle()
268 | .setRight(-1 * (size + VSliderPanel.this.tabSize), Style.Unit.PX);
269 | }
270 | else {
271 | VSliderPanel.this.navigationElem.getStyle()
272 | .setRight(-1 * size, Style.Unit.PX);
273 | }
274 | }
275 | }
276 | else {
277 | VSliderPanel.this.contentNode.getStyle()
278 | .setHeight(size, Style.Unit.PX);
279 | if (VSliderPanel.this.mode.equals(SliderMode.BOTTOM)) {
280 | if (VSliderPanel.this.flowInContent) {
281 | // new
282 | VSliderPanel.this.contentNode.getStyle()
283 | .setTop(-1 * size, Style.Unit.PX);
284 | VSliderPanel.this.navigationElem.getStyle()
285 | .setTop(-1 * (size + VSliderPanel.this.tabSize), Style.Unit.PX);
286 | }
287 | else {
288 | VSliderPanel.this.contentNode.getStyle()
289 | .setTop(-1 * size + VSliderPanel.this.tabSize, Style.Unit.PX);
290 | VSliderPanel.this.navigationElem.getStyle()
291 | .setTop(-1 * size, Style.Unit.PX);
292 | }
293 | }
294 | else {
295 | VSliderPanel.this.contentNode.getFirstChildElement()
296 | .getStyle()
297 | .setPosition(Position.ABSOLUTE);
298 | VSliderPanel.this.contentNode.getFirstChildElement()
299 | .getStyle()
300 | .setTop(-1 * (VSliderPanel.this.componentSize - size), Style.Unit.PX);
301 | VSliderPanel.this.navigationElem.getStyle()
302 | .setTop(size, Style.Unit.PX);
303 | }
304 | }
305 | }
306 |
307 | @Override
308 | protected void onUpdate(final double progress) {
309 | changeSize(extractProportionalLength(progress));
310 | }
311 |
312 | @Override
313 | protected void onStart() {
314 | VSliderPanel.this.contentNode.getStyle()
315 | .setDisplay(Display.BLOCK);
316 | if (VSliderPanel.this.componentSize == null || VSliderPanel.this.componentSize <= 0) {
317 | if (VSliderPanel.this.mode.isVertical()) {
318 | VSliderPanel.this.contentNode.getStyle()
319 | .clearWidth();
320 | if (VSliderPanel.this.contentNode.getFirstChildElement() != null) {
321 | VSliderPanel.this.componentSize = VSliderPanel.this.contentNode.getFirstChildElement()
322 | .getOffsetWidth();
323 | }
324 | }
325 | else {
326 | VSliderPanel.this.contentNode.getStyle()
327 | .clearHeight();
328 | if (VSliderPanel.this.contentNode.getFirstChildElement() != null) {
329 | VSliderPanel.this.componentSize = VSliderPanel.this.contentNode.getFirstChildElement()
330 | .getOffsetHeight();
331 | }
332 | }
333 | }
334 | };
335 |
336 | @Override
337 | protected void onComplete() {
338 | VSliderPanel.this.expand = this.animateToExpand;
339 | updateTabElemClassName();
340 |
341 | if (!VSliderPanel.this.expand) {
342 | changeSize(0);
343 | }
344 | else {
345 | changeSize(VSliderPanel.this.componentSize);
346 | }
347 |
348 | if (VSliderPanel.this.listener != null && this.fireToggleEvent) {
349 | VSliderPanel.this.listener.onToggle(VSliderPanel.this.expand);
350 | }
351 | };
352 |
353 | private int extractProportionalLength(final double progress) {
354 | if (this.animateToExpand) {
355 | return (int) (VSliderPanel.this.componentSize * progress);
356 | }
357 | else {
358 | return (int) (VSliderPanel.this.componentSize * (1.0 - progress));
359 | }
360 | }
361 | }
362 |
363 | /**
364 | * run animation with params
365 | *
366 | * @param expand final state
367 | * @param duration milliseconds how long the animation takes
368 | * @param fireToggleEvent should an event get fired afterwards
369 | */
370 | public void animateTo(final boolean expand, final int duration, final boolean fireToggleEvent) {
371 |
372 | if (this.slideAnimation.isRunning())
373 | return;
374 |
375 | this.slideAnimation.setAnimateToExpand(expand, fireToggleEvent);
376 | this.slideAnimation.run(duration);
377 | }
378 |
379 | public class ScheduleTimer extends Timer {
380 | private boolean expand, animated;
381 |
382 | @Override
383 | public void run() {
384 | setExpand(this.expand, this.animated);
385 | }
386 |
387 | public void setValues(final boolean expand, final boolean animated) {
388 | this.expand = expand;
389 | this.animated = animated;
390 | }
391 | }
392 |
393 | private ScheduleTimer scheduleTimer;
394 |
395 | /**
396 | * schedule animation with delay
397 | *
398 | * @param expand final state
399 | * @param animated should get animated
400 | * @param delayMillis milliseconds of delayed execution
401 | */
402 | public void scheduleExpand(final boolean expand, final boolean animated, final int delayMillis) {
403 | if (this.scheduleTimer == null) {
404 | this.scheduleTimer = new ScheduleTimer();
405 | }
406 | this.scheduleTimer.setValues(expand, animated);
407 | this.scheduleTimer.schedule(delayMillis);
408 | }
409 |
410 | /**
411 | * adds custom styleNames to wrapper
412 | *
413 | * @param styles add styleName to all nodes
414 | */
415 | public void setStyles(final String styles) {
416 | this.wrapperNode.setClassName(this.wrapperBaseClassName + styles);
417 | this.contentNode.setClassName(VSliderPanel.CLASSNAME + "-content" + styles);
418 | this.navigationElem.setClassName(VSliderPanel.CLASSNAME + "-navigator" + styles);
419 | this.tabElem.setClassName(this.tabBaseClassName + styles);
420 | // to set old open/closed class
421 | updateTabElemClassName();
422 | }
423 |
424 | /**
425 | * checks whether the event comes from an element within the slider dom tree
426 | *
427 | * @param event NativeEvent
428 | * @return true when events comes from within
429 | */
430 | private boolean eventTargetsPopup(NativeEvent event) {
431 | EventTarget target = event.getEventTarget();
432 | if (Element.is(target)) {
433 | return getElement().isOrHasChild(Element.as(target));
434 | }
435 | return false;
436 | }
437 |
438 | /**
439 | * checks whether the event come's from a elements that lays visually within the slider
440 | * it doesn't lay directly in the dom tree - for example dropdown popups
441 | *
442 | * @param event NativeEvent
443 | * @return true when events comes from within
444 | */
445 | private boolean eventTargetsInnerElementsPopover(NativeEvent event) {
446 | EventTarget target = event.getEventTarget();
447 | if (Element.is(target)) {
448 | Element targetElement = Element.as(target);
449 |
450 | int absoluteLeft = targetElement.getAbsoluteLeft();
451 | int absoluteTop = targetElement.getAbsoluteTop();
452 |
453 | return contentNode.getAbsoluteLeft() <= absoluteLeft && contentNode.getAbsoluteRight() >= absoluteLeft && contentNode.getAbsoluteTop() <= absoluteTop
454 | && contentNode.getAbsoluteBottom() >= absoluteTop;
455 | }
456 | return false;
457 | }
458 |
459 | @Override
460 | public void onPreviewNativeEvent(NativePreviewEvent event) {
461 | if (autoCollapseSlider && event != null && !event.isCanceled() && expand) {
462 | Event nativeEvent = Event.as(event.getNativeEvent());
463 |
464 | switch (nativeEvent.getTypeInt()) {
465 | case Event.ONMOUSEDOWN:
466 | case Event.ONTOUCHSTART:
467 | case Event.ONDBLCLICK:
468 |
469 | if (eventTargetsPopup(nativeEvent)) {
470 | return;
471 | }
472 | if (eventTargetsInnerElementsPopover(nativeEvent)) {
473 | return;
474 | }
475 | setExpand(false, true);
476 | }
477 | }
478 | }
479 |
480 | public boolean isEnabled() {
481 | return this.enabled;
482 | }
483 |
484 | public void setEnabled(boolean enabled) {
485 | this.enabled = enabled;
486 | if (!enabled) {
487 | wrapperNode.addClassName("v-disabled");
488 | tabElem.setAttribute("disabled", "on");
489 | return;
490 | }
491 | wrapperNode.removeClassName("v-disabled");
492 | tabElem.removeAttribute("disabled");
493 | }
494 |
495 | }
496 |
--------------------------------------------------------------------------------