Bug 511712 - Run cleanup action on eclipse.platform.ui/bundles to use
enhanced for loop - Part6
Change-Id: Ib8a226279df3f3bd9bc1c696f19df73a8a9d8897
Signed-off-by: David Weiser <david.weiser@vogella.com>
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/CellLayout.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/CellLayout.java
index 51c75e5..2179511 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/CellLayout.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/CellLayout.java
@@ -636,9 +636,7 @@
// Determine which controls are in this row
gridInfo.getRow(rowControls, idx, computingRows);
- for (int colIdx = 0; colIdx < rowControls.length; colIdx++) {
- int control = rowControls[colIdx];
-
+ for (int control : rowControls) {
// The getRow method will insert -1 into empty cells... skip these.
if (control != -1) {
int controlStart = gridInfo.getStartPos(
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/LayoutCache.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/LayoutCache.java
index 35cfa11..3d164e6 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/LayoutCache.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/layout/LayoutCache.java
@@ -113,8 +113,8 @@
* Flushes the cache.
*/
public void flush() {
- for (int idx = 0; idx < caches.length; idx++) {
- caches[idx].flush();
+ for (SizeCache cache : caches) {
+ cache.flush();
}
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java
index de3fdf8..6b25e4c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/ContributionRoot.java
@@ -14,7 +14,6 @@
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -88,9 +87,7 @@
* Unregister all visible when expressions from the menu service.
*/
public void release() {
- for (Iterator<IContributionItem> itemIter = itemsToExpressions.keySet().iterator(); itemIter
- .hasNext();) {
- IContributionItem item = itemIter.next();
+ for (IContributionItem item : itemsToExpressions.keySet()) {
// menuService.unregisterVisibleWhen(item, restriction);
item.dispose();
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/LegacyActionPersistence.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/LegacyActionPersistence.java
index 97a72ab..452e9f3 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/LegacyActionPersistence.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/LegacyActionPersistence.java
@@ -430,37 +430,29 @@
final IConfigurationElement[][] indexedConfigurationElements = new IConfigurationElement[5][];
// Sort the actionSets extension point.
- final IConfigurationElement[] actionSetsExtensionPoint = registry
- .getConfigurationElementsFor(EXTENSION_ACTION_SETS);
- for (int i = 0; i < actionSetsExtensionPoint.length; i++) {
- final IConfigurationElement element = actionSetsExtensionPoint[i];
- final String name = element.getName();
+ for (final IConfigurationElement configElement : registry.getConfigurationElementsFor(EXTENSION_ACTION_SETS)) {
+ final String name = configElement.getName();
if (TAG_ACTION_SET.equals(name)) {
- addElementToIndexedArray(element, indexedConfigurationElements,
+ addElementToIndexedArray(configElement, indexedConfigurationElements,
INDEX_ACTION_SETS, actionSetCount++);
}
}
// Sort the editorActions extension point.
- final IConfigurationElement[] editorActionsExtensionPoint = registry
- .getConfigurationElementsFor(EXTENSION_EDITOR_ACTIONS);
- for (int i = 0; i < editorActionsExtensionPoint.length; i++) {
- final IConfigurationElement element = editorActionsExtensionPoint[i];
- final String name = element.getName();
+ for (final IConfigurationElement configElement : registry
+ .getConfigurationElementsFor(EXTENSION_EDITOR_ACTIONS)) {
+ final String name = configElement.getName();
if (TAG_EDITOR_CONTRIBUTION.equals(name)) {
- addElementToIndexedArray(element, indexedConfigurationElements,
+ addElementToIndexedArray(configElement, indexedConfigurationElements,
INDEX_EDITOR_CONTRIBUTIONS, editorContributionCount++);
}
}
// Sort the viewActions extension point.
- final IConfigurationElement[] viewActionsExtensionPoint = registry
- .getConfigurationElementsFor(EXTENSION_VIEW_ACTIONS);
- for (int i = 0; i < viewActionsExtensionPoint.length; i++) {
- final IConfigurationElement element = viewActionsExtensionPoint[i];
- final String name = element.getName();
+ for (final IConfigurationElement configElement : registry.getConfigurationElementsFor(EXTENSION_VIEW_ACTIONS)) {
+ final String name = configElement.getName();
if (TAG_VIEW_CONTRIBUTION.equals(name)) {
- addElementToIndexedArray(element, indexedConfigurationElements,
+ addElementToIndexedArray(configElement, indexedConfigurationElements,
INDEX_VIEW_CONTRIBUTIONS, viewContributionCount++);
}
}
@@ -504,28 +496,23 @@
private final void readActions(final String primaryId,
final IConfigurationElement[] elements, final List warningsToLog,
final Expression visibleWhenExpression, final String viewId) {
- for (int i = 0; i < elements.length; i++) {
- final IConfigurationElement element = elements[i];
-
+ for (final IConfigurationElement configElement : elements) {
/*
* We might need the identifier to generate the command, so we'll
* read it out now.
*/
- final String id = readRequired(element, ATT_ID, warningsToLog,
- "Actions require an id"); //$NON-NLS-1$
+ final String id = readRequired(configElement, ATT_ID, warningsToLog, "Actions require an id"); //$NON-NLS-1$
if (id == null) {
continue;
}
// Try to break out the command part of the action.
- final ParameterizedCommand command = convertActionToCommand(
- element, primaryId, id, warningsToLog);
+ final ParameterizedCommand command = convertActionToCommand(configElement, primaryId, id, warningsToLog);
if (command == null) {
continue;
}
- convertActionToHandler(element, id, command, visibleWhenExpression,
- viewId, warningsToLog);
+ convertActionToHandler(configElement, id, command, visibleWhenExpression, viewId, warningsToLog);
// TODO Read the overrideActionId attribute
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuAdditionCacheEntry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuAdditionCacheEntry.java
index eaf85cf..d3eab27 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuAdditionCacheEntry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuAdditionCacheEntry.java
@@ -204,9 +204,7 @@
private void addMenuChildren(final MElementContainer<MMenuElement> container,
IConfigurationElement parent, String filter) {
- IConfigurationElement[] items = parent.getChildren();
- for (int i = 0; i < items.length; i++) {
- final IConfigurationElement child = items[i];
+ for (final IConfigurationElement child : parent.getChildren()) {
String itemType = child.getName();
String id = MenuHelper.getId(child);
@@ -413,19 +411,17 @@
toolBarContribution.setPositionInParent(position);
toolBarContribution.getTags().add("scheme:" + location.getScheme()); //$NON-NLS-1$
- IConfigurationElement[] items = toolbar.getChildren();
- for (int i = 0; i < items.length; i++) {
- final IConfigurationElement item = items[i];
- String itemType = item.getName();
+ for (final IConfigurationElement child : toolbar.getChildren()) {
+ String itemType = child.getName();
if (IWorkbenchRegistryConstants.TAG_COMMAND.equals(itemType)) {
- MToolBarElement element = createToolBarCommandAddition(item);
+ MToolBarElement element = createToolBarCommandAddition(child);
toolBarContribution.getChildren().add(element);
} else if (IWorkbenchRegistryConstants.TAG_SEPARATOR.equals(itemType)) {
- MToolBarElement element = createToolBarSeparatorAddition(item);
+ MToolBarElement element = createToolBarSeparatorAddition(child);
toolBarContribution.getChildren().add(element);
} else if (IWorkbenchRegistryConstants.TAG_CONTROL.equals(itemType)) {
- MToolBarElement element = createToolControlAddition(item);
+ MToolBarElement element = createToolControlAddition(child);
toolBarContribution.getChildren().add(element);
} else if (IWorkbenchRegistryConstants.TAG_DYNAMIC.equals(itemType)) {
ContextFunction generator = new ContextFunction() {
@@ -434,12 +430,12 @@
ServiceLocator sl = new ServiceLocator();
sl.setContext(context);
DynamicToolBarContributionItem dynamicItem = new DynamicToolBarContributionItem(
- MenuHelper.getId(item), sl, item);
+ MenuHelper.getId(child), sl, child);
return dynamicItem;
}
};
- MToolBarElement element = createToolDynamicAddition(item);
+ MToolBarElement element = createToolDynamicAddition(child);
RenderedElementUtil.setContributionManager(element, generator);
toolBarContribution.getChildren().add(element);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
index c896575..6be1323 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuHelper.java
@@ -418,9 +418,9 @@
HashMap<String, String> map = new HashMap<>();
IConfigurationElement[] parameters = element
.getChildren(IWorkbenchRegistryConstants.TAG_PARAMETER);
- for (int i = 0; i < parameters.length; i++) {
- String name = parameters[i].getAttribute(IWorkbenchRegistryConstants.ATT_NAME);
- String value = parameters[i].getAttribute(IWorkbenchRegistryConstants.ATT_VALUE);
+ for (IConfigurationElement parameter : parameters) {
+ String name = parameter.getAttribute(IWorkbenchRegistryConstants.ATT_NAME);
+ String value = parameter.getAttribute(IWorkbenchRegistryConstants.ATT_VALUE);
if (name != null && value != null) {
map.put(name, value);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuPersistence.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuPersistence.java
index baa032a..4c78321 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuPersistence.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/menus/MenuPersistence.java
@@ -114,17 +114,13 @@
private void readAdditions() {
final IExtensionRegistry registry = Platform.getExtensionRegistry();
ArrayList<IConfigurationElement> configElements = new ArrayList<>();
-
- final IConfigurationElement[] menusExtensionPoint = registry
- .getConfigurationElementsFor(EXTENSION_MENUS);
-
// Create a cache entry for every menu addition;
- for (int i = 0; i < menusExtensionPoint.length; i++) {
- if (PL_MENU_CONTRIBUTION.equals(menusExtensionPoint[i].getName())) {
+ for (IConfigurationElement configElement : registry.getConfigurationElementsFor(EXTENSION_MENUS)) {
+ if (PL_MENU_CONTRIBUTION.equals(configElement.getName())) {
if (contributorFilter == null
|| contributorFilter.matcher(
- menusExtensionPoint[i].getContributor().getName()).matches()) {
- configElements.add(menusExtensionPoint[i]);
+ configElement.getContributor().getName()).matches()) {
+ configElements.add(configElement);
}
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/misc/StatusUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/misc/StatusUtil.java
index 53b3af4..f1b83f7 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/misc/StatusUtil.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/misc/StatusUtil.java
@@ -15,7 +15,6 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
@@ -40,16 +39,14 @@
List result = new ArrayList();
if (aStatus.isMultiStatus()) {
- IStatus[] children = aStatus.getChildren();
- for (int i = 0; i < children.length; i++) {
- IStatus currentChild = children[i];
- if (currentChild.isMultiStatus()) {
- Iterator childStatiiEnum = flatten(currentChild).iterator();
+ for (IStatus status : aStatus.getChildren()) {
+ if (status.isMultiStatus()) {
+ Iterator childStatiiEnum = flatten(status).iterator();
while (childStatiiEnum.hasNext()) {
result.add(childStatiiEnum.next());
}
} else {
- result.add(currentChild);
+ result.add(status);
}
}
} else {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PreferencesAdapter.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PreferencesAdapter.java
index 05e2900..e8af82e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PreferencesAdapter.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PreferencesAdapter.java
@@ -40,12 +40,8 @@
public Set keySet() {
Set result = new HashSet();
- String[] names = store.propertyNames();
-
- for (int i = 0; i < names.length; i++) {
- String string = names[i];
-
- result.add(string);
+ for (String name : store.propertyNames()) {
+ result.add(name);
}
return result;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyListenerList.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyListenerList.java
index 08a3119..c4979c7 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyListenerList.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyListenerList.java
@@ -76,10 +76,8 @@
Collection result = Collections.EMPTY_SET;
HashSet union = null;
- for (int i = 0; i < propertyIds.length; i++) {
- String property = propertyIds[i];
-
- List existingListeners = (List)listeners.get(property);
+ for (String property : propertyIds) {
+ List existingListeners = (List)listeners.get(property);
if (existingListeners != null) {
if (result == Collections.EMPTY_SET) {
@@ -138,9 +136,7 @@
}
public void add(String[] propertyIds, IPropertyMapListener newListener) {
- for (int i = 0; i < propertyIds.length; i++) {
- String id = propertyIds[i];
-
+ for (String id : propertyIds) {
addInternal(id, newListener);
}
newListener.listenerAttached();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyMapAdapter.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyMapAdapter.java
index f33781b..c616eda 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyMapAdapter.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyMapAdapter.java
@@ -80,8 +80,8 @@
protected final void firePropertyChange(String[] prefIds) {
if (ignoreCount > 0) {
- for (int i = 0; i < prefIds.length; i++) {
- queuedEvents.add(prefIds[i]);
+ for (String prefId : prefIds) {
+ queuedEvents.add(prefId);
}
return;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyUtil.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyUtil.java
index 76c988e..8b50557 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyUtil.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/PropertyUtil.java
@@ -71,9 +71,7 @@
public static IPropertyMap union(IPropertyMap[] sources) {
PropertyMapUnion result = new PropertyMapUnion();
- for (int i = 0; i < sources.length; i++) {
- IPropertyMap map = sources[i];
-
+ for (IPropertyMap map : sources) {
result.addMap(map);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkbenchPreferenceExtensionNode.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkbenchPreferenceExtensionNode.java
index 63e2b22..6fad5d4 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkbenchPreferenceExtensionNode.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkbenchPreferenceExtensionNode.java
@@ -72,9 +72,8 @@
IConfigurationElement[] references = getConfigurationElement()
.getChildren(IWorkbenchRegistryConstants.TAG_KEYWORD_REFERENCE);
HashSet list = new HashSet(references.length);
- for (int i = 0; i < references.length; i++) {
- IConfigurationElement page = references[i];
- String id = page.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
+ for (IConfigurationElement configElement : references) {
+ String id = configElement.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
if (id != null) {
list.add(id);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkingCopyPreferences.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkingCopyPreferences.java
index e3b8ce8..dd224f9 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkingCopyPreferences.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/preferences/WorkingCopyPreferences.java
@@ -94,15 +94,13 @@
checkRemoved();
// clear all values (long way so people get notified)
- String[] keys = keys();
- for (int i = 0; i < keys.length; i++) {
- remove(keys[i]);
+ for (String key : keys()) {
+ remove(key);
}
// remove children
- String[] childNames = childrenNames();
- for (int i = 0; i < childNames.length; i++) {
- node(childNames[i]).removeNode();
+ for (String childName : childrenNames()) {
+ node(childName).removeNode();
}
// mark as removed
@@ -122,9 +120,8 @@
if (!visitor.visit(this)) {
return;
}
- String[] childNames = childrenNames();
- for (int i = 0; i < childNames.length; i++) {
- ((IEclipsePreferences) node(childNames[i])).accept(visitor);
+ for (String childName : childrenNames()) {
+ ((IEclipsePreferences) node(childName)).accept(visitor);
}
}
@@ -152,8 +149,8 @@
return;
}
PreferenceChangeEvent event = new PreferenceChangeEvent(this, key, oldValue, newValue);
- for (int i = 0; i < listeners.length; i++) {
- ((IPreferenceChangeListener) listeners[i]).preferenceChange(event);
+ for (Object listener : listeners) {
+ ((IPreferenceChangeListener) listener).preferenceChange(event);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/AnimationManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/AnimationManager.java
index c1f3dbb..78040da 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/AnimationManager.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/AnimationManager.java
@@ -148,9 +148,8 @@
ProgressManager manager = ProgressManager.getInstance();
jobs.clear();
setAnimated(false);
- JobInfo[] currentInfos = manager.getJobInfos(showsDebug());
- for (int i = 0; i < currentInfos.length; i++) {
- addJob(currentInfos[i]);
+ for (JobInfo currentInfo : manager.getJobInfos(showsDebug())) {
+ addJob(currentInfo);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java
index a68bb6a..c07d911 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/DetailedProgressViewer.java
@@ -135,14 +135,14 @@
Set newItems = new HashSet(elements.length);
Control[] existingChildren = control.getChildren();
- for (int i = 0; i < existingChildren.length; i++) {
- if (existingChildren[i].getData() != null)
- newItems.add(existingChildren[i].getData());
+ for (Control child : existingChildren) {
+ if (child.getData() != null)
+ newItems.add(child.getData());
}
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] != null)
- newItems.add(elements[i]);
+ for (Object element : elements) {
+ if (element != null)
+ newItems.add(element);
}
JobTreeElement[] infos = new JobTreeElement[newItems.size()];
@@ -153,8 +153,8 @@
}
// Update with the new elements to prevent flash
- for (int i = 0; i < existingChildren.length; i++) {
- ((ProgressInfoItem) existingChildren[i]).dispose();
+ for (Control child : existingChildren) {
+ ((ProgressInfoItem) child).dispose();
}
int totalSize = Math.min(newItems.size(), MAX_DISPLAYED);
@@ -206,10 +206,8 @@
@Override
public void select() {
-
- Control[] children = control.getChildren();
- for (int i = 0; i < children.length; i++) {
- ProgressInfoItem child = (ProgressInfoItem) children[i];
+ for (Control element : control.getChildren()) {
+ ProgressInfoItem child = (ProgressInfoItem) element;
if (!item.equals(child)) {
child.selectWidgets(false);
}
@@ -280,14 +278,13 @@
@Override
protected Widget doFindItem(Object element) {
- Control[] existingChildren = control.getChildren();
- for (int i = 0; i < existingChildren.length; i++) {
- if (existingChildren[i].isDisposed()
- || existingChildren[i].getData() == null) {
+ for (Control control : control.getChildren()) {
+ if (control.isDisposed()
+ || control.getData() == null) {
continue;
}
- if (existingChildren[i].getData().equals(element)) {
- return existingChildren[i];
+ if (control.getData().equals(element)) {
+ return control;
}
}
return null;
@@ -341,11 +338,11 @@
@Override
public void remove(Object[] elements) {
- for (int i = 0; i < elements.length; i++) {
- JobTreeElement treeElement = (JobTreeElement) elements[i];
+ for (Object element : elements) {
+ JobTreeElement treeElement = (JobTreeElement) element;
// Make sure we are not keeping this one
if (FinishedJobs.getInstance().isKept(treeElement)) {
- Widget item = doFindItem(elements[i]);
+ Widget item = doFindItem(element);
if (item != null) {
((ProgressInfoItem) item).refresh();
}
@@ -359,7 +356,7 @@
item = doFindItem(parent);
}
if (item != null) {
- unmapElement(elements[i]);
+ unmapElement(element);
item.dispose();
}
}
@@ -411,10 +408,9 @@
private void refreshAll() {
Object[] infos = getSortedChildren(getRoot());
- Control[] existingChildren = control.getChildren();
- for (int i = 0; i < existingChildren.length; i++) {
- existingChildren[i].dispose();
+ for (Control control : control.getChildren()) {
+ control.dispose();
}
@@ -434,11 +430,10 @@
* area.
*/
private void updateVisibleItems() {
- Control[] children = control.getChildren();
int top = scrolled.getOrigin().y;
int bottom = top + scrolled.getParent().getBounds().height;
- for (int i = 0; i < children.length; i++) {
- ProgressInfoItem item = (ProgressInfoItem) children[i];
+ for (Control control : control.getChildren()) {
+ ProgressInfoItem item = (ProgressInfoItem) control;
item.setDisplayed(top, bottom);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java
index 79234a0..a861252 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java
@@ -153,10 +153,9 @@
}
private void checkForDuplicates(GroupInfo info) {
- Object[] objects = info.getChildren();
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof JobInfo) {
- checkForDuplicates((JobInfo) objects[i]);
+ for (Object child : info.getChildren()) {
+ if (child instanceof JobInfo) {
+ checkForDuplicates((JobInfo) child);
}
}
}
@@ -164,8 +163,8 @@
private void checkForDuplicates(JobTreeElement info) {
JobTreeElement[] toBeRemoved = findJobsToRemove(info);
if (toBeRemoved != null) {
- for (int i = 0; i < toBeRemoved.length; i++) {
- remove(toBeRemoved[i]);
+ for (JobTreeElement element : toBeRemoved) {
+ remove(element);
}
}
}
@@ -192,9 +191,8 @@
}
if (fire) {
- Object l[] = getListeners();
- for (int i = 0; i < l.length; i++) {
- KeptJobsListener jv = (KeptJobsListener) l[i];
+ for (Object listener : getListeners()) {
+ KeptJobsListener jv = (KeptJobsListener) listener;
jv.finished(info);
}
}
@@ -221,22 +219,20 @@
if (myJob != null) {
- Object prop = myJob
- .getProperty(ProgressManagerUtil.KEEPONE_PROPERTY);
+ Object prop = myJob.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY);
if (prop instanceof Boolean && ((Boolean) prop).booleanValue()) {
ArrayList found = null;
JobTreeElement[] all;
all = (JobTreeElement[]) keptjobinfos.toArray(new JobTreeElement[keptjobinfos.size()]);
- for (int i = 0; i < all.length; i++) {
- JobTreeElement jte = all[i];
- if (jte != info && jte.isJobInfo()) {
- Job job = ((JobInfo) jte).getJob();
+ for (JobTreeElement jobTreeElement : all) {
+ if (jobTreeElement != info && jobTreeElement.isJobInfo()) {
+ Job job = ((JobInfo) jobTreeElement).getJob();
if (job != null && job != myJob
&& job.belongsTo(myJob)) {
if (found == null) {
found = new ArrayList();
}
- found.add(jte);
+ found.add(jobTreeElement);
}
}
}
@@ -264,15 +260,14 @@
}
if (toBeRemoved != null) {
- for (int i = 0; i < toBeRemoved.length; i++) {
- remove(toBeRemoved[i]);
+ for (JobTreeElement jobTreeElement : toBeRemoved) {
+ remove(jobTreeElement);
}
}
if (fire) {
- Object l[] = getListeners();
- for (int i = 0; i < l.length; i++) {
- KeptJobsListener jv = (KeptJobsListener) l[i];
+ for (Object listener : getListeners()) {
+ KeptJobsListener jv = (KeptJobsListener) listener;
jv.finished(info);
}
}
@@ -282,9 +277,9 @@
public void removeErrorJobs() {
JobTreeElement[] infos = getKeptElements();
- for (int i = 0; i < infos.length; i++) {
- if (infos[i].isJobInfo()) {
- JobInfo info1 = (JobInfo) infos[i];
+ for (JobTreeElement info : infos) {
+ if (info.isJobInfo()) {
+ JobInfo info1 = (JobInfo) info;
Job job = info1.getJob();
if (job != null) {
IStatus status = job.getResult();
@@ -313,14 +308,14 @@
// delete all elements that have jte as their direct or indirect
// parent
JobTreeElement jtes[] = (JobTreeElement[]) keptjobinfos.toArray(new JobTreeElement[keptjobinfos.size()]);
- for (int i = 0; i < jtes.length; i++) {
- JobTreeElement parent = (JobTreeElement) jtes[i].getParent();
+ for (JobTreeElement jobTreeElement : jtes) {
+ JobTreeElement parent = (JobTreeElement) jobTreeElement.getParent();
if (parent != null) {
if (parent == jte || parent.getParent() == jte) {
- if (keptjobinfos.remove(jtes[i])) {
- disposeAction(jtes[i]);
+ if (keptjobinfos.remove(jobTreeElement)) {
+ disposeAction(jobTreeElement);
}
- finishedTime.remove(jtes[i]);
+ finishedTime.remove(jobTreeElement);
}
}
}
@@ -329,9 +324,8 @@
if (fire) {
// notify listeners
- Object l[] = getListeners();
- for (int i = 0; i < l.length; i++) {
- KeptJobsListener jv = (KeptJobsListener) l[i];
+ for (Object listener : getListeners()) {
+ KeptJobsListener jv = (KeptJobsListener) listener;
jv.removed(jte);
}
}
@@ -386,17 +380,16 @@
synchronized (keptjobinfos) {
JobTreeElement[] all = (JobTreeElement[]) keptjobinfos
.toArray(new JobTreeElement[keptjobinfos.size()]);
- for (int i = 0; i < all.length; i++) {
- disposeAction(all[i]);
+ for (JobTreeElement jobTreeElement : all) {
+ disposeAction(jobTreeElement);
}
keptjobinfos.clear();
finishedTime.clear();
}
// notify listeners
- Object l[] = getListeners();
- for (int i = 0; i < l.length; i++) {
- KeptJobsListener jv = (KeptJobsListener) l[i];
+ for (Object listener : getListeners()) {
+ KeptJobsListener jv = (KeptJobsListener) listener;
jv.removed(null);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/GroupInfo.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/GroupInfo.java
index 268a9e5..5aaf295 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/GroupInfo.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/GroupInfo.java
@@ -182,9 +182,8 @@
@Override
public void cancel() {
- Object[] jobInfos = getChildren();
- for (int i = 0; i < jobInfos.length; i++) {
- ((JobInfo) jobInfos[i]).cancel();
+ for (Object jobInfo : getChildren()) {
+ ((JobInfo) jobInfo).cancel();
}
// Call the refresh so that this is updated immediately
updateInProgressManager();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationProcessor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationProcessor.java
index 3912e97..46cb734 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationProcessor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationProcessor.java
@@ -52,9 +52,8 @@
//Do nothing while animation is happening
}
- ProgressAnimationItem[] animationItems = getAnimationItems();
- for (int i = 0; i < animationItems.length; i++) {
- animationItems[i].animationDone();
+ for (ProgressAnimationItem animationItem : getAnimationItems()) {
+ animationItem.animationDone();
}
}
@@ -83,9 +82,8 @@
@Override
public void animationStarted() {
- AnimationItem[] animationItems = getAnimationItems();
- for (int i = 0; i < animationItems.length; i++) {
- animationItems[i].animationStart();
+ for (AnimationItem animationItem : getAnimationItems()) {
+ animationItem.animationStart();
}
}
@@ -101,17 +99,15 @@
* @return ProgressAnimationItem[]
*/
private ProgressAnimationItem[] getAnimationItems() {
- ProgressAnimationItem[] animationItems = new ProgressAnimationItem[items
- .size()];
+ ProgressAnimationItem[] animationItems = new ProgressAnimationItem[items.size()];
items.toArray(animationItems);
return animationItems;
}
@Override
public void animationFinished() {
- AnimationItem[] animationItems = getAnimationItems();
- for (int i = 0; i < animationItems.length; i++) {
- animationItems[i].animationDone();
+ for (AnimationItem animationItem : getAnimationItems()) {
+ animationItem.animationDone();
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java
index 26af58f..9bf57fe 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java
@@ -505,9 +505,9 @@
// Only do it if there is an indeterminate task
// There may be no task so we don't want to create it
// until we know for sure
- for (int i = 0; i < infos.length; i++) {
- if (infos[i].hasTaskInfo()
- && infos[i].getTaskInfo().totalWork == IProgressMonitor.UNKNOWN) {
+ for (JobInfo jobInfo : infos) {
+ if (jobInfo.hasTaskInfo()
+ && jobInfo.getTaskInfo().totalWork == IProgressMonitor.UNKNOWN) {
createProgressBar(SWT.INDETERMINATE);
break;
}
@@ -606,8 +606,8 @@
private boolean isCompleted() {
JobInfo[] infos = getJobInfos();
- for (int i = 0; i < infos.length; i++) {
- if (infos[i].getJob().getState() != Job.NONE) {
+ for (JobInfo jobInfo : infos) {
+ if (jobInfo.getJob().getState() != Job.NONE) {
return false;
}
}
@@ -637,9 +637,8 @@
*/
private boolean isRunning() {
- JobInfo[] infos = getJobInfos();
- for (int i = 0; i < infos.length; i++) {
- int state = infos[i].getJob().getState();
+ for (JobInfo jobInfo : getJobInfos()) {
+ int state = jobInfo.getJob().getState();
if (state == Job.WAITING || state == Job.RUNNING)
return true;
}
@@ -688,11 +687,10 @@
.getImage(DISABLED_STOP_IMAGE_KEY));
}
- JobInfo[] infos = getJobInfos();
- for (int i = 0; i < infos.length; i++) {
+ for (JobInfo jobInfo : getJobInfos()) {
// Only disable if there is an unresponsive operation
- if (infos[i].isCanceled() && !isCompleted()) {
+ if (jobInfo.isCanceled() && !isCompleted()) {
actionButton.setEnabled(false);
return;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java
index 6db2763..97a7db1 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java
@@ -217,8 +217,8 @@
if (currentInfo.updateAll) {
currentInfo.reset();
- for (int i = 0; i < collectors.length; i++) {
- collectors[i].refresh();
+ for (IProgressUpdateCollector collector : collectors) {
+ collector.refresh();
}
} else {
@@ -234,9 +234,7 @@
currentInfo.reset();
- for (int v = 0; v < collectors.length; v++) {
- IProgressUpdateCollector collector = collectors[v];
-
+ for (IProgressUpdateCollector collector : collectors) {
if (updateItems.length > 0) {
collector.refresh(updateItems);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewerContentProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewerContentProvider.java
index 2737d95..2800717 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewerContentProvider.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewerContentProvider.java
@@ -115,9 +115,8 @@
@Override
public void refresh(Object[] elements) {
- Object[] refreshes = getRoots(elements, true);
- for (int i = 0; i < refreshes.length; i++) {
- progressViewer.refresh(refreshes[i], true);
+ for (Object refresh : getRoots(elements, true)) {
+ progressViewer.refresh(refresh, true);
}
}
@@ -135,8 +134,7 @@
Set all = new HashSet();
- for (int i = 0; i < elements.length; i++) {
- Object element = elements[i];
+ for (Object element : elements) {
all.add(element);
}
@@ -167,19 +165,19 @@
return elements;
}
HashSet roots = new HashSet();
- for (int i = 0; i < elements.length; i++) {
- JobTreeElement element = (JobTreeElement) elements[i];
- if (element.isJobInfo()) {
- GroupInfo group = ((JobInfo) element).getGroupInfo();
+ for (Object element : elements) {
+ JobTreeElement jobTreeElement = (JobTreeElement) element;
+ if (jobTreeElement.isJobInfo()) {
+ GroupInfo group = ((JobInfo) jobTreeElement).getGroupInfo();
if (group == null) {
- roots.add(element);
+ roots.add(jobTreeElement);
} else {
if (subWithParent) {
roots.add(group);
}
}
} else {
- roots.add(element);
+ roots.add(jobTreeElement);
}
}
return roots.toArray();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java
index e616b5c..7128e33 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java
@@ -222,9 +222,8 @@
jobs.clear();
jobInfoMap.clear();
setAnimated(false);
- JobInfo[] currentInfos = manager.getJobInfos(showsDebug());
- for (int i = 0; i < currentInfos.length; i++) {
- addJob(currentInfos[i]);
+ for (JobInfo currentInfo : manager.getJobInfos(showsDebug())) {
+ addJob(currentInfo);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/ActionProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/ActionProvider.java
index b271322..2c41470 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/ActionProvider.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/ActionProvider.java
@@ -57,9 +57,8 @@
collectContributions(menu, result);
ActionContributionItem[] actions = (ActionContributionItem[]) result
.toArray(new ActionContributionItem[result.size()]);
- for (int i = 0; i < actions.length; i++) {
- ActionElement actionElement = new ActionElement(actions[i],
- this);
+ for (ActionContributionItem action : actions) {
+ ActionElement actionElement = new ActionElement(action, this);
idToElement.put(actionElement.getId(), actionElement);
}
}
@@ -69,9 +68,7 @@
}
private void collectContributions(MenuManager menu, Set result) {
- IContributionItem[] items = menu.getItems();
- for (int i = 0; i < items.length; i++) {
- IContributionItem item = items[i];
+ for (IContributionItem item : menu.getItems()) {
if (item instanceof SubContributionItem) {
item = ((SubContributionItem) item).getInnerItem();
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/EditorProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/EditorProvider.java
index 3466d55..dd9c103 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/EditorProvider.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/EditorProvider.java
@@ -43,9 +43,8 @@
if (activePage == null) {
return new QuickAccessElement[0];
}
- IEditorReference[] editors = activePage.getEditorReferences();
- for (int i = 0; i < editors.length; i++) {
- EditorElement editorElement = new EditorElement(editors[i],
+ for (IEditorReference editor : activePage.getEditorReferences()) {
+ EditorElement editorElement = new EditorElement(editor,
this);
idToElement.put(editorElement.getId(), editorElement);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PropertiesProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PropertiesProvider.java
index 8a0675c..08a639d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PropertiesProvider.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/PropertiesProvider.java
@@ -44,24 +44,19 @@
public QuickAccessElement[] getElements() {
if (idToElement == null) {
idToElement = new HashMap();
- IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage != null) {
PropertyPageManager pageManager = new PropertyPageManager();
ISelection selection = activePage.getSelection();
if (selection instanceof IStructuredSelection
&& !selection.isEmpty()) {
- Object element = ((IStructuredSelection) selection)
- .getFirstElement();
- PropertyPageContributorManager.getManager().contribute(
- pageManager, element);
- List list = pageManager
- .getElements(PreferenceManager.PRE_ORDER);
- IPreferenceNode[] properties = (IPreferenceNode[]) list
- .toArray(new IPreferenceNode[list.size()]);
- for (int i = 0; i < properties.length; i++) {
+ Object element = ((IStructuredSelection) selection).getFirstElement();
+ PropertyPageContributorManager.getManager().contribute(pageManager, element);
+ List list = pageManager.getElements(PreferenceManager.PRE_ORDER);
+ IPreferenceNode[] properties = (IPreferenceNode[]) list.toArray(new IPreferenceNode[list.size()]);
+ for (IPreferenceNode property : properties) {
PropertiesElement propertiesElement = new PropertiesElement(
- element, properties[i], this);
+ element, property, this);
idToElement.put(propertiesElement.getId(),
propertiesElement);
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java
index df0b9a4..c010b07 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java
@@ -728,8 +728,7 @@
textLayout.setText(QuickAccessMessages.QuickAccess_AvailableCategories);
int maxProviderWidth = (textLayout.getBounds().width);
textLayout.setFont(boldFont);
- for (int i = 0; i < providers.length; i++) {
- QuickAccessProvider provider = providers[i];
+ for (QuickAccessProvider provider : providers) {
textLayout.setText(provider.getName());
int width = (textLayout.getBounds().width);
if (width > maxProviderWidth) {
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java
index a38b56e..dd57c0a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessDialog.java
@@ -99,8 +99,8 @@
new WizardProvider(), new PreferenceProvider(),
new PropertiesProvider() };
providerMap = new HashMap();
- for (int i = 0; i < providers.length; i++) {
- providerMap.put(providers[i].getId(), providers[i]);
+ for (QuickAccessProvider provider : providers) {
+ providerMap.put(provider.getId(), provider);
}
QuickAccessDialog.this.contents = new QuickAccessContents(providers) {
@Override
@@ -282,8 +282,8 @@
TriggerSequence[] sequences = getInvokingCommandKeySequences();
if (sequences == null)
return;
- for (int i = 0; i < sequences.length; i++) {
- if (sequences[i].equals(keySequence)) {
+ for (TriggerSequence sequence : sequences) {
+ if (sequence.equals(keySequence)) {
e.doit = false;
contents.setShowAllMatches(!contents.getShowAllMatches());
return;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessEntry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessEntry.java
index 9579642..d2442cc 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessEntry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/QuickAccessEntry.java
@@ -147,10 +147,8 @@
if (firstInCategory || providerMatchRegions.length > 0) {
textLayout.setText(provider.getName());
if (boldStyle != null) {
- for (int i = 0; i < providerMatchRegions.length; i++) {
- int[] matchRegion = providerMatchRegions[i];
- textLayout.setStyle(boldStyle, matchRegion[0],
- matchRegion[1]);
+ for (int[] matchRegion : providerMatchRegions) {
+ textLayout.setStyle(boldStyle, matchRegion[0], matchRegion[1]);
}
}
} else {
@@ -175,8 +173,7 @@
event.height = Math.max(event.height, iconSize + 3);
event.width += iconSize + 4;
if (boldStyle != null) {
- for (int i = 0; i < elementMatchRegions.length; i++) {
- int[] matchRegion = elementMatchRegions[i];
+ for (int[] matchRegion : elementMatchRegions) {
textLayout.setStyle(boldStyle, matchRegion[0], matchRegion[1]);
}
}
@@ -196,8 +193,7 @@
if (firstInCategory || providerMatchRegions.length > 0) {
textLayout.setText(provider.getName());
if (boldStyle != null) {
- for (int i = 0; i < providerMatchRegions.length; i++) {
- int[] matchRegion = providerMatchRegions[i];
+ for (int[] matchRegion : providerMatchRegions) {
textLayout.setStyle(boldStyle, matchRegion[0],
matchRegion[1]);
}
@@ -221,9 +217,9 @@
StyledString.QUALIFIER_STYLER, new StyledString(commandElement
.getCommand()));
StyleRange[] styleRanges = styledString.getStyleRanges();
- for (int i = 0; i < styleRanges.length; i++) {
- textLayout.setStyle(styleRanges[i], styleRanges[i].start,
- styleRanges[i].start + styleRanges[i].length);
+ for (StyleRange styleRange : styleRanges) {
+ textLayout.setStyle(styleRange, styleRange.start,
+ styleRange.start + styleRange.length);
}
}
}
@@ -246,8 +242,7 @@
destWidth, destHeight);
textLayout.setText(label);
if (boldStyle != null) {
- for (int i = 0; i < elementMatchRegions.length; i++) {
- int[] matchRegion = elementMatchRegions[i];
+ for (int[] matchRegion : elementMatchRegions) {
textLayout.setStyle(boldStyle, matchRegion[0], matchRegion[1]);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java
index 5f6d0b3..fdb6a26 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/SearchField.java
@@ -164,8 +164,8 @@
new EditorProvider(), new ViewProvider(application, window),
new PerspectiveProvider(), commandProvider, new ActionProvider(),
new WizardProvider(), new PreferenceProvider(), new PropertiesProvider() };
- for (int i = 0; i < providers.length; i++) {
- providerMap.put(providers[i].getId(), providers[i]);
+ for (QuickAccessProvider provider : providers) {
+ providerMap.put(provider.getId(), provider);
}
restoreDialog();
@@ -438,19 +438,17 @@
Monitor[] monitors = toSearch.getMonitors();
Monitor result = monitors[0];
- for (int idx = 0; idx < monitors.length; idx++) {
- Monitor current = monitors[idx];
-
- Rectangle clientArea = current.getClientArea();
+ for (Monitor currentMonitor : monitors) {
+ Rectangle clientArea = currentMonitor.getClientArea();
if (clientArea.contains(toFind)) {
- return current;
+ return currentMonitor;
}
int distance = Geometry.distanceSquared(Geometry.centerPoint(clientArea), toFind);
if (distance < closest) {
closest = distance;
- result = current;
+ result = currentMonitor;
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/WizardProvider.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/WizardProvider.java
index 1c279f2..cd956cf 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/WizardProvider.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/quickaccess/WizardProvider.java
@@ -63,9 +63,8 @@
private void collectWizards(IWizardCategory category, List<IWizardDescriptor> result) {
result.addAll(Arrays.asList(category.getWizards()));
- IWizardCategory[] childCategories = category.getCategories();
- for (int i = 0; i < childCategories.length; i++) {
- collectWizards(childCategories[i], result);
+ for (IWizardCategory childCategory : category.getCategories()) {
+ collectWizards(childCategory, result);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ActionSetRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ActionSetRegistry.java
index eb11998..1666d5a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ActionSetRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ActionSetRegistry.java
@@ -15,7 +15,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-
import org.eclipse.core.commands.contexts.Context;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -213,17 +212,12 @@
* Reads the registry.
*/
private void readFromRegistry() {
- IExtension[] extensions = getActionSetExtensionPoint().getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- addActionSets(PlatformUI.getWorkbench().getExtensionTracker(),
- extensions[i]);
+ for (IExtension extension : getActionSetExtensionPoint().getExtensions()) {
+ addActionSets(PlatformUI.getWorkbench().getExtensionTracker(), extension);
}
- extensions = getActionSetPartAssociationExtensionPoint()
- .getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- addActionSetPartAssociations(PlatformUI.getWorkbench()
- .getExtensionTracker(), extensions[i]);
+ for (IExtension extension : getActionSetPartAssociationExtensionPoint().getExtensions()) {
+ addActionSetPartAssociations(PlatformUI.getWorkbench().getExtensionTracker(), extension);
}
}
@@ -243,14 +237,10 @@
* @param extension
*/
private void addActionSetPartAssociations(IExtensionTracker tracker, IExtension extension) {
- IConfigurationElement [] elements = extension.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
if (element.getName().equals(IWorkbenchRegistryConstants.TAG_ACTION_SET_PART_ASSOCIATION)) {
String actionSetId = element.getAttribute(IWorkbenchRegistryConstants.ATT_TARGET_ID);
- IConfigurationElement[] children = element.getChildren();
- for (int j = 0; j < children.length; j++) {
- IConfigurationElement child = children[j];
+ for (IConfigurationElement child : element.getChildren()) {
if (child.getName().equals(IWorkbenchRegistryConstants.TAG_PART)) {
String partId = child.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
if (partId != null) {
@@ -281,9 +271,7 @@
* @param extension
*/
private void addActionSets(IExtensionTracker tracker, IExtension extension) {
- IConfigurationElement [] elements = extension.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- IConfigurationElement element = elements[i];
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
if (element.getName().equals(IWorkbenchRegistryConstants.TAG_ACTION_SET)) {
try {
ActionSetDescriptor desc = new ActionSetDescriptor(element);
@@ -318,8 +306,7 @@
* @param objects
*/
private void removeActionSetPartAssociations(Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- Object object = objects[i];
+ for (Object object : objects) {
if (object instanceof ActionSetPartAssociation) {
ActionSetPartAssociation association = (ActionSetPartAssociation) object;
String actionSetId = association.actionSetId;
@@ -342,8 +329,7 @@
* @param objects
*/
private void removeActionSets(Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- Object object = objects[i];
+ for (Object object : objects) {
if (object instanceof IActionSetDescriptor) {
IActionSetDescriptor desc = (IActionSetDescriptor) object;
removeActionSet(desc);
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/CategorizedPageRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/CategorizedPageRegistryReader.java
index 5a3e6a5..3313ab7 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/CategorizedPageRegistryReader.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/CategorizedPageRegistryReader.java
@@ -144,9 +144,7 @@
//reset the flag
workDone = false;
List deferred = new ArrayList();
- for (int i = 0; i < nodes.length; i++) {
- // Iterate through all the nodes
- CategoryNode categoryNode = nodes[i];
+ for (CategoryNode categoryNode : nodes) {
Object node = categoryNode.getNode();
String category = getCategory(node);
@@ -187,8 +185,7 @@
} while (nodes.length > 0 && workDone); // loop while we still have nodes to work on and the list is shrinking
// log anything left over.
- for (int i = 0; i < nodes.length; i++) {
- CategoryNode categoryNode = nodes[i];
+ for (CategoryNode categoryNode : nodes) {
// Could not find the parent - log
WorkbenchPlugin.log(StatusUtil.newStatus(IStatus.WARNING,
invalidCategoryNodeMessage(categoryNode), null));
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorDescriptor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorDescriptor.java
index a8540c4..2de2a3d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorDescriptor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorDescriptor.java
@@ -13,7 +13,6 @@
import java.io.File;
import java.io.Serializable;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -159,11 +158,9 @@
* @return org.eclipse.swt.program.Program
*/
private static Program findProgram(String programName) {
-
- Program[] programs = Program.getPrograms();
- for (int i = 0; i < programs.length; i++) {
- if (programs[i].getName().equals(programName)) {
- return programs[i];
+ for (Program program : Program.getPrograms()) {
+ if (program.getName().equals(programName)) {
+ return program;
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
index 6d7db57..3b5243e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistry.java
@@ -277,13 +277,10 @@
*/
private void addExternalEditorsToEditorMap() {
// Add registered editors (may include external editors).
- FileEditorMapping maps[] = typeEditorMappings.allMappings();
- for (int i = 0; i < maps.length; i++) {
- FileEditorMapping map = maps[i];
+ for (FileEditorMapping map : typeEditorMappings.allMappings()) {
IEditorDescriptor[] descArray = map.getEditors();
- for (int n = 0; n < descArray.length; n++) {
- IEditorDescriptor desc = descArray[n];
- mapIDtoEditor.put(desc.getId(), desc);
+ for (IEditorDescriptor desc : descArray) {
+ mapIDtoEditor.put(desc.getId(), desc);
}
}
}
@@ -309,13 +306,12 @@
* @see IEditorRegistry#PROP_CONTENTS
*/
private void firePropertyChange(final int type) {
- Object[] array = getListeners();
- for (int nX = 0; nX < array.length; nX++) {
- final IPropertyListener l = (IPropertyListener) array[nX];
+ for (Object listener : getListeners()) {
+ final IPropertyListener propertyListener = (IPropertyListener) listener;
SafeRunner.run(new SafeRunnable() {
@Override
public void run() {
- l.propertyChanged(EditorRegistry.this, type);
+ propertyListener.propertyChanged(EditorRegistry.this, type);
}
});
}
@@ -443,9 +439,7 @@
*/
public IEditorDescriptor[] getSortedEditorsFromOS() {
List<IEditorDescriptor> externalEditors = new ArrayList<>();
- Program[] programs = Program.getPrograms();
-
- for (int i = 0; i < programs.length; i++) {
+ for (Program program : Program.getPrograms()) {
//1FPLRL2: ITPUI:WINNT - NOTEPAD editor cannot be launched
//Some entries start with %SystemRoot%
//For such cases just use the file name as they are generally
@@ -456,12 +450,11 @@
EditorDescriptor editor = new EditorDescriptor();
editor.setOpenMode(EditorDescriptor.OPEN_EXTERNAL);
- editor.setProgram(programs[i]);
+ editor.setProgram(program);
// determine the program icon this editor would need (do not let it
// be cached in the workbench registry)
- ImageDescriptor desc = new ExternalProgramImageDescriptor(
- programs[i]);
+ ImageDescriptor desc = new ExternalProgramImageDescriptor(program);
editor.setImageDescriptor(desc);
externalEditors.add(editor);
}
@@ -645,12 +638,10 @@
reader = new StringReader(xmlString);
}
XMLMemento memento = XMLMemento.createReadRoot(reader);
- IMemento[] edMementos = memento
- .getChildren(IWorkbenchConstants.TAG_DESCRIPTOR);
// Get the editors and validate each one
- for (int i = 0; i < edMementos.length; i++) {
+ for (IMemento childMemento : memento.getChildren(IWorkbenchConstants.TAG_DESCRIPTOR)) {
EditorDescriptor editor = new EditorDescriptor();
- boolean valid = editor.loadValues(edMementos[i]);
+ boolean valid = editor.loadValues(childMemento);
if (!valid) {
continue;
}
@@ -740,35 +731,26 @@
*
* @throws WorkbenchException
*/
- public void readResources(Map<String, IEditorDescriptor> editorTable, Reader reader)
- throws WorkbenchException {
+ public void readResources(Map<String, IEditorDescriptor> editorTable, Reader reader) throws WorkbenchException {
XMLMemento memento = XMLMemento.createReadRoot(reader);
String versionString = memento.getString(IWorkbenchConstants.TAG_VERSION);
boolean versionIs31 = "3.1".equals(versionString); //$NON-NLS-1$
- IMemento[] extMementos = memento
- .getChildren(IWorkbenchConstants.TAG_INFO);
- for (int i = 0; i < extMementos.length; i++) {
- String name = extMementos[i]
- .getString(IWorkbenchConstants.TAG_NAME);
+ for (IMemento childMemento : memento.getChildren(IWorkbenchConstants.TAG_INFO)) {
+ String name = childMemento.getString(IWorkbenchConstants.TAG_NAME);
if (name == null) {
name = "*"; //$NON-NLS-1$
}
- String extension = extMementos[i]
- .getString(IWorkbenchConstants.TAG_EXTENSION);
- IMemento[] idMementos = extMementos[i]
- .getChildren(IWorkbenchConstants.TAG_EDITOR);
+ String extension = childMemento.getString(IWorkbenchConstants.TAG_EXTENSION);
+ IMemento[] idMementos = childMemento.getChildren(IWorkbenchConstants.TAG_EDITOR);
String[] editorIDs = new String[idMementos.length];
for (int j = 0; j < idMementos.length; j++) {
- editorIDs[j] = idMementos[j]
- .getString(IWorkbenchConstants.TAG_ID);
+ editorIDs[j] = idMementos[j].getString(IWorkbenchConstants.TAG_ID);
}
- idMementos = extMementos[i]
- .getChildren(IWorkbenchConstants.TAG_DELETED_EDITOR);
+ idMementos = childMemento.getChildren(IWorkbenchConstants.TAG_DELETED_EDITOR);
String[] deletedEditorIDs = new String[idMementos.length];
for (int j = 0; j < idMementos.length; j++) {
- deletedEditorIDs[j] = idMementos[j]
- .getString(IWorkbenchConstants.TAG_ID);
+ deletedEditorIDs[j] = idMementos[j].getString(IWorkbenchConstants.TAG_ID);
}
String key = name;
if (extension != null && extension.length() > 0) {
@@ -779,18 +761,18 @@
mapping = new FileEditorMapping(name, extension);
}
List<IEditorDescriptor> editors = new ArrayList<>();
- for (int j = 0; j < editorIDs.length; j++) {
- if (editorIDs[j] != null) {
- IEditorDescriptor editor = editorTable.get(editorIDs[j]);
+ for (String editorID : editorIDs) {
+ if (editorID != null) {
+ IEditorDescriptor editor = editorTable.get(editorID);
if (editor != null) {
editors.add(editor);
}
}
}
List<IEditorDescriptor> deletedEditors = new ArrayList<>();
- for (int j = 0; j < deletedEditorIDs.length; j++) {
- if (deletedEditorIDs[j] != null) {
- IEditorDescriptor editor = editorTable.get(deletedEditorIDs[j]);
+ for (String deletedEditorID : deletedEditorIDs) {
+ if (deletedEditorID != null) {
+ IEditorDescriptor editor = editorTable.get(deletedEditorID);
if (editor != null) {
deletedEditors.add(editor);
}
@@ -800,16 +782,16 @@
List<IEditorDescriptor> defaultEditors = new ArrayList<>();
if (versionIs31) { // parse the new format
- idMementos = extMementos[i]
+ idMementos = childMemento
.getChildren(IWorkbenchConstants.TAG_DEFAULT_EDITOR);
String[] defaultEditorIds = new String[idMementos.length];
for (int j = 0; j < idMementos.length; j++) {
defaultEditorIds[j] = idMementos[j]
.getString(IWorkbenchConstants.TAG_ID);
}
- for (int j = 0; j < defaultEditorIds.length; j++) {
- if (defaultEditorIds[j] != null) {
- IEditorDescriptor editor = editorTable.get(defaultEditorIds[j]);
+ for (String defaultEditorId : defaultEditorIds) {
+ if (defaultEditorId != null) {
+ IEditorDescriptor editor = editorTable.get(defaultEditorId);
if (editor != null) {
defaultEditors.add(editor);
}
@@ -826,9 +808,7 @@
// Add any new editors that have already been read from the registry
// which were not deleted.
- IEditorDescriptor[] editorsArray = mapping.getEditors();
- for (int j = 0; j < editorsArray.length; j++) {
- IEditorDescriptor descriptor = editorsArray[j];
+ for (IEditorDescriptor descriptor : mapping.getEditors()) {
if (descriptor != null && !contains(editors, descriptor) && !deletedEditors.contains(descriptor)) {
editors.add(descriptor);
}
@@ -987,13 +967,11 @@
XMLMemento memento = XMLMemento
.createWriteRoot(IWorkbenchConstants.TAG_EDITORS);
memento.putString(IWorkbenchConstants.TAG_VERSION, "3.1"); //$NON-NLS-1$
- FileEditorMapping maps[] = typeEditorMappings.userMappings();
- for (int mapsIndex = 0; mapsIndex < maps.length; mapsIndex++) {
- FileEditorMapping type = maps[mapsIndex];
- IMemento editorMemento = memento.createChild(IWorkbenchConstants.TAG_INFO);
- editorMemento.putString(IWorkbenchConstants.TAG_NAME, type.getName());
- editorMemento.putString(IWorkbenchConstants.TAG_EXTENSION, type.getExtension());
- IEditorDescriptor[] editorArray = type.getEditors();
+ for (FileEditorMapping fileEditorMapping : typeEditorMappings.userMappings()) {
+ IMemento editorMemento = memento.createChild(IWorkbenchConstants.TAG_INFO);
+ editorMemento.putString(IWorkbenchConstants.TAG_NAME, fileEditorMapping.getName());
+ editorMemento.putString(IWorkbenchConstants.TAG_EXTENSION, fileEditorMapping.getExtension());
+ IEditorDescriptor[] editorArray = fileEditorMapping.getEditors();
for (IEditorDescriptor editor : editorArray) {
if (editor == null) {
continue;
@@ -1004,7 +982,7 @@
IMemento idMemento = editorMemento.createChild(IWorkbenchConstants.TAG_EDITOR);
idMemento.putString(IWorkbenchConstants.TAG_ID, editor.getId());
}
- editorArray = type.getDeletedEditors();
+ editorArray = fileEditorMapping.getDeletedEditors();
for (IEditorDescriptor editor : editorArray) {
if (editor == null) {
continue;
@@ -1015,7 +993,7 @@
IMemento idMemento = editorMemento.createChild(IWorkbenchConstants.TAG_DELETED_EDITOR);
idMemento.putString(IWorkbenchConstants.TAG_ID, editor.getId());
}
- editorArray = type.getDeclaredDefaultEditors();
+ editorArray = fileEditorMapping.getDeclaredDefaultEditors();
for (IEditorDescriptor editor : editorArray) {
if (editor == null) {
continue;
@@ -1071,8 +1049,7 @@
*/
public void setFileEditorMappings(FileEditorMapping[] newResourceTypes) {
typeEditorMappings = new EditorMap();
- for (int i = 0; i < newResourceTypes.length; i++) {
- FileEditorMapping mapping = newResourceTypes[i];
+ for (FileEditorMapping mapping : newResourceTypes) {
typeEditorMappings.put(mappingKeyFor(mapping), mapping);
}
extensionImages = new HashMap<>();
@@ -1117,8 +1094,8 @@
private void sortInternalEditors() {
IEditorDescriptor[] array = sortEditors(sortedEditorsFromPlugins);
sortedEditorsFromPlugins = new ArrayList<>();
- for (int i = 0; i < array.length; i++) {
- sortedEditorsFromPlugins.add(array[i]);
+ for (IEditorDescriptor element : array) {
+ sortedEditorsFromPlugins.add(element);
}
}
@@ -1261,9 +1238,9 @@
@Override
public void removeExtension(IExtension source, Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof IEditorDescriptor) {
- IEditorDescriptor desc = (IEditorDescriptor) objects[i];
+ for (Object object : objects) {
+ if (object instanceof IEditorDescriptor) {
+ IEditorDescriptor desc = (IEditorDescriptor) object;
sortedEditorsFromPlugins.remove(desc);
mapIDtoEditor.values().remove(desc);
@@ -1328,12 +1305,12 @@
public void addExtension(IExtensionTracker tracker, IExtension extension) {
EditorRegistryReader eReader = new EditorRegistryReader();
IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- String id = elements[i].getAttribute(IWorkbenchConstants.TAG_ID);
+ for (IConfigurationElement element : elements) {
+ String id = element.getAttribute(IWorkbenchConstants.TAG_ID);
if (id != null && findEditor(id) != null) {
continue;
}
- eReader.readElement(this, elements[i]);
+ eReader.readElement(this, element);
}
}
@@ -1580,12 +1557,8 @@
List<IFileEditorMapping> allMappings = new ArrayList<>(Arrays.asList(standardMappings));
// mock-up content type extensions into IFileEditorMappings
- IContentType [] contentTypes = Platform.getContentTypeManager().getAllContentTypes();
- for (int i = 0; i < contentTypes.length; i++) {
- IContentType type = contentTypes[i];
- String [] extensions = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
- for (int j = 0; j < extensions.length; j++) {
- String extension = extensions[j];
+ for (IContentType type : Platform.getContentTypeManager().getAllContentTypes()) {
+ for (String extension : type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)) {
boolean found = false;
for (IFileEditorMapping mapping : allMappings) {
if ("*".equals(mapping.getName()) && extension.equals(mapping.getExtension())) { //$NON-NLS-1$
@@ -1599,9 +1572,7 @@
}
}
- String [] filenames = type.getFileSpecs(IContentType.FILE_NAME_SPEC);
- for (int j = 0; j < filenames.length; j++) {
- String wholename = filenames[j];
+ for (String wholename : type.getFileSpecs(IContentType.FILE_NAME_SPEC)) {
int idx = wholename.indexOf('.');
String name = idx == -1 ? wholename : wholename.substring(0, idx);
String extension = idx == -1 ? "" : wholename.substring(idx + 1); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistryReader.java
index a648dde..2639708 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistryReader.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/EditorRegistryReader.java
@@ -131,8 +131,8 @@
}
IConfigurationElement [] bindings = element.getChildren(IWorkbenchRegistryConstants.TAG_CONTENT_TYPE_BINDING);
- for (int i = 0; i < bindings.length; i++) {
- String contentTypeId = bindings[i].getAttribute(IWorkbenchRegistryConstants.ATT_CONTENT_TYPE_ID);
+ for (IConfigurationElement binding : bindings) {
+ String contentTypeId = binding.getAttribute(IWorkbenchRegistryConstants.ATT_CONTENT_TYPE_ID);
if (contentTypeId == null) {
continue;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/KeywordRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/KeywordRegistry.java
index 0ba6ca4..fb36206 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/KeywordRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/KeywordRegistry.java
@@ -12,7 +12,6 @@
import java.util.HashMap;
import java.util.Map;
-
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -61,20 +60,17 @@
private KeywordRegistry() {
IExtensionTracker tracker = PlatformUI.getWorkbench().getExtensionTracker();
tracker.registerHandler(this, ExtensionTracker.createExtensionPointFilter(getExtensionPointFilter()));
- IExtension[] extensions = getExtensionPointFilter().getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- addExtension(PlatformUI.getWorkbench().getExtensionTracker(),
- extensions[i]);
+ for (IExtension extension : getExtensionPointFilter().getExtensions()) {
+ addExtension(PlatformUI.getWorkbench().getExtensionTracker(), extension);
}
}
@Override
public void addExtension(IExtensionTracker tracker, IExtension extension) {
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i].getName().equals(TAG_KEYWORD)) {
- String name = elements[i].getAttribute(ATT_LABEL);
- String id = elements[i].getAttribute(ATT_ID);
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
+ if (element.getName().equals(TAG_KEYWORD)) {
+ String name = element.getAttribute(ATT_LABEL);
+ String id = element.getAttribute(ATT_ID);
internalKeywordMap.put(id, name);
PlatformUI.getWorkbench().getExtensionTracker().registerObject(
extension, id, IExtensionTracker.REF_WEAK);
@@ -99,9 +95,9 @@
@Override
public void removeExtension(IExtension extension, Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof String) {
- internalKeywordMap.remove(objects[i]);
+ for (Object object : objects) {
+ if (object instanceof String) {
+ internalKeywordMap.remove(object);
}
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveParameterValues.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveParameterValues.java
index fb801eb..d34af8d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveParameterValues.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PerspectiveParameterValues.java
@@ -31,8 +31,7 @@
final IPerspectiveDescriptor[] perspectives = PlatformUI.getWorkbench()
.getPerspectiveRegistry().getPerspectives();
- for (int i = 0; i < perspectives.length; i++) {
- final IPerspectiveDescriptor perspective = perspectives[i];
+ for (final IPerspectiveDescriptor perspective : perspectives) {
values.put(perspective.getLabel(), perspective.getId());
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageParameterValues.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageParameterValues.java
index d8550d7..65aa0b7 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageParameterValues.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageParameterValues.java
@@ -70,9 +70,7 @@
private final void collectParameterValues(final Map values,
final IPreferenceNode[] preferenceNodes, final String namePrefix) {
- for (int i = 0; i < preferenceNodes.length; i++) {
- final IPreferenceNode preferenceNode = preferenceNodes[i];
-
+ for (final IPreferenceNode preferenceNode : preferenceNodes) {
final String name;
if (namePrefix == null) {
name = preferenceNode.getLabelText();
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageRegistryReader.java
index 397153a..f754b8c 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageRegistryReader.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferencePageRegistryReader.java
@@ -90,8 +90,8 @@
@Override
Object findNode(Object parent, String currentToken) {
IPreferenceNode[] subNodes = ((WorkbenchPreferenceNode) parent).getSubNodes();
- for (int i = 0; i < subNodes.length; i++) {
- WorkbenchPreferenceNode node = (WorkbenchPreferenceNode) subNodes[i];
+ for (IPreferenceNode subNode : subNodes) {
+ WorkbenchPreferenceNode node = (WorkbenchPreferenceNode) subNode;
if (node.getId().equals(currentToken)) {
return node;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java
index 5a6d887..8eec29d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/PreferenceTransferRegistryReader.java
@@ -149,29 +149,24 @@
* <code>null</code> for all nodes
*/
public static Map getEntry(IConfigurationElement element) {
- IConfigurationElement[] entries = element
- .getChildren(IWorkbenchRegistryConstants.TAG_ENTRY);
+ IConfigurationElement[] entries = element.getChildren(IWorkbenchRegistryConstants.TAG_ENTRY);
if (entries.length == 0) {
return null;
}
Map map = new HashMap(entries.length);
- for (int i = 0; i < entries.length; i++) {
- IConfigurationElement entry = entries[i];
- IConfigurationElement[] keys = entry
- .getChildren(IWorkbenchRegistryConstants.ATT_KEY);
+ for (IConfigurationElement entry : entries) {
+ IConfigurationElement[] keys = entry.getChildren(IWorkbenchRegistryConstants.ATT_KEY);
PreferenceFilterEntry[] prefFilters = null;
if (keys.length > 0) {
prefFilters = new PreferenceFilterEntry[keys.length];
for (int j = 0; j < keys.length; j++) {
IConfigurationElement keyElement = keys[j];
- prefFilters[j] = new PreferenceFilterEntry(keyElement
- .getAttribute(IWorkbenchRegistryConstants.ATT_NAME),
- keyElement
- .getAttribute(IWorkbenchRegistryConstants.ATT_MATCH_TYPE));
+ prefFilters[j] = new PreferenceFilterEntry(
+ keyElement.getAttribute(IWorkbenchRegistryConstants.ATT_NAME),
+ keyElement.getAttribute(IWorkbenchRegistryConstants.ATT_MATCH_TYPE));
}
}
- map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE),
- prefFilters);
+ map.put(entry.getAttribute(IWorkbenchRegistryConstants.ATT_NODE), prefFilters);
}
return map;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/RegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/RegistryReader.java
index 2c95761..18b15ec 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/RegistryReader.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/RegistryReader.java
@@ -157,8 +157,8 @@
}
IExtension[] extensions = point.getExtensions();
extensions = orderExtensions(extensions);
- for (int i = 0; i < extensions.length; i++) {
- readExtension(extensions[i]);
+ for (IExtension extension : extensions) {
+ readExtension(extension);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewParameterValues.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewParameterValues.java
index 11d7559..5be70bd 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewParameterValues.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewParameterValues.java
@@ -31,8 +31,7 @@
final IViewDescriptor[] views = PlatformUI.getWorkbench()
.getViewRegistry().getViews();
- for (int i = 0; i < views.length; i++) {
- final IViewDescriptor view = views[i];
+ for (final IViewDescriptor view : views) {
values.put(view.getLabel(), view.getId());
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardParameterValues.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardParameterValues.java
index dc597aa..a81928d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardParameterValues.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardParameterValues.java
@@ -12,7 +12,6 @@
import java.util.HashMap;
import java.util.Map;
-
import org.eclipse.core.commands.IParameterValues;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.wizards.IWizardCategory;
@@ -62,10 +61,8 @@
private void addParameterValues(Map values, IWizardCategory wizardCategory) {
- final IWizardDescriptor[] wizardDescriptors = wizardCategory
- .getWizards();
- for (int i = 0; i < wizardDescriptors.length; i++) {
- final IWizardDescriptor wizardDescriptor = wizardDescriptors[i];
+ for (final IWizardDescriptor wizardDescriptor : wizardCategory.getWizards()) {
+
// Note: using description instead of label for the name
// to reduce possibilities of key collision in the map
@@ -81,10 +78,7 @@
values.put(name, id);
}
- final IWizardCategory[] childCategories = wizardCategory
- .getCategories();
- for (int i = 0; i < childCategories.length; i++) {
- final IWizardCategory childCategory = childCategories[i];
+ for (final IWizardCategory childCategory : wizardCategory.getCategories()) {
addParameterValues(values, childCategory);
}
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java
index 2fce7a7..2157360 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java
@@ -77,8 +77,8 @@
path = ""; //$NON-NLS-1$
String[] categoryPath = category.getParentPath();
if (categoryPath != null) {
- for (int nX = 0; nX < categoryPath.length; nX++) {
- path += categoryPath[nX] + '/';
+ for (String parentPath : categoryPath) {
+ path += parentPath + '/';
}
}
path += cat.getId();
@@ -230,8 +230,8 @@
Collections.sort(Arrays.asList(flatArray), comparer);
// Add each category.
- for (int nX = 0; nX < flatArray.length; nX++) {
- Category cat = flatArray[nX].getCategory();
+ for (CategoryNode categoryNode : flatArray) {
+ Category cat = categoryNode.getCategory();
finishCategory(cat);
}
@@ -248,9 +248,9 @@
// Traverse down into parent category.
if (categoryPath != null) {
- for (int i = 0; i < categoryPath.length; i++) {
+ for (String parentPath : categoryPath) {
WizardCollectionElement tempElement = getChildWithID(parent,
- categoryPath[i]);
+ parentPath);
if (tempElement == null) {
// The parent category is invalid. By returning here the
// category will be dropped and any wizard within the category
@@ -370,9 +370,8 @@
*/
protected WizardCollectionElement getChildWithID(
WizardCollectionElement parent, String id) {
- Object[] children = parent.getChildren(null);
- for (int i = 0; i < children.length; ++i) {
- WizardCollectionElement currentChild = (WizardCollectionElement) children[i];
+ for (Object child : parent.getChildren(null)) {
+ WizardCollectionElement currentChild = (WizardCollectionElement) child;
if (currentChild.getId().equals(id)) {
return currentChild;
}
@@ -403,8 +402,8 @@
*/
private void pruneEmptyCategories(WizardCollectionElement parent) {
Object[] children = parent.getChildren(null);
- for (int nX = 0; nX < children.length; nX++) {
- WizardCollectionElement child = (WizardCollectionElement) children[nX];
+ for (Object element : children) {
+ WizardCollectionElement child = (WizardCollectionElement) element;
pruneEmptyCategories(child);
boolean shouldPrune = child.getId().equals(FULL_EXAMPLES_WIZARD_CATEGORY);
if (child.isEmpty() && shouldPrune) {
@@ -540,9 +539,8 @@
* @return WorkbenchWizardElement matching the given id, if found; null otherwise
*/
public WorkbenchWizardElement findWizard(String id) {
- Object[] wizards = getWizardCollectionElements();
- for (int nX = 0; nX < wizards.length; nX++) {
- WizardCollectionElement collection = (WizardCollectionElement) wizards[nX];
+ for (Object wizard : getWizardCollectionElements()) {
+ WizardCollectionElement collection = (WizardCollectionElement) wizard;
WorkbenchWizardElement element = collection.findWizard(id, true);
if (element != null && !WorkbenchActivityHelper.restrictUseOf(element)) {
return element;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetDescriptor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetDescriptor.java
index f5dd49e..6629c43 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetDescriptor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetDescriptor.java
@@ -91,8 +91,7 @@
if (containsChildren.length > 0) {
List byClassList = new ArrayList(containsChildren.length);
List byAdapterList = new ArrayList(containsChildren.length);
- for (int i = 0; i < containsChildren.length; i++) {
- IConfigurationElement child = containsChildren[i];
+ for (IConfigurationElement child : containsChildren) {
String className = child
.getAttribute(IWorkbenchRegistryConstants.ATT_CLASS);
if (className != null)
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetRegistry.java
index ccac8c0..d34606e 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/WorkingSetRegistry.java
@@ -15,7 +15,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
@@ -209,17 +208,16 @@
@Override
public void addExtension(IExtensionTracker tracker, IExtension extension) {
WorkingSetRegistryReader reader = new WorkingSetRegistryReader(this);
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- reader.readElement(elements[i]);
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
+ reader.readElement(element);
}
}
@Override
public void removeExtension(IExtension extension, Object[] objects) {
- for (int i = 0; i < objects.length; i++) {
- if (objects[i] instanceof WorkingSetDescriptor) {
- WorkingSetDescriptor desc = (WorkingSetDescriptor) objects[i];
+ for (Object object : objects) {
+ if (object instanceof WorkingSetDescriptor) {
+ WorkingSetDescriptor desc = (WorkingSetDescriptor) object;
workingSetDescriptors.remove(desc.getId());
}
}