Search in sources :

Example 11 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project hale by halestudio.

the class WMSWizardPage method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    IWizardContainer container = getContainer();
    if (container instanceof IPageChangeProvider) {
        ((IPageChangeProvider) container).addPageChangedListener(new IPageChangedListener() {

            @Override
            public void pageChanged(PageChangedEvent event) {
                if (event.getSelectedPage() == WMSWizardPage.this) {
                    onShowPage();
                }
            }
        });
    }
    createContent(parent);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent)

Example 12 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project hale by halestudio.

the class HaleWizardPage method createControl.

/**
 * @see WizardPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    IWizardContainer container = getContainer();
    if (container instanceof IPageChangeProvider) {
        ((IPageChangeProvider) container).addPageChangedListener(changeListener = new IPageChangedListener() {

            @Override
            public void pageChanged(PageChangedEvent event) {
                if (event.getSelectedPage() == HaleWizardPage.this) {
                    if (wasShown) {
                        onShowPage(false);
                    } else {
                        wasShown = true;
                        onShowPage(true);
                    }
                }
            }
        });
    }
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new FillLayout());
    createContent(page);
    setControl(page);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) Composite(org.eclipse.swt.widgets.Composite) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 13 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project eclipse-integration-commons by spring-projects.

the class GenericCommandWizard method resizeWizard.

protected void resizeWizard(Control control) {
    Point size = control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    IWizardContainer container = getContainer();
    if (container != null) {
        container.getShell().setSize(size);
    }
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) Point(org.eclipse.swt.graphics.Point)

Example 14 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer in project epp.mpc by eclipse.

the class MarketplacePage method showNextPage.

protected void showNextPage() {
    IWizardContainer container = getContainer();
    if (container == null) {
        return;
    }
    IWizardPage currentPage = container.getCurrentPage();
    if (currentPage == MarketplacePage.this && currentPage.isPageComplete()) {
        IWizardPage nextPage = getNextPage();
        if (nextPage != null && nextPage instanceof WizardPage) {
            ((WizardPage) nextPage).setPageComplete(true);
            container.showPage(nextPage);
        }
    }
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IWizardPage(org.eclipse.jface.wizard.IWizardPage) WizardPage(org.eclipse.jface.wizard.WizardPage) IWizardPage(org.eclipse.jface.wizard.IWizardPage)

Example 15 with IWizardContainer

use of org.eclipse.jface.wizard.IWizardContainer 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();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) EnumSet(java.util.EnumSet) Set(java.util.Set) HashSet(java.util.HashSet) AbstractProvisioningOperation(org.eclipse.epp.internal.mpc.ui.operations.AbstractProvisioningOperation) 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) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) Job(org.eclipse.core.runtime.jobs.Job) ProvisioningJob(org.eclipse.equinox.p2.operations.ProvisioningJob) ProfileChangeOperationComputer(org.eclipse.epp.internal.mpc.ui.operations.ProfileChangeOperationComputer) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) OperationType(org.eclipse.epp.internal.mpc.ui.operations.ProfileChangeOperationComputer.OperationType) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

IWizardContainer (org.eclipse.jface.wizard.IWizardContainer)19 IPageChangeProvider (org.eclipse.jface.dialogs.IPageChangeProvider)5 IPageChangedListener (org.eclipse.jface.dialogs.IPageChangedListener)5 PageChangedEvent (org.eclipse.jface.dialogs.PageChangedEvent)5 WizardDialog (org.eclipse.jface.wizard.WizardDialog)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 Composite (org.eclipse.swt.widgets.Composite)4 URISyntaxException (java.net.URISyntaxException)3 IPageChangingListener (org.eclipse.jface.dialogs.IPageChangingListener)3 PageChangingEvent (org.eclipse.jface.dialogs.PageChangingEvent)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 Button (org.eclipse.swt.widgets.Button)3 Group (org.eclipse.swt.widgets.Group)3 Label (org.eclipse.swt.widgets.Label)3 Text (org.eclipse.swt.widgets.Text)3 Date (java.util.Date)2 TreeSet (java.util.TreeSet)2 Matcher (java.util.regex.Matcher)2 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)2