Project

General

Profile

« Previous | Next » 

Revision b645428a

Added by Cherian Mathew over 8 years ago

Simplify update process

View differences:

eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/update/UpdateHandler.java
39 39
 */
40 40
public class UpdateHandler extends PreloadingRepositoryHandler {
41 41

  
42
    boolean hasNoRepos = false;
43 42

  
44 43
    @Override
45 44
    protected void doExecute(LoadMetadataRepositoryJob job) {
46
        if (hasNoRepos) {
47
            return;
48
        }
45

  
49 46
        UpdateOperation operation = new UpdateOperation(ProvisioningUI.getDefaultUI().getSession());
50 47

  
51 48
        // check for updates
52
        IStatus status = checkForUpdates(operation);
53

  
54

  
55
        if (status.isOK() && status.getSeverity() != IStatus.ERROR) {
56

  
57
            boolean doInstall = MessagingUtils.confirmDialog("Updates available", "Do you want to install the available updates ?");
58
            if(doInstall) {
59
                ProvisioningJob provisioningJob = operation.getProvisioningJob(null);
60
                if (provisioningJob == null) {
61
                    MessagingUtils.messageDialog("Error in performing update",
62
                            operation,
63
                            "ProvisioningJob could not be created." + System.getProperty("line.separator") +
64
                            "Either this application does not support p2 software installation or this application has been launched from within the Eclipse IDE",
65
                            null,
66
                            false);
67

  
68
                } else {
69
                    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
70
                        if (UpdateSingleIUWizard.validFor(operation)) {
71
                            // Special case for only updating a single root
72
                            UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
73
                            WizardDialog dialog = new WizardDialog(getShell(), wizard);
74
                            dialog.create();
75
                            dialog.open();
76
                        } else {
77
                            // Open the normal version of the update wizard
78
                            getProvisioningUI().openUpdateWizard(false, operation, job);
79
                        }
80
                    }
81
                }
49
        checkForUpdates(operation);
50

  
51
        ProvisioningJob provisioningJob = operation.getProvisioningJob(null);
52
        if (provisioningJob == null) {
53
            MessagingUtils.messageDialog("Error in performing update",
54
                    operation,
55
                    "ProvisioningJob could not be created." + System.getProperty("line.separator") +
56
                    "Either this application does not support p2 software installation or this application has been launched from within the Eclipse IDE",
57
                    null,
58
                    false);
59

  
60
        } else if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
61
            if (UpdateSingleIUWizard.validFor(operation)) {
62
                // Special case for only updating a single root
63
                UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation);
64
                WizardDialog dialog = new WizardDialog(getShell(), wizard);
65
                dialog.create();
66
                dialog.open();
67
            } else {
68
                // Open the normal version of the update wizard
69
                getProvisioningUI().openUpdateWizard(false, operation, job);
82 70
            }
83
        } else {
84
            MessagingUtils.informationDialog("Checking for updates", status);
85 71
        }
86 72
    }
87 73

  

Also available in: Unified diff