File tree Expand file tree Collapse file tree 6 files changed +74
-12
lines changed
src/main/java/gwt/material/design/amcore/client/data Expand file tree Collapse file tree 6 files changed +74
-12
lines changed Original file line number Diff line number Diff line change 1+ package gwt .material .design .amcore .client .data ;
2+
3+ import com .google .gwt .core .client .JavaScriptObject ;
4+ import com .google .gwt .json .client .JSONArray ;
5+ import com .google .gwt .json .client .JSONObject ;
6+ import com .google .gwt .json .client .JSONValue ;
7+
8+ import java .util .ArrayList ;
9+ import java .util .List ;
10+
11+ public class ChartData <T > {
12+
13+ private List <DataProvider <T >> providers = new ArrayList <>();
14+ private List <T > data = new ArrayList <>();
15+
16+ public ChartData () {
17+ }
18+
19+ public ChartData (List <T > data ) {
20+ this .data = data ;
21+ }
22+
23+ public ChartData add (DataProvider <T > providers ) {
24+ this .providers .add (providers );
25+ return this ;
26+ }
27+
28+ public JavaScriptObject get () {
29+ JSONArray array = new JSONArray ();
30+ data .forEach (t -> {
31+ if (t != null ) {
32+ JSONObject object = new JSONObject ();
33+ providers .forEach (provider -> {
34+ String property = provider .getProperty ();
35+ JSONValue value = provider .getValue (t );
36+
37+ if (property != null && value != null ) {
38+ object .put (property , value );
39+ }
40+ });
41+ array .set (data .indexOf (t ), object );
42+ }
43+ });
44+ return array .getJavaScriptObject ();
45+ }
46+
47+
48+ public List <T > getData () {
49+ return data ;
50+ }
51+
52+ public void setData (List <T > data ) {
53+ this .data = data ;
54+ }
55+ }
Original file line number Diff line number Diff line change 1+ package gwt .material .design .amcore .client .data ;
2+
3+ import com .google .gwt .json .client .JSONValue ;
4+
5+ public interface DataProvider <T > {
6+
7+ String getProperty ();
8+
9+ JSONValue getValue (T object );
10+ }
Original file line number Diff line number Diff line change 77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
99 * You may obtain a copy of the License at
10- *
10+ *
1111 * http://www.apache.org/licenses/LICENSE-2.0
12- *
12+ *
1313 * Unless required by applicable law or agreed to in writing, software
1414 * distributed under the License is distributed on an "AS IS" BASIS,
1515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3131import jsinterop .annotations .JsType ;
3232
3333@ JsType (isNative = true )
34- public class DataSource extends BaseObjectsEvents {
34+ public class DataSource extends BaseObjectsEvents {
3535
3636 @ JsProperty
3737 public Component component ;
Original file line number Diff line number Diff line change 77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
99 * You may obtain a copy of the License at
10- *
10+ *
1111 * http://www.apache.org/licenses/LICENSE-2.0
12- *
12+ *
1313 * Unless required by applicable law or agreed to in writing, software
1414 * distributed under the License is distributed on an "AS IS" BASIS,
1515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Original file line number Diff line number Diff line change 77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
99 * You may obtain a copy of the License at
10- *
10+ *
1111 * http://www.apache.org/licenses/LICENSE-2.0
12- *
12+ *
1313 * Unless required by applicable law or agreed to in writing, software
1414 * distributed under the License is distributed on an "AS IS" BASIS,
1515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Original file line number Diff line number Diff line change 77 * Licensed under the Apache License, Version 2.0 (the "License");
88 * you may not use this file except in compliance with the License.
99 * You may obtain a copy of the License at
10- *
10+ *
1111 * http://www.apache.org/licenses/LICENSE-2.0
12- *
12+ *
1313 * Unless required by applicable law or agreed to in writing, software
1414 * distributed under the License is distributed on an "AS IS" BASIS,
1515 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1919 */
2020package gwt .material .design .amcore .client .data .parser ;
2121
22- import gwt .material .design .amcore .client .events .EventTarget ;
23- import gwt .material .design .jquery .client .api .Functions ;
24- import jsinterop .annotations .JsMethod ;
2522import jsinterop .annotations .JsProperty ;
2623import jsinterop .annotations .JsType ;
2724
You can’t perform that action at this time.
0 commit comments