summaryrefslogtreecommitdiffstats
path: root/compatibility-client
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-09-29 14:13:37 +0200
committerTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-09-29 15:13:37 +0300
commit46950473fdb3cfb9d44660b3a642a9229cecded2 (patch)
tree76caf6a1ffe1fdb9c111b551a42a2507b3dda4b4 /compatibility-client
parent3c7a9514117b348336b89306de735d92c8e9f463 (diff)
downloadvaadin-framework-46950473fdb3cfb9d44660b3a642a9229cecded2.tar.gz
vaadin-framework-46950473fdb3cfb9d44660b3a642a9229cecded2.zip
UIDL to implement Iterable (#10101)
Diffstat (limited to 'compatibility-client')
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VListSelect.java5
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VNativeSelect.java5
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java4
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java34
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java9
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java5
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java6
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java5
-rw-r--r--compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java16
9 files changed, 39 insertions, 50 deletions
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VListSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VListSelect.java
index 7a5b7e0935..acc99e7ace 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VListSelect.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VListSelect.java
@@ -18,7 +18,6 @@ package com.vaadin.v7.client.ui;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -90,8 +89,8 @@ public class VListSelect extends VOptionGroupBase {
// need to deselect when something else is selected since it's only
// used in single select mode.
}
- for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
- final UIDL optionUidl = (UIDL) i.next();
+ for (final Object child : uidl) {
+ final UIDL optionUidl = (UIDL) child;
updateOrCreateItem(optionUidl.getStringAttribute("caption"),
optionUidl.getStringAttribute("key"), nextIndex,
previousKeys);
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VNativeSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VNativeSelect.java
index ff5541c88c..0dcad75648 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VNativeSelect.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VNativeSelect.java
@@ -17,7 +17,6 @@
package com.vaadin.v7.client.ui;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import com.google.gwt.event.dom.client.ChangeEvent;
@@ -58,8 +57,8 @@ public class VNativeSelect extends VOptionGroupBase implements Field {
select.addItem("", (String) null);
}
boolean selected = false;
- for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
- final UIDL optionUidl = (UIDL) i.next();
+ for (final Object child : uidl) {
+ final UIDL optionUidl = (UIDL) child;
select.addItem(optionUidl.getStringAttribute("caption"),
optionUidl.getStringAttribute("key"));
if (optionUidl.hasAttribute("selected")) {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
index e3d94b0d4a..6150625547 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
@@ -134,8 +134,8 @@ public class VOptionGroup extends VOptionGroupBase
Roles.getRadiogroupRole().set(getElement());
}
- for (final Iterator<?> it = uidl.getChildIterator(); it.hasNext();) {
- final UIDL opUidl = (UIDL) it.next();
+ for (final Object child : uidl) {
+ final UIDL opUidl = (UIDL) child;
String itemHtml = opUidl.getStringAttribute("caption");
if (!htmlContentAllowed) {
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
index 9c9665d7ce..364afb0592 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
@@ -1662,9 +1662,8 @@ public class VScrollTable extends FlowPanel
return;
}
- final Iterator<?> it = actionsUidl.getChildIterator();
- while (it.hasNext()) {
- final UIDL action = (UIDL) it.next();
+ for (final Object child : actionsUidl) {
+ final UIDL action = (UIDL) child;
final String key = action.getStringAttribute("key");
final String caption = action.getStringAttribute("caption");
actionMap.put(key + "_c", caption);
@@ -3649,12 +3648,11 @@ public class VScrollTable extends FlowPanel
}
public void updateCellsFromUIDL(UIDL uidl) {
- Iterator<?> it = uidl.getChildIterator();
HashSet<String> updated = new HashSet<String>();
boolean refreshContentWidths = initializedAndAttached
&& hadScrollBars != willHaveScrollbars();
- while (it.hasNext()) {
- final UIDL col = (UIDL) it.next();
+ for (Object child : uidl) {
+ final UIDL col = (UIDL) child;
final String cid = col.getStringAttribute("cid");
updated.add(cid);
@@ -4586,10 +4584,9 @@ public class VScrollTable extends FlowPanel
* The UIDL
*/
public void updateCellsFromUIDL(UIDL uidl) {
- Iterator<?> columnIterator = uidl.getChildIterator();
HashSet<String> updated = new HashSet<String>();
- while (columnIterator.hasNext()) {
- final UIDL col = (UIDL) columnIterator.next();
+ for (Object child : uidl) {
+ final UIDL col = (UIDL) child;
final String cid = col.getStringAttribute("cid");
updated.add(cid);
@@ -4870,10 +4867,9 @@ public class VScrollTable extends FlowPanel
public void renderInitialRows(UIDL rowData, int firstIndex, int rows) {
firstRendered = firstIndex;
setLastRendered(firstIndex + rows - 1);
- final Iterator<?> it = rowData.getChildIterator();
aligns = tHead.getColumnAlignments();
- while (it.hasNext()) {
- final VScrollTableRow row = createRow((UIDL) it.next(), aligns);
+ for (final Object child : rowData) {
+ final VScrollTableRow row = createRow((UIDL) child, aligns);
addRow(row);
}
if (isAttached()) {
@@ -4884,7 +4880,7 @@ public class VScrollTable extends FlowPanel
public void renderRows(UIDL rowData, int firstIndex, int rows) {
// FIXME REVIEW
aligns = tHead.getColumnAlignments();
- final Iterator<?> it = rowData.getChildIterator();
+ final Iterator<?> it = rowData.iterator();
if (firstIndex == lastRendered + 1) {
while (it.hasNext()) {
final VScrollTableRow row = prepareRow((UIDL) it.next());
@@ -5005,7 +5001,7 @@ public class VScrollTable extends FlowPanel
protected List<VScrollTableRow> insertRows(UIDL rowData, int firstIndex,
int rows) {
aligns = tHead.getColumnAlignments();
- final Iterator<?> it = rowData.getChildIterator();
+ final Iterator<?> it = rowData.iterator();
List<VScrollTableRow> insertedRows = new ArrayList<VScrollTableRow>();
if (firstIndex == lastRendered + 1) {
@@ -5628,9 +5624,7 @@ public class VScrollTable extends FlowPanel
protected void addCellsFromUIDL(UIDL uidl, char[] aligns, int col,
int visibleColumnIndex) {
- final Iterator<?> cells = uidl.getChildIterator();
- while (cells.hasNext()) {
- final Object cell = cells.next();
+ for (final Object cell : uidl) {
visibleColumnIndex++;
String columnId = visibleColOrder[visibleColumnIndex];
@@ -6718,11 +6712,10 @@ public class VScrollTable extends FlowPanel
htmlContentAllowed = uidl.getBooleanAttribute("gen_html");
spanColumns = uidl.getBooleanAttribute("gen_span");
- final Iterator<?> cells = uidl.getChildIterator();
if (spanColumns) {
int colCount = uidl.getChildCount();
- if (cells.hasNext()) {
- final Object cell = cells.next();
+ // add the first cell only
+ for (final Object cell : uidl) {
if (cell instanceof String) {
addSpannedCell(uidl, cell.toString(), aligns[0], "",
htmlContentAllowed, false, null, colCount);
@@ -6730,6 +6723,7 @@ public class VScrollTable extends FlowPanel
addSpannedCell(uidl, (Widget) cell, aligns[0], "",
false, colCount);
}
+ break;
}
} else {
super.addCellsFromUIDL(uidl, aligns, col,
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java
index 903b611ff3..dc76d6cd2d 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTreeTable.java
@@ -196,7 +196,8 @@ public class VTreeTable extends VScrollTable {
treeSpacer.setClassName(classname);
container.insertFirst(treeSpacer);
depth = rowUidl.hasAttribute("depth")
- ? rowUidl.getIntAttribute("depth") : 0;
+ ? rowUidl.getIntAttribute("depth")
+ : 0;
setIndent();
isTreeCellAdded = true;
return true;
@@ -341,11 +342,10 @@ public class VTreeTable extends VScrollTable {
htmlContentAllowed = uidl.getBooleanAttribute("gen_html");
spanColumns = uidl.getBooleanAttribute("gen_span");
- final Iterator<?> cells = uidl.getChildIterator();
if (spanColumns) {
int colCount = uidl.getChildCount();
- if (cells.hasNext()) {
- final Object cell = cells.next();
+ // add the first cell only
+ for (final Object cell : uidl) {
if (cell instanceof String) {
addSpannedCell(uidl, cell.toString(), aligns[0], "",
htmlContentAllowed, false, null, colCount);
@@ -353,6 +353,7 @@ public class VTreeTable extends VScrollTable {
addSpannedCell(uidl, (Widget) cell, aligns[0], "",
false, colCount);
}
+ break;
}
} else {
super.addCellsFromUIDL(uidl, aligns, col,
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java
index cf8e379818..c996fdc06a 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java
@@ -18,7 +18,6 @@ package com.vaadin.v7.client.ui;
import java.util.ArrayList;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -231,8 +230,8 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler,
selections.setMultipleSelect(isMultiselect());
options.clear();
selections.clear();
- for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
- final UIDL optionUidl = (UIDL) i.next();
+ for (final Object child : uidl) {
+ final UIDL optionUidl = (UIDL) child;
if (optionUidl.hasAttribute("selected")) {
selections.addItem(optionUidl.getStringAttribute("caption"),
optionUidl.getStringAttribute("key"));
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java
index dce1a4e84e..968defbe63 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/CalendarConnector.java
@@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -394,9 +393,8 @@ public class CalendarConnector extends AbstractLegacyComponentConnector
*/
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- Iterator<Object> childIterator = uidl.getChildIterator();
- while (childIterator.hasNext()) {
- UIDL child = (UIDL) childIterator.next();
+ for (Object c : uidl) {
+ UIDL child = (UIDL) c;
if (DROPHANDLER_ACCEPT_CRITERIA_PAINT_TAG.equals(child.getTag())) {
if (getWidget().getDropHandler() == null) {
getWidget().setDropHandler(showingMonthView()
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
index c50b4f977c..b3b4405a1b 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
@@ -16,7 +16,6 @@
package com.vaadin.v7.client.ui.combobox;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import com.google.gwt.core.client.Scheduler;
@@ -126,8 +125,8 @@ public class ComboBoxConnector extends AbstractFieldConnector
List<FilterSelectSuggestion> newSuggestions = new ArrayList<FilterSelectSuggestion>();
- for (final Iterator<?> i = options.getChildIterator(); i.hasNext();) {
- final UIDL optionUidl = (UIDL) i.next();
+ for (final Object child : options) {
+ final UIDL optionUidl = (UIDL) child;
final FilterSelectSuggestion suggestion = getWidget().new FilterSelectSuggestion(
optionUidl);
newSuggestions.add(suggestion);
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java
index d03c0bf55a..dd8305b90b 100644
--- a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java
+++ b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java
@@ -80,7 +80,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector
getWidget().readonly = isReadOnly();
getWidget().dragMode = uidl.hasAttribute("dragMode")
- ? uidl.getIntAttribute("dragMode") : 0;
+ ? uidl.getIntAttribute("dragMode")
+ : 0;
getWidget().isNullSelectionAllowed = uidl
.getBooleanAttribute("nullselect");
@@ -98,8 +99,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector
TreeNode childTree = null;
UIDL childUidl = null;
- for (final Iterator<?> i = uidl.getChildIterator(); i.hasNext();) {
- childUidl = (UIDL) i.next();
+ for (final Object child : uidl) {
+ childUidl = (UIDL) child;
if ("actions".equals(childUidl.getTag())) {
updateActionMap(childUidl);
continue;
@@ -213,7 +214,7 @@ public class TreeConnector extends AbstractLegacyComponentConnector
VConsole.error(e);
}
- renderChildNodes(rootNode, (Iterator) uidl.getChildIterator(),
+ renderChildNodes(rootNode, (Iterator) uidl.iterator(),
levelProperty + 1);
}
}
@@ -224,9 +225,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector
* @param uidl
*/
private void updateActionMap(UIDL uidl) {
- final Iterator<?> it = uidl.getChildIterator();
- while (it.hasNext()) {
- final UIDL action = (UIDL) it.next();
+ for (final Object child : uidl) {
+ final UIDL action = (UIDL) child;
final String key = action.getStringAttribute("key");
final String caption = action
.getStringAttribute(TreeConstants.ATTRIBUTE_ACTION_CAPTION);
@@ -265,7 +265,7 @@ public class TreeConnector extends AbstractLegacyComponentConnector
if (uidl.getChildCount() == 0) {
treeNode.childNodeContainer.setVisible(false);
} else {
- renderChildNodes(treeNode, (Iterator) uidl.getChildIterator(),
+ renderChildNodes(treeNode, (Iterator) uidl.iterator(),
level + 1);
treeNode.childrenLoaded = true;
}