Cleanups.

* Foreach conversion.
* Removed useless non-javadoc comments.
* Use isEmpty.

Change-Id: I86a3291f3abf30a8dee2b4a4c008978b24ec75d3
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/bundles/org.eclipse.equinox.p2.ui/.classpath b/bundles/org.eclipse.equinox.p2.ui/.classpath
index 4f83b23..eca7bdb 100644
--- a/bundles/org.eclipse.equinox.p2.ui/.classpath
+++ b/bundles/org.eclipse.equinox.p2.ui/.classpath
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java
index a0d6dcb..5fac49a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/PreselectedIUInstallWizard.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2013 IBM Corporation and others.
+ * Copyright (c) 2009, 2018 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -82,17 +82,11 @@
 		}
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#getErrorReportingPage()
-	 */
 	@Override
 	protected IResolutionErrorReportingPage createErrorReportingPage() {
 		return (IResolutionErrorReportingPage) mainPage;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningOperationWizard#getProfileChangeOperation(java.lang.Object[])
-	 */
 	@Override
 	protected ProfileChangeOperation getProfileChangeOperation(Object[] elements) {
 		InstallOperation op = new InstallOperation(ui.getSession(), ElementUtils.elementsToIUs(elements));
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
index a6e9506..071f07c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008, 2010 IBM Corporation and others.
+ * Copyright (c) 2008, 2018 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -44,10 +44,10 @@
 		IPlanner planner = (IPlanner) ui.getSession().getProvisioningAgent().getService(IPlanner.SERVICE_NAME);
 		try {
 			Set<IInstallableUnit> allUpdates = new HashSet<>();
-			for (int i = 0; i < iusToUpdate.length; i++) {
+			for (IInstallableUnit unit : iusToUpdate) {
 				if (monitor.isCanceled())
 					return Collector.emptyCollector();
-				IQueryResult<IInstallableUnit> updates = planner.updatesFor(iusToUpdate[i], new ProvisioningContext(ui.getSession().getProvisioningAgent()), SubMonitor.convert(monitor, totalWork / 2 / iusToUpdate.length));
+				IQueryResult<IInstallableUnit> updates = planner.updatesFor(unit, new ProvisioningContext(ui.getSession().getProvisioningAgent()), SubMonitor.convert(monitor, totalWork / 2 / iusToUpdate.length));
 				allUpdates.addAll(updates.toUnmodifiableSet());
 			}
 			return query.perform(allUpdates.iterator());
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
index b024d38..d5b433f 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/viewers/IUDetailsLabelProvider.java
@@ -54,8 +54,8 @@
 			this.columnConfig = ProvUI.getIUColumnConfig();
 		else
 			this.columnConfig = columnConfig;
-		for (int i = 0; i < this.columnConfig.length; i++)
-			if (this.columnConfig[i].getColumnType() == IUColumnConfig.COLUMN_ID) {
+		for (IUColumnConfig config : this.columnConfig)
+			if (config.getColumnType() == IUColumnConfig.COLUMN_ID) {
 				showingId = true;
 				break;
 			}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
index a23ffc5..291ed51 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/InstalledSoftwarePage.java
@@ -204,12 +204,12 @@
 		if (updateButton == null || updateButton.isDisposed())
 			return;
 		Button[] buttons = {updateButton, uninstallButton, propertiesButton};
-		for (int i = 0; i < buttons.length; i++) {
-			Action action = (Action) buttons[i].getData(BUTTON_ACTION);
+		for (Button button : buttons) {
+			Action action = (Action) button.getData(BUTTON_ACTION);
 			if (action == null || !action.isEnabled())
-				buttons[i].setEnabled(false);
+				button.setEnabled(false);
 			else
-				buttons[i].setEnabled(true);
+				button.setEnabled(true);
 		}
 	}
 
@@ -220,8 +220,8 @@
 	private int getDefaultWidth(Control control) {
 		IUColumnConfig[] columns = getColumnConfig();
 		int totalWidth = 0;
-		for (int i = 0; i < columns.length; i++) {
-			totalWidth += columns[i].getWidthInPixels(control);
+		for (IUColumnConfig column : columns) {
+			totalWidth += column.getWidthInPixels(control);
 		}
 		return totalWidth + 20; // buffer for surrounding composites
 	}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
index 2309333..b5ce61a 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/ProvisioningUI.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2015 IBM Corporation and others.
+ * Copyright (c) 2009, 2018 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -445,9 +445,9 @@
 			// If there is no user nickname assigned to this repo but there is a provider name, then set the nickname.
 			// This will keep the name in the manager even when the repo is not loaded
 			String name = manager.getRepositoryProperty(location, IRepository.PROP_NICKNAME);
-			if (name == null || name.length() == 0) {
+			if (name == null || name.isEmpty()) {
 				name = repo.getName();
-				if (name != null && name.length() > 0)
+				if (name != null && !name.isEmpty())
 					manager.setRepositoryProperty(location, IRepository.PROP_NICKNAME, name);
 			}
 		} catch (ProvisionException e) {
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
index 05c6340..d796aef 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RepositoryManipulationPage.java
@@ -639,9 +639,9 @@
 		MetadataRepositoryElement[] selected = getSelectedElements();
 		if (selected.length >= 1) {
 			boolean enableSites = !toggleMeansDisable(selected);
-			for (int i = 0; i < selected.length; i++) {
-				selected[i].setEnabled(enableSites);
-				getInput().put(selected[i]);
+			for (MetadataRepositoryElement select : selected) {
+				select.setEnabled(enableSites);
+				getInput().put(select);
 			}
 			updateForEnablementChange(selected);
 		}
@@ -652,8 +652,8 @@
 		if (comparator.getSortKey() == RepositoryDetailsLabelProvider.COL_ENABLEMENT)
 			repositoryViewer.refresh(true);
 		else
-			for (int i = 0; i < updated.length; i++)
-				repositoryViewer.update(updated[i], null);
+			for (MetadataRepositoryElement element : updated)
+				repositoryViewer.update(element, null);
 		changed = true;
 	}
 
@@ -662,8 +662,8 @@
 			MetadataRepositoryElement[] imported = UpdateManagerCompatibility.importSites(getShell());
 			if (imported.length > 0) {
 				changed = true;
-				for (int i = 0; i < imported.length; i++)
-					getInput().put(imported[i]);
+				for (MetadataRepositoryElement element : imported)
+					getInput().put(element);
 				safeRefresh(null);
 			}
 		});
@@ -821,8 +821,8 @@
 			if (MessageDialog.openQuestion(getShell(), ProvUIMessages.RepositoryManipulationPage_RemoveConfirmTitle, message)) {
 
 				changed = true;
-				for (int i = 0; i < selections.length; i++) {
-					getInput().remove(selections[i]);
+				for (MetadataRepositoryElement selection : selections) {
+					getInput().remove(selection);
 				}
 				safeRefresh(null);
 			}
@@ -909,9 +909,11 @@
 	// Otherwise it means enable.
 	private boolean toggleMeansDisable(MetadataRepositoryElement[] elements) {
 		double count = 0;
-		for (int i = 0; i < elements.length; i++)
-			if (elements[i].isEnabled())
+		for (MetadataRepositoryElement element : elements) {
+			if (element.isEnabled()) {
 				count++;
+			}
+		}
 		return (count / elements.length) > 0.5;
 	}
 
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
index b8ef51b..b7d0f8c 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/RevertProfilePage.java
@@ -415,7 +415,7 @@
 			text = CopyUtils.getIndentedClipboardText(configContentsViewer.getStructuredSelection().toArray(), labelProvider);
 		} else if (activeControl == configsViewer.getControl()) {
 			Object[] elements = configsViewer.getStructuredSelection().toArray();
-			StringBuffer buffer = new StringBuffer();
+			StringBuilder buffer = new StringBuilder();
 			for (int i = 0; i < elements.length; i++) {
 				if (elements[i] instanceof RollbackProfileElement) {
 					if (i > 0)
@@ -426,7 +426,7 @@
 			text = buffer.toString();
 		} else
 			return;
-		if (text.length() == 0)
+		if (text.isEmpty())
 			return;
 		Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
 		clipboard.setContents(new Object[] {text}, new Transfer[] {TextTransfer.getInstance()});