use of org.eclipse.epp.mpc.ui.Operation 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();
}
}
}
use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method checkForUnavailable.
/**
* Verifies that we found what we were looking for: it's possible that we have connector descriptors that are no
* longer available on their respective sites. In that case we must inform the user. Unfortunately this is the
* earliest point at which we can know.
*/
private void checkForUnavailable(final List<IInstallableUnit> installableUnits) throws CoreException {
// at least one selected connector could not be found in a repository
Set<String> foundIds = new HashSet<String>();
for (IInstallableUnit unit : installableUnits) {
foundIds.add(unit.getId());
}
Set<String> installFeatureIds = new HashSet<String>();
for (FeatureEntry entry : featureEntries) {
Operation operation = entry.computeChangeOperation();
if (operation == Operation.INSTALL || operation == Operation.UPDATE) {
installFeatureIds.add(entry.getFeatureDescriptor().getId());
}
}
// $NON-NLS-1$
String message = "";
// $NON-NLS-1$
String detailedMessage = "";
for (CatalogItem descriptor : items) {
StringBuilder unavailableIds = null;
for (String id : getFeatureIds(descriptor)) {
if (!foundIds.contains(id) && installFeatureIds.contains(id)) {
if (unavailableIds == null) {
unavailableIds = new StringBuilder();
} else {
unavailableIds.append(Messages.ProvisioningOperation_commaSeparator);
}
unavailableIds.append(id);
}
}
if (unavailableIds != null) {
if (message.length() > 0) {
message += Messages.ProvisioningOperation_commaSeparator;
}
message += descriptor.getName();
if (detailedMessage.length() > 0) {
detailedMessage += Messages.ProvisioningOperation_commaSeparator;
}
detailedMessage += NLS.bind(Messages.ProvisioningOperation_unavailableFeatures, new Object[] { descriptor.getName(), unavailableIds.toString(), descriptor.getSiteUrl() });
}
}
if (message.length() > 0) {
// instead of aborting here we ask the user if they wish to proceed anyways
final boolean[] okayToProceed = new boolean[1];
final String finalMessage = message;
Display.getDefault().syncExec(new Runnable() {
public void run() {
okayToProceed[0] = MessageDialog.openQuestion(WorkbenchUtil.getShell(), Messages.ProvisioningOperation_proceedQuestion, NLS.bind(Messages.ProvisioningOperation_unavailableSolutions_proceedQuestion, new Object[] { finalMessage }));
}
});
if (!okayToProceed[0]) {
throw new CoreException(new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.ProvisioningOperation_unavailableSolutions, detailedMessage), null));
}
}
}
use of org.eclipse.epp.mpc.ui.Operation in project epp.mpc by eclipse.
the class SelectionModelStateSerializerTest method testSerialize.
// (expected=AssertionError.class)//FIXME bug 487157: disabled until entries declare Neon compatibility
@Test
@Category(RemoteTests.class)
public void testSerialize() {
catalog.performDiscovery(new NullProgressMonitor());
assertFalse(catalog.getItems().isEmpty());
assertTrue(catalog.getItems().size() > 4);
// first two are promoted downloads, which might not be installable in current target
CatalogItem firstItem = catalog.getItems().get(2);
CatalogItem secondItem = catalog.getItems().get(3);
assertThat(firstItem.getDescription(), not(startsWith(PROMOTED_MARKER)));
assertThat(secondItem.getDescription(), not(startsWith(PROMOTED_MARKER)));
assertThat(firstItem.getInstallableUnits(), not(empty()));
assertThat(secondItem.getInstallableUnits(), not(empty()));
selectionModel.select(firstItem, Operation.INSTALL);
selectionModel.select(secondItem, Operation.INSTALL);
SelectionModelStateSerializer serializer = new SelectionModelStateSerializer(catalog, selectionModel);
String state = serializer.serialize();
assertNotNull(state);
assertFalse(state.trim().length() == 0);
assertTrue(selectionModel.computeProvisioningOperationViable());
selectionModel.clear();
assertTrue(selectionModel.getItemToSelectedOperation().isEmpty());
assertFalse(selectionModel.computeProvisioningOperationViable());
serializer.deserialize(state, new NullProgressMonitor());
assertEquals(2, selectionModel.getItemToSelectedOperation().size());
assertTrue(selectionModel.computeProvisioningOperationViable());
Map<CatalogItem, Operation> itemToOperation = selectionModel.getItemToSelectedOperation();
assertEquals(Operation.INSTALL, itemToOperation.get(firstItem));
assertEquals(Operation.INSTALL, itemToOperation.get(secondItem));
}
Aggregations