Search in sources :

Example 6 with FeatureEntry

use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.

the class ProfileChangeOperationComputer method pruneNonUninstall.

private void pruneNonUninstall(List<IInstallableUnit> installableUnits) {
    Set<String> installableFeatureIds = new HashSet<String>();
    for (FeatureEntry featureEntry : featureEntries) {
        if (featureEntry.computeChangeOperation() == Operation.UNINSTALL) {
            installableFeatureIds.add(featureEntry.getFeatureDescriptor().getId());
        }
    }
    Iterator<IInstallableUnit> it = installableUnits.iterator();
    while (it.hasNext()) {
        IInstallableUnit iu = it.next();
        if (!installableFeatureIds.contains(iu.getId())) {
            it.remove();
        }
    }
}
Also used : FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 7 with FeatureEntry

use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry 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));
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) ProfileChangeOperation(org.eclipse.equinox.p2.operations.ProfileChangeOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) Operation(org.eclipse.epp.mpc.ui.Operation) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) CoreException(org.eclipse.core.runtime.CoreException) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 8 with FeatureEntry

use of org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry in project epp.mpc by eclipse.

the class FeatureSelectionWizardPage method createControl.

public void createControl(Composite parent) {
    container = new Composite(parent, SWT.NONE);
    switchResultLayout = new StackLayout();
    container.setLayout(switchResultLayout);
    GridData data = new GridData(GridData.FILL_BOTH);
    container.setLayoutData(data);
    defaultComposite = new Composite(container, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(defaultComposite);
    Composite treeContainer = new Composite(defaultComposite, SWT.NULL);
    GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).applyTo(treeContainer);
    TreeColumnLayout columnLayout = new TreeColumnLayout();
    treeContainer.setLayout(columnLayout);
    viewer = new CheckboxTreeViewer(treeContainer, SWT.MULTI | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.setUseHashlookup(true);
    viewer.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 == e2) {
                return 0;
            }
            String s1;
            String s2;
            if (e1 instanceof CatalogItemEntry) {
                s1 = ((CatalogItemEntry) e1).getItem().getName();
                s2 = ((CatalogItemEntry) e2).getItem().getName();
            } else {
                FeatureEntry fe1 = (FeatureEntry) e1;
                FeatureEntry fe2 = (FeatureEntry) e2;
                if (fe1.getInstallableUnitItem().isOptional() != fe2.getInstallableUnitItem().isOptional()) {
                    // required items first
                    return fe1.getInstallableUnitItem().isOptional() ? 1 : -1;
                }
                s1 = fe1.getFeatureDescriptor().getName();
                s2 = fe2.getFeatureDescriptor().getName();
            }
            int i = s1.compareToIgnoreCase(s2);
            if (i == 0) {
                i = s1.compareTo(s2);
                if (i == 0) {
                    i = new Integer(System.identityHashCode(e1)).compareTo(System.identityHashCode(e2));
                }
            }
            return i;
        }
    });
    viewer.setContentProvider(new ContentProvider());
    viewer.setInput(getWizard().getSelectionModel());
    viewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            boolean checked = event.getChecked();
            if (event.getElement() instanceof CatalogItemEntry) {
                CatalogItemEntry entry = (CatalogItemEntry) event.getElement();
                for (FeatureEntry child : entry.getChildren()) {
                    child.setChecked(checked);
                }
            } else if (event.getElement() instanceof FeatureEntry) {
                FeatureEntry featureEntry = (FeatureEntry) event.getElement();
                featureEntry.setChecked(checked);
            }
            refreshState();
        }
    });
    column = new TreeViewerColumn(viewer, SWT.NONE);
    column.setLabelProvider(new DelegatingStyledCellLabelProvider(new LabelProvider()));
    columnLayout.setColumnData(column.getColumn(), new ColumnWeightData(100, 100, true));
    detailsControl = new Group(defaultComposite, SWT.SHADOW_IN);
    detailsControl.setText(Messages.FeatureSelectionWizardPage_details);
    GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, 300).exclude(true).applyTo(detailsControl);
    GridLayoutFactory.fillDefaults().applyTo(detailsControl);
    detailStatusText = new Text(detailsControl, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(detailStatusText);
    setControl(container);
    Dialog.applyDialogFont(container);
    MarketplaceClientUi.setDefaultHelp(getControl());
    flipToDefaultComposite();
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) RemediationGroup(org.eclipse.equinox.internal.p2.ui.dialogs.RemediationGroup) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Text(org.eclipse.swt.widgets.Text) StyledString(org.eclipse.jface.viewers.StyledString) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) StackLayout(org.eclipse.swt.custom.StackLayout) GridData(org.eclipse.swt.layout.GridData) CatalogItemEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry) DelegatingStyledCellLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) DelegatingStyledCellLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider) IStyledLabelProvider(org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider)

Aggregations

FeatureEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry)8 HashSet (java.util.HashSet)5 CatalogItemEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.CatalogItemEntry)4 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)4 HashMap (java.util.HashMap)3 Operation (org.eclipse.epp.mpc.ui.Operation)3 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)3 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)3 RemediationOperation (org.eclipse.equinox.p2.operations.RemediationOperation)3 UninstallOperation (org.eclipse.equinox.p2.operations.UninstallOperation)3 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 InstallOperation (org.eclipse.equinox.p2.operations.InstallOperation)2 StyledString (org.eclipse.jface.viewers.StyledString)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Collection (java.util.Collection)1