Search in sources :

Example 1 with Update

use of org.eclipse.equinox.p2.operations.Update 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 Update

use of org.eclipse.equinox.p2.operations.Update in project translationstudio8 by heartsome.

the class UpdateDescriptionPage method getUpdateDescDetailText.

private String getUpdateDescDetailText() {
    StringBuffer descBf = new StringBuffer();
    Update[] updates = operation.getSelectedUpdates();
    if (updates.length == 0) {
        // no udpates;
        setPageComplete(false);
        return P2UpdateUtil.UPDATE_PROMPT_INFO_NO_UPDATE;
    }
    Update update = updates[0];
    AvailableUpdateElement newElement = new AvailableUpdateElement(null, update.replacement, update.toUpdate, ui.getProfileId(), ProvUI.getQueryContext(ui.getPolicy()).getShowProvisioningPlanChildren());
    descBf.append(P2UpdateUtil.UI_WIZARD_DESC_PAGE_DESC_DETAIL).append(newElement.getIU().getVersion()).append("\n\n");
    newElement.setQueryable(operation.getProvisioningPlan().getAdditions());
    Object[] children = newElement.getChildren(newElement);
    StringBuffer temp = new StringBuffer();
    if (children != null && children.length != 0) {
        AvailableIUElement c = (AvailableIUElement) children[0];
        String detail = c.getIU().getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
        if (detail == null)
            detail = "";
        temp.append(detail);
    }
    String descResult = "";
    if (temp.length() != 0) {
        String lang = CommonFunction.getSystemLanguage();
        String szh = "[-zh-]";
        String sen = "[-en-]";
        if (lang.equals("en")) {
            descResult = temp.substring(sen.length() + 1, temp.indexOf(szh) - 1);
        } else if (lang.equals("zh")) {
            descResult = temp.substring(temp.indexOf(szh) + szh.length() + 1, temp.length());
        }
    }
    return descBf.append(descResult).toString();
// String detail = "";
// Object[] elements = root.getChildren(root);
// if(elements.length > 0){
// AvailableUpdateElement element = (AvailableUpdateElement) elements[0];
// Object[] children = element.getChildren(element);
// if(children != null && children.length != 0){
// AvailableIUElement c = (AvailableIUElement) children[0];
// IInstallableUnit selectedIU = ElementUtils.elementToIU(c);
// detail = selectedIU.getProperty(IInstallableUnit.PROP_DESCRIPTION, null);
// if (detail == null)
// detail = "";
// }
// }
}
Also used : AvailableUpdateElement(org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) Update(org.eclipse.equinox.p2.operations.Update) AvailableIUElement(org.eclipse.equinox.internal.p2.ui.model.AvailableIUElement)

Example 3 with Update

use of org.eclipse.equinox.p2.operations.Update in project translationstudio8 by heartsome.

the class UpdateWizard method initializeResolutionModelElements.

protected void initializeResolutionModelElements(Object[] selectedElements) {
    root = new IUElementListRoot();
    ArrayList<AvailableUpdateElement> list = new ArrayList<AvailableUpdateElement>(selectedElements.length);
    for (int i = 0; i < selectedElements.length; i++) {
        if (selectedElements[i] instanceof AvailableUpdateElement) {
            AvailableUpdateElement element = (AvailableUpdateElement) selectedElements[i];
            AvailableUpdateElement newElement = new AvailableUpdateElement(root, element.getIU(), element.getIUToBeUpdated(), getProfileId(), shouldShowProvisioningPlanChildren());
            list.add(newElement);
        } else if (selectedElements[i] instanceof Update) {
            Update update = (Update) selectedElements[i];
            AvailableUpdateElement newElement = new AvailableUpdateElement(root, update.replacement, update.toUpdate, getProfileId(), shouldShowProvisioningPlanChildren());
            list.add(newElement);
        }
    }
    root.setChildren(list.toArray());
}
Also used : IUElementListRoot(org.eclipse.equinox.internal.p2.ui.model.IUElementListRoot) ArrayList(java.util.ArrayList) AvailableUpdateElement(org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement) Update(org.eclipse.equinox.p2.operations.Update)

Example 4 with Update

use of org.eclipse.equinox.p2.operations.Update 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 5 with Update

use of org.eclipse.equinox.p2.operations.Update 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)

Aggregations

UpdateOperation (org.eclipse.equinox.p2.operations.UpdateOperation)5 URI (java.net.URI)4 CoreException (org.eclipse.core.runtime.CoreException)4 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)4 IStatus (org.eclipse.core.runtime.IStatus)3 UpdateSingleIUWizard (org.eclipse.equinox.internal.p2.ui.dialogs.UpdateSingleIUWizard)3 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)3 Update (org.eclipse.equinox.p2.operations.Update)3 IMetadataRepositoryManager (org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 BundleContext (org.osgi.framework.BundleContext)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 URISyntaxException (java.net.URISyntaxException)2 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)2 AvailableUpdateElement (org.eclipse.equinox.internal.p2.ui.model.AvailableUpdateElement)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)2 RemediationOperation (org.eclipse.equinox.p2.operations.RemediationOperation)2 File (java.io.File)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1