use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.
the class MarketplaceWizard method computeNewInstallCatalogItems.
private Set<CatalogItem> computeNewInstallCatalogItems() {
Set<CatalogItem> items = new HashSet<CatalogItem>();
Map<CatalogItem, Collection<String>> iusByCatalogItem = new HashMap<CatalogItem, Collection<String>>();
for (CatalogItemEntry entry : getSelectionModel().getCatalogItemEntries()) {
List<FeatureEntry> features = entry.getChildren();
Collection<String> featureIds = new ArrayList<String>(features.size());
for (FeatureEntry feature : features) {
if (feature.computeChangeOperation() == Operation.INSTALL) {
featureIds.add(feature.getFeatureDescriptor().getId());
}
}
if (!featureIds.isEmpty()) {
iusByCatalogItem.put(entry.getItem(), featureIds);
}
}
for (IInstallableUnit unit : operationIUs) {
for (Entry<CatalogItem, Collection<String>> entry : iusByCatalogItem.entrySet()) {
if (entry.getValue().contains(unit.getId())) {
items.add(entry.getKey());
}
}
}
return items;
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method computeCheckedViewerState.
public void computeCheckedViewerState() {
// compute which ones should be checked. (update scenario where only part of a feature is installed)
List<Object> checkedElements = new ArrayList<Object>();
List<Object> grayCheckedElements = new ArrayList<Object>();
for (CatalogItemEntry entry : getWizard().getSelectionModel().getCatalogItemEntries()) {
int childCheckCount = 0;
boolean childGrayed = false;
for (FeatureEntry child : entry.getChildren()) {
if (child.isChecked()) {
checkedElements.add(child);
++childCheckCount;
}
}
if (childCheckCount > 0) {
for (FeatureEntry child : entry.getChildren()) {
if (!child.isChecked() && !child.getInstallableUnitItem().isOptional()) {
child.setChecked(true);
checkedElements.add(child);
++childCheckCount;
}
}
}
for (FeatureEntry child : entry.getChildren()) {
if (child.isGrayed()) {
checkedElements.add(child);
grayCheckedElements.add(child);
childGrayed = true;
}
}
if (childCheckCount == entry.getChildren().size()) {
checkedElements.add(entry);
} else if (childCheckCount > 0 || childGrayed) {
grayCheckedElements.add(entry);
checkedElements.add(entry);
}
}
viewer.setCheckedElements(checkedElements.toArray());
viewer.setGrayedElements(grayCheckedElements.toArray());
viewer.refresh(true);
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method updateSelectionModel.
private void updateSelectionModel(Set<FeatureDescriptor> featureDescriptors) {
Map<String, FeatureDescriptor> descriptorById = new HashMap<String, FeatureDescriptor>();
for (FeatureDescriptor fd : featureDescriptors) {
descriptorById.put(fd.getId(), fd);
}
SelectionModel selectionModel = getWizard().getSelectionModel();
for (CatalogItemEntry entry : selectionModel.getCatalogItemEntries()) {
for (FeatureEntry child : entry.getChildren()) {
FeatureDescriptor descriptor = descriptorById.get(child.getFeatureDescriptor().getId());
if (descriptor != null) {
child.setFeatureDescriptor(descriptor);
}
}
}
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.
the class MarketplaceWizard method updateProfileChangeOperation.
public void updateProfileChangeOperation() {
removeAddedRepositoryLocations();
addedRepositoryLocations = null;
profileChangeOperation = null;
operationIUs = null;
IWizardContainer wizardContainer = getContainer();
if (getSelectionModel().computeProvisioningOperationViable()) {
ProfileChangeOperationComputer provisioningOperation = null;
try {
final Map<CatalogItem, Operation> itemToOperation = getSelectionModel().getItemToSelectedOperation();
final Set<CatalogItem> selectedItems = getSelectionModel().getSelectedCatalogItems();
OperationType operationType = null;
for (Map.Entry<CatalogItem, Operation> entry : itemToOperation.entrySet()) {
if (!selectedItems.contains(entry.getKey())) {
continue;
}
OperationType entryOperationType = OperationType.map(entry.getValue());
if (entryOperationType != null) {
if (operationType == null || operationType == OperationType.UPDATE || entryOperationType == OperationType.CHANGE) {
operationType = entryOperationType;
}
}
}
Map<FeatureEntry, Operation> featureEntries = getSelectionModel().getFeatureEntryToOperation(false, false);
if (operationType == OperationType.CHANGE || operationType == OperationType.UPDATE) {
Set<OperationType> featureOperations = EnumSet.noneOf(OperationType.class);
for (Entry<FeatureEntry, Operation> entry : featureEntries.entrySet()) {
OperationType operation = OperationType.map(entry.getValue());
if (operation != null) {
featureOperations.add(operation);
}
}
if (featureOperations.contains(OperationType.INSTALL) && featureOperations.contains(OperationType.UPDATE)) {
// just perform install instead, which covers update
featureOperations.remove(OperationType.UPDATE);
}
if (featureOperations.size() == 1) {
operationType = featureOperations.iterator().next();
}
}
URI dependenciesRepository = null;
if (getConfiguration().getCatalogDescriptor().getDependenciesRepository() != null) {
try {
dependenciesRepository = getConfiguration().getCatalogDescriptor().getDependenciesRepository().toURI();
} catch (URISyntaxException e) {
throw new InvocationTargetException(e);
}
}
provisioningOperation = new ProfileChangeOperationComputer(operationType, selectedItems, featureEntries.keySet(), dependenciesRepository, getConfiguration().getCatalogDescriptor().isInstallFromAllRepositories() ? ProfileChangeOperationComputer.ResolutionStrategy.FALLBACK_STRATEGY : ProfileChangeOperationComputer.ResolutionStrategy.SELECTED_REPOSITORIES, withRemediation);
wizardContainer.run(true, true, provisioningOperation);
profileChangeOperation = provisioningOperation.getOperation();
operationIUs = provisioningOperation.getIus();
addedRepositoryLocations = provisioningOperation.getAddedRepositoryLocations();
operationNewInstallItems = computeNewInstallCatalogItems();
errorMessage = provisioningOperation.getErrorMessage();
final IStatus result = profileChangeOperation.getResolutionResult();
if (result != null && operationIUs != null && operationIUs.length > 0 && operationType == OperationType.INSTALL) {
switch(result.getSeverity()) {
case IStatus.ERROR:
Job job = new Job(Messages.MarketplaceWizard_errorNotificationJob) {
IStatus r = result;
Set<CatalogItem> items = new HashSet<CatalogItem>(itemToOperation.keySet());
IInstallableUnit[] ius = operationIUs;
String details = profileChangeOperation.getResolutionDetails();
{
setSystem(false);
setUser(false);
setPriority(LONG);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
getCatalog().installErrorReport(monitor, r, items, ius, details);
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
};
job.schedule();
}
}
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
IStatus status;
if (cause instanceof CoreException) {
status = ((CoreException) cause).getStatus();
} else {
status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.MarketplaceWizard_problemsPerformingProvisioningOperation, new Object[] { cause.getMessage() }), cause);
}
MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
} catch (InterruptedException e) {
// canceled
MarketplaceClientUi.log(IStatus.CANCEL, MarketplaceClientUi.BUNDLE_ID, Messages.MarketplaceWizard_ProvisioningOperationCancelled, e);
} finally {
if (provisioningOperation != null) {
addedRepositoryLocations = provisioningOperation.getAddedRepositoryLocations();
}
}
}
// re-get the container - in case the wizard was closed in the meantime, this will be null...
wizardContainer = getContainer();
if (wizardContainer != null && wizardContainer.getCurrentPage() == featureSelectionWizardPage) {
featureSelectionWizardPage.updateMessage();
}
}
use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method pruneNonInstall.
private void pruneNonInstall(List<IInstallableUnit> installableUnits) {
Set<String> installableFeatureIds = new HashSet<String>();
for (FeatureEntry featureEntry : featureEntries) {
Operation operation = featureEntry.computeChangeOperation();
if (operation == Operation.INSTALL || operation == Operation.UPDATE) {
installableFeatureIds.add(featureEntry.getFeatureDescriptor().getId());
}
}
Iterator<IInstallableUnit> it = installableUnits.iterator();
while (it.hasNext()) {
IInstallableUnit iu = it.next();
if (!installableFeatureIds.contains(iu.getId())) {
it.remove();
}
}
}
Aggregations