Skip to content

Commit 9cb13d3

Browse files
author
Paul Stockley
committed
Update to use gwt-interop-utils library
1 parent bb286e3 commit 9cb13d3

File tree

32 files changed

+173
-352
lines changed

32 files changed

+173
-352
lines changed

src/gwt/react/api_sanity_test/apisanitytest.gwt.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<!-- Inherrit the core Web Toolkit stuff. -->
44
<inherits name='com.google.gwt.user.User' />
55
<inherits name="com.google.gwt.resources.Resources" />
6+
<inherits name="gwt.interop.utils.InteropUtils" />
67
<inherits name="gwt.react.React" />
78

89
<set-property name="user.agent" value="safari"/>

src/gwt/react/api_sanity_test/client/App.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
package gwt.react.api_sanity_test.client;
22

33
import com.google.gwt.core.client.EntryPoint;
4+
import com.google.gwt.core.client.GWT;
45
import com.google.gwt.dom.client.Document;
56
import com.google.gwt.user.client.Window;
7+
import gwt.interop.utils.client.collections.JsArray;
8+
import gwt.interop.utils.shared.collections.ArrayListAdapter;
9+
import gwt.interop.utils.shared.collections.Array;
10+
import gwt.interop.utils.shared.collections.ArrayFactory;
611
import gwt.react.client.api.React;
712
import gwt.react.client.api.ReactDOM;
813
import gwt.react.client.api.ReactDOMServer;
9-
import gwt.react.client.components.ReactClass;
1014
import gwt.react.client.elements.DOMElement;
1115
import gwt.react.client.proptypes.html.HtmlProps;
1216

17+
import java.util.List;
18+
1319
import static gwt.react.client.api.React.DOM.div;
1420

1521
public class App implements EntryPoint {
1622

1723
@Override
1824
public void onModuleLoad() {
19-
ArrayTests.run();
20-
MapTests.run();
21-
ObjectLiteralTests.run();
22-
23-
ReactClass<StatefulReactClassSpec.Props> statefulComponent = React.createClass(new StatefulReactClassSpec());
2425

25-
StatefulReactClassSpec.Props statefulCompProps = new StatefulReactClassSpec.Props();
26+
StatefulExample.Props statefulCompProps = new StatefulExample.Props();
2627
statefulCompProps.aProp = "aPropValue";
2728

2829
DOMElement<HtmlProps> appComp =
@@ -40,7 +41,7 @@ public void onModuleLoad() {
4041
div(null, "Child 1 should be red"),
4142
div(null, "Child 2 should be red (should be the last child)")
4243
),
43-
React.createElement(statefulComponent, statefulCompProps)
44+
React.createElement(StatefulExample.component, statefulCompProps)
4445
);
4546

4647
ReactDOM.render(appComp, Document.get().getElementById("mainCont"), () -> Window.alert("Rendered"));

src/gwt/react/api_sanity_test/client/ArrayTests.java

Lines changed: 0 additions & 154 deletions
This file was deleted.

src/gwt/react/api_sanity_test/client/ChildApiTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package gwt.react.api_sanity_test.client;
22

3+
import gwt.interop.utils.shared.collections.Array;
34
import gwt.react.client.api.React;
45
import gwt.react.client.components.StatelessComponent;
56
import gwt.react.client.elements.ReactElement;
67
import gwt.react.client.proptypes.BaseContext;
78
import gwt.react.client.proptypes.BaseProps;
89
import gwt.react.client.proptypes.html.CssProps;
910
import gwt.react.client.proptypes.html.HtmlProps;
10-
import gwt.react.shared.utils.Array;
1111

1212
import static gwt.react.client.api.GwtReact.castAsReactElement;
1313
import static gwt.react.client.api.React.DOM.br;

src/gwt/react/api_sanity_test/client/MapTests.java

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/gwt/react/api_sanity_test/client/ObjectLiteralTests.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/gwt/react/api_sanity_test/client/StatefulReactClassSpec.java renamed to src/gwt/react/api_sanity_test/client/StatefulExample.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
import com.google.gwt.dom.client.InputElement;
44
import com.google.gwt.user.client.Window;
5+
import gwt.interop.utils.client.plainobjects.JsPlainObj;
6+
import gwt.react.client.api.React;
7+
import gwt.react.client.components.ReactClass;
58
import gwt.react.client.components.ReactClassSpec;
69
import gwt.react.client.elements.ReactElement;
710
import gwt.react.client.events.FormEvent;
811
import gwt.react.client.proptypes.BaseProps;
912
import gwt.react.client.proptypes.html.BtnProps;
1013
import gwt.react.client.proptypes.html.InputProps;
11-
import gwt.react.client.utils.ObjLiteral;
1214
import jsinterop.annotations.JsOverlay;
1315
import jsinterop.annotations.JsPackage;
1416
import jsinterop.annotations.JsType;
@@ -17,15 +19,15 @@
1719

1820
@SuppressWarnings("unused")
1921
@JsType
20-
class StatefulReactClassSpec extends ReactClassSpec<StatefulReactClassSpec.Props, StatefulReactClassSpec.State> {
22+
class StatefulExample extends ReactClassSpec<StatefulExample.Props, StatefulExample.State> {
2123

2224
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name="Object")
2325
static class Props extends BaseProps {
2426
String aProp;
2527
}
2628

2729
@JsType(isNative = true, namespace = JsPackage.GLOBAL, name="Object")
28-
static class State extends ObjLiteral {
30+
static class State extends JsPlainObj {
2931
String aStateVar;
3032

3133
@JsOverlay
@@ -72,20 +74,20 @@ public void componentDidMount() {
7274
}
7375

7476
public void componentWillReceiveProps(Props nextProps) {
75-
Window.alert("componentDidMount called (nextProps "+ nextProps.toString() + ")");
77+
Window.alert("componentDidMount called (nextProps "+ nextProps.toJSONString() + ")");
7678
}
7779

7880
public boolean shouldComponentUpdate(Props nextProps, State nextState) {
79-
Window.alert("componentWillReceiveProps called (nextProps "+ nextProps.toString() + " nextState " + nextState.toString() + ")");
81+
Window.alert("componentWillReceiveProps called (nextProps "+ nextProps.toJSONString() + " nextState " + nextState.toJSONString() + ")");
8082
return true;
8183
}
8284

8385
public void componentWillUpdate(Props nextProps, State nextState) {
84-
Window.alert("componentWillUpdate called (nextProps "+ nextProps.toString() + " nextState " + nextState.toString() + ")");
86+
Window.alert("componentWillUpdate called (nextProps "+ nextProps.toJSONString() + " nextState " + nextState.toJSONString() + ")");
8587
}
8688

8789
public void componentDidUpdate(Props prevProps, State prevState) {
88-
Window.alert("componentDidUpdate called (prevProps "+ prevProps.toString() + " prevState " + prevState.toString() + ")");
90+
Window.alert("componentDidUpdate called (prevProps "+ prevProps.toJSONString() + " prevState " + prevState.toJSONString() + ")");
8991
}
9092

9193
public void componentWillUnmount() {
@@ -95,4 +97,6 @@ public void componentWillUnmount() {
9597
private String getDescription() {
9698
return "Click Me (state=" + getState().aStateVar + ", props=" + getProps().aProp + ")";
9799
}
100+
101+
public static ReactClass<Props> component = React.createClass(new StatefulExample());
98102
}

0 commit comments

Comments
 (0)