Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-11-21 14:39:00 -0500
committerKarsten Thoms2019-12-11 05:33:10 -0500
commitfc32f1d80889af9abf2a4ed2460deb1c3a2e8371 (patch)
tree0ef1e159bb1a5f1aef01bc601afaedeca5ddd926 /examples
parentb477bd8d3c77424ba052b2805184cf696f30d966 (diff)
downloadeclipse.platform.swt-fc32f1d80889af9abf2a4ed2460deb1c3a2e8371.tar.gz
eclipse.platform.swt-fc32f1d80889af9abf2a4ed2460deb1c3a2e8371.tar.xz
eclipse.platform.swt-fc32f1d80889af9abf2a4ed2460deb1c3a2e8371.zip
Use jdk 5 for-each loop
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: Iea93040f03a56b0e16fef194e4e99f71954664a4 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java4
-rw-r--r--examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java3
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/CTable.java12
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/ColorMenu.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/GradientDialog.java3
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java3
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java4
7 files changed, 15 insertions, 18 deletions
diff --git a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
index 388885b874..c09d8d9112 100644
--- a/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
+++ b/examples/org.eclipse.swt.examples.browser.demos/src/org/eclipse/swt/examples/browser/demos/views/PawnTab.java
@@ -235,9 +235,9 @@ public class PawnTab {
boolean hasMore = false;
cntWhite = 0; cntBlack = 0;
- for (int i = 0; i < game.length; i++)
+ for (byte[] element : game)
for (int j = 0; j < game[0].length; j++) {
- switch (game[i][j]) {
+ switch (element[j]) {
case EMPTY: hasMore = true; break;
case WHITE: cntWhite++; break;
case BLACK: cntBlack++; break;
diff --git a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java
index 52f20cd99b..91bcaafdc0 100644
--- a/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java
+++ b/examples/org.eclipse.swt.examples.ole.win32/src/org/eclipse/swt/examples/ole/win32/OlePlugin.java
@@ -155,8 +155,7 @@ public class OlePlugin extends AbstractUIPlugin {
*/
public static void freeResources() {
if (images != null) {
- for (int i = 0; i < images.length; ++i) {
- final Image image = images[i];
+ for (final Image image : images) {
if (image != null) image.dispose();
}
images = null;
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/CTable.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/CTable.java
index 56b64d1145..762ca3c2de 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/CTable.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/accessibility/CTable.java
@@ -3896,8 +3896,8 @@ public void setItemCount (int count) {
}
int newSelectedCount = 0;
- for (int i = 0; i < selectedItems.length; i++) {
- if (!selectedItems [i].isDisposed ()) newSelectedCount++;
+ for (CTableItem selectedItem : selectedItems) {
+ if (!selectedItem.isDisposed ()) newSelectedCount++;
}
if (newSelectedCount != selectedItems.length) {
/* one or more selected items have been disposed */
@@ -4095,10 +4095,10 @@ void setSelection (CTableItem[] items, boolean updateViewport) {
boolean tableSelectionChanged = false;
if (isFocusControl () || (getStyle () & SWT.HIDE_SELECTION) == 0) {
- for (int i = 0; i < oldSelection.length; i++) {
- if (!oldSelection [i].isSelected ()) {
- redrawItem (oldSelection [i].index, true);
- oldSelection[i].getAccessible(getAccessible(), 0).selectionChanged();
+ for (CTableItem item : oldSelection) {
+ if (!item.isSelected ()) {
+ redrawItem (item.index, true);
+ item.getAccessible(getAccessible(), 0).selectionChanged();
tableSelectionChanged = true;
}
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/ColorMenu.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/ColorMenu.java
index 8794dfe676..9dc8921946 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/ColorMenu.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/ColorMenu.java
@@ -298,8 +298,8 @@ public class ColorMenu {
switch (event.type) {
case SWT.Dispose:
- for (int i = 0; i < resources.size(); i++) {
- resources.get(i).dispose();
+ for (Resource resource : resources) {
+ resource.dispose();
}
resources = new ArrayList<>();
break;
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/GradientDialog.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/GradientDialog.java
index ea18fde7c7..5500e9689a 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/GradientDialog.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/graphics/GradientDialog.java
@@ -83,8 +83,7 @@ public class GradientDialog extends Dialog {
createDialogControls(dialog);
dialog.addListener(SWT.Close, event -> {
- for (int i = 0; i < resources.size(); i++) {
- Object obj = resources.get(i);
+ for (Image obj : resources) {
if (obj != null && obj instanceof Resource) {
((Resource) obj).dispose();
}
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
index cf982f3540..dbaab82237 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
@@ -62,8 +62,7 @@ Color getColor(int type) {
}
boolean inBlockComment(int start, int end) {
- for (int i=0; i<blockComments.size(); i++) {
- int[] offsets = blockComments.get(i);
+ for (int[] offsets : blockComments) {
// start of comment in the line
if ((offsets[0] >= start) && (offsets[0] <= end)) return true;
// end of comment in the line
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java
index 2177b48b88..ee52e362f0 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java
@@ -909,8 +909,8 @@ public class TextEditor {
String[] names = new String[fontNames.length];
int count = 0;
mainfor:
- for (int i = 0; i < fontNames.length; i++) {
- String fontName = fontNames[i].getName();
+ for (FontData fontData : fontNames) {
+ String fontName = fontData.getName();
if (fontName.startsWith("@")) //$NON-NLS-1$
continue;
for (int j = 0; j < count; j++) {

Back to the top