|
Lines 11-18
Link Here
|
| 11 |
package org.eclipse.equinox.internal.provisional.p2.ui.operations; |
11 |
package org.eclipse.equinox.internal.provisional.p2.ui.operations; |
| 12 |
|
12 |
|
| 13 |
import java.net.URL; |
13 |
import java.net.URL; |
|
|
14 |
import java.util.ArrayList; |
| 14 |
import org.eclipse.core.runtime.*; |
15 |
import org.eclipse.core.runtime.*; |
|
|
16 |
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; |
| 17 |
import org.eclipse.equinox.internal.p2.ui.ProvUIActivator; |
| 18 |
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.IArtifactRepositoryManager; |
| 15 |
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; |
19 |
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException; |
|
|
20 |
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; |
| 21 |
import org.eclipse.equinox.internal.provisional.p2.core.repository.IRepository; |
| 22 |
import org.eclipse.equinox.internal.provisional.p2.core.repository.RepositoryEvent; |
| 23 |
import org.eclipse.equinox.internal.provisional.p2.metadata.repository.IMetadataRepositoryManager; |
| 24 |
import org.osgi.framework.ServiceReference; |
| 16 |
|
25 |
|
| 17 |
/** |
26 |
/** |
| 18 |
* Operation that adds colocated artifact and metadata repositories |
27 |
* Operation that adds colocated artifact and metadata repositories |
|
Lines 33-46
Link Here
|
| 33 |
} |
42 |
} |
| 34 |
|
43 |
|
| 35 |
protected IStatus doBatchedExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException { |
44 |
protected IStatus doBatchedExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException { |
|
|
45 |
// Special case: if a repo is already known by the manager is disabled, |
| 46 |
// then enable it. Note that this means the implementation of undo is |
| 47 |
// not correct. Undoing this operation will remove the repos, but we do not make use |
| 48 |
// of the undo protocol in 3.4.x so we live with this problem. |
| 49 |
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236077 |
| 50 |
ArrayList disabledMetaRepos = new ArrayList(); |
| 51 |
IMetadataRepositoryManager metaMgr = (IMetadataRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IMetadataRepositoryManager.class.getName()); |
| 52 |
if (metaMgr != null) { |
| 53 |
URL[] disabled = metaMgr.getKnownRepositories(IMetadataRepositoryManager.REPOSITORIES_DISABLED); |
| 54 |
for (int i = 0; i < disabled.length; i++) |
| 55 |
disabledMetaRepos.add(disabled[i].toExternalForm()); |
| 56 |
} |
| 57 |
ArrayList disabledArtifactRepos = new ArrayList(); |
| 58 |
IArtifactRepositoryManager artifactMgr = (IArtifactRepositoryManager) ServiceHelper.getService(ProvUIActivator.getContext(), IArtifactRepositoryManager.class.getName()); |
| 59 |
if (artifactMgr != null) { |
| 60 |
URL[] disabled = artifactMgr.getKnownRepositories(IArtifactRepositoryManager.REPOSITORIES_DISABLED); |
| 61 |
for (int i = 0; i < disabled.length; i++) |
| 62 |
disabledArtifactRepos.add(disabled[i].toExternalForm()); |
| 63 |
} |
| 36 |
for (int i = 0; i < urls.length; i++) { |
64 |
for (int i = 0; i < urls.length; i++) { |
| 37 |
ProvisioningUtil.addMetadataRepository(urls[i]); |
65 |
if (metaMgr != null && disabledMetaRepos.contains(urls[i].toExternalForm())) { |
| 38 |
ProvisioningUtil.addArtifactRepository(urls[i]); |
66 |
metaMgr.setEnabled(urls[i], true); |
|
|
67 |
publishEvent(new RepositoryEvent(urls[i], IRepository.TYPE_METADATA, RepositoryEvent.ADDED, true)); |
| 68 |
} else |
| 69 |
ProvisioningUtil.addMetadataRepository(urls[i]); |
| 70 |
if (artifactMgr != null && disabledArtifactRepos.contains(urls[i].toExternalForm())) { |
| 71 |
artifactMgr.setEnabled(urls[i], true); |
| 72 |
publishEvent(new RepositoryEvent(urls[i], IRepository.TYPE_ARTIFACT, RepositoryEvent.ADDED, true)); |
| 73 |
} else |
| 74 |
ProvisioningUtil.addArtifactRepository(urls[i]); |
| 39 |
} |
75 |
} |
| 40 |
added = true; |
76 |
added = true; |
| 41 |
return okStatus(); |
77 |
return okStatus(); |
| 42 |
} |
78 |
} |
| 43 |
|
79 |
|
|
|
80 |
private void publishEvent(RepositoryEvent event) { |
| 81 |
ServiceReference busReference = ProvUIActivator.getContext().getServiceReference(IProvisioningEventBus.SERVICE_NAME); |
| 82 |
if (busReference != null) |
| 83 |
((IProvisioningEventBus) ProvUIActivator.getContext().getService(busReference)).publishEvent(event); |
| 84 |
} |
| 85 |
|
| 44 |
protected IStatus doBatchedUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException { |
86 |
protected IStatus doBatchedUndo(IProgressMonitor monitor, IAdaptable uiInfo) throws ProvisionException { |
| 45 |
for (int i = 0; i < urls.length; i++) { |
87 |
for (int i = 0; i < urls.length; i++) { |
| 46 |
ProvisioningUtil.removeMetadataRepository(urls[i], monitor); |
88 |
ProvisioningUtil.removeMetadataRepository(urls[i], monitor); |