use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project translationstudio8 by heartsome.
the class UpdateDescriptionPage method getUpdateDescDetailText.
private String getUpdateDescDetailText() {
StringBuffer descBf = new StringBuffer();
Update[] updates = operation.getSelectedUpdates();
if (updates.length == 0) {
// no udpates;
setPageComplete(false);
return P2UpdateUtil.UPDATE_PROMPT_INFO_NO_UPDATE;
}
Update update = updates[0];
AvailableUpdateElement newElement = new AvailableUpdateElement(null, update.replacement, update.toUpdate, ui.getProfileId(), ProvUI.getQueryContext(ui.getPolicy()).getShowProvisioningPlanChildren());
descBf.append(P2UpdateUtil.UI_WIZARD_DESC_PAGE_DESC_DETAIL).append(newElement.getIU().getVersion()).append("\n\n");
newElement.setQueryable(operation.getProvisioningPlan().getAdditions());
Object[] children = newElement.getChildren(newElement);
StringBuffer temp = new StringBuffer();
if (children != null && children.length != 0) {
AvailableIUElement c = (AvailableIUElement) children[0];
String detail = c.getIU().getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
if (detail == null)
detail = "";
temp.append(detail);
}
String descResult = "";
if (temp.length() != 0) {
String lang = CommonFunction.getSystemLanguage();
String szh = "[-zh-]";
String sen = "[-en-]";
if (lang.equals("en")) {
descResult = temp.substring(sen.length() + 1, temp.indexOf(szh) - 1);
} else if (lang.equals("zh")) {
descResult = temp.substring(temp.indexOf(szh) + szh.length() + 1, temp.length());
}
}
return descBf.append(descResult).toString();
// String detail = "";
// Object[] elements = root.getChildren(root);
// if(elements.length > 0){
// AvailableUpdateElement element = (AvailableUpdateElement) elements[0];
// Object[] children = element.getChildren(element);
// if(children != null && children.length != 0){
// AvailableIUElement c = (AvailableIUElement) children[0];
// IInstallableUnit selectedIU = ElementUtils.elementToIU(c);
// detail = selectedIU.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
// if (detail == null)
// detail = "";
// }
// }
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project knime-core by knime.
the class InstallMissingNodesJob method findExtensions.
private IStatus findExtensions(final IProgressMonitor monitor, final List<NodeAndBundleInformation> missingNodes, final Set<IInstallableUnit> featuresToInstall) {
ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
Bundle myself = FrameworkUtil.getBundle(getClass());
try {
IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) session.getProvisioningAgent().getService(IMetadataRepositoryManager.SERVICE_NAME);
for (URI uri : metadataManager.getKnownRepositories(IRepositoryManager.REPOSITORIES_ALL)) {
if (!missingNodes.isEmpty()) {
IMetadataRepository repo = metadataManager.loadRepository(uri, monitor);
for (Iterator<NodeAndBundleInformation> it = missingNodes.iterator(); it.hasNext(); ) {
NodeAndBundleInformation info = it.next();
if (searchInRepository(repo, info, metadataManager, monitor, featuresToInstall)) {
it.remove();
}
}
}
}
return Status.OK_STATUS;
} catch (ProvisionException ex) {
NodeLogger.getLogger(getClass()).error("Could not create provisioning agent: " + ex.getMessage(), ex);
return new Status(IStatus.ERROR, myself.getSymbolicName(), "Could not query updates site for missing extensions", ex);
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project knime-core by knime.
the class InstallMissingNodesJob method startInstallJob.
private void startInstallJob(final Set<IInstallableUnit> featuresToInstall) {
final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
Job.getJobManager().cancel(LoadMetadataRepositoryJob.LOAD_FAMILY);
final LoadMetadataRepositoryJob loadJob = new LoadMetadataRepositoryJob(provUI);
loadJob.setProperty(LoadMetadataRepositoryJob.ACCUMULATE_LOAD_ERRORS, Boolean.toString(true));
loadJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(final IJobChangeEvent event) {
if (PlatformUI.isWorkbenchRunning() && event.getResult().isOK()) {
Display.getDefault().asyncExec(() -> {
if (Display.getDefault().isDisposed()) {
NodeLogger.getLogger("Display disposed, aborting install action");
// fixes AP-8376, AP-8380, AP-7184
return;
}
provUI.getPolicy().setRepositoriesVisible(false);
provUI.openInstallWizard(featuresToInstall, new InstallOperation(provUI.getSession(), featuresToInstall), loadJob);
provUI.getPolicy().setRepositoriesVisible(true);
});
}
}
});
loadJob.setUser(true);
loadJob.schedule();
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project gemoc-studio by eclipse.
the class PrepareInstallProfileJob method run.
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.InstallConnectorsJob_task_configuring, 100);
try {
final Collection<IInstallableUnit> ius = computeInstallableUnits(monitor.newChild(50));
checkCancelled(monitor);
final InstallOperation installOperation = resolve(monitor.newChild(50), ius, repositoryLocations.toArray(new URI[0]));
checkCancelled(monitor);
if (!headless) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
openInstallWizard(provisioningUI, ius, installOperation);
}
});
}
} finally {
monitor.done();
}
} catch (OperationCanceledException e) {
throw new InterruptedException();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project gemoc-studio by eclipse.
the class PrepareInstallProfileJob method computeInstallableUnits.
public Collection<IInstallableUnit> computeInstallableUnits(SubMonitor monitor) throws CoreException {
try {
monitor.setWorkRemaining(100);
// add repository urls and load meta data
List<IMetadataRepository> repositories = addRepositories(monitor.newChild(50));
final List<IInstallableUnit> installableUnits = queryInstallableUnits(monitor.newChild(50), repositories);
removeOldVersions(installableUnits);
checkForUnavailable(installableUnits);
return installableUnits;
// MultiStatus status = new MultiStatus(DiscoveryUi.ID_PLUGIN, 0,
// Messages.PrepareInstallProfileJob_ok, null);
// ius = installableUnits.toArray(new
// IInstallableUnit[installableUnits.size()]);
// ProfileChangeRequest profileChangeRequest =
// InstallAction.computeProfileChangeRequest(ius, profileId,
// status, new SubProgressMonitor(monitor,
// installableConnectors.size()));
// if (status.getSeverity() > IStatus.WARNING) {
// throw new CoreException(status);
// }
// if (profileChangeRequest == null) {
// // failed but no indication as to why
// throw new CoreException(new Status(IStatus.ERROR,
// DiscoveryUi.ID_PLUGIN,
// Messages.PrepareInstallProfileJob_computeProfileChangeRequestFailed,
// null));
// }
// PlannerResolutionOperation operation = new
// PlannerResolutionOperation(
// Messages.PrepareInstallProfileJob_calculatingRequirements,
// profileId, profileChangeRequest, null,
// status, true);
// IStatus operationStatus = operation.execute(new
// SubProgressMonitor(monitor, installableConnectors.size()));
// if (operationStatus.getSeverity() > IStatus.WARNING) {
// throw new CoreException(operationStatus);
// }
//
// plannerResolutionOperation = operation;
} catch (URISyntaxException e) {
// should never happen, since we already validated URLs.
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.InstallConnectorsJob_unexpectedError_url, e));
} catch (MalformedURLException e) {
// should never happen, since we already validated URLs.
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.InstallConnectorsJob_unexpectedError_url, e));
} finally {
monitor.done();
}
}
Aggregations