Repository: ant-ivyde Updated Branches: refs/heads/master ca1749189 -> f808b0b4f
http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java index 70fcbc5..935635a 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/NewIvyDEContainerWizard.java @@ -59,10 +59,9 @@ public class NewIvyDEContainerWizard extends Wizard { JavaCore.setClasspathContainer(path, new IJavaProject[] {project}, new IClasspathContainer[] {ivycp}, null); IClasspathEntry[] entries = project.getRawClasspath(); - List newEntries = new ArrayList(Arrays.asList(entries)); + List<IClasspathEntry> newEntries = new ArrayList<>(Arrays.asList(entries)); newEntries.add(newEntry); - entries = (IClasspathEntry[]) newEntries - .toArray(new IClasspathEntry[newEntries.size()]); + entries = newEntries.toArray(new IClasspathEntry[newEntries.size()]); project.setRawClasspath(entries, project.getOutputLocation(), null); ivycp.launchResolve(false, null); } catch (JavaModelException e) { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java index eaf1284..72ec5da 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/SettingsSetupEditor.java @@ -20,7 +20,6 @@ package org.apache.ivyde.internal.eclipse.ui; import java.io.File; import java.net.MalformedURLException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.apache.ivyde.eclipse.IvyDEException; @@ -51,7 +50,7 @@ public class SettingsSetupEditor extends Composite { public static final String TOOLTIP_PROPERTY_FILES = "Comma separated list of build property" + " files.\nExample: build.properties, override.properties"; - private final List listeners = new ArrayList(); + private final List<SettingsEditorListener> listeners = new ArrayList<>(); private IvyDEException settingsError; @@ -190,9 +189,8 @@ public class SettingsSetupEditor extends Composite { void settingsUpdated() { synchronized (listeners) { SettingsSetup setup = getIvySettingsSetup(); - Iterator it = listeners.iterator(); - while (it.hasNext()) { - ((SettingsEditorListener) it.next()).settingsEditorUpdated(setup); + for (SettingsEditorListener listener : listeners) { + listener.settingsEditorUpdated(setup); } } } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java index 4db8f90..0f3a9c9 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsole.java @@ -266,11 +266,11 @@ public class IvyConsole extends MessageConsole implements MessageLogger { } // MessageLogger implementation - private List problems = new ArrayList(); + private final List<String> problems = new ArrayList<>(); - private List warns = new ArrayList(); + private final List<String> warns = new ArrayList<>(); - private List errors = new ArrayList(); + private final List<String> errors = new ArrayList<>(); private boolean showProgress = true; @@ -308,7 +308,7 @@ public class IvyConsole extends MessageConsole implements MessageLogger { getErrors().add(msg); } - public List getProblems() { + public List<String> getProblems() { return problems; } @@ -323,11 +323,11 @@ public class IvyConsole extends MessageConsole implements MessageLogger { errors.clear(); } - public List getErrors() { + public List<String> getErrors() { return errors; } - public List getWarns() { + public List<String> getWarns() { return warns; } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java index 490b568..18dda87 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyConsoleFilterAction.java @@ -25,10 +25,13 @@ import org.eclipse.jface.action.Separator; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; +import java.util.Arrays; +import java.util.List; + public class IvyConsoleFilterAction extends Action implements IMenuCreator { - private static final String[] LOG_LEVEL_MESSAGES = {"error", "warning", "info", "verbose", - "debug"}; + private static final List<String> LOG_LEVEL_MESSAGES = Arrays.asList("error", "warning", "info", "verbose", + "debug"); private Menu fMenu; @@ -58,25 +61,25 @@ public class IvyConsoleFilterAction extends Action implements IMenuCreator { } fMenu = new Menu(parent); - for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) { - final int logLevel = i; - Action action = new Action(LOG_LEVEL_MESSAGES[i]) { + for (final String logLevelMessage : LOG_LEVEL_MESSAGES) { + final int logLevel = LOG_LEVEL_MESSAGES.indexOf(logLevelMessage); + Action action = new Action(logLevelMessage) { public void run() { console.setLogLevel(logLevel); } }; - action.setChecked(console.getLogLevel() == i); + action.setChecked(console.getLogLevel() == logLevel); addActionToMenu(fMenu, action); } new Separator().fill(fMenu, -1); - for (int i = 0; i < LOG_LEVEL_MESSAGES.length; i++) { - final int logLevel = i; - Action action = new Action("IvyDE " + LOG_LEVEL_MESSAGES[i]) { + for (final String logLevelMessage : LOG_LEVEL_MESSAGES) { + final int logLevel = LOG_LEVEL_MESSAGES.indexOf(logLevelMessage); + Action action = new Action("IvyDE " + logLevelMessage) { public void run() { console.getIvyDEMessageLogger().setLogLevel(logLevel); } }; - action.setChecked(console.getIvyDEMessageLogger().getLogLevel() == i); + action.setChecked(console.getIvyDEMessageLogger().getLogLevel() == logLevel); addActionToMenu(fMenu, action); } return fMenu; http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java index 0d9258e..6c09361 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/console/IvyDEMessageLogger.java @@ -90,15 +90,15 @@ public class IvyDEMessageLogger implements MessageLogger { // do nothing } - public List getProblems() { + public List<String> getProblems() { return Collections.emptyList(); } - public List getErrors() { + public List<String> getErrors() { return Collections.emptyList(); } - public List getWarns() { + public List<String> getWarns() { return Collections.emptyList(); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java index 07fd208..ea60b66 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvyModuleDescriptorEditor.java @@ -18,7 +18,6 @@ package org.apache.ivyde.internal.eclipse.ui.editors; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.apache.ivyde.common.ivyfile.IvyModuleDescriptorModel; @@ -66,9 +65,9 @@ public class IvyModuleDescriptorEditor extends FormEditor implements IResourceCh private Browser browser; - private List/* <IvyEditorPageDescriptor> */ivyEditorPageDescriptors = new ArrayList(); + private final List<IvyEditorPageDescriptor> ivyEditorPageDescriptors = new ArrayList<>(); - private List/* <ModuleDescriptorExtensionDescriptor> */moduleDescriptorExtensionDescriptors = new ArrayList(); + private final List<ModuleDescriptorExtensionDescriptor> moduleDescriptorExtensionDescriptors = new ArrayList<>(); /** * Creates a multi-page editor example. @@ -141,10 +140,7 @@ public class IvyModuleDescriptorEditor extends FormEditor implements IResourceCh private IvyModuleDescriptorModel getIvyCompletionModel(IvyModelSettings ivyModelSettings) { IvyModuleDescriptorModel ivyModuleDescriptorModel = new IvyModuleDescriptorModel( ivyModelSettings); - Iterator iterator = moduleDescriptorExtensionDescriptors.iterator(); - while (iterator.hasNext()) { - ModuleDescriptorExtensionDescriptor descriptor = (ModuleDescriptorExtensionDescriptor) iterator - .next(); + for (ModuleDescriptorExtensionDescriptor descriptor : moduleDescriptorExtensionDescriptors) { ModuleDescriptorExtension moduleDescriptorExtension = descriptor .createModuleDescriptorExtension(); if (moduleDescriptorExtension != null) { @@ -192,10 +188,7 @@ public class IvyModuleDescriptorEditor extends FormEditor implements IResourceCh } private void addIvyEditorPageExtensions() { - Iterator iterator = ivyEditorPageDescriptors.iterator(); - while (iterator.hasNext()) { - IvyEditorPageDescriptor ivyEditorPageDescriptor = (IvyEditorPageDescriptor) iterator - .next(); + for (IvyEditorPageDescriptor ivyEditorPageDescriptor : ivyEditorPageDescriptors) { IvyEditorPage page = ivyEditorPageDescriptor.createPage(); try { page.initialize(this); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java index 7543e90..f768f16 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/IvySettingsEditor.java @@ -17,13 +17,10 @@ */ package org.apache.ivyde.internal.eclipse.ui.editors; -import java.util.Iterator; -import java.util.List; - import org.apache.ivyde.common.ivysettings.IvySettingsModel; import org.apache.ivyde.common.model.IvyModel; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; -import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; import org.apache.ivyde.internal.eclipse.ui.core.IvyFileEditorInput; import org.apache.ivyde.internal.eclipse.ui.editors.xml.EclipseIvyModelSettings; import org.apache.ivyde.internal.eclipse.ui.editors.xml.IvyContentAssistProcessor; @@ -122,12 +119,9 @@ public class IvySettingsEditor extends FormEditor implements IResourceChangeList public void doSave(IProgressMonitor monitor) { xmlEditor.doSave(monitor); IFile file = ((IvyFileEditorInput) getEditorInput()).getFile(); - List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper - .getContainersFromIvySettings(file); - Iterator/* <IvyClasspathContainer> */itContainers = containers.iterator(); - while (itContainers.hasNext()) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainers.next(); - ivycp.launchResolve(false, null); + for (IvyClasspathContainer container : IvyClasspathContainerHelper + .getContainersFromIvySettings(file)) { + container.launchResolve(false, null); } } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java index f046480..e453ad9 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/ColorManager.java @@ -18,7 +18,6 @@ package org.apache.ivyde.internal.eclipse.ui.editors.xml; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import org.apache.ivyde.internal.eclipse.ui.preferences.PreferenceConstants; @@ -30,16 +29,14 @@ import org.eclipse.swt.widgets.Display; public class ColorManager { - private Map fKeyTable = new HashMap(); + private final Map<String, RGB> fKeyTable = new HashMap<>(); - private Map fDisplayTable = new HashMap(); + private final Map<Display, Map<RGB, Color>> fDisplayTable = new HashMap<>(); public void dispose(Display display) { - Map colorTable = (Map) fDisplayTable.get(display); + Map<RGB, Color> colorTable = fDisplayTable.get(display); if (colorTable != null) { - Iterator e = colorTable.values().iterator(); - while (e.hasNext()) { - Color color = (Color) e.next(); + for (Color color : colorTable.values()) { if (color != null && !color.isDisposed()) { color.dispose(); } @@ -53,9 +50,9 @@ public class ColorManager { } final Display display = Display.getCurrent(); - Map colorTable = (Map) fDisplayTable.get(display); + Map<RGB, Color> colorTable = fDisplayTable.get(display); if (colorTable == null) { - colorTable = new HashMap(); + colorTable = new HashMap<>(); fDisplayTable.put(display, colorTable); display.disposeExec(new Runnable() { public void run() { @@ -64,7 +61,7 @@ public class ColorManager { }); } - Color color = (Color) colorTable.get(rgb); + Color color = colorTable.get(rgb); if (color == null) { color = new Color(Display.getCurrent(), rgb); colorTable.put(rgb, color); @@ -77,7 +74,7 @@ public class ColorManager { if (key == null) { return null; } - RGB rgb = (RGB) fKeyTable.get(key); + RGB rgb = fKeyTable.get(key); return getColor(rgb); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java index eec5f1e..1bb2fa8 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/editors/xml/EclipseIvyModelSettings.java @@ -21,6 +21,7 @@ import java.util.List; import org.apache.ivy.Ivy; import org.apache.ivyde.common.model.IvyModelSettings; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; import org.apache.ivyde.internal.eclipse.IvyPlugin; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; @@ -40,8 +41,8 @@ public class EclipseIvyModelSettings implements IvyModelSettings { this(IvyClasspathContainerHelper.getContainersFromIvyFile(ivyfile)); } - private EclipseIvyModelSettings(List/* <IvyClasspathContainer> */containers) { - this(containers.isEmpty() ? null : (IvyClasspathContainerImpl) containers.iterator().next()); + private EclipseIvyModelSettings(List<IvyClasspathContainer> containers) { + this(containers.isEmpty() ? null : (IvyClasspathContainerImpl) containers.get(0)); } private EclipseIvyModelSettings(IvyClasspathContainerImpl ivycp) { http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java index 6f29f5d..eea7db0 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/CleanCacheAction.java @@ -17,7 +17,6 @@ */ package org.apache.ivyde.internal.eclipse.ui.menu; -import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -35,7 +34,7 @@ import org.eclipse.swt.widgets.Display; public class CleanCacheAction extends Action { - private final List/* <Cleanable> */cleanables; + private final List<Cleanable> cleanables; private final String name; @@ -89,13 +88,13 @@ public class CleanCacheAction extends Action { } } - public CleanCacheAction(String name, List/* <Cleanable> */cleanables) { + public CleanCacheAction(String name, List<Cleanable> cleanables) { this.name = name; this.cleanables = cleanables; } public void run() { - final boolean ok[] = new boolean[1]; + final boolean[] ok = new boolean[1]; Display.getDefault().syncExec(new Runnable() { public void run() { ok[0] = MessageDialog.openConfirm(IvyPlugin.getActiveWorkbenchShell(), name, @@ -104,9 +103,7 @@ public class CleanCacheAction extends Action { } }); if (ok[0]) { - Iterator itCleanable = cleanables.iterator(); - while (itCleanable.hasNext()) { - Cleanable cleanable = (Cleanable) itCleanable.next(); + for (Cleanable cleanable : cleanables) { cleanable.launchClean(); IvyDEMessage.info("Ivy cache cleaned: " + cleanable.getName()); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java index e73a10d..e10d364 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/IvyMenuContributionItem.java @@ -23,7 +23,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -33,6 +32,7 @@ import org.apache.ivy.Ivy; import org.apache.ivy.core.cache.RepositoryCacheManager; import org.apache.ivy.core.cache.ResolutionCacheManager; import org.apache.ivyde.eclipse.IvyNatureHelper; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; import org.apache.ivyde.internal.eclipse.IvyPlugin; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; @@ -75,8 +75,7 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements } protected IContributionItem[] getContributionItems() { - ISelectionService selectionService = (ISelectionService) serviceLocator - .getService(ISelectionService.class); + ISelectionService selectionService = (ISelectionService) serviceLocator.getService(ISelectionService.class); if (selectionService == null) { return new IContributionItem[0]; } @@ -85,29 +84,26 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements return new IContributionItem[0]; } - Map/* <IProject, Set<IvyClasspathContainer>> */containers = new HashMap(); + Map<IProject, Set<IvyClasspathContainer>> containers = new HashMap<>(); - Map/* <IProject, Set<StandaloneRetrieveSetup>> */retrieveSetups = new HashMap(); + Map<IProject, Set<StandaloneRetrieveSetup>> retrieveSetups = new HashMap<>(); // this give info about if the selection is only based of classpath containers boolean onlyContainers = true; int totalSelected = 0; - Iterator it = ((IStructuredSelection) selection).iterator(); - while (it.hasNext()) { + for (Object element : ((IStructuredSelection) selection).toList()) { totalSelected++; - Object element = it.next(); boolean projectCollected = collectProject(containers, retrieveSetups, element); if (projectCollected) { onlyContainers = false; } else { - IWorkingSet workingSet = (IWorkingSet) IvyPlugin.adapt(element, IWorkingSet.class); + IWorkingSet workingSet = IvyPlugin.adapt(element, IWorkingSet.class); if (workingSet != null) { onlyContainers = false; - IAdaptable[] elements = workingSet.getElements(); - for (int i = 0; i < elements.length; i++) { - collectProject(containers, retrieveSetups, elements[i]); + for (IAdaptable elem : workingSet.getElements()) { + collectProject(containers, retrieveSetups, elem); } } else if (element instanceof ClassPathContainer) { collectContainer(containers, (ClassPathContainer) element); @@ -115,12 +111,12 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements } } - List/* <IContributionItem> */items; + List<MenuManager> items; MenuManager menuManager; if (onlyContainers) { // we we have only containers, no need to have a root menu entry menuManager = null; - items = new ArrayList(); + items = new ArrayList<>(); } else { menuManager = new MenuManager("Ivy", IvyPlugin .getImageDescriptor("icons/logo16x16.gif"), "org.apache.ivyde.eclipse.menu"); @@ -138,14 +134,9 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements // add retrieve if (!retrieveSetups.isEmpty()) { boolean oneProject = retrieveSetups.size() == 1 && totalSelected == 1; - Iterator itProject = retrieveSetups.entrySet().iterator(); - while (itProject.hasNext()) { - Entry entry = (Entry) itProject.next(); - IProject project = (IProject) entry.getKey(); - Iterator itSetup = ((Set) entry.getValue()).iterator(); - while (itSetup.hasNext()) { - StandaloneRetrieveSetup retrieveSetup = (StandaloneRetrieveSetup) itSetup - .next(); + for (Entry<IProject, Set<StandaloneRetrieveSetup>> entry : retrieveSetups.entrySet()) { + IProject project = entry.getKey(); + for (StandaloneRetrieveSetup retrieveSetup : entry.getValue()) { RetrieveAction action = new RetrieveAction(retrieveSetup); action.setText("Retrieve '" + retrieveSetup.getName() + (oneProject ? "'" : "' of " + project.getName())); @@ -164,10 +155,10 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements // add clean cache if (!containers.isEmpty()) { if (totalSelected == 1 && containers.size() == 1 - && ((Set) containers.values().iterator().next()).size() == 1) { + && containers.values().iterator().next().size() == 1) { // only one container - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) ((Set) containers.values() - .iterator().next()).iterator().next(); + IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) containers.values() + .iterator().next().iterator().next(); Ivy ivy = ivycp.getState().getCachedIvy(); if (ivy != null) { addCleanableForSingleContainer(menuManager, items, ivy); @@ -187,28 +178,28 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements // add remove ivy nature addCommand(menuManager, items, RemoveIvyNatureHandler.COMMAND_ID); - return (IContributionItem[]) items.toArray(new IContributionItem[items.size()]); + return items.toArray(new IContributionItem[items.size()]); } - private void addCommand(MenuManager menuManager, List/* <IContributionItem> */items, + private void addCommand(MenuManager menuManager, List<MenuManager> items, String commandId) { CommandContributionItemParameter parm = new CommandContributionItemParameter( serviceLocator, null, commandId, CommandContributionItem.STYLE_PUSH); fillMenu(menuManager, items, new CommandContributionItem(parm)); } - private void fillMenu(MenuManager menuManager, List/* <IContributionItem> */items, - IContributionItem item) { + private void fillMenu(MenuManager menuManager, List<MenuManager> items, + IContributionItem commandContributionItem) { if (menuManager != null) { - menuManager.add(item); + menuManager.add(commandContributionItem); } else { - items.add(item); + items.add((MenuManager) commandContributionItem); } } - private boolean collectProject(Map/* <IProject, Set<IvyClasspathContainer>> */containers, - Map/* <IProject, Set<StandaloneRetrieveSetup>> */retrieveSetups, Object element) { - IProject project = (IProject) IvyPlugin.adapt(element, IProject.class); + private boolean collectProject(Map<IProject, Set<IvyClasspathContainer>> containers, + Map<IProject, Set<StandaloneRetrieveSetup>> retrieveSetups, Object element) { + IProject project = IvyPlugin.adapt(element, IProject.class); if (project != null && project.isOpen() && IvyNatureHelper.hasNature(project)) { doCollectProject(containers, retrieveSetups, project); return true; @@ -216,14 +207,14 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements return false; } - private void doCollectProject(Map/* <IProject, Set<IvyClasspathContainer>> */containers, - Map/* <IProject, Set<StandaloneRetrieveSetup>> */retrieveSetups, IProject project) { - List ivycps = IvyClasspathContainerHelper.getContainers(project); - if (!ivycps.isEmpty()) { - containers.put(project, new HashSet(ivycps)); + private void doCollectProject(Map<IProject, Set<IvyClasspathContainer>> containers, + Map<IProject, Set<StandaloneRetrieveSetup>> retrieveSetups, IProject project) { + List<IvyClasspathContainer> containerList = IvyClasspathContainerHelper.getContainers(project); + if (!containerList.isEmpty()) { + containers.put(project, new HashSet<>(containerList)); } RetrieveSetupManager manager = IvyPlugin.getDefault().getRetrieveSetupManager(); - List setupList; + List<StandaloneRetrieveSetup> setupList; try { setupList = manager.getSetup(project); } catch (IOException e) { @@ -232,11 +223,11 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements return; } if (!setupList.isEmpty()) { - retrieveSetups.put(project, new HashSet(setupList)); + retrieveSetups.put(project, new HashSet<>(setupList)); } } - private boolean collectContainer(Map/* <IProject, Set<IvyClasspathContainer>> */containers, + private boolean collectContainer(Map<IProject, Set<IvyClasspathContainer>> containers, ClassPathContainer element) { IvyClasspathContainerImpl ivycp = IvyClasspathUtil.jdt2IvyCPC(element); if (ivycp == null) { @@ -246,25 +237,25 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements return true; } - private void doCollectContainer(Map/* <IProject, Set<IvyClasspathContainer>> */containers, + private void doCollectContainer(Map<IProject, Set<IvyClasspathContainer>> containers, IvyClasspathContainerImpl ivycp) { IJavaProject javaProject = ivycp.getConf().getJavaProject(); if (javaProject == null) { return; } - Set/* <IvyClasspathContainer> */cplist = (Set) containers.get(javaProject.getProject()); - if (cplist == null) { - cplist = new HashSet(); - containers.put(javaProject.getProject(), cplist); + Set<IvyClasspathContainer> containerSet = containers.get(javaProject.getProject()); + if (containerSet == null) { + containerSet = new HashSet<>(); + containers.put(javaProject.getProject(), containerSet); } - cplist.add(ivycp); + containerSet.add(ivycp); } private void addCleanableForSingleContainer(MenuManager menuManager, - List/* <IContributionItem> */items, Ivy ivy) { - List/* <Cleanable> */allCleanables = new ArrayList(); - List/* <Cleanable> */repositoryCleanables = new ArrayList(); - List/* <Cleanable> */resolutionCleanables = new ArrayList(); + List<MenuManager> items, Ivy ivy) { + List<Cleanable> allCleanables = new ArrayList<>(); + List<Cleanable> repositoryCleanables = new ArrayList<>(); + List<Cleanable> resolutionCleanables = new ArrayList<>(); addResolutionCleanable(allCleanables, ivy); addResolutionCleanable(resolutionCleanables, ivy); @@ -275,29 +266,21 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements addCleanable(menuManager, items, "Clean all caches", allCleanables); addCleanable(menuManager, items, "Clean the resolution cache", resolutionCleanables); addCleanable(menuManager, items, "Clean every repository cache", repositoryCleanables); - Iterator itCleanable = resolutionCleanables.iterator(); - while (itCleanable.hasNext()) { - Cleanable cleanable = (Cleanable) itCleanable.next(); + for (Cleanable cleanable : resolutionCleanables) { addCleanable(menuManager, items, "Clean the cache '" + cleanable.getName() + "'", - Collections.singletonList(cleanable)); + Collections.singletonList(cleanable)); } } private void addCleanableForManyContainers(MenuManager menuManager, - List/* <IContributionItem> */items, Collection/* - * <Set<IvyClasspathContainer >> - */containerSets) { - List/* <Cleanable> */allCleanables = new ArrayList(); - List/* <Cleanable> */repositoryCleanables = new ArrayList(); - List/* <Cleanable> */resolutionCleanables = new ArrayList(); - - Iterator itSet = containerSets.iterator(); - while (itSet.hasNext()) { - Set set = (Set) itSet.next(); - Iterator itContainer = set.iterator(); - while (itContainer.hasNext()) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainer.next(); - Ivy ivy = ivycp.getState().getCachedIvy(); + List<MenuManager> items, Collection<Set<IvyClasspathContainer>> containerSets) { + List<Cleanable> allCleanables = new ArrayList<>(); + List<Cleanable> repositoryCleanables = new ArrayList<>(); + List<Cleanable> resolutionCleanables = new ArrayList<>(); + + for (Set<IvyClasspathContainer> containerSet : containerSets) { + for (IvyClasspathContainer container : containerSet) { + Ivy ivy = ((IvyClasspathContainerImpl) container).getState().getCachedIvy(); if (ivy != null) { addResolutionCleanable(allCleanables, ivy); addResolutionCleanable(resolutionCleanables, ivy); @@ -312,20 +295,19 @@ public class IvyMenuContributionItem extends CompoundContributionItem implements addCleanable(menuManager, items, "Clean every repository cache", repositoryCleanables); } - private void addResolutionCleanable(List/* <Cleanable> */cleanables, Ivy ivy) { + private void addResolutionCleanable(List<Cleanable> cleanables, Ivy ivy) { ResolutionCacheManager manager = ivy.getSettings().getResolutionCacheManager(); cleanables.add(new ResolutionCacheCleanable(manager)); } - private void addRepositoryCleanable(List/* <Cleanable> */cleanables, Ivy ivy) { - RepositoryCacheManager[] managers = ivy.getSettings().getRepositoryCacheManagers(); - for (int i = 0; i < managers.length; i++) { - cleanables.add(new RepositoryCacheCleanable(managers[i])); + private void addRepositoryCleanable(List<Cleanable> cleanables, Ivy ivy) { + for (RepositoryCacheManager manager : ivy.getSettings().getRepositoryCacheManagers()) { + cleanables.add(new RepositoryCacheCleanable(manager)); } } - public void addCleanable(MenuManager menuManager, List/* <IContributionItem> */items, - String name, List/* <Cleanable> */cleanables) { + public void addCleanable(MenuManager menuManager, List<MenuManager> items, + String name, List<Cleanable> cleanables) { CleanCacheAction action = new CleanCacheAction(name, cleanables); action.setText(name); fillMenu(menuManager, items, new ActionContributionItem(action)); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java index f1ff591..372b095 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/menu/RetrieveAction.java @@ -41,7 +41,7 @@ public class RetrieveAction extends Action { public void run() { RetrieveSetup retrieveSetup = setup.getRetrieveSetup(); - List confs = IvyClasspathUtil.split(retrieveSetup.getRetrieveConfs()); + List<String> confs = IvyClasspathUtil.split(retrieveSetup.getRetrieveConfs()); IvyResolver resolver = new IvyResolver(setup.getIvyXmlPath(), confs, setup.getProject()); resolver.setRetrievePattern(retrieveSetup.getRetrievePattern()); resolver.setRetrieveSync(retrieveSetup.isRetrieveSync()); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java index 955bc7b..a8e9d99 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/IvyDEProjectPreferences.java @@ -18,7 +18,6 @@ package org.apache.ivyde.internal.eclipse.ui.preferences; import java.io.IOException; -import java.util.Iterator; import java.util.List; import org.apache.ivyde.internal.eclipse.IvyPlugin; @@ -69,7 +68,7 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout(2, false)); - final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class); + final IProject project = IvyPlugin.adapt(getElement(), IProject.class); Label label = new Label(composite, SWT.NONE); label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 0)); @@ -104,12 +103,13 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP newButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); newButton.setText("New..."); newButton.addSelectionListener(new SelectionAdapter() { + @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent e) { StandaloneRetrieveSetup setup = new StandaloneRetrieveSetup(); EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog( getShell(), project, setup); if (editDialog.open() == Window.OK) { - List list = ((List) table.getInput()); + List<Object> list = (List<Object>) table.getInput(); list.add(editDialog.getStandaloneRetrieveSetup()); table.refresh(); } @@ -129,12 +129,10 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP removeButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); removeButton.setText("Remove"); removeButton.addSelectionListener(new SelectionAdapter() { + @SuppressWarnings("unchecked") public void widgetSelected(SelectionEvent e) { - List list = ((List) table.getInput()); - Iterator it = ((IStructuredSelection) table.getSelection()).iterator(); - while (it.hasNext()) { - list.remove(it.next()); - } + List<Object> list = (List<Object>) table.getInput(); + list.removeAll(((IStructuredSelection) table.getSelection()).toList()); table.refresh(); } }); @@ -152,7 +150,7 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP } }); - List retrieveSetups; + List<StandaloneRetrieveSetup> retrieveSetups; try { retrieveSetups = retrieveSetupManager.getSetup(project); } catch (IOException e) { @@ -163,12 +161,13 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP return composite; } + @SuppressWarnings("unchecked") private void openEdit(IStructuredSelection selection, IProject project) { StandaloneRetrieveSetup setup = (StandaloneRetrieveSetup) selection.getFirstElement(); EditStandaloneRetrieveDialog editDialog = new EditStandaloneRetrieveDialog(getShell(), project, setup); if (editDialog.open() == Window.OK) { - List list = ((List) table.getInput()); + List<Object> list = (List<Object>) table.getInput(); list.set(list.indexOf(setup), editDialog.getStandaloneRetrieveSetup()); table.refresh(); } @@ -200,10 +199,11 @@ public class IvyDEProjectPreferences extends PropertyPage implements IWorkbenchP } + @SuppressWarnings("unchecked") public boolean performOk() { - final IProject project = (IProject) IvyPlugin.adapt(getElement(), IProject.class); + final IProject project = IvyPlugin.adapt(getElement(), IProject.class); - List/* <StandaloneRetrieveSetup> */retrieveSetups = (List) table.getInput(); + List<StandaloneRetrieveSetup> retrieveSetups = (List<StandaloneRetrieveSetup>) table.getInput(); try { retrieveSetupManager.save(project, retrieveSetups); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java index 62e81ba..aa5503d 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/preferences/PreferenceConstants.java @@ -131,14 +131,13 @@ public final class PreferenceConstants { public static final String ERROR_POPUP = "error.popup"; - public static final Set/*<String>*/ ALL = new HashSet(); + public static final Set<String> ALL = new HashSet<>(); static { - Field[] fields = PreferenceConstants.class.getFields(); - for (int i = 0; i < fields.length; i++) { - if (Modifier.isStatic(fields[i].getModifiers())) { + for (Field field : PreferenceConstants.class.getFields()) { + if (Modifier.isStatic(field.getModifiers())) { try { - ALL.add(fields[i].get(null)); + ALL.add((String) field.get(null)); } catch (IllegalArgumentException | IllegalAccessException e) { throw new RuntimeException(e); } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java index d255d14..c38b350 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReportView.java @@ -55,11 +55,11 @@ public class ReportView extends ViewPart implements ISelectionListener { public void selectionChanged(IWorkbenchPart part, ISelection sel) { if (sel instanceof IStructuredSelection) { - IvyClasspathContainer ivycp = IvyClasspathContainerHelper + IvyClasspathContainer container = IvyClasspathContainerHelper .getContainer((IStructuredSelection) sel); - if (ivycp != null) { + if (container != null) { browser.setText("<html></html>"); - URL report = ivycp.getReportUrl(); + URL report = container.getReportUrl(); if (report == null || !browser.setUrl(report.toExternalForm())) { browser.setText("<html></html>"); IvyDEMessage.warn("Impossible to set report view url to " + report.toExternalForm()); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java index 2c815e7..d992863 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/ui/views/ReverseDependencyExplorerView.java @@ -17,8 +17,8 @@ */ package org.apache.ivyde.internal.eclipse.ui.views; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.internal.eclipse.IvyPlugin; -import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; import org.apache.ivyde.internal.eclipse.handlers.OpenIvyFileHandler; import org.apache.ivyde.internal.eclipse.revdepexplorer.IvyUtil; import org.apache.ivyde.internal.eclipse.revdepexplorer.MultiRevDependencyDescriptor; @@ -156,8 +156,8 @@ public class ReverseDependencyExplorerView extends ViewPart { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object element = selection.getFirstElement(); if (element instanceof CPDependencyDescriptor) { - IvyClasspathContainerImpl cp = ((CPDependencyDescriptor) element).container; - OpenIvyFileHandler.open(cp); + IvyClasspathContainer container = ((CPDependencyDescriptor) element).container; + OpenIvyFileHandler.open(container); } } }); @@ -326,7 +326,7 @@ public class ReverseDependencyExplorerView extends ViewPart { public Object[] getChildren(Object parent) { if (parent instanceof MultiRevDependencyDescriptor) { MultiRevDependencyDescriptor mrdd = (MultiRevDependencyDescriptor) parent; - IvyClasspathContainerImpl[] containers = mrdd.getIvyClasspathContainers(); + IvyClasspathContainer[] containers = mrdd.getIvyClasspathContainers(); Object[] wrappedProjects = new Object[containers.length]; for (int i = 0; i < containers.length; i++) { @@ -357,11 +357,11 @@ public class ReverseDependencyExplorerView extends ViewPart { } class CPDependencyDescriptor { - private final IvyClasspathContainerImpl container; + private final IvyClasspathContainer container; private final MultiRevDependencyDescriptor multiRevisionDescriptor; - public CPDependencyDescriptor(IvyClasspathContainerImpl container, + public CPDependencyDescriptor(IvyClasspathContainer container, MultiRevDependencyDescriptor multiRevisionDescriptor) { this.container = container; this.multiRevisionDescriptor = multiRevisionDescriptor; @@ -374,7 +374,7 @@ public class ReverseDependencyExplorerView extends ViewPart { return multiRevisionDescriptor.getRevisions(container); } - public IvyClasspathContainerImpl getIvyClasspathContainer() { + public IvyClasspathContainer getIvyClasspathContainer() { return container; } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java index 1604e65..efc9415 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/IvyDEStrategy.java @@ -31,10 +31,10 @@ import org.apache.ivy.plugins.version.VersionMatcher; */ public class IvyDEStrategy extends ComparatorLatestStrategy { - final class MridComparator implements Comparator { - public int compare(Object o1, Object o2) { - String rev1 = ((ModuleRevisionId) o1).getRevision(); - String rev2 = ((ModuleRevisionId) o2).getRevision(); + final class MridComparator implements Comparator<ModuleRevisionId> { + public int compare(ModuleRevisionId o1, ModuleRevisionId o2) { + String rev1 = o1.getRevision(); + String rev2 = o2.getRevision(); boolean latestRev1 = rev1.startsWith("latest") || rev1.startsWith("working"); boolean latestRev2 = rev2.startsWith("latest") || rev2.startsWith("working"); @@ -89,10 +89,10 @@ public class IvyDEStrategy extends ComparatorLatestStrategy { * inspired by PHP version_compare one, unless a dynamic revision is given, in which case the * version matcher is used to perform the comparison. */ - final class ArtifactInfoComparator implements Comparator { - public int compare(Object o1, Object o2) { - String rev1 = ((ArtifactInfo) o1).getRevision(); - String rev2 = ((ArtifactInfo) o2).getRevision(); + final class ArtifactInfoComparator implements Comparator<ArtifactInfo> { + public int compare(ArtifactInfo o1, ArtifactInfo o2) { + String rev1 = o1.getRevision(); + String rev2 = o2.getRevision(); /* * The revisions can still be not resolved, so we use the current version matcher to @@ -117,9 +117,9 @@ public class IvyDEStrategy extends ComparatorLatestStrategy { } } - private final Comparator mridComparator = new MridComparator(); + private final Comparator<ModuleRevisionId> mridComparator = new MridComparator(); - private final Comparator artifactInfoComparator = new ArtifactInfoComparator(); + private final Comparator<ArtifactInfo> artifactInfoComparator = new ArtifactInfoComparator(); public IvyDEStrategy() { setComparator(artifactInfoComparator); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java index 1f89e3c..9ff8674 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResolver.java @@ -203,8 +203,7 @@ public class WorkspaceResolver extends AbstractResolver { continue; } for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(p)) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container; - ModuleDescriptor md = ivycp.getState().getCachedModuleDescriptor(); + ModuleDescriptor md = ((IvyClasspathContainerImpl) container).getState().getCachedModuleDescriptor(); if (md == null) { continue; } http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java index bf99d1a..bc0f910 100644 --- a/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java +++ b/org.apache.ivyde.eclipse/src/java/org/apache/ivyde/internal/eclipse/workspaceresolver/WorkspaceResourceChangeListener.java @@ -19,16 +19,14 @@ package org.apache.ivyde.internal.eclipse.workspaceresolver; import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import org.apache.ivyde.eclipse.IvyNatureHelper; +import org.apache.ivyde.eclipse.cp.IvyClasspathContainer; import org.apache.ivyde.eclipse.cp.IvyClasspathContainerHelper; import org.apache.ivyde.internal.eclipse.IvyPlugin; import org.apache.ivyde.internal.eclipse.cpcontainer.IvyClasspathContainerImpl; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceChangeEvent; @@ -92,7 +90,7 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener private void projectClosed(final IProject project) { // Check if one of Ivy projects is being removed - List containers = IvyClasspathContainerHelper.getContainers(project); + List<IvyClasspathContainer> containers = IvyClasspathContainerHelper.getContainers(project); if (containers.isEmpty()) { return; } @@ -100,12 +98,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener // Found an Ivy container in this project -- notify dependent projects // to perform fresh resolve - List affectedContainers = getAffectedContainers(project.getFullPath()); - - Iterator it = affectedContainers.iterator(); - while (it.hasNext()) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next(); - ivycp.launchResolve(false, null); + for (IvyClasspathContainer affectedContainer : getAffectedContainers(project.getFullPath())) { + affectedContainer.launchResolve(false, null); } } @@ -117,14 +111,12 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener return; } - final Collection projects = new LinkedHashSet(); - IResourceDelta[] projDeltas = delta.getAffectedChildren(IResourceDelta.CHANGED); - for (int i = 0; i < projDeltas.length; ++i) { - IResourceDelta projDelta = projDeltas[i]; - if ((projDelta.getFlags() & IResourceDelta.OPEN) == 0) { + final Collection<IResource> projects = new LinkedHashSet<>(); + for (IResourceDelta projectDelta : delta.getAffectedChildren(IResourceDelta.CHANGED)) { + if ((projectDelta.getFlags() & IResourceDelta.OPEN) == 0) { continue; } - IResource resource = projDeltas[i].getResource(); + IResource resource = projectDelta.getResource(); if (!(resource instanceof IProject)) { continue; } @@ -139,12 +131,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener // Let's try to be nice and use the workspace method to schedule resolves in // dependent projects after the open operation has finished. - List allContainers = getAllContainersExcludingProjects(projects); - - Iterator it = allContainers.iterator(); - while (it.hasNext()) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) it.next(); - ivycp.launchResolve(false, null); + for (IvyClasspathContainer container : getAllContainersExcludingProjects(projects)) { + container.launchResolve(false, null); } } @@ -154,8 +142,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener * @param projectPath IPath * @return List<IvyClasspathContainer> */ - private List getAffectedContainers(IPath projectPath) { - List/* <IvyClasspathContainer> */allContainers = new ArrayList(); + private List<IvyClasspathContainer> getAffectedContainers(IPath projectPath) { + List<IvyClasspathContainer> allContainers = new ArrayList<>(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IJavaProject[] projects; @@ -167,16 +155,10 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener return allContainers; } - for (int i = 0; i < projects.length; i++) { - IJavaProject javaProject = projects[i]; - List/* <IvyClasspathContainer> */containers = IvyClasspathContainerHelper - .getContainers(javaProject); - Iterator/* <IvyClasspathContainer> */itContainer = containers.iterator(); - while (itContainer.hasNext()) { - IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) itContainer.next(); - IClasspathEntry[] containerEntries = ivycp.getClasspathEntries(); - for (int j = 0; j < containerEntries.length; j++) { - IClasspathEntry containerEntry = containerEntries[j]; + for (IJavaProject javaProject : projects) { + for (IvyClasspathContainer container : IvyClasspathContainerHelper.getContainers(javaProject)) { + IvyClasspathContainerImpl ivycp = (IvyClasspathContainerImpl) container; + for (IClasspathEntry containerEntry : ivycp.getClasspathEntries()) { if (containerEntry == null || containerEntry.getEntryKind() != IClasspathEntry.CPE_PROJECT || !containerEntry.getPath().equals(projectPath)) { @@ -191,8 +173,8 @@ public class WorkspaceResourceChangeListener implements IResourceChangeListener return allContainers; } - private List getAllContainersExcludingProjects(Collection openedProjects) { - List/* <IvyClasspathContainer> */allContainers = new ArrayList(); + private List<IvyClasspathContainer> getAllContainersExcludingProjects(Collection<IResource> openedProjects) { + List<IvyClasspathContainer> allContainers = new ArrayList<>(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IJavaProject[] projects; http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java index 58d5a5d..6aaae12 100644 --- a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java +++ b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/ivyfile/IvyFileUpdaterTest.java @@ -20,16 +20,18 @@ package org.apache.ivyde.common.ivyfile; import java.io.File; import java.io.IOException; -import junit.framework.TestCase; - import org.apache.ivy.core.module.id.ModuleId; import org.apache.ivy.core.module.id.ModuleRevisionId; import org.apache.ivy.util.FileUtil; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; -public class IvyFileUpdaterTest extends TestCase { - private IvyFileUpdater updater = new IvyFileUpdater(); +public class IvyFileUpdaterTest { + private final IvyFileUpdater updater = new IvyFileUpdater(); - public void testAddDependency() throws Exception { + @Test + public void testAddDependency() throws IOException { testAddDependency("addDependency1"); testAddDependency("addDependency2"); testAddDependency("addDependency3"); @@ -50,8 +52,8 @@ public class IvyFileUpdaterTest extends TestCase { FileUtil.readEntirely(IvyFileUpdaterTest.class.getResourceAsStream(test + "/expected.xml")), FileUtil.readEntirely(dest)); } - - public void testRemoveDependency() throws Exception { + @Test + public void testRemoveDependency() throws IOException { testRemoveDependency("removeDependency1"); testRemoveDependency("removeDependency2"); testRemoveDependency("removeDependency3"); http://git-wip-us.apache.org/repos/asf/ant-ivyde/blob/f808b0b4/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java ---------------------------------------------------------------------- diff --git a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java index ab8446d..a0a6054 100644 --- a/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java +++ b/org.apache.ivyde.eclipse/test/java/org/apache/ivyde/common/model/IvyFileUtilTest.java @@ -17,25 +17,27 @@ */ package org.apache.ivyde.common.model; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; import java.util.Map; -import junit.framework.TestCase; - import org.apache.ivyde.common.ivyfile.IvyModuleDescriptorFile; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; -public class IvyFileUtilTest extends TestCase { - String hibContentStr; +public class IvyFileUtilTest { + private static String hibContentStr; - public IvyFileUtilTest(String name) { - super(name); - byte content[]; - try { - RandomAccessFile accessFile = new RandomAccessFile(getClass().getResource( - "/ivy-hibernate.xml").getFile(), "r"); - content = new byte[(int) accessFile.length()]; + @BeforeClass + public static void setUp() throws IOException { + try (RandomAccessFile accessFile = new RandomAccessFile(IvyFileUtilTest.class.getResource( + "/ivy-hibernate.xml").getFile(), "r")) { + byte[] content = new byte[(int) accessFile.length()]; accessFile.read(content); hibContentStr = new String(content); } catch (IOException e) { @@ -44,25 +46,28 @@ public class IvyFileUtilTest extends TestCase { } } + @Test public void testInTag() { IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", hibContentStr); - boolean b = ivyFile.inTag(200); + boolean b = ivyFile.inTag(1000); assertEquals(b, true); } + @Test public void testGetTagName() { IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", hibContentStr); - String tag = ivyFile.getTagName(200); + String tag = ivyFile.getTagName(1000); assertEquals("info", tag); - tag = ivyFile.getTagName(864); + tag = ivyFile.getTagName(1600); assertEquals("description", tag); // tag = IvyFileUtil.getTagName(1000); } + @Test public void testGetAllAttsValues() { String test = "<test att1=\"value1\" att2 =\"value 2 \" att3 =\" value3 \" att4 = \" 4 \""; IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", test); - Map all = ivyFile.getAllAttsValues(1); + Map<String, String> all = ivyFile.getAllAttsValues(1); assertNotNull(all); assertEquals(4, all.size()); assertEquals("value1", all.get("att1")); @@ -71,12 +76,13 @@ public class IvyFileUtilTest extends TestCase { assertEquals(" 4 ", all.get("att4")); } + @Test public void testGetAttributeName() { String test = "<test nospace=\"\" 1Space =\"\" 2Space = \"\" lotofSpace = \" \""; IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", test); String name = ivyFile.getAttributeName(15); assertEquals("nospace", name); - name = ivyFile.getAttributeName(28); + name = ivyFile.getAttributeName(26); assertEquals("1Space", name); name = ivyFile.getAttributeName(39); assertEquals("2Space", name); @@ -84,26 +90,33 @@ public class IvyFileUtilTest extends TestCase { assertEquals("lotofSpace", name); } + @Test public void testGetParentTagName() { IvyFile ivyFile = new IvyModuleDescriptorFile(null, "", hibContentStr); - String tag = ivyFile.getParentTagName(200); + String tag = ivyFile.getParentTagName(1000); assertEquals("ivy-module", tag); - tag = ivyFile.getParentTagName(2000); + tag = ivyFile.getParentTagName(2600); assertEquals("configurations", tag); - tag = ivyFile.getParentTagName(1981); + tag = ivyFile.getParentTagName(2493); assertEquals("configurations", tag); - tag = ivyFile.getParentTagName(1000); + tag = ivyFile.getParentTagName(1700); assertEquals("description", tag); - tag = ivyFile.getParentTagName(5015); + tag = ivyFile.getParentTagName(5585); assertNull(tag); } + @Test + @Ignore public void testReadyForValue() { } + @Test + @Ignore public void testGetStringIndex() { } + @Test + @Ignore public void testGetQualifier() { } }
