You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2009/06/29 19:48:08 UTC
svn commit: r789397 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget:
./ cache/ form/ html/ text/ tree/
Author: doogie
Date: Mon Jun 29 17:48:07 2009
New Revision: 789397
URL: http://svn.apache.org/viewvc?rev=789397&view=rev
Log:
Mostly varied generics markup enhancements. A few scattered for-loop
changes.
Modified:
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java
ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Mon Jun 29 17:48:07 2009
@@ -95,7 +95,7 @@
* Enables/disables boundary comments for this widget.
* @param context The screen rendering context
*/
- public void setWidgetBoundaryComments(Map<String, Object> context) {
+ public void setWidgetBoundaryComments(Map<String, ? extends Object> context) {
Map<String, ? extends Object> parameters = UtilGenerics.checkMap(context.get("parameters"));
enableWidgetBoundaryComments = widgetBoundaryCommentsEnabled(parameters);
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/cache/WidgetContextCacheKey.java Mon Jun 29 17:48:07 2009
@@ -82,7 +82,7 @@
protected Map<String, Object> context;
- public WidgetContextCacheKey(Map<String, Object> context) {
+ public WidgetContextCacheKey(Map<String, ? extends Object> context) {
this.context = FastMap.newInstance();
this.context.putAll(context);
}
@@ -106,9 +106,7 @@
Set<String> unifiedContext = FastSet.newInstance();
unifiedContext.addAll(this.context.keySet());
unifiedContext.addAll(key.context.keySet());
- Iterator fieldNameIt = unifiedContext.iterator();
- while (fieldNameIt.hasNext()) {
- String fieldName = (String)fieldNameIt.next();
+ for (String fieldName: unifiedContext) {
if (fieldNamesToSkip.contains(fieldName)) {
continue;
}
@@ -122,7 +120,7 @@
return false;
}
if ("parameters".equals(fieldName)) {
- if (!parametersAreEqual(UtilGenerics.checkMap(field1), UtilGenerics.checkMap(field2))) {
+ if (!parametersAreEqual(UtilGenerics.<String, Object>checkMap(field1), UtilGenerics.<String, Object>checkMap(field2))) {
return false;
}
continue;
@@ -137,21 +135,18 @@
public String toString() {
Map<String, Object> printableMap = FastMap.newInstance();
- Iterator fieldNameIt = this.context.keySet().iterator();
- while (fieldNameIt.hasNext()) {
- String fieldName = (String)fieldNameIt.next();
+ for (String fieldName: this.context.keySet()) {
if (!fieldNamesToSkip.contains(fieldName) && !"parameters".equals(fieldName)) {
printableMap.put(fieldName, this.context.get(fieldName));
}
}
- return printMap(printableMap) + "\n" + printMap((Map)this.context.get("parameters"));
+ Map<String, Object> parameters = UtilGenerics.checkMap(this.context.get("parameters"));
+ return printMap(printableMap) + "\n" + printMap(parameters);
}
- public static String printMap(Map map) {
+ public static String printMap(Map<String, ? extends Object> map) {
Map<String, Object> printableMap = FastMap.newInstance();
- Iterator fieldNameIt = map.keySet().iterator();
- while (fieldNameIt.hasNext()) {
- String fieldName = (String)fieldNameIt.next();
+ for (String fieldName: map.keySet()) {
if (!fieldNamesToSkip.contains(fieldName) &&
!fieldName.startsWith("javax.servlet") &&
!fieldName.startsWith("org.apache") &&
@@ -162,13 +157,11 @@
return UtilMisc.printMap(printableMap);
}
- public static boolean parametersAreEqual(Map<Object, Object> map1, Map<Object, Object> map2) {
- Set<Object> unifiedContext = FastSet.newInstance();
+ public static boolean parametersAreEqual(Map<String, ? extends Object> map1, Map<String, ? extends Object> map2) {
+ Set<String> unifiedContext = FastSet.newInstance();
unifiedContext.addAll(map1.keySet());
unifiedContext.addAll(map2.keySet());
- Iterator fieldNameIt = unifiedContext.iterator();
- while (fieldNameIt.hasNext()) {
- String fieldName = (String)fieldNameIt.next();
+ for (String fieldName: unifiedContext) {
if (fieldNamesToSkip.contains(fieldName)) {
continue;
}
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Mon Jun 29 17:48:07 2009
@@ -663,11 +663,11 @@
* @param encoder
* @return
*/
- public String getEntry(Map<String, Object> context) {
+ public String getEntry(Map<String, ? extends Object> context) {
return this.getEntry(context, "");
}
- public String getEntry(Map<String, Object> context , String defaultValue) {
+ public String getEntry(Map<String, ? extends Object> context , String defaultValue) {
Boolean isError = (Boolean) context.get("isError");
Boolean useRequestParameters = (Boolean) context.get("useRequestParameters");
@@ -823,7 +823,7 @@
*
* @return
*/
- public String getParameterName(Map<String, Object> context) {
+ public String getParameterName(Map<String, ? extends Object> context) {
String baseName;
if (UtilValidate.isNotEmpty(this.parameterName)) {
baseName = this.parameterName;
@@ -856,7 +856,7 @@
return event;
}
- public String getAction(Map<String, Object> context) {
+ public String getAction(Map<String, ? extends Object> context) {
if (this.action != null && this.action.getOriginal() != null) {
return action.expandString(context);
} else {
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Mon Jun 29 17:48:07 2009
@@ -854,9 +854,7 @@
}
// list out all options according to the option list
- Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator();
- while (optionValueIter.hasNext()) {
- ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
+ for (ModelFormField.OptionValue optionValue: allOptionValues) {
String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context);
writer.append("<option");
// if current value should be selected in the list, select it
@@ -943,9 +941,7 @@
String action = modelFormField.getAction(context);
// list out all options according to the option list
- Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator();
- while (optionValueIter.hasNext()) {
- ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
+ for (ModelFormField.OptionValue optionValue: allOptionValues) {
writer.append("<input type=\"checkbox\"");
@@ -996,9 +992,7 @@
String action = modelFormField.getAction(context);
// list out all options according to the option list
- Iterator<ModelFormField.OptionValue> optionValueIter = allOptionValues.iterator();
- while (optionValueIter.hasNext()) {
- ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
+ for (ModelFormField.OptionValue optionValue: allOptionValues) {
writer.append("<div");
@@ -1360,9 +1354,7 @@
* @see org.ofbiz.widget.form.FormStringRenderer#renderFormClose(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelForm)
*/
public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException {
- Iterator<ModelFormField> submitFields = modelForm.getMultiSubmitFields().iterator();
- while (submitFields.hasNext()) {
- ModelFormField submitField = (ModelFormField) submitFields.next();
+ for (ModelFormField submitField: modelForm.getMultiSubmitFields()) {
if (submitField != null) {
// Threw this in that as a hack to keep the submit button from expanding the first field
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java Mon Jun 29 17:48:07 2009
@@ -75,7 +75,7 @@
this.renderer = new HtmlFormRenderer(request, response);
this.context = new HashMap<String, Object>();
- Map parameterMap = UtilHttp.getParameterMap(request);
+ Map<String, Object> parameterMap = UtilHttp.getParameterMap(request);
context.put("parameters", parameterMap);
//make sure the locale is in the context
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/text/TextFormRenderer.java Mon Jun 29 17:48:07 2009
@@ -119,9 +119,7 @@
this.makeTextString(writer, modelFormField.getWidgetStyle(), ModelFormField.FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues));
}
} else {
- Iterator optionValueIter = allOptionValues.iterator();
- while (optionValueIter.hasNext()) {
- ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
+ for (ModelFormField.OptionValue optionValue: allOptionValues) {
String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context);
if ((UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey()) && "selected".equals(dropDownField.getCurrent())) ||
(UtilValidate.isEmpty(currentValue) && noCurrentSelectedKey != null && noCurrentSelectedKey.equals(optionValue.getKey()))) {
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Mon Jun 29 17:48:07 2009
@@ -116,10 +116,7 @@
postTrailOpenDepth = 999;
}
- List nodeElements = UtilXml.childElementList(treeElement, "node");
- Iterator nodeElementIter = nodeElements.iterator();
- while (nodeElementIter.hasNext()) {
- Element nodeElementEntry = (Element) nodeElementIter.next();
+ for (Element nodeElementEntry: UtilXml.childElementList(treeElement, "node")) {
ModelNode node = new ModelNode(nodeElementEntry, this);
String nodeName = node.getName();
nodeList.add(node);
@@ -340,10 +337,7 @@
this.condition = new ModelTreeCondition(modelTree, conditionElement);
}
- List subNodeElements = UtilXml.childElementList(nodeElement, "sub-node");
- Iterator subNodeElementIter = subNodeElements.iterator();
- while (subNodeElementIter.hasNext()) {
- Element subNodeElementEntry = (Element) subNodeElementIter.next();
+ for (Element subNodeElementEntry: UtilXml.childElementList(nodeElement, "sub-node")) {
ModelSubNode subNode = new ModelSubNode(subNodeElementEntry, this);
subNodeList.add(subNode);
}
@@ -401,10 +395,8 @@
//if (Debug.infoOn()) Debug.logInfo(" processChildren:" + processChildren, module);
if (processChildren.booleanValue()) {
getChildren(context);
- Iterator nodeIter = this.subNodeValues.iterator();
int newDepth = depth + 1;
- while (nodeIter.hasNext()) {
- Object[] arr = (Object[]) nodeIter.next();
+ for (Object[] arr: this.subNodeValues) {
ModelNode node = (ModelNode) arr[0];
Map<String, Object> val = UtilGenerics.checkMap(arr[1]);
//GenericPK pk = val.getPrimaryKey();
@@ -421,9 +413,9 @@
newContext.putAll(val);
}
String targetEntityId = null;
- List targetNodeTrail = UtilGenerics.checkList(context.get("targetNodeTrail"));
+ List<String> targetNodeTrail = UtilGenerics.checkList(context.get("targetNodeTrail"));
if (newDepth < targetNodeTrail.size()) {
- targetEntityId = (String) targetNodeTrail.get(newDepth);
+ targetEntityId = targetNodeTrail.get(newDepth);
}
if ((targetEntityId != null && targetEntityId.equals(thisEntityId)) || this.showPeers(newDepth, context)) {
node.renderNodeString(writer, newContext, treeStringRenderer, newDepth);
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeAction.java Mon Jun 29 17:48:07 2009
@@ -102,7 +102,7 @@
}
*/
- public static void runSubActions(List<ModelTreeAction> actions, Map<String, Object> context) {
+ public static void runSubActions(List<? extends ModelTreeAction> actions, Map<String, Object> context) {
for (ModelTreeAction action: actions) {
if (Debug.verboseOn()) Debug.logVerbose("Running tree action " + action.getClass().getName(), module);
action.runAction(context);
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTreeCondition.java Mon Jun 29 17:48:07 2009
@@ -60,7 +60,7 @@
this.rootCondition = readCondition(modelTree, firstChildElement);
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
if (rootCondition == null) {
return true;
}
@@ -74,7 +74,7 @@
this.modelTree = modelTree;
}
- public abstract boolean eval(Map<String, Object> context);
+ public abstract boolean eval(Map<String, ? extends Object> context);
}
public static List<TreeCondition> readSubConditions(ModelTree modelTree, Element conditionElement) {
@@ -117,14 +117,14 @@
}
public static class And extends TreeCondition {
- protected List<TreeCondition> subConditions;
+ protected List<? extends TreeCondition> subConditions;
public And(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.subConditions = readSubConditions(modelTree, condElement);
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
// return false for the first one in the list that is false, basic and algo
for (TreeCondition subCondition: subConditions) {
if (!subCondition.eval(context)) {
@@ -136,14 +136,14 @@
}
public static class Xor extends TreeCondition {
- protected List<TreeCondition> subConditions;
+ protected List<? extends TreeCondition> subConditions;
public Xor(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.subConditions = readSubConditions(modelTree, condElement);
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
// if more than one is true stop immediately and return false; if all are false return false; if only one is true return true
boolean foundOneTrue = false;
for (TreeCondition subCondition: subConditions) {
@@ -161,14 +161,14 @@
}
public static class Or extends TreeCondition {
- protected List<TreeCondition> subConditions;
+ protected List<? extends TreeCondition> subConditions;
public Or(ModelTree modelTree, Element condElement) {
super (modelTree, condElement);
this.subConditions = readSubConditions(modelTree, condElement);
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
// return true for the first one in the list that is true, basic or algo
for (TreeCondition subCondition: subConditions) {
if (subCondition.eval(context)) {
@@ -188,7 +188,7 @@
this.subCondition = readCondition(modelTree, firstChildElement);
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
return !this.subCondition.eval(context);
}
}
@@ -203,7 +203,7 @@
this.actionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("action"));
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
// if no user is logged in, treat as if the user does not have permission
GenericValue userLogin = (GenericValue) context.get("userLogin");
if (userLogin != null) {
@@ -242,7 +242,7 @@
this.classExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("class"));
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
String methodName = this.methodExdr.expandString(context);
String className = this.classExdr.expandString(context);
@@ -309,7 +309,7 @@
this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format"));
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
String value = this.valueExdr.expandString(context);
String format = this.formatExdr.expandString(context);
@@ -359,7 +359,7 @@
this.formatExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("format"));
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
String format = this.formatExdr.expandString(context);
Object fieldVal = this.fieldAcsr.get(context);
@@ -402,7 +402,7 @@
this.exprExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("expr"));
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
Object fieldVal = this.fieldAcsr.get(context);
String expr = this.exprExdr.expandString(context);
Pattern pattern = null;
@@ -436,7 +436,7 @@
if (this.fieldAcsr.isEmpty()) this.fieldAcsr = FlexibleMapAccessor.getInstance(condElement.getAttribute("field-name"));
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
Object fieldVal = this.fieldAcsr.get(context);
return ObjectType.isEmpty(fieldVal);
}
@@ -449,7 +449,7 @@
this.permissionChecker = new EntityPermissionChecker(condElement);
}
- public boolean eval(Map<String, Object> context) {
+ public boolean eval(Map<String, ? extends Object> context) {
boolean passed = permissionChecker.runPermissionCheck(context);
return passed;
Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java?rev=789397&r1=789396&r2=789397&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java Mon Jun 29 17:48:07 2009
@@ -113,10 +113,7 @@
if (treeFileDoc != null) {
// read document and construct ModelTree for each tree element
Element rootElement = treeFileDoc.getDocumentElement();
- List treeElements = UtilXml.childElementList(rootElement, "tree");
- Iterator treeElementIter = treeElements.iterator();
- while (treeElementIter.hasNext()) {
- Element treeElement = (Element) treeElementIter.next();
+ for (Element treeElement: UtilXml.childElementList(rootElement, "tree")) {
ModelTree modelTree = new ModelTree(treeElement, delegator, dispatcher);
modelTree.setTreeLocation(treeLocation);
modelTreeMap.put(modelTree.getName(), modelTree);