Author: alessio.soldano(a)jboss.com
Date: 2013-02-01 13:02:05 -0500 (Fri, 01 Feb 2013)
New Revision: 480
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/GroupWiseTreeElement.java
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java
webgui/branches/cdi-jsf/src/main/webapp/index.xhtml
Log:
Further fixes on handling of group elements with nested types
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java 2013-02-01
09:04:23 UTC (rev 479)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/ClientConversationBean.java 2013-02-01
18:02:05 UTC (rev 480)
@@ -175,7 +175,7 @@
}
private static TreeNodeImpl convertOperationParametersToGui(WSMethod wsMethod,
WSDynamicClient client) {
- WiseTreeElementBuilder builder = new WiseTreeElementBuilder(client);
+ WiseTreeElementBuilder builder = new WiseTreeElementBuilder(client, true);
TreeNodeImpl rootElement = new TreeNodeImpl();
Collection<? extends WebParameter> parameters = wsMethod.getWebParams().values();
SOAPBinding soapBindingAnn =
wsMethod.getEndpoint().getUnderlyingObjectClass().getAnnotation(SOAPBinding.class);
@@ -185,14 +185,14 @@
rpcLit = style != null && SOAPBinding.Style.RPC.equals(style);
}
for (WebParameter parameter : parameters) {
- WiseTreeElement wte = builder.buildTreeFromType(parameter.getType(),
parameter.getName(), !rpcLit);
+ WiseTreeElement wte = builder.buildTreeFromType(parameter.getType(),
parameter.getName(), null, !rpcLit);
rootElement.addChild(wte.getId(), wte);
}
return rootElement;
}
private static TreeNodeImpl convertOperationResultToGui(InvocationResult result,
WSDynamicClient client) {
- WiseTreeElementBuilder builder = new WiseTreeElementBuilder(client);
+ WiseTreeElementBuilder builder = new WiseTreeElementBuilder(client, false);
TreeNodeImpl rootElement = new TreeNodeImpl();
Map<String, Type> resTypes = new HashMap<String, Type>();
for (Entry<String, Object> res : result.getResult().entrySet()) {
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/GroupWiseTreeElement.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/GroupWiseTreeElement.java 2013-02-01
09:04:23 UTC (rev 479)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/GroupWiseTreeElement.java 2013-02-01
18:02:05 UTC (rev 480)
@@ -16,6 +16,7 @@
*/
package org.jboss.wise.gui.treeElement;
+import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Iterator;
import java.util.LinkedList;
@@ -95,6 +96,10 @@
}
return returnList;
}
+
+ public String getType() {
+ return ((Class<?>) ((ParameterizedType)
this.classType).getActualTypeArguments()[0]).getSimpleName();
+ }
public int getSize() {
Iterator<Object> keyIt = this.getChildrenKeysIterator();
Modified:
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java
===================================================================
---
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java 2013-02-01
09:04:23 UTC (rev 479)
+++
webgui/branches/cdi-jsf/src/main/java/org/jboss/wise/gui/treeElement/WiseTreeElementBuilder.java 2013-02-01
18:02:05 UTC (rev 480)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source
- * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual
+ * Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
@@ -47,18 +47,16 @@
public class WiseTreeElementBuilder {
private WSDynamicClient client;
+ private boolean request;
- public WiseTreeElementBuilder(WSDynamicClient client) {
+ public WiseTreeElementBuilder(WSDynamicClient client, boolean request) {
this.client = client;
+ this.request = request;
}
- public WiseTreeElement buildTreeFromType(Type type, String name, boolean nillable) {
- return buildTreeFromType(type, name, null, nillable, null, null, new HashMap<Type,
WiseTreeElement>(), new HashSet<Type>());
+ public WiseTreeElement buildTreeFromType(Type type, String name, Object value,
boolean nillable) {
+ return buildTreeFromType(type, name, value, nillable, null, null, new HashMap<Type,
WiseTreeElement>(), new HashSet<Type>());
}
-
- public WiseTreeElement buildTreeFromType(Type type, String name, Object obj, boolean
nillable) {
- return buildTreeFromType(type, name, obj, nillable, null, null, new HashMap<Type,
WiseTreeElement>(), new HashSet<Type>());
- }
private WiseTreeElement buildTreeFromType(Type type,
String name,
@@ -91,12 +89,17 @@
Set<Type> stack) {
Type firstTypeArg = pt.getActualTypeArguments()[0];
if (Collection.class.isAssignableFrom((Class<?>) pt.getRawType())) {
- WiseTreeElement prototype = this.buildTreeFromType(firstTypeArg, name, null, true,
null, null, typeMap, stack);
- GroupWiseTreeElement group = new GroupWiseTreeElement(pt, name, prototype);
- if (obj != null) {
- for (Object o : (Collection) obj) {
- group.addChild(IDGenerator.nextVal(), this.buildTreeFromType(firstTypeArg, name, o,
true, null, null, typeMap, stack));
+ GroupWiseTreeElement group;
+ if (obj != null || request) {
+ WiseTreeElement prototype = this.buildTreeFromType(firstTypeArg, name, null, true,
null, null, typeMap, stack);
+ group = new GroupWiseTreeElement(pt, name, prototype);
+ if (obj != null) {
+ for (Object o : (Collection) obj) {
+ group.addChild(IDGenerator.nextVal(), this.buildTreeFromType(firstTypeArg, name, o,
true, null, null, typeMap, stack));
+ }
}
+ } else {
+ group = new GroupWiseTreeElement(pt, name, null);
}
return group;
} else {
@@ -140,7 +143,7 @@
}
return element;
} else { // complex
- if (stack.contains(cl)) {
+ if (request && stack.contains(cl)) {
Logger.getLogger(this.getClass()).debug("* lazy");
return new LazyLoadWiseTreeElement(cl, name, typeMap);
}
@@ -148,7 +151,9 @@
Logger.getLogger(this.getClass()).debug("* complex");
ComplexWiseTreeElement complex = new ComplexWiseTreeElement(cl, name);
- stack.add(cl);
+ if (request) {
+ stack.add(cl);
+ }
for (Field field : ReflectionUtils.getAllFields(cl)) {
XmlElement elemAnnotation = field.getAnnotation(XmlElement.class);
XmlElementRef refAnnotation = field.getAnnotation(XmlElementRef.class);
@@ -177,8 +182,10 @@
WiseTreeElement element = this.buildTreeFromType(field.getGenericType(), fieldName,
fieldValue, true, cl, namespace, typeMap, stack);
complex.addChild(element.getId(), element);
}
- stack.remove(cl);
- typeMap.put(cl, complex.clone());
+ if (request) {
+ stack.remove(cl);
+ typeMap.put(cl, complex.clone());
+ }
if (!nillable) {
complex.setNillable(false);
}
Modified: webgui/branches/cdi-jsf/src/main/webapp/index.xhtml
===================================================================
--- webgui/branches/cdi-jsf/src/main/webapp/index.xhtml 2013-02-01 09:04:23 UTC (rev 479)
+++ webgui/branches/cdi-jsf/src/main/webapp/index.xhtml 2013-02-01 18:02:05 UTC (rev 480)
@@ -72,7 +72,7 @@
</a4j:commandLink>
</rich:treeNode>
<rich:treeNode type="group">
- <h:outputText value="[#{node.prototype.type}]"
styleClass="tipoCampo" />
+ <h:outputText value="[#{node.type}]"
styleClass="tipoCampo" />
<h:selectBooleanCheckbox value="#{node.notNil}"
disabled="true" />
<h:outputText value=" " />
<a4j:commandLink name="Add"
action="#{clientConversationBean.addChild(node)}"
reRender="richTree">
@@ -86,8 +86,11 @@
<h:outputText value="#{node.type} ..." />
<h:outputText value=" " />
<a4j:commandLink name="Load"
action="#{clientConversationBean.lazyLoadChild(node)}"
reRender="richTree" rendered="#{not node.resolved}">
- load
+ Load
</a4j:commandLink>
+ <a4j:commandLink
action="#{clientConversationBean.removeChild(node)}"
rerender="richTree" rendered="#{node.removable}">
+ Remove
+ </a4j:commandLink>
</rich:treeNode>
<rich:treeNode type="complex">
<h:outputText value="#{node.type} : #{node.name} " />
@@ -220,15 +223,8 @@
<h:outputText value="{#{node.namespace}}" />
</rich:treeNode>
<rich:treeNode type="group">
- <h:outputText value="#{node.prototype.type}[#{node.size}]"
/>
+ <h:outputText value="#{node.type}[#{node.size}]" />
</rich:treeNode>
- <rich:treeNode type="lazy">
- <h:outputText value="#{node.type} ..." />
- <h:outputText value=" " />
- <a4j:commandLink name="Load"
action="#{clientConversationBean.lazyLoadChild(node)}"
reRender="richResTree" rendered="#{not node.resolved}">
- load
- </a4j:commandLink>
- </rich:treeNode>
<rich:treeNode type="complex">
<h:outputText value="#{node.type} : #{node.name}" />
</rich:treeNode>