Revision: 9556
Author: [email protected]
Date: Fri Jan 14 09:32:27 2011
Log: Integrate EditorModel LeafValueEditor+CompositeEditor fix into GWT 2.2
branch.
http://code.google.com/p/google-web-toolkit/source/detail?r=9556
Modified:
/releases/2.2/user/src/com/google/gwt/editor/rebind/model/EditorModel.java
/releases/2.2/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java
=======================================
---
/releases/2.2/user/src/com/google/gwt/editor/rebind/model/EditorModel.java
Fri Jan 14 06:09:32 2011
+++
/releases/2.2/user/src/com/google/gwt/editor/rebind/model/EditorModel.java
Fri Jan 14 09:32:27 2011
@@ -28,6 +28,7 @@
import com.google.gwt.editor.client.CompositeEditor;
import com.google.gwt.editor.client.Editor;
import com.google.gwt.editor.client.IsEditor;
+import com.google.gwt.editor.client.LeafValueEditor;
import java.util.ArrayList;
import java.util.Arrays;
@@ -60,7 +61,7 @@
if (compositeEditorIntf.equals(parameterized.getBaseType())) {
JClassType[] typeArgs = parameterized.getTypeArgs();
assert typeArgs.length == 3;
- return new JClassType[]{typeArgs[1], typeArgs[2]};
+ return new JClassType[] {typeArgs[1], typeArgs[2]};
}
}
}
@@ -175,6 +176,8 @@
*/
private final JGenericType isEditorIntf;
+ private final JGenericType leafValueEditorIntf;
+
private final TreeLogger logger;
private final EditorModel parentModel;
@@ -216,6 +219,8 @@
assert isEditorIntf != null : "No IsEditor type";
compositeEditorIntf =
oracle.findType(CompositeEditor.class.getName()).isGenericType();
assert compositeEditorIntf != null : "No CompositeEditor type";
+ leafValueEditorIntf =
oracle.findType(LeafValueEditor.class.getName()).isGenericType();
+ assert leafValueEditorIntf != null;
JClassType[] interfaces = intf.getImplementedInterfaces();
if (interfaces.length != 1) {
@@ -244,6 +249,7 @@
this.editorType = editorType;
this.editorSoFar = subEditor;
this.isEditorIntf = parent.isEditorIntf;
+ this.leafValueEditorIntf = parent.leafValueEditorIntf;
this.parentModel = parent;
this.proxyType = proxyType;
this.typeData = parent.typeData;
@@ -301,41 +307,44 @@
List<EditorData> flatData = new ArrayList<EditorData>();
List<EditorData> toReturn = new ArrayList<EditorData>();
- for (JClassType type : editorType.getFlattenedSupertypeHierarchy()) {
- for (JField field : type.getFields()) {
- if (field.isPrivate() || field.isStatic()
- || field.getAnnotation(Editor.Ignore.class) != null) {
- continue;
- }
- JType fieldClassType = field.getType();
- if (shouldExamine(fieldClassType)) {
- List<EditorData> data =
createEditorData(EditorAccess.via(field));
- accumulateEditorData(data, flatData, toReturn);
- }
- }
- for (JMethod method : type.getMethods()) {
- if (method.isPrivate() || method.isStatic()
- || method.getAnnotation(Editor.Ignore.class) != null) {
- continue;
- }
- JType methodReturnType = method.getReturnType();
- if (shouldExamine(methodReturnType)
- && method.getParameters().length == 0) {
- EditorAccess access = EditorAccess.via(method);
- if (access.getPath().equals("as")
- && isEditorIntf.isAssignableFrom(editorType)) {
- // Ignore IsEditor.asEditor()
+ // Only look for sub-editor accessors if the editor isn't a leaf
+ if (!leafValueEditorIntf.isAssignableFrom(editorType)) {
+ for (JClassType type : editorType.getFlattenedSupertypeHierarchy()) {
+ for (JField field : type.getFields()) {
+ if (field.isPrivate() || field.isStatic()
+ || field.getAnnotation(Editor.Ignore.class) != null) {
+ continue;
+ }
+ JType fieldClassType = field.getType();
+ if (shouldExamine(fieldClassType)) {
+ List<EditorData> data =
createEditorData(EditorAccess.via(field));
+ accumulateEditorData(data, flatData, toReturn);
+ }
+ }
+ for (JMethod method : type.getMethods()) {
+ if (method.isPrivate() || method.isStatic()
+ || method.getAnnotation(Editor.Ignore.class) != null) {
continue;
- } else if (access.getPath().equals("createEditorForTraversal")
- && compositeEditorIntf.isAssignableFrom(editorType)) {
- // Ignore CompositeEditor.createEditorForTraversal();
- continue;
- }
- List<EditorData> data = createEditorData(access);
- accumulateEditorData(data, flatData, toReturn);
- }
- }
- type = type.getSuperclass();
+ }
+ JType methodReturnType = method.getReturnType();
+ if (shouldExamine(methodReturnType)
+ && method.getParameters().length == 0) {
+ EditorAccess access = EditorAccess.via(method);
+ if (access.getPath().equals("as")
+ && isEditorIntf.isAssignableFrom(editorType)) {
+ // Ignore IsEditor.asEditor()
+ continue;
+ } else if (access.getPath().equals("createEditorForTraversal")
+ && compositeEditorIntf.isAssignableFrom(editorType)) {
+ // Ignore CompositeEditor.createEditorForTraversal();
+ continue;
+ }
+ List<EditorData> data = createEditorData(access);
+ accumulateEditorData(data, flatData, toReturn);
+ }
+ }
+ type = type.getSuperclass();
+ }
}
if (compositeEditorIntf.isAssignableFrom(editorType)) {
=======================================
---
/releases/2.2/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java
Fri Jan 14 06:09:32 2011
+++
/releases/2.2/user/test/com/google/gwt/editor/rebind/model/EditorModelTest.java
Fri Jan 14 09:32:27 2011
@@ -831,10 +831,12 @@
return code;
}
}, new MockJavaResource("t.CompositeAndLeafEditorDriver") {
- // Tests that we descend into sub-editor of a CompositeEditor that
also
- // is
- // a LeafValueEditor (this is the case for the
- // c.g.g.editor.client.adapters.OptionalFieldEditor)
+ /*
+ * Tests that we descend into sub-editor of a CompositeEditor that
also is
+ * a LeafValueEditor (this is the case for the
+ * c.g.g.editor.client.adapters.OptionalFieldEditor). Also test that
any
+ * editor-like fields within the LeafValueEditor are ignored.
+ */
@Override
protected CharSequence getContent() {
StringBuilder code = new StringBuilder();
@@ -856,6 +858,7 @@
code.append(" OptionalBEditor bEditor();");
code.append(" }");
code.append(" interface OptionalBEditor extends
CompositeEditor<BProxy, BProxy, BEditor>, LeafValueEditor<BProxy> {");
+ code.append(" LeafValueEditor<String> ignored();");
code.append(" }");
code.append(" interface BEditor extends Editor<BProxy> {");
code.append(" @Editor.Path(\"string\") SimpleEditor<String>
coEditor();");
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors