diff options
author | Alexander Kurtakov | 2018-04-25 11:23:48 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-04-25 11:23:48 +0000 |
commit | b79089e44d71e2e837f2b119f1c297f28681e487 (patch) | |
tree | 8eb33c638121d85ebf2dfbef529ebad35cee7fcd | |
parent | 15000065081411a10e766ecb1ce90d4c947a8ca8 (diff) | |
download | rt.equinox.p2-b79089e44d71e2e837f2b119f1c297f28681e487.tar.gz rt.equinox.p2-b79089e44d71e2e837f2b119f1c297f28681e487.tar.xz rt.equinox.p2-b79089e44d71e2e837f2b119f1c297f28681e487.zip |
Cleanups.I20180425-0910I20180425-0725
* Foreach conversion.
* Removed useless non-javadoc comments.
* Use isEmpty.
Change-Id: I86a3291f3abf30a8dee2b4a4c008978b24ec75d3
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
8 files changed, 31 insertions, 35 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui/.classpath b/bundles/org.eclipse.equinox.p2.ui/.classpath index 4f83b2397..eca7bdba8 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 a0d6dcb6b..5fac49ab9 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 @@ public class PreselectedIUInstallWizard extends WizardWithLicenses { } } - /* (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 a6e950616..071f07cef 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 @@ public class QueryableUpdates implements IQueryable<IInstallableUnit> { 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 b024d381c..d5b433f8f 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 @@ public class IUDetailsLabelProvider extends ColumnLabelProvider implements ITabl 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 a23ffc52c..291ed510c 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 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable 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 @@ public class InstalledSoftwarePage extends InstallationPage implements ICopyable 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 2309333f7..b5ce61ae5 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 @@ public class ProvisioningUI { // 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 05c634027..d796aefd0 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 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb 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 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb 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 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb 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 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb 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 @@ public class RepositoryManipulationPage extends PreferencePage implements IWorkb // 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 b8ef51b2a..b7d0f8c74 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 @@ public class RevertProfilePage extends InstallationPage implements ICopyable { 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 @@ public class RevertProfilePage extends InstallationPage implements ICopyable { 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()}); |