Search in sources :

Example 1 with UpdateOperation

use of org.eclipse.equinox.p2.operations.UpdateOperation in project cubrid-manager by CUBRID.

the class UpdateHandler method doExecute.

protected void doExecute(LoadMetadataRepositoryJob job) {
    if (isNoRepos) {
        return;
    }
    UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
    // check for updates
    IStatus status = operation.resolveModal(null);
    // AUTO check update and there is not update
    if (isAutoCheckUpdate) {
        // user cancelled
        if (status.getSeverity() == IStatus.CANCEL) {
            return;
        }
        // Special case those statuses where we would never want to open a wizard
        if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
            return;
        }
        // there is no plan, so we can't continue.  Report any reason found
        if (operation.getProvisioningPlan() == null && !status.isOK()) {
            return;
        }
    }
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        if (UpdateSingleIUWizard.validFor(operation)) {
            // Special case for only updating a single root
            UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
            WizardDialog dialog = new WizardDialog(getShell(), wizard);
            dialog.create();
            dialog.open();
        } else {
            // Open the normal version of the update wizard
            getProvisioningUI().openUpdateWizard(false, operation, job);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 2 with UpdateOperation

use of org.eclipse.equinox.p2.operations.UpdateOperation in project knime-core by knime.

the class BugfixMessageInjector method checkNewMinorVersion.

private List<String> checkNewMinorVersion() throws IOException, URISyntaxException {
    final ProvisioningUI provUI = ProvisioningUI.getDefaultUI();
    RepositoryTracker tracker = provUI.getRepositoryTracker();
    if (tracker == null) {
        // if run from the IDE there will be no tracker
        return Collections.emptyList();
    }
    UpdateOperation op = new UpdateOperation(provUI.getSession());
    op.resolveModal(new NullProgressMonitor());
    return Stream.of(op.getPossibleUpdates()).map(u -> u.toUpdate.getProperty("org.eclipse.equinox.p2.name")).sorted().distinct().collect(Collectors.toList());
}
Also used : RepositoryTracker(org.eclipse.equinox.p2.operations.RepositoryTracker) XPathExpressionException(javax.xml.xpath.XPathExpressionException) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TransformerException(javax.xml.transform.TransformerException) XPath(javax.xml.xpath.XPath) XPathConstants(javax.xml.xpath.XPathConstants) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) Collectors(java.util.stream.Collectors) File(java.io.File) XPathFactory(javax.xml.xpath.XPathFactory) List(java.util.List) Stream(java.util.stream.Stream) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Document(org.w3c.dom.Document) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) SAXException(org.xml.sax.SAXException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) TransformerFactory(javax.xml.transform.TransformerFactory) Collections(java.util.Collections) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProvisioningUI(org.eclipse.equinox.p2.ui.ProvisioningUI) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) RepositoryTracker(org.eclipse.equinox.p2.operations.RepositoryTracker)

Example 3 with UpdateOperation

use of org.eclipse.equinox.p2.operations.UpdateOperation in project yamcs-studio by yamcs.

the class UpdateHandler method doExecute.

@Override
protected void doExecute(LoadMetadataRepositoryJob job) {
    if (hasNoRepos) {
        MessageDialog.openInformation(null, "Update Yamcs Studio", "Could not check for updates since no repository is configured");
        return;
    }
    UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null);
    // check for updates
    operation.resolveModal(null);
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        if (UpdateSingleIUWizard.validFor(operation)) {
            // Special case for only updating a single root
            UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
            WizardDialog dialog = new WizardDialog(getShell(), wizard);
            dialog.create();
            dialog.open();
        } else {
            // Open the normal version of the update wizard
            getProvisioningUI().openUpdateWizard(false, operation, job);
        }
    }
}
Also used : UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 4 with UpdateOperation

use of org.eclipse.equinox.p2.operations.UpdateOperation in project portfolio by buchen.

the class UpdateHelper method checkForUpdates.

private NewVersion checkForUpdates(IProgressMonitor monitor) throws OperationCanceledException, CoreException {
    ProvisioningSession session = new ProvisioningSession(agent);
    operation = new UpdateOperation(session);
    configureUpdateOperation(operation);
    IStatus status = operation.resolveModal(monitor);
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE)
        return null;
    if (status.getSeverity() == IStatus.CANCEL)
        throw new OperationCanceledException();
    if (status.getSeverity() == IStatus.ERROR)
        throw new CoreException(status);
    Update[] possibleUpdates = operation.getPossibleUpdates();
    Update update = possibleUpdates.length > 0 ? possibleUpdates[0] : null;
    if (update == null) {
        return new NewVersion(Messages.LabelUnknownVersion);
    } else {
        NewVersion v = new NewVersion(update.replacement.getVersion().toString());
        v.setMinimumJavaVersionRequired(// $NON-NLS-1$
        update.replacement.getProperty("latest.changes.minimumJavaVersionRequired", null));
        // try for locale first
        String history = // 
        update.replacement.getProperty(VERSION_HISTORY + "_" + Locale.getDefault().getLanguage(), // $NON-NLS-1$
        null);
        if (history == null)
            history = update.replacement.getProperty(VERSION_HISTORY, null);
        if (history != null)
            v.setVersionHistory(history);
        return v;
    }
}
Also used : ProvisioningSession(org.eclipse.equinox.p2.operations.ProvisioningSession) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) Update(org.eclipse.equinox.p2.operations.Update)

Example 5 with UpdateOperation

use of org.eclipse.equinox.p2.operations.UpdateOperation in project knime-core by knime.

the class InvokeUpdateAction method openWizard.

@Override
protected void openWizard(final LoadMetadataRepositoryJob job, final ProvisioningUI provUI) {
    final UpdateOperation operation = provUI.getUpdateOperation(null, null);
    // check for updates
    operation.resolveModal(null);
    PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {

        @Override
        public void run() {
            Shell shell = PlatformUI.getWorkbench().getModalDialogShellProvider().getShell();
            if (!operation.hasResolved()) {
                MessageDialog.openInformation(shell, "Update KNIME...", "No updates were found");
            } else if (provUI.getPolicy().continueWorkingWithOperation(operation, shell)) {
                if (UpdateSingleIUWizard.validFor(operation)) {
                    // Special case for only updating a single root
                    UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(provUI, operation);
                    WizardDialog dialog = new WizardDialog(shell, wizard);
                    dialog.create();
                    if (dialog.open() == 0) {
                        clearOsgiAreaBeforeRestart();
                    }
                } else {
                    // Open the normal version of the update wizard
                    if (provUI.openUpdateWizard(false, operation, job) == 0) {
                        clearOsgiAreaBeforeRestart();
                    }
                }
            }
        }
    });
}
Also used : Shell(org.eclipse.swt.widgets.Shell) UpdateOperation(org.eclipse.equinox.p2.operations.UpdateOperation) UpdateSingleIUWizard(org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

UpdateOperation (org.eclipse.equinox.p2.operations.UpdateOperation)6 IStatus (org.eclipse.core.runtime.IStatus)3 UpdateSingleIUWizard (org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 ProvisioningSession (org.eclipse.equinox.p2.operations.ProvisioningSession)2 ProvisioningUI (org.eclipse.equinox.p2.ui.ProvisioningUI)2 File (java.io.File)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URISyntaxException (java.net.URISyntaxException)1 Collections (java.util.Collections)1 List (java.util.List)1 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 TransformerFactory (javax.xml.transform.TransformerFactory)1