diff options
Diffstat (limited to 'org.eclipse.m2e.discovery')
7 files changed, 77 insertions, 268 deletions
diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java index 292bb3d4..0d9f8fa3 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/MavenDiscoveryService.java @@ -11,16 +11,11 @@ package org.eclipse.m2e.internal.discovery; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.net.URI; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.plugin.MojoExecution; @@ -28,37 +23,21 @@ import org.apache.maven.project.MavenProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubMonitor; -import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.discovery.Catalog; import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem; -import org.eclipse.equinox.internal.p2.ui.ProvUI; -import org.eclipse.equinox.internal.p2.ui.ProvUIActivator; -import org.eclipse.equinox.internal.p2.ui.ProvUIImages; -import org.eclipse.equinox.internal.p2.ui.ProvUIMessages; -import org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement; -import org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot; -import org.eclipse.equinox.internal.provisional.configurator.Configurator; +import org.eclipse.equinox.internal.p2.ui.discovery.wizards.Messages; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.engine.IProfileRegistry; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.metadata.IVersionedId; -import org.eclipse.equinox.p2.metadata.VersionedId; -import org.eclipse.equinox.p2.operations.ProvisioningJob; -import org.eclipse.equinox.p2.operations.RepositoryTracker; import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.query.QueryUtil; -import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; -import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.window.Window; import org.eclipse.m2e.core.MavenPlugin; import org.eclipse.m2e.core.embedder.IMaven; import org.eclipse.m2e.core.internal.lifecyclemapping.LifecycleMappingFactory; @@ -76,11 +55,8 @@ import org.eclipse.m2e.core.internal.lifecyclemapping.model.PluginExecutionMetad import org.eclipse.m2e.core.project.configurator.MojoExecutionKey; import org.eclipse.m2e.core.ui.internal.wizards.IImportWizardPageFactory; import org.eclipse.m2e.internal.discovery.operation.MavenDiscoveryInstallOperation; -import org.eclipse.m2e.internal.discovery.operation.RestartInstallOperation; -import org.eclipse.m2e.internal.discovery.wizards.DiscoverySelectableIUsPage; +import org.eclipse.m2e.internal.discovery.wizards.MavenDiscoveryUi; import org.eclipse.osgi.util.NLS; -import org.eclipse.ui.progress.IProgressConstants; -import org.eclipse.ui.progress.IProgressConstants2; import org.eclipse.ui.statushandlers.StatusManager; import org.osgi.framework.Bundle; import org.osgi.framework.ServiceFactory; @@ -318,50 +294,22 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi } } - public void implement(List<IMavenDiscoveryProposal> proposals, IProgressMonitor monitor) { - List<CatalogItem> items = toCatalogItems(proposals); - - boolean restart = isRestartRequired(proposals, monitor); - final MavenDiscoveryInstallOperation op = new MavenDiscoveryInstallOperation(items, restart); + public boolean implement(List<IMavenDiscoveryProposal> proposals, IRunnableWithProgress postInstallHook, + IRunnableContext context) { try { - op.run(monitor); - - if(restart) { - ProvisioningUI.getDefaultUI().schedule(op.getOperation().getProvisioningJob(monitor), 0); - } else { - ProvisioningJob job = op.getOperation().getProvisioningJob(monitor); - job.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); - job.setProperty(IProgressConstants.NO_IMMEDIATE_ERROR_PROMPT_PROPERTY, Boolean.TRUE); - job.setProperty(IProgressConstants.ICON_PROPERTY, ProvUIImages.getImageDescriptor(ProvUIImages.IMG_PROFILE)); - job.setProperty(IProgressConstants2.SHOW_IN_TASKBAR_ICON_PROPERTY, Boolean.TRUE); - IStatus status = job.runModal(monitor); - if(status.isOK()) { - applyProfileChanges(); - } else { - StatusManager.getManager().handle(status); - } - } - + MavenDiscoveryInstallOperation runner = new MavenDiscoveryInstallOperation(toCatalogItems(proposals), + postInstallHook, true); + context.run(true, true, runner); + int openInstallWizard = MavenDiscoveryUi.openInstallWizard(runner.getOperation(), postInstallHook); + return openInstallWizard == Window.OK; } catch(InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + IStatus status = new Status(IStatus.ERROR, DiscoveryActivator.PLUGIN_ID, NLS.bind( + Messages.ConnectorDiscoveryWizard_installProblems, new Object[] {e.getCause().getMessage()}), e.getCause()); + StatusManager.getManager().handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG); + return false; } catch(InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - private void applyProfileChanges() { - Configurator configurator = (Configurator) ServiceHelper.getService(ProvUIActivator.getContext(), - Configurator.class.getName()); - try { - configurator.applyConfiguration(); - } catch(IOException e) { - ProvUI.handleException(e, ProvUIMessages.ProvUI_ErrorDuringApplyConfig, StatusManager.LOG | StatusManager.BLOCK); - } catch(IllegalStateException e) { - IStatus illegalApplyStatus = new Status(IStatus.WARNING, ProvUIActivator.PLUGIN_ID, 0, - ProvUIMessages.ProvisioningOperationRunner_CannotApplyChanges, e); - ProvUI.reportStatus(illegalApplyStatus, StatusManager.LOG | StatusManager.BLOCK); + // canceled + return false; } } @@ -375,193 +323,10 @@ public class MavenDiscoveryService implements IImportWizardPageFactory, IMavenDi return items; } - public boolean isRestartRequired(List<IMavenDiscoveryProposal> proposals, IProgressMonitor monitor) { - return MavenDiscovery.requireRestart(toCatalogItems(proposals)); - } - public Object getService(Bundle bundle, ServiceRegistration registration) { return new MavenDiscoveryService(false); // not a factory instance } public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) { } - - /* (non-Javadoc) - * @see org.eclipse.m2e.core.ui.internal.wizards.IImportWizardPageFactory#getPage(java.util.List, org.eclipse.jface.operation.IRunnableContext) - */ - public IWizardPage getPage(final List<IMavenDiscoveryProposal> proposals, IRunnableContext context) - throws InvocationTargetException, InterruptedException { - - final IWizardPage[] page = new IWizardPage[1]; - if(proposals != null && !proposals.isEmpty()) { - context.run(false, false, new IRunnableWithProgress() { - - public void run(IProgressMonitor monitor) throws InvocationTargetException { - SubMonitor subMon = SubMonitor.convert(monitor, 11); - try { - List<CatalogItem> installableConnectors = new ArrayList<CatalogItem>(proposals.size()); - for(IMavenDiscoveryProposal proposal : proposals) { - if(proposal instanceof InstallCatalogItemMavenDiscoveryProposal) { - installableConnectors.add(((InstallCatalogItemMavenDiscoveryProposal) proposal).getCatalogItem()); - } - } - addRepositories(installableConnectors, subMon.newChild(10)); - IInstallableUnit[] ius = computeInstallableUnits(installableConnectors, subMon.newChild(1)); - RestartInstallOperation operation = new RestartInstallOperation(ProvisioningUI.getDefaultUI().getSession(), - Arrays.asList(ius)); - - IUElementListRoot root = new IUElementListRoot(); - ArrayList<AvailableIUElement> list = new ArrayList<AvailableIUElement>(operation.getIUs().size()); - for(IInstallableUnit iu : operation.getIUs()) { - AvailableIUElement element = new AvailableIUElement(root, iu, ProvisioningUI.getDefaultUI() - .getProfileId(), false); - list.add(element); - } - root.setChildren(list.toArray()); - page[0] = new DiscoverySelectableIUsPage(ProvisioningUI.getDefaultUI(), operation, root, ius); - } catch(CoreException e) { - throw new InvocationTargetException(e); - } finally { - subMon.done(); - } - } - }); - } - return page[0]; - } - - /* - * Compute the InstallableUnits & IMetadataRepository - */ - private static IInstallableUnit[] computeInstallableUnits(List<CatalogItem> installableConnectors, - IProgressMonitor progressMonitor) throws CoreException { - SubMonitor monitor = SubMonitor.convert(progressMonitor); - try { - List<IMetadataRepository> repositories = addRepositories(installableConnectors, monitor.newChild(50)); - final List<IInstallableUnit> installableUnits = queryInstallableUnits(installableConnectors, - monitor.newChild(50), repositories); - - return installableUnits.toArray(new IInstallableUnit[installableUnits.size()]); - } finally { - monitor.done(); - } - } - - /* - * Get IUs to install from the specified repository - */ - private static List<IInstallableUnit> queryInstallableUnits(List<CatalogItem> installableConnectors, IProgressMonitor progressMonitor, - List<IMetadataRepository> repositories) { - final List<IInstallableUnit> installableUnits = new ArrayList<IInstallableUnit>(installableConnectors.size()); - - SubMonitor monitor = SubMonitor.convert(progressMonitor, installableConnectors.size()); - try { - for(CatalogItem item : installableConnectors) { - SubMonitor subMon = monitor.newChild(1); - checkCancelled(monitor); - URI address = URI.create(item.getSiteUrl()); - // get repository - IMetadataRepository repository = null; - for(IMetadataRepository candidate : repositories) { - if(address.equals(candidate.getLocation())) { - repository = candidate; - break; - } - } - if(repository == null) { - log.warn(NLS.bind(Messages.MavenDiscoveryInstallOperation_missingRepository, item.getName(), - item.getSiteUrl())); - // Continue so we gather all the problems before telling the user - continue; - } - // get IUs - checkCancelled(monitor); - - Set<IVersionedId> ids = getDescriptorIds(installableConnectors, repository); - for(IVersionedId versionedId : ids) { - IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.createIUQuery(versionedId), - subMon.newChild(1)); - Set<IInstallableUnit> matches = result.toSet(); - if(matches.size() == 1) { - installableUnits.addAll(matches); - } else if(matches.size() == 0) { - log.warn(NLS.bind(Messages.MavenDiscoveryInstallOperation_missingIU, item.getName(), versionedId.toString())); - } else { - // Choose the highest available version - IInstallableUnit match = null; - for(IInstallableUnit iu : matches) { - if(match == null || iu.getVersion().compareTo(match.getVersion()) > 0) { - match = iu; - } - } - if(match != null) { - installableUnits.add(match); - } - } - } - } - return installableUnits; - } finally { - monitor.done(); - } - } - - /* - * Add the necessary repositories - */ - private static List<IMetadataRepository> addRepositories(List<CatalogItem> installableConnectors, SubMonitor monitor) - throws CoreException { - // tell p2 that it's okay to use these repositories - Set<URI> repositoryLocations = new HashSet<URI>(); - for(CatalogItem items : installableConnectors) { - repositoryLocations.add(URI.create(items.getSiteUrl())); - } - - RepositoryTracker repositoryTracker = ProvisioningUI.getDefaultUI().getRepositoryTracker(); - monitor.setWorkRemaining(installableConnectors.size() * 5); - for(CatalogItem descriptor : installableConnectors) { - URI uri = URI.create(descriptor.getSiteUrl()); - if(repositoryLocations.add(uri)) { - checkCancelled(monitor); - repositoryTracker.addRepository(uri, null, ProvisioningUI.getDefaultUI().getSession()); - } - monitor.worked(1); - } - - // fetch meta-data for these repositories - ArrayList<IMetadataRepository> repositories = new ArrayList<IMetadataRepository>(); - monitor.setWorkRemaining(repositories.size()); - IMetadataRepositoryManager manager = (IMetadataRepositoryManager) ProvisioningUI.getDefaultUI().getSession() - .getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME); - monitor.setTaskName("Contacting repositories"); - for(URI uri : repositoryLocations) { - checkCancelled(monitor); - IMetadataRepository repository = manager.loadRepository(uri, new NullProgressMonitor()); - monitor.worked(1); - repositories.add(repository); - } - return repositories; - } - - /* - * Get the IVersionedId expected to be in the repository - */ - protected static Set<IVersionedId> getDescriptorIds(List<CatalogItem> installableConnectors, - IMetadataRepository repository) { - Set<IVersionedId> ids = new HashSet<IVersionedId>(); - for(CatalogItem item : installableConnectors) { - if(repository.getLocation().equals(URI.create(item.getSiteUrl()))) { - for(String id : item.getInstallableUnits()) { - ids.add(VersionedId.parse(id)); - } - } - } - return ids; - } - - private static void checkCancelled(IProgressMonitor monitor) { - if(monitor.isCanceled()) { - throw new OperationCanceledException(); - } - } } diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java index 009b054f..b84c27da 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/MavenDiscoveryInstallOperation.java @@ -63,8 +63,12 @@ public class MavenDiscoveryInstallOperation implements IRunnableWithProgress { private RestartInstallOperation operation; - public MavenDiscoveryInstallOperation(List<CatalogItem> installableConnectors, boolean restart) { + private final IRunnableWithProgress postInstallHook; + + public MavenDiscoveryInstallOperation(List<CatalogItem> installableConnectors, IRunnableWithProgress postInstallHook, + boolean restart) { this.installableConnectors = installableConnectors; + this.postInstallHook = postInstallHook; this.restart = restart; this.session = ProvisioningUI.getDefaultUI().getSession(); } @@ -236,7 +240,7 @@ public class MavenDiscoveryInstallOperation implements IRunnableWithProgress { URI[] repositories, boolean requireRestart) throws CoreException { SubMonitor mon = SubMonitor.convert(monitor, ius.length); try { - RestartInstallOperation op = new RestartInstallOperation(session, Arrays.asList(ius)); + RestartInstallOperation op = new RestartInstallOperation(session, Arrays.asList(ius), postInstallHook); op.setRestartPolicy(requireRestart ? ProvisioningJob.RESTART_ONLY : ProvisioningJob.RESTART_NONE); IStatus operationStatus = op.resolveModal(mon); if(operationStatus.getSeverity() > IStatus.WARNING) { diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/RestartInstallOperation.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/RestartInstallOperation.java index 5481ddc4..dfa22169 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/RestartInstallOperation.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/operation/RestartInstallOperation.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.m2e.internal.discovery.operation; +import java.lang.reflect.InvocationTargetException; import java.util.Collection; import org.eclipse.core.runtime.IProgressMonitor; @@ -19,6 +20,7 @@ import org.eclipse.equinox.p2.operations.InstallOperation; import org.eclipse.equinox.p2.operations.ProfileModificationJob; import org.eclipse.equinox.p2.operations.ProvisioningJob; import org.eclipse.equinox.p2.operations.ProvisioningSession; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.m2e.internal.discovery.startup.UpdateConfigurationStartup; @@ -29,14 +31,18 @@ public class RestartInstallOperation extends InstallOperation { private int restartPolicy = ProvisioningJob.RESTART_ONLY; - private ProvisioningSession session; + private final ProvisioningSession session; - private Collection<IInstallableUnit> toInstall; + private final Collection<IInstallableUnit> toInstall; - public RestartInstallOperation(ProvisioningSession session, Collection<IInstallableUnit> toInstall) { + private final IRunnableWithProgress postInstallHook; + + public RestartInstallOperation(ProvisioningSession session, Collection<IInstallableUnit> toInstall, + IRunnableWithProgress postInstallHook) { super(session, toInstall); this.session = session; this.toInstall = toInstall; + this.postInstallHook = postInstallHook; } @Override @@ -45,7 +51,7 @@ public class RestartInstallOperation extends InstallOperation { if(job != null && job instanceof ProfileModificationJob) { ((ProfileModificationJob) job).setRestartPolicy(restartPolicy); UpdateMavenConfigurationProvisioningJob ucJob = new UpdateMavenConfigurationProvisioningJob(((ProfileModificationJob) job), - session); + session, postInstallHook); return ucJob; } return job; @@ -71,14 +77,30 @@ public class RestartInstallOperation extends InstallOperation { private ProfileModificationJob job; - public UpdateMavenConfigurationProvisioningJob(ProfileModificationJob job, ProvisioningSession session) { + private final IRunnableWithProgress postInstallHook; + + public UpdateMavenConfigurationProvisioningJob(ProfileModificationJob job, ProvisioningSession session, IRunnableWithProgress postInstallHook) { super(job.getName(), session, job.getProfileId(), null, null); this.job = job; + this.postInstallHook = postInstallHook; } @Override public IStatus runModal(IProgressMonitor monitor) { + // install IStatus status = job.run(monitor); + + if (status.isOK() && postInstallHook != null) { + try { + postInstallHook.run(monitor); + } catch(InvocationTargetException e) { + // XXX log + } catch(InterruptedException e) { + // XXX log + // still offer restart if import failed? + } + } + if(status.isOK()) { // If the installation doesn't require a restart, launch the reconfiguration now. if(getRestartPolicy() == ProvisioningJob.RESTART_NONE) { diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/DiscoverySelectableIUsPage.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/DiscoverySelectableIUsPage.java index 6b8e4743..ed3bd04d 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/DiscoverySelectableIUsPage.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/DiscoverySelectableIUsPage.java @@ -87,7 +87,7 @@ public class DiscoverySelectableIUsPage extends ResolutionStatusPage implements public DiscoverySelectableIUsPage(ProvisioningUI ui, RestartInstallOperation operation, IUElementListRoot root, IInstallableUnit[] ius) { - super("IUSelectionPage", ui, new MavenDiscoveryInstallWizard(ui, operation, operation.getIUs(), null)); //$NON-NLS-1$ + super("IUSelectionPage", ui, new MavenDiscoveryInstallWizard(ui, operation, operation.getIUs(), null, null)); //$NON-NLS-1$ this.initialSelections = ius; this.root = root; this.operation = operation; @@ -451,7 +451,7 @@ public class DiscoverySelectableIUsPage extends ResolutionStatusPage implements private AcceptLicensesWizardPage nextPage; public InstallPage(ProvisioningUI ui, IUElementListRoot root, RestartInstallOperation operation) { - super(ui, new MavenDiscoveryInstallWizard(ui, operation, operation.getIUs(), null), root, operation); + super(ui, new MavenDiscoveryInstallWizard(ui, operation, operation.getIUs(), null, null), root, operation); this.operation = operation; } diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryInstallWizard.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryInstallWizard.java index 5e29f4e1..4cbc2e88 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryInstallWizard.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryInstallWizard.java @@ -21,6 +21,7 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.operations.ProfileChangeOperation; import org.eclipse.equinox.p2.ui.LoadMetadataRepositoryJob; import org.eclipse.equinox.p2.ui.ProvisioningUI; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.m2e.internal.discovery.operation.RestartInstallOperation; /* @@ -30,10 +31,13 @@ import org.eclipse.m2e.internal.discovery.operation.RestartInstallOperation; public class MavenDiscoveryInstallWizard extends PreselectedIUInstallWizard { private boolean waitingForOtherJobs; + private final IRunnableWithProgress postInstallHook; public MavenDiscoveryInstallWizard(ProvisioningUI ui, RestartInstallOperation operation, - Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob job) { + Collection<IInstallableUnit> initialSelections, LoadMetadataRepositoryJob job, + IRunnableWithProgress postInstallHook) { super(ui, operation, initialSelections, job); + this.postInstallHook = postInstallHook; } /* (non-Javadoc) @@ -41,7 +45,8 @@ public class MavenDiscoveryInstallWizard extends PreselectedIUInstallWizard { */ @Override protected ProfileChangeOperation getProfileChangeOperation(Object[] elements) { - RestartInstallOperation op = new RestartInstallOperation(ui.getSession(), ElementUtils.elementsToIUs(elements)); + RestartInstallOperation op = new RestartInstallOperation(ui.getSession(), ElementUtils.elementsToIUs(elements), + postInstallHook); op.setRestartPolicy(((RestartInstallOperation) operation).getRestartPolicy()); op.setProfileId(getProfileId()); return op; diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java index f357076c..d398bcad 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryUi.java @@ -23,6 +23,7 @@ import org.eclipse.equinox.internal.p2.ui.dialogs.ProvisioningWizardDialog; import org.eclipse.equinox.internal.p2.ui.discovery.wizards.Messages; import org.eclipse.equinox.p2.ui.ProvisioningUI; import org.eclipse.jface.operation.IRunnableContext; +import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.WizardDialog; import org.eclipse.m2e.internal.discovery.DiscoveryActivator; import org.eclipse.m2e.internal.discovery.operation.MavenDiscoveryInstallOperation; @@ -38,17 +39,28 @@ import org.eclipse.ui.statushandlers.StatusManager; * * Copied from org.eclipse.equinox.internal.p2.ui.discovery.DiscoveryUi */ +@SuppressWarnings("restriction") public abstract class MavenDiscoveryUi { private MavenDiscoveryUi() { // don't allow clients to instantiate } - public static boolean install(List<CatalogItem> descriptors, IRunnableContext context) { + /** + * Installs specified + * + * @param descriptors is the list of catalog items to install + * @param postInstallHook additional operation to perform after installation has completed and before restart, can be + * null + * @param context + * @return + */ + public static boolean install(List<CatalogItem> descriptors, IRunnableWithProgress postInstallHook, + IRunnableContext context) { try { - MavenDiscoveryInstallOperation runner = new MavenDiscoveryInstallOperation(descriptors, true); + MavenDiscoveryInstallOperation runner = new MavenDiscoveryInstallOperation(descriptors, postInstallHook, true); context.run(true, true, runner); - openInstallWizard(runner.getOperation()); + openInstallWizard(runner.getOperation(), postInstallHook); } catch (InvocationTargetException e) { IStatus status = new Status(IStatus.ERROR, DiscoveryActivator.PLUGIN_ID, NLS.bind( Messages.ConnectorDiscoveryWizard_installProblems, new Object[] {e.getCause().getMessage()}), e.getCause()); @@ -61,8 +73,9 @@ public abstract class MavenDiscoveryUi { return true; } - public static int openInstallWizard(RestartInstallOperation operation) { - MavenDiscoveryInstallWizard wizard = new MavenDiscoveryInstallWizard(ProvisioningUI.getDefaultUI(), operation, operation.getIUs(), null); + public static int openInstallWizard(RestartInstallOperation operation, IRunnableWithProgress postInstallHook) { + MavenDiscoveryInstallWizard wizard = new MavenDiscoveryInstallWizard(ProvisioningUI.getDefaultUI(), operation, + operation.getIUs(), null, postInstallHook); WizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); dialog.create(); PlatformUI.getWorkbench().getHelpSystem().setHelp(dialog.getShell(), IProvHelpContextIds.INSTALL_WIZARD); diff --git a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryWizard.java b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryWizard.java index ba29c815..28c6b034 100644 --- a/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryWizard.java +++ b/org.eclipse.m2e.discovery/src/org/eclipse/m2e/internal/discovery/wizards/MavenDiscoveryWizard.java @@ -34,6 +34,6 @@ public class MavenDiscoveryWizard extends DiscoveryWizard { @Override public boolean performFinish() { - return MavenDiscoveryUi.install(getCatalogPage().getInstallableConnectors(), getContainer()); + return MavenDiscoveryUi.install(getCatalogPage().getInstallableConnectors(), null, getContainer()); } } |