diff options
author | Carsten Hammer | 2019-09-25 20:02:31 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-10-16 05:12:10 +0000 |
commit | 55af3c84c9551c91b30db58af3d71aa03ca2b033 (patch) | |
tree | 03a6bea59a094cbbd97590bbc8af96ae4cd07f2e | |
parent | e06819792b23c8e9305c7d5662cc11c39c781577 (diff) | |
download | rt.equinox.p2-55af3c84c9551c91b30db58af3d71aa03ca2b033.tar.gz rt.equinox.p2-55af3c84c9551c91b30db58af3d71aa03ca2b033.tar.xz rt.equinox.p2-55af3c84c9551c91b30db58af3d71aa03ca2b033.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: I0895b7e934ede33af1bbacd6d7aaa70c316f190e
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
5 files changed, 36 insertions, 29 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java index 24f25a349..d74d38d1b 100644 --- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/AbstractPage.java @@ -101,10 +101,13 @@ public abstract class AbstractPage extends WizardPage implements Listener { Object[] checked = viewer.getCheckedElements(); if (checkState == null) checkState = new ArrayList<>(checked.length); - for (int i = 0; i < checked.length; i++) - if (!viewer.getGrayed(checked[i])) - if (!checkState.contains(checked[i])) - checkState.add(checked[i]); + for (Object checked1 : checked) { + if (!viewer.getGrayed(checked1)) { + if (!checkState.contains(checked1)) { + checkState.add(checked1); + } + } + } }); } @@ -384,8 +387,8 @@ public abstract class AbstractPage extends WizardPage implements Listener { if (contentProvider.hasChildren(event.getElement())) { Set<Object> unchecked = new HashSet<>(); Object[] children = contentProvider.getChildren(event.getElement()); - for (int i = 0; i < children.length; i++) { - unchecked.add(children[i]); + for (Object child : children) { + unchecked.add(child); } Iterator<Object> iter = filteredTree.checkState.iterator(); while (iter.hasNext()) { @@ -706,8 +709,8 @@ public abstract class AbstractPage extends WizardPage implements Listener { if (directoryNames != null) { // destination setDestinationValue(directoryNames[0]); - for (int i = 0; i < directoryNames.length; i++) { - addDestinationItem(directoryNames[i]); + for (String directoryName : directoryNames) { + addDestinationItem(directoryName); } setDestinationValue(""); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java index 86516d933..56ff67ec3 100644 --- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportPage.java @@ -130,8 +130,8 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage */ public P2ImportIUPatternFilter(IUColumnConfig[] columnConfig) { super(); - for (int i = 0; i < columnConfig.length; i++) { - int field = columnConfig[i].getColumnType(); + for (IUColumnConfig columnConfig1 : columnConfig) { + int field = columnConfig1.getColumnType(); if (field == IUColumnConfig.COLUMN_ID) checkId = true; else if (field == IUColumnConfig.COLUMN_NAME) @@ -328,8 +328,8 @@ public class ImportPage extends AbstractImportPage implements ISelectableIUsPage public Object[] getCheckedIUElements() { Object[] checked = viewer.getCheckedElements(); List<IUDetail> checkedFeatures = new ArrayList<>(checked.length); - for (int i = 0; i < checked.length; i++) { - IUDetail feature = (IUDetail) checked[i]; + for (Object checked1 : checked) { + IUDetail feature = (IUDetail) checked1; IUDetail[] existingFeatures = newProposedFeature.get(feature); if (existingFeatures == null) checkedFeatures.add(feature); diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java index 263fd5b2d..25b911a93 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationPage.java @@ -114,10 +114,13 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis Object[] checked = viewer.getCheckedElements(); if (checkState == null) checkState = new ArrayList<>(checked.length); - for (int i = 0; i < checked.length; i++) - if (!viewer.getGrayed(checked[i])) - if (!checkState.contains(checked[i])) - checkState.add(checked[i]); + for (Object checked1 : checked) { + if (!viewer.getGrayed(checked1)) { + if (!checkState.contains(checked1)) { + checkState.add(checked1); + } + } + } }); } @@ -382,8 +385,8 @@ public class MigrationPage extends WizardPage implements ISelectableIUsPage, Lis if (contentProvider.hasChildren(event.getElement())) { Set<Object> unchecked = new HashSet<>(); Object[] children = contentProvider.getChildren(event.getElement()); - for (int i = 0; i < children.length; i++) { - unchecked.add(children[i]); + for (Object child : children) { + unchecked.add(child); } Iterator<Object> iter = filteredTree.checkState.iterator(); while (iter.hasNext()) { diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java index 23555547b..03f1b4f4e 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/migration/MigrationWizard.java @@ -112,11 +112,11 @@ public class MigrationWizard extends InstallWizard implements IImportWizard { .asList(metaManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)); if (reposToMigrate != null && metaManager != null && artifactManager != null) { - for (int i = 0; i < reposToMigrate.length; i++) { - if (!currentMetaRepos.contains(reposToMigrate[i])) { - metaManager.addRepository(reposToMigrate[i]); - artifactManager.addRepository(reposToMigrate[i]); - addedRepos.add(reposToMigrate[i]); + for (URI repoToMigrate : reposToMigrate) { + if (!currentMetaRepos.contains(repoToMigrate)) { + metaManager.addRepository(repoToMigrate); + artifactManager.addRepository(repoToMigrate); + addedRepos.add(repoToMigrate); } } } diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RevertProfilePageWithCompare.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RevertProfilePageWithCompare.java index 51af20439..ad4b08c4e 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RevertProfilePageWithCompare.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/RevertProfilePageWithCompare.java @@ -74,9 +74,10 @@ public class RevertProfilePageWithCompare extends RevertProfilePage { // compare is enabled if there are two elements selected Object[] selection = structuredSelection.toArray(); if (selection.length == 2) { - for (int i = 0; i < selection.length; i++) { - if (!(selection[i] instanceof RollbackProfileElement)) + for (Object selection1 : selection) { + if (!(selection1 instanceof RollbackProfileElement)) { return false; + } } return true; } @@ -177,13 +178,13 @@ public class RevertProfilePageWithCompare extends RevertProfilePage { Set<ProvElementNode> children = new HashSet<>(); if (pe instanceof RollbackProfileElement) { Object[] c = ((RollbackProfileElement) pe).getChildren(null); - for (int i = 0; i < c.length; i++) { - children.add(new ProvElementNode(c[i])); + for (Object c1 : c) { + children.add(new ProvElementNode(c1)); } } else if (pe instanceof InstalledIUElement) { Object[] c = ((InstalledIUElement) pe).getChildren(null); - for (int i = 0; i < c.length; i++) { - children.add(new ProvElementNode(c[i])); + for (Object c1 : c) { + children.add(new ProvElementNode(c1)); } } return children.toArray(); |