use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class ProvisioningJobListener method done.
@Override
public void done(IJobChangeEvent event) {
if (event.getResult().isOK()) {
Job job = new Job(Messages.ProvisioningJobListener_notificationTaskName) {
{
setPriority(Job.LONG);
setSystem(true);
setUser(true);
}
@Override
protected IStatus run(final IProgressMonitor monitor) {
ConcurrentTaskManager taskManager = new ConcurrentTaskManager(installItems.size(), Messages.ProvisioningJobListener_notificationTaskName);
for (CatalogItem item : installItems) {
if (item instanceof MarketplaceNodeCatalogItem) {
final MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
taskManager.submit(new Runnable() {
public void run() {
INode node = nodeItem.getData();
URL marketplaceUrl = nodeItem.getMarketplaceUrl();
IMarketplaceService marketplaceService = ServiceHelper.getMarketplaceServiceLocator().getMarketplaceService(marketplaceUrl.toString());
marketplaceService.reportInstallSuccess(node, new NullProgressMonitor() {
@Override
public boolean isCanceled() {
return monitor.isCanceled();
}
});
}
});
}
}
try {
taskManager.waitUntilFinished(monitor);
} catch (CoreException e) {
return e.getStatus();
}
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
};
job.schedule();
}
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class SelectionModel method getCatalogItemEntries.
public List<CatalogItemEntry> getCatalogItemEntries() {
if (entries == null) {
List<CatalogItemEntry> entries = new ArrayList<CatalogItemEntry>();
for (Entry<CatalogItem, Operation> entry : itemToOperation.entrySet()) {
CatalogItem item = entry.getKey();
Operation operation = entry.getValue();
CatalogItemEntry itemEntry = createItemEntry(item, operation);
entries.add(itemEntry);
}
this.entries = entries;
}
return entries;
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class SelectionModelStateSerializer method serialize.
public String serialize() {
StringBuilder state = new StringBuilder(1024);
for (Map.Entry<CatalogItem, Operation> entry : selectionModel.getItemToSelectedOperation().entrySet()) {
if (entry.getValue() != Operation.NONE) {
if (state.length() > 0) {
state.append(' ');
}
INode data = (INode) entry.getKey().getData();
state.append(data.getId());
state.append('=');
state.append(entry.getValue().name());
}
}
return state.toString();
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class SelectionModelStateSerializer method deserialize.
/**
* @param state
* the state to restore
* @param operationByNodeExtras
* additional operations to include
* @param monitor
*/
public void deserialize(String state, Map<String, Operation> operationByNodeExtras, IProgressMonitor monitor) {
Map<String, Operation> operationByNodeId = new HashMap<String, Operation>();
if (state != null && state.length() > 0) {
// $NON-NLS-1$
Pattern pattern = Pattern.compile("([^\\s=]+)=(\\S+)");
Matcher matcher = pattern.matcher(state);
while (matcher.find()) {
String nodeId = matcher.group(1);
String operationName = matcher.group(2);
Operation operation = Operation.valueOf(operationName);
operationByNodeId.put(nodeId, operation);
}
}
if (operationByNodeExtras != null) {
operationByNodeId.putAll(operationByNodeExtras);
}
if (!operationByNodeId.isEmpty()) {
catalog.performQuery(monitor, operationByNodeId.keySet());
for (CatalogItem item : catalog.getItems()) {
if (item instanceof MarketplaceNodeCatalogItem) {
MarketplaceNodeCatalogItem nodeItem = (MarketplaceNodeCatalogItem) item;
Operation operation = operationByNodeId.get(nodeItem.getData().getId());
if (operation != null && operation != Operation.NONE) {
if (nodeItem.isInstalled() && operation == Operation.INSTALL) {
operation = Operation.UPDATE;
}
selectionModel.select(nodeItem, operation);
}
}
}
}
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogItem in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method installErrorReport.
public void installErrorReport(IProgressMonitor monitor, IStatus result, Set<CatalogItem> items, IInstallableUnit[] operationIUs, String resolutionDetails) throws CoreException {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_sendingErrorNotification, 100);
try {
Set<Node> nodes = new HashSet<Node>();
for (CatalogItem item : items) {
Object data = item.getData();
if (data instanceof INode) {
nodes.add((Node) data);
}
}
Set<String> iuIdsAndVersions = new HashSet<String>();
for (IInstallableUnit iu : operationIUs) {
String id = iu.getId();
String version = iu.getVersion() == null ? null : iu.getVersion().toString();
// $NON-NLS-1$
iuIdsAndVersions.add(id + "," + version);
}
marketplaceService.reportInstallError(result, nodes, iuIdsAndVersions, resolutionDetails, progress);
} finally {
progress.done();
}
}
Aggregations