diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.properties b/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.properties index 372fe98ce9..b7224084f5 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.properties +++ b/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.properties @@ -20,6 +20,8 @@ Update.command=Check for Updates Update.command.mnemonic=U Install.command=Install New Software... Install.command.mnemonic=S +InstallSources.command=Install Sources +InstallSources.command.mnemonic=o InstallationDetails.command=Installation Details InstallationDetails.command.mnemonic=I TempInstallView.command=Installation Information diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.xml b/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.xml index 802b742a12..e05fa133e3 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.xml +++ b/bundles/org.eclipse.equinox.p2.ui.sdk/plugin.xml @@ -54,6 +54,10 @@ name="%Install.command" id="org.eclipse.equinox.p2.ui.sdk.install"> + + + + @@ -93,6 +101,16 @@ + + + + + { + MessageDialog.openInformation(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), + ProvSDKMessages.InstallSourcesHandler_EnabledTitle, + ProvSDKMessages.InstallSourcesHandler_EnabledMessage); + // Trigger an update operation to fetch sources + triggerUpdateForSources(provUI); + }); + } else { + PlatformUI.getWorkbench().getDisplay().asyncExec(() -> { + MessageDialog.openInformation(PlatformUI.getWorkbench().getModalDialogShellProvider().getShell(), + ProvSDKMessages.InstallSourcesHandler_DisabledTitle, + ProvSDKMessages.InstallSourcesHandler_DisabledMessage); + }); + } + } + return result; + } else { + return plan.getStatus(); + } + } finally { + sub.done(); + } + } + }; + + job.setUser(true); + job.schedule(); + + return null; + } + + /** + * Triggers an update operation to fetch missing source bundles + */ + private void triggerUpdateForSources(ProvisioningUI provUI) { + UpdateOperation op = provUI.getUpdateOperation(null, null); + + Job updateJob = new Job(ProvSDKMessages.InstallSourcesHandler_UpdateJobName) { + @Override + protected IStatus run(IProgressMonitor monitor) { + IStatus result = op.resolveModal(monitor); + if (result.isOK() && op.hasResolved()) { + // Schedule the provisioning job + ProvisioningJob provJob = op.getProvisioningJob(monitor); + if (provJob != null) { + provJob.schedule(); + } + } + return Status.OK_STATUS; + } + }; + updateJob.setUser(true); + updateJob.schedule(); + } + + protected ProvisioningUI getProvisioningUI() { + return ProvisioningUI.getDefaultUI(); + } +} diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java index c42a8638a8..95ecf67dd5 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java +++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/ProvSDKMessages.java @@ -100,5 +100,12 @@ public class ProvSDKMessages extends NLS { public static String TrustPreferencePage_TrustAllYes; public static String TrustPreferencePage_TypeColumn; public static String TrustPreferencePage_ValidityColumn; + public static String InstallSourcesHandler_DisabledMessage; + public static String InstallSourcesHandler_DisabledTitle; + public static String InstallSourcesHandler_EnabledMessage; + public static String InstallSourcesHandler_EnabledTitle; + public static String InstallSourcesHandler_JobName; + public static String InstallSourcesHandler_ProgressTaskName; + public static String InstallSourcesHandler_UpdateJobName; } diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties index c2a3a84eff..75a3297f34 100644 --- a/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties +++ b/bundles/org.eclipse.equinox.p2.ui.sdk/src/org/eclipse/equinox/internal/p2/ui/sdk/messages.properties @@ -85,3 +85,10 @@ TrustPreferencePage_TrustAllNo=No, Prompt Me Instead TrustPreferencePage_TrustAllYes=Yes, I Accept the Risk TrustPreferencePage_TypeColumn=Type TrustPreferencePage_ValidityColumn=Validity Dates +InstallSourcesHandler_DisabledMessage=Source bundle installation has been disabled. Source bundles will not be automatically installed. +InstallSourcesHandler_DisabledTitle=Install Sources Disabled +InstallSourcesHandler_EnabledMessage=Source bundle installation has been enabled. An update will be performed to fetch missing source bundles. +InstallSourcesHandler_EnabledTitle=Install Sources Enabled +InstallSourcesHandler_JobName=Toggling source bundle installation +InstallSourcesHandler_ProgressTaskName=Updating source installation preference... +InstallSourcesHandler_UpdateJobName=Fetching source bundles...