diff options
21 files changed, 205 insertions, 232 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/.classpath b/bundles/org.eclipse.equinox.p2.ui.discovery/.classpath index 64c5e31b7..eca7bdba8 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/.classpath +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/.classpath @@ -1,6 +1,6 @@ <?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/J2SE-1.5"/> + <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="output" path="bin"/> diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.ui.discovery/.settings/org.eclipse.jdt.core.prefs index 2a689a7f3..6b05c7a68 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/.settings/org.eclipse.jdt.core.prefs +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/.settings/org.eclipse.jdt.core.prefs @@ -10,13 +10,16 @@ org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -33,7 +36,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod= org.eclipse.jdt.core.compiler.problem.discouragedReference=warning org.eclipse.jdt.core.compiler.problem.emptyStatement=warning org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled org.eclipse.jdt.core.compiler.problem.fieldHiding=warning @@ -50,7 +53,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -59,7 +62,7 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore @@ -67,20 +70,22 @@ org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error org.eclipse.jdt.core.compiler.problem.nullReference=warning org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore -org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore -org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled @@ -95,6 +100,9 @@ org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore @@ -102,6 +110,7 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=error org.eclipse.jdt.core.compiler.problem.unusedLabel=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=warning @@ -114,7 +123,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning -org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui.discovery/META-INF/MANIFEST.MF index 56abd39d6..91f8059d5 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/META-INF/MANIFEST.MF @@ -2,10 +2,10 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.equinox.p2.ui.discovery;singleton:=true -Bundle-Version: 1.0.300.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-Localization: plugin -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, org.eclipse.equinox.p2.discovery;bundle-version="[1.0.0,1.2.0)", diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/pom.xml b/bundles/org.eclipse.equinox.p2.ui.discovery/pom.xml index 89dbb8489..4b9b1c81a 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/pom.xml +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/pom.xml @@ -9,6 +9,6 @@ </parent> <groupId>org.eclipse.equinox</groupId> <artifactId>org.eclipse.equinox.p2.ui.discovery</artifactId> - <version>1.0.300-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <packaging>eclipse-plugin</packaging> </project> diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowBundleCatalogCommandHandler.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowBundleCatalogCommandHandler.java index 570bf299b..be7bb7c76 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowBundleCatalogCommandHandler.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowBundleCatalogCommandHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -34,8 +34,9 @@ public class ShowBundleCatalogCommandHandler extends AbstractHandler { private static final String ID_PARAMETER_TAGS = "org.eclipse.equinox.p2.ui.discovery.commands.TagsParameter"; //$NON-NLS-1$ + @Override public Object execute(ExecutionEvent event) { - Set<Tag> tags = new LinkedHashSet<Tag>(); + Set<Tag> tags = new LinkedHashSet<>(); String tagString = event.getParameter(ID_PARAMETER_TAGS); if (tagString != null) { String[] tagIds = tagString.split("\\s*,\\s*"); //$NON-NLS-1$ @@ -66,7 +67,7 @@ public class ShowBundleCatalogCommandHandler extends AbstractHandler { catalog.setEnvironment(DiscoveryCore.createEnvironment()); catalog.setVerifyUpdateSiteAvailability(true); - catalog.setTags(new ArrayList<Tag>(tags)); + catalog.setTags(new ArrayList<>(tags)); CatalogConfiguration configuration = new CatalogConfiguration(); configuration.setShowTagFilter(tags.size() > 0); diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowRepositoryCatalogCommandHandler.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowRepositoryCatalogCommandHandler.java index f4789b49f..1a5f7da49 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowRepositoryCatalogCommandHandler.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/commands/ShowRepositoryCatalogCommandHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -31,6 +31,7 @@ public class ShowRepositoryCatalogCommandHandler extends AbstractHandler { private static final String ID_PARAMETER_REPOSITORY = "org.eclipse.equinox.p2.ui.discovery.commands.RepositoryParameter"; //$NON-NLS-1$ + @Override public Object execute(ExecutionEvent event) throws ExecutionException { String location = event.getParameter(ID_PARAMETER_REPOSITORY); if (location == null) { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java index 7959e5f70..340665579 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/operations/DiscoveryInstallOperation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -54,10 +54,11 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { if (installableConnectors == null || installableConnectors.isEmpty()) { throw new IllegalArgumentException(); } - this.installableConnectors = new ArrayList<CatalogItem>(installableConnectors); + this.installableConnectors = new ArrayList<>(installableConnectors); this.provisioningUI = ProvisioningUI.getDefaultUI(); } + @Override public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException { try { SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.InstallConnectorsJob_task_configuring, 150); @@ -74,17 +75,9 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { monitor.setTaskName(ProvUIMessages.ProvisioningOperationWizard_Remediation_Operation); final RemediationOperation remediationOperation = new RemediationOperation(provisioningUI.getSession(), installOperation.getProfileChangeRequest()); remediationOperation.resolveModal(monitor.newChild(50)); - Display.getDefault().asyncExec(new Runnable() { - public void run() { - provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, remediationOperation, null); - } - }); + Display.getDefault().asyncExec(() -> provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, remediationOperation, null)); } else { - Display.getDefault().asyncExec(new Runnable() { - public void run() { - provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, null); - } - }); + Display.getDefault().asyncExec(() -> provisioningUI.openInstallWizard(Arrays.asList(ius), installOperation, null)); } } finally { monitor.done(); @@ -158,7 +151,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { */ private void checkForUnavailable(final List<IInstallableUnit> installableUnits) throws CoreException { // at least one selected connector could not be found in a repository - Set<String> foundIds = new HashSet<String>(); + Set<String> foundIds = new HashSet<>(); for (IInstallableUnit unit : installableUnits) { foundIds.add(unit.getId()); } @@ -194,11 +187,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { // instead of aborting here we ask the user if they wish to proceed anyways final boolean[] okayToProceed = new boolean[1]; final String finalMessage = message; - Display.getDefault().syncExec(new Runnable() { - public void run() { - okayToProceed[0] = MessageDialog.openQuestion(WorkbenchUtil.getShell(), Messages.InstallConnectorsJob_questionProceed, NLS.bind(Messages.InstallConnectorsJob_questionProceed_long, new Object[] {finalMessage})); - } - }); + Display.getDefault().syncExec(() -> okayToProceed[0] = MessageDialog.openQuestion(WorkbenchUtil.getShell(), Messages.InstallConnectorsJob_questionProceed, NLS.bind(Messages.InstallConnectorsJob_questionProceed_long, new Object[] {finalMessage}))); if (!okayToProceed[0]) { throw new CoreException(new Status(IStatus.ERROR, DiscoveryUi.ID_PLUGIN, NLS.bind(Messages.InstallConnectorsJob_connectorsNotAvailable, detailedMessage), null)); } @@ -211,7 +200,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { * highest version. */ private void removeOldVersions(final List<IInstallableUnit> installableUnits) { - Map<String, Version> symbolicNameToVersion = new HashMap<String, Version>(); + Map<String, Version> symbolicNameToVersion = new HashMap<>(); for (IInstallableUnit unit : installableUnits) { Version version = symbolicNameToVersion.get(unit.getId()); if (version == null || version.compareTo(unit.getVersion()) < 0) { @@ -219,7 +208,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { } } if (symbolicNameToVersion.size() != installableUnits.size()) { - for (IInstallableUnit unit : new ArrayList<IInstallableUnit>(installableUnits)) { + for (IInstallableUnit unit : new ArrayList<>(installableUnits)) { Version version = symbolicNameToVersion.get(unit.getId()); if (!version.equals(unit.getVersion())) { installableUnits.remove(unit); @@ -235,7 +224,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { * ensure that the user gets the one that they asked for. */ private List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories) throws URISyntaxException { - final List<IInstallableUnit> installableUnits = new ArrayList<IInstallableUnit>(); + final List<IInstallableUnit> installableUnits = new ArrayList<>(); monitor.setWorkRemaining(repositories.size()); for (final IMetadataRepository repository : repositories) { @@ -260,7 +249,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { // tell p2 that it's okay to use these repositories ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession(); RepositoryTracker repositoryTracker = ProvisioningUI.getDefaultUI().getRepositoryTracker(); - repositoryLocations = new HashSet<URI>(); + repositoryLocations = new HashSet<>(); monitor.setWorkRemaining(installableConnectors.size() * 5); for (CatalogItem descriptor : installableConnectors) { URI uri = new URL(descriptor.getSiteUrl()).toURI(); @@ -275,7 +264,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { } // fetch meta-data for these repositories - ArrayList<IMetadataRepository> repositories = new ArrayList<IMetadataRepository>(); + ArrayList<IMetadataRepository> repositories = new ArrayList<>(); monitor.setWorkRemaining(repositories.size()); IMetadataRepositoryManager manager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); for (URI uri : repositoryLocations) { @@ -287,7 +276,7 @@ public class DiscoveryInstallOperation implements IRunnableWithProgress { } private Set<String> getDescriptorIds(final IMetadataRepository repository) throws URISyntaxException { - final Set<String> installableUnitIdsThisRepository = new HashSet<String>(); + final Set<String> installableUnitIdsThisRepository = new HashSet<>(); // determine all installable units for this repository for (CatalogItem descriptor : installableConnectors) { try { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java index 621f61d86..ae437f8d2 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/repository/RepositoryDiscoveryStrategy.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Tasktop Technologies and others. + * Copyright (c) 2010, 2017 Tasktop Technologies 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 @@ -48,10 +48,10 @@ public class RepositoryDiscoveryStrategy extends AbstractDiscoveryStrategy { private final Map<String, CatalogItem> catalogItemById; public RepositoryDiscoveryStrategy() { - this.locations = new ArrayList<URI>(); - this.sourceByRepository = new HashMap<IMetadataRepository, RepositorySource>(); - this.categoryById = new HashMap<String, CatalogCategory>(); - this.catalogItemById = new HashMap<String, CatalogItem>(); + this.locations = new ArrayList<>(); + this.sourceByRepository = new HashMap<>(); + this.categoryById = new HashMap<>(); + this.catalogItemById = new HashMap<>(); } public void addLocation(URI location) { @@ -106,7 +106,7 @@ public class RepositoryDiscoveryStrategy extends AbstractDiscoveryStrategy { } // fetch meta-data for these repositories - ArrayList<IMetadataRepository> repositories = new ArrayList<IMetadataRepository>(); + ArrayList<IMetadataRepository> repositories = new ArrayList<>(); IMetadataRepositoryManager manager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); for (URI uri : locations) { IMetadataRepository repository = manager.loadRepository(uri, monitor.newChild(1)); diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java index 646be5624..9c1040218 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 @@ -125,11 +125,9 @@ public abstract class ControlListItem<T> extends Composite { @Override public void mouseExit(MouseEvent e) { enterCount--; - getDisplay().asyncExec(new Runnable() { - public void run() { - if (!isDisposed()) { - updateHotState(); - } + getDisplay().asyncExec(() -> { + if (!isDisposed()) { + updateHotState(); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java index c68ac0ede..d794a6d35 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/ControlListViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2017 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 @@ -79,10 +79,12 @@ public abstract class ControlListViewer extends StructuredViewer { control.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); control.setBackgroundMode(SWT.INHERIT_FORCE); control.addControlListener(new ControlListener() { + @Override public void controlMoved(ControlEvent e) { updateVisibleItems(); } + @Override public void controlResized(ControlEvent e) { updateVisibleItems(); } @@ -105,6 +107,7 @@ public abstract class ControlListViewer extends StructuredViewer { control.addTraverseListener(new TraverseListener() { private boolean handleEvent = true; + @Override public void keyTraversed(TraverseEvent event) { if (!handleEvent) { return; @@ -178,7 +181,7 @@ public abstract class ControlListViewer extends StructuredViewer { ViewerComparator sorter = getComparator(); // Use a Set in case we are getting something added that exists - Set<Object> newItems = new HashSet<Object>(elements.length); + Set<Object> newItems = new HashSet<>(elements.length); Control[] existingChildren = control.getChildren(); for (Control element : existingChildren) { @@ -253,6 +256,7 @@ public abstract class ControlListViewer extends StructuredViewer { // } // }); item.setIndexListener(new ControlListItem.IndexListener() { + @Override public void selectNext() { Control[] children = control.getChildren(); for (int i = 0; i < children.length; i++) { @@ -265,6 +269,7 @@ public abstract class ControlListViewer extends StructuredViewer { } } + @Override public void selectPrevious() { Control[] children = control.getChildren(); for (int i = 0; i < children.length; i++) { @@ -277,11 +282,13 @@ public abstract class ControlListViewer extends StructuredViewer { } } + @Override public void select() { setSelection(new StructuredSelection(item.getData())); setFocus(); } + @Override public void open() { handleOpen(); } @@ -330,7 +337,7 @@ public abstract class ControlListViewer extends StructuredViewer { @Override protected List<?> getSelectionFromWidget() { Control[] children = control.getChildren(); - ArrayList<Object> selection = new ArrayList<Object>(children.length); + ArrayList<Object> selection = new ArrayList<>(children.length); for (Control child : children) { ControlListItem<?> item = (ControlListItem<?>) child; if (item.isSelected() && item.getData() != null) { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java index 330fbe53e..790ffa9f0 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/FilteredViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2011 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -21,7 +21,8 @@ import org.eclipse.jface.layout.GridLayoutFactory; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; import org.eclipse.ui.progress.WorkbenchJob; @@ -67,11 +68,9 @@ public abstract class FilteredViewer { public void createControl(Composite parent) { container = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().margins(0, 0).applyTo(container); - container.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (refreshJob != null) { - refreshJob.cancel(); - } + container.addDisposeListener(e -> { + if (refreshJob != null) { + refreshJob.cancel(); } }); @@ -99,18 +98,12 @@ public abstract class FilteredViewer { filterText = new TextSearchControl(parent, automaticFind); if (automaticFind) { - filterText.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - filterTextChanged(); - } - }); + filterText.addModifyListener(e -> filterTextChanged()); } else { - filterText.getTextControl().addTraverseListener(new TraverseListener() { - public void keyTraversed(TraverseEvent e) { - if (e.detail == SWT.TRAVERSE_RETURN) { - e.doit = false; - filterTextChanged(); - } + filterText.getTextControl().addTraverseListener(e -> { + if (e.detail == SWT.TRAVERSE_RETURN) { + e.doit = false; + filterTextChanged(); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientCanvas.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientCanvas.java index 2f47eb2b2..9e345c18c 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientCanvas.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/GradientCanvas.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2017 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 @@ -15,7 +15,8 @@ import java.util.Hashtable; import java.util.Map; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; /** * Based on org.eclipse.ui.internal.forms.widgets.FormHeading. @@ -45,7 +46,7 @@ public class GradientCanvas extends Canvas { private Image gradientImage; - Map<String, Color> colors = new Hashtable<String, Color>(); + Map<String, Color> colors = new Hashtable<>(); private int flags; @@ -74,25 +75,17 @@ public class GradientCanvas extends Canvas { super(parent, style); setBackgroundMode(SWT.INHERIT_DEFAULT); setSeparatorAlignment(SWT.BOTTOM); - addListener(SWT.Paint, new Listener() { - public void handleEvent(Event e) { - onPaint(e.gc); - } - }); - addListener(SWT.Dispose, new Listener() { - public void handleEvent(Event e) { - if (gradientImage != null) { - // TODO e3.4 FormImages.getInstance().markFinished(gradientImage); - gradientImage.dispose(); - gradientImage = null; - } + addListener(SWT.Paint, e -> onPaint(e.gc)); + addListener(SWT.Dispose, e -> { + if (gradientImage != null) { + // TODO e3.4 FormImages.getInstance().markFinished(gradientImage); + gradientImage.dispose(); + gradientImage = null; } }); - addListener(SWT.Resize, new Listener() { - public void handleEvent(Event e) { - if (gradientInfo != null || (backgroundImage != null && !isBackgroundImageTiled())) { - updateGradientImage(); - } + addListener(SWT.Resize, e -> { + if (gradientInfo != null || (backgroundImage != null && !isBackgroundImageTiled())) { + updateGradientImage(); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java index ad75e8203..256a69d34 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2017 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 @@ -29,12 +29,12 @@ public class PatternFilter extends ViewerFilter { /* * Cache of filtered elements in the tree */ - private final Map<Object, Object> cache = new HashMap<Object, Object>(); + private final Map<Object, Object> cache = new HashMap<>(); /* * Maps parent elements to TRUE or FALSE */ - private final Map<Object, Boolean> foundAnyCache = new HashMap<Object, Boolean>(); + private final Map<Object, Boolean> foundAnyCache = new HashMap<>(); private boolean useCache = false; @@ -274,7 +274,7 @@ public class PatternFilter extends ViewerFilter { * @return an array of words */ private String[] getWords(String text) { - List<String> words = new ArrayList<String>(); + List<String> words = new ArrayList<>(); // Break the text up into words, separating based on whitespace and // common punctuation. // Previously used String.split(..., "\\W"), where "\W" is a regular diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java index 65355cc2d..50b2bb3c1 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -43,24 +43,29 @@ public class SelectionProviderAdapter extends EventManager implements ISelection public SelectionProviderAdapter() { } + @Override public void addSelectionChangedListener(ISelectionChangedListener listener) { addListenerObject(listener); } + @Override public ISelection getSelection() { return selection; } + @Override public void removeSelectionChangedListener(ISelectionChangedListener listener) { removeListenerObject(listener); } + @Override public void selectionChanged(final SelectionChangedEvent event) { this.selection = event.getSelection(); Object[] listeners = getListeners(); for (int i = 0; i < listeners.length; ++i) { final ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i]; SafeRunner.run(new SafeRunnable() { + @Override public void run() { listener.selectionChanged(event); } @@ -68,6 +73,7 @@ public class SelectionProviderAdapter extends EventManager implements ISelection } } + @Override public void setSelection(ISelection selection) { selectionChanged(new SelectionChangedEvent(this, selection)); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java index 5f545f7db..efd8c88a3 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/TextSearchControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 Tasktop Technologies and others. + * Copyright (c) 2010, 2017 Tasktop Technologies 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 @@ -81,9 +81,9 @@ public class TextSearchControl extends Composite { private final boolean automaticFind; - private final Set<SelectionListener> selectionListeners = new HashSet<SelectionListener>(); + private final Set<SelectionListener> selectionListeners = new HashSet<>(); - private Collection<String> searchHistory = new LinkedHashSet<String>(); + private Collection<String> searchHistory = new LinkedHashSet<>(); private boolean hasHistorySupport; @@ -120,13 +120,7 @@ public class TextSearchControl extends Composite { findControl = createLabelButtonControl(this, textControl, JFaceResources.getImageRegistry().getDescriptor(FIND_ICON), "Find", "Find", ICON_SEARCH); clearControl = createLabelButtonControl(this, textControl, JFaceResources.getImageRegistry().getDescriptor(CLEAR_ICON), WorkbenchMessages.FilteredTree_ClearToolTip, //FilteredTree_AccessibleListenerClearButton, WorkbenchMessages.FilteredTree_ClearToolTip, ICON_CANCEL); - addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent e) { - updateButtonVisibilityAndEnablement(); - - } - }); + addModifyListener(e -> updateButtonVisibilityAndEnablement()); updateButtonVisibilityAndEnablement(); } @@ -204,17 +198,15 @@ public class TextSearchControl extends Composite { labelButton.setImage(inactiveImage); labelButton.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); labelButton.setToolTipText(toolTipText); - labelButton.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - if (nativeImage == null && activeImage != null && !activeImage.isDisposed()) { - activeImage.dispose(); - } - if (inactiveImage != null && !inactiveImage.isDisposed()) { - inactiveImage.dispose(); - } - if (pressedImage != null && !pressedImage.isDisposed()) { - pressedImage.dispose(); - } + labelButton.addDisposeListener(e -> { + if (nativeImage == null && activeImage != null && !activeImage.isDisposed()) { + activeImage.dispose(); + } + if (inactiveImage != null && !inactiveImage.isDisposed()) { + inactiveImage.dispose(); + } + if (pressedImage != null && !pressedImage.isDisposed()) { + pressedImage.dispose(); } }); labelButton.addMouseListener(new MouseAdapter() { @@ -226,6 +218,7 @@ public class TextSearchControl extends Composite { fMoveListener = new MouseMoveListener() { private boolean fMouseInButton = true; + @Override public void mouseMove(MouseEvent e) { boolean mouseInButton = isMouseInButton(e); if (mouseInButton != fMouseInButton) { @@ -258,21 +251,21 @@ public class TextSearchControl extends Composite { } }); - labelButton.addMouseTrackListener(new MouseTrackListener() { + labelButton.addMouseTrackListener(new MouseTrackAdapter() { + @Override public void mouseEnter(MouseEvent e) { if (labelButton.getImage() != activeImage) { labelButton.setImage(activeImage); } } + @Override public void mouseExit(MouseEvent e) { if (labelButton.getImage() != inactiveImage) { labelButton.setImage(inactiveImage); } } - public void mouseHover(MouseEvent e) { - } }); labelButton.getAccessible().addAccessibleListener(new AccessibleAdapter() { @@ -396,7 +389,7 @@ public class TextSearchControl extends Composite { if (memento == null) { return; } - List<String> history = new ArrayList<String>(); + List<String> history = new ArrayList<>(); IMemento rootMemento = memento.getChild(FIND_MEMENTO_TYPE); if (rootMemento != null) { diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/AbstractDiscoveryItem.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/AbstractDiscoveryItem.java index 3237d0c69..b661de244 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/AbstractDiscoveryItem.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/AbstractDiscoveryItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Tasktop Technologies and others. + * Copyright (c) 2010, 2017 Tasktop Technologies 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 @@ -46,52 +46,44 @@ public abstract class AbstractDiscoveryItem<T> extends ControlListItem<T> { protected void hookTooltip(final Control parent, final Widget tipActivator, final Control exitControl, final Control titleControl, AbstractCatalogSource source, Overview overview, Image image) { final OverviewToolTip toolTip = new OverviewToolTip(parent, source, overview, image); - Listener listener = new Listener() { - public void handleEvent(Event event) { - switch (event.type) { - case SWT.MouseHover : - toolTip.show(titleControl); - break; - case SWT.Dispose : - case SWT.MouseWheel : - toolTip.hide(); - break; - } - + Listener listener = event -> { + switch (event.type) { + case SWT.MouseHover : + toolTip.show(titleControl); + break; + case SWT.Dispose : + case SWT.MouseWheel : + toolTip.hide(); + break; } + }; tipActivator.addListener(SWT.Dispose, listener); tipActivator.addListener(SWT.MouseWheel, listener); if (image != null) { tipActivator.addListener(SWT.MouseHover, listener); } - Listener selectionListener = new Listener() { - public void handleEvent(Event event) { - toolTip.show(titleControl); - } - }; + Listener selectionListener = event -> toolTip.show(titleControl); tipActivator.addListener(SWT.Selection, selectionListener); - Listener exitListener = new Listener() { - public void handleEvent(Event event) { - switch (event.type) { - case SWT.MouseWheel : - toolTip.hide(); - break; - case SWT.MouseExit : - /* - * Check if the mouse exit happened because we move over the - * tooltip - */ - Rectangle containerBounds = exitControl.getBounds(); - Point displayLocation = exitControl.getParent().toDisplay(containerBounds.x, containerBounds.y); - containerBounds.x = displayLocation.x; - containerBounds.y = displayLocation.y; - if (containerBounds.contains(Display.getCurrent().getCursorLocation())) { - break; - } - toolTip.hide(); + Listener exitListener = event -> { + switch (event.type) { + case SWT.MouseWheel : + toolTip.hide(); + break; + case SWT.MouseExit : + /* + * Check if the mouse exit happened because we move over the + * tooltip + */ + Rectangle containerBounds = exitControl.getBounds(); + Point displayLocation = exitControl.getParent().toDisplay(containerBounds.x, containerBounds.y); + containerBounds.x = displayLocation.x; + containerBounds.y = displayLocation.y; + if (containerBounds.contains(Display.getCurrent().getCursorLocation())) { break; - } + } + toolTip.hide(); + break; } }; hookRecursively(exitControl, exitListener); diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogConfiguration.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogConfiguration.java index 33ea6e884..e0060eefd 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogConfiguration.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogConfiguration.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Tasktop Technologies and others. + * Copyright (c) 2010, 2017 Tasktop Technologies 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 @@ -21,7 +21,7 @@ import org.eclipse.equinox.internal.p2.discovery.model.Tag; */ public class CatalogConfiguration { - private final List<CatalogFilter> filters = new ArrayList<CatalogFilter>(); + private final List<CatalogFilter> filters = new ArrayList<>(); private boolean showCategories = true; @@ -101,7 +101,7 @@ public class CatalogConfiguration { public void setSelectedTags(Collection<Tag> selectedTags) { if (selectedTags != null) { - this.selectedTags = new HashSet<Tag>(selectedTags); + this.selectedTags = new HashSet<>(selectedTags); } else { this.selectedTags = null; } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogPage.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogPage.java index c546f0d56..30380c41d 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogPage.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -16,8 +16,6 @@ package org.eclipse.equinox.internal.p2.ui.discovery.wizards; import java.util.List; import org.eclipse.equinox.internal.p2.discovery.Catalog; import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.window.IShellProvider; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.widgets.Composite; @@ -48,13 +46,10 @@ public class CatalogPage extends WizardPage implements IShellProvider { setDescription(Messages.ConnectorDiscoveryWizardMainPage_pageDescription); } + @Override public void createControl(Composite parent) { viewer = doCreateViewer(parent); - viewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - setPageComplete(!viewer.getCheckedItems().isEmpty()); - } - }); + viewer.addSelectionChangedListener(event -> setPageComplete(!viewer.getCheckedItems().isEmpty())); setControl(viewer.getControl()); } @@ -72,11 +67,9 @@ public class CatalogPage extends WizardPage implements IShellProvider { protected void doUpdateCatalog() { if (!updated) { updated = true; - Display.getCurrent().asyncExec(new Runnable() { - public void run() { - if (!getControl().isDisposed() && isCurrentPage()) { - viewer.updateCatalog(); - } + Display.getCurrent().asyncExec(() -> { + if (!getControl().isDisposed() && isCurrentPage()) { + viewer.updateCatalog(); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java index b9ad40662..01ecd0696 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/CatalogViewer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -30,12 +30,12 @@ import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableContext; -import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.viewers.*; import org.eclipse.jface.window.IShellProvider; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.*; import org.eclipse.ui.statushandlers.StatusManager; @@ -61,6 +61,7 @@ public class CatalogViewer extends FilteredViewer { this.hasCategories = hasCategories; } + @Override public void dispose() { catalog = null; } @@ -69,6 +70,7 @@ public class CatalogViewer extends FilteredViewer { return catalog; } + @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof CatalogCategory) { return ((CatalogCategory) parentElement).getItems().toArray(); @@ -76,9 +78,10 @@ public class CatalogViewer extends FilteredViewer { return null; } + @Override public Object[] getElements(Object inputElement) { if (catalog != null) { - List<Object> elements = new ArrayList<Object>(); + List<Object> elements = new ArrayList<>(); if (hasCategories()) { elements.addAll(catalog.getCategories()); } @@ -88,6 +91,7 @@ public class CatalogViewer extends FilteredViewer { return new Object[0]; } + @Override public Object getParent(Object element) { if (element instanceof CatalogCategory) { return catalog; @@ -98,6 +102,7 @@ public class CatalogViewer extends FilteredViewer { return null; } + @Override public boolean hasChildren(Object element) { if (element instanceof CatalogCategory) { return ((CatalogCategory) element).getItems().size() > 0; @@ -105,6 +110,7 @@ public class CatalogViewer extends FilteredViewer { return false; } + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { this.catalog = (Catalog) newInput; } @@ -182,7 +188,7 @@ public class CatalogViewer extends FilteredViewer { final Catalog catalog; - private final List<CatalogItem> checkedItems = new ArrayList<CatalogItem>(); + private final List<CatalogItem> checkedItems = new ArrayList<>(); private boolean complete; @@ -223,9 +229,9 @@ public class CatalogViewer extends FilteredViewer { this.showInstalled = configuration.isShowInstalled(); this.showCategories = configuration.isShowCategories(); if (configuration.getSelectedTags() != null) { - this.visibleTags = new HashSet<Tag>(configuration.getSelectedTags()); + this.visibleTags = new HashSet<>(configuration.getSelectedTags()); } else { - this.visibleTags = new HashSet<Tag>(); + this.visibleTags = new HashSet<>(); } setMinimumHeight(DEFAULT_HEIGHT); setComplete(false); @@ -284,10 +290,12 @@ public class CatalogViewer extends FilteredViewer { showInstalledCheckbox.setText(Messages.DiscoveryViewer_Show_Installed); showInstalledCheckbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } + @Override public void widgetSelected(SelectionEvent e) { if (ignoreUpdates) { return; @@ -305,10 +313,12 @@ public class CatalogViewer extends FilteredViewer { checkbox.setSelection(visibleTags.contains(tag)); checkbox.setText(tag.getLabel()); checkbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } + @Override public void widgetSelected(SelectionEvent e) { boolean selection = checkbox.getSelection(); if (selection) { @@ -388,12 +398,10 @@ public class CatalogViewer extends FilteredViewer { }); resources = new DiscoveryResources(container.getDisplay()); - _viewer.getControl().addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - resources.dispose(); - if (catalog != null) - catalog.dispose(); - } + _viewer.getControl().addDisposeListener(e -> { + resources.dispose(); + if (catalog != null) + catalog.dispose(); }); _viewer.addFilter(new Filter()); return _viewer; @@ -436,7 +444,7 @@ public class CatalogViewer extends FilteredViewer { } public List<CatalogItem> getCheckedItems() { - return new ArrayList<CatalogItem>(checkedItems); + return new ArrayList<>(checkedItems); } public CatalogConfiguration getConfiguration() { @@ -444,7 +452,7 @@ public class CatalogViewer extends FilteredViewer { } protected Set<String> getInstalledFeatures(IProgressMonitor monitor) { - Set<String> features = new HashSet<String>(); + Set<String> features = new HashSet<>(); IProfile profile = ProvUI.getProfileRegistry(ProvisioningUI.getDefaultUI().getSession()).getProfile(ProvisioningUI.getDefaultUI().getProfileId()); if (profile != null) { IQueryResult<IInstallableUnit> result = profile.available(QueryUtil.createIUGroupQuery(), monitor); @@ -529,7 +537,7 @@ public class CatalogViewer extends FilteredViewer { } public void setSelection(IStructuredSelection selection) { - Set<CatalogItem> selected = new HashSet<CatalogItem>(); + Set<CatalogItem> selected = new HashSet<>(); for (Object descriptor : selection.toArray()) { if (descriptor instanceof CatalogItem) { selected.add((CatalogItem) descriptor); @@ -560,19 +568,17 @@ public class CatalogViewer extends FilteredViewer { boolean wasError = false; try { final IStatus[] result = new IStatus[1]; - context.run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) throws InterruptedException { - if (installedFeatures == null) { - installedFeatures = getInstalledFeatures(monitor); - } - - result[0] = catalog.performDiscovery(monitor); - if (monitor.isCanceled()) { - throw new InterruptedException(); - } + context.run(true, true, monitor -> { + if (installedFeatures == null) { + installedFeatures = getInstalledFeatures(monitor); + } - postDiscovery(); + result[0] = catalog.performDiscovery(monitor); + if (monitor.isCanceled()) { + throw new InterruptedException(); } + + postDiscovery(); }); if (result[0] != null && !result[0].isOK()) { @@ -598,11 +604,9 @@ public class CatalogViewer extends FilteredViewer { protected void verifyUpdateSiteAvailability() { if (configuration.isVerifyUpdateSiteAvailability() && !catalog.getItems().isEmpty()) { try { - context.run(true, true, new IRunnableWithProgress() { - public void run(IProgressMonitor monitor) { - SiteVerifier verifier = new SiteVerifier(catalog); - verifier.verifySiteAvailability(monitor); - } + context.run(true, true, monitor -> { + SiteVerifier verifier = new SiteVerifier(catalog); + verifier.verifySiteAvailability(monitor); }); } catch (InvocationTargetException e) { IStatus status = computeStatus(e, Messages.ConnectorDiscoveryWizardMainPage_unexpectedException); diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java index e0d3b3fa6..d2ef6a726 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/DiscoveryItem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Tasktop Technologies and others. + * Copyright (c) 2010, 2017 Tasktop Technologies 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 @@ -60,11 +60,7 @@ public class DiscoveryItem<T extends CatalogItem> extends AbstractDiscoveryItem< this.item = item; this.viewer = viewer; item.addPropertyChangeListener(this); - this.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - item.removePropertyChangeListener(DiscoveryItem.this); - } - }); + this.addDisposeListener(e -> item.removePropertyChangeListener(DiscoveryItem.this)); createContent(); initializeListeners(); } @@ -170,10 +166,12 @@ public class DiscoveryItem<T extends CatalogItem> extends AbstractDiscoveryItem< public void initializeListeners() { checkbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } + @Override public void widgetSelected(SelectionEvent e) { boolean selected = checkbox.getSelection(); maybeModifySelection(selected); @@ -212,13 +210,12 @@ public class DiscoveryItem<T extends CatalogItem> extends AbstractDiscoveryItem< return true; } + @Override public void propertyChange(PropertyChangeEvent evt) { if (!isDisposed()) { - getDisplay().asyncExec(new Runnable() { - public void run() { - if (!isDisposed()) { - refresh(); - } + getDisplay().asyncExec(() -> { + if (!isDisposed()) { + refresh(); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/OverviewToolTip.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/OverviewToolTip.java index 4d6b20669..e40e39348 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/OverviewToolTip.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/wizards/OverviewToolTip.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Tasktop Technologies and others. + * Copyright (c) 2009, 2017 Tasktop Technologies 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 @@ -24,7 +24,8 @@ import org.eclipse.jface.window.ToolTip; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.*; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.*; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.*; @@ -66,11 +67,7 @@ class OverviewToolTip extends GradientToolTip { image = computeImage(source, overview.getScreenshot()); if (image != null) { final Image fimage = image; - container.addDisposeListener(new DisposeListener() { - public void widgetDisposed(DisposeEvent e) { - fimage.dispose(); - } - }); + container.addDisposeListener(e -> fimage.dispose()); } } final boolean hasLearnMoreLink = overview.getUrl() != null && overview.getUrl().length() > 0; @@ -141,10 +138,12 @@ class OverviewToolTip extends GradientToolTip { link.setBackground(null); link.setToolTipText(NLS.bind(Messages.ConnectorDescriptorToolTip_detailsLink_tooltip, overview.getUrl())); link.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { WorkbenchUtil.openUrl(overview.getUrl(), IWorkbenchBrowserSupport.AS_EXTERNAL); } + @Override public void widgetDefaultSelected(SelectionEvent e) { widgetSelected(e); } @@ -160,11 +159,9 @@ class OverviewToolTip extends GradientToolTip { } // hack: cause the tooltip to gain focus so that we can capture the escape key // this must be done async since the tooltip is not yet visible. - Display.getCurrent().asyncExec(new Runnable() { - public void run() { - if (!parent.isDisposed()) { - parent.setFocus(); - } + Display.getCurrent().asyncExec(() -> { + if (!parent.isDisposed()) { + parent.setFocus(); } }); return container; |