Project

General

Profile

Revision 663c54dd

ID663c54dd93b544b4dc68a44a761fdcfe4e8867d3
Parent a088cd55
Child 249a8e67

Added by Patrick Plitzner over 2 years ago

ref #7268 Added confirm dialog to p2 update handler + i18n

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/update/UpdateHandler.java
12 12

  
13 13
import java.net.URI;
14 14

  
15
import org.apache.log4j.Logger;
15 16
import org.eclipse.core.runtime.IProgressMonitor;
16 17
import org.eclipse.core.runtime.IStatus;
17 18
import org.eclipse.core.runtime.Status;
......
28 29
import org.eclipse.jface.dialogs.MessageDialog;
29 30
import org.eclipse.swt.widgets.Shell;
30 31

  
32
import eu.etaxonomy.taxeditor.l10n.Messages;
33

  
31 34
/**
32 35
 * UpdateHandler invokes the check for updates UI
33 36
 *
......
35 38
 */
36 39
public class UpdateHandler {
37 40

  
41
    private Logger logger = Logger.getLogger(getClass());
42

  
43
    private UpdateOperation operation;
44

  
38 45
    @Execute
39 46
    public void execute(final IProvisioningAgent agent, final Shell shell, final UISynchronize sync,
40 47
            final IWorkbench workbench) {
41
        Job updateJob = new Job("Update Job") {
48
        Job checkUpdateJob = new Job(Messages.UpdateHandler_CHECK_UPDATE_JOB) {
42 49
            @Override
43 50
            protected IStatus run(final IProgressMonitor monitor) {
44
                return checkForUpdates(agent, shell, sync, workbench, monitor);
51
                return checkForUpdates(agent, shell, sync, monitor);
45 52
            }
46 53
        };
47
        updateJob.schedule();
54
        checkUpdateJob.schedule();
55

  
56

  
57
        checkUpdateJob.addJobChangeListener(new JobChangeAdapter() {
58
            @Override
59
            public void done(IJobChangeEvent event) {
60
                if (event.getResult().isOK()) {
61
                    sync.syncExec(new Runnable() {
62

  
63
                        @Override
64
                        public void run() {
65
                            if(MessageDialog.openConfirm(shell, Messages.UpdateHandler_UPDATES_FOUND_TITLE, Messages.UpdateHandler_UPDATES_FOUND_MESSAGE)){
66
                                Job installUpdateJob = new Job(Messages.UpdateHandler_INSTALL_JOB) {
67
                                    @Override
68
                                    protected IStatus run(final IProgressMonitor monitor) {
69
                                        // run installation
70
                                        ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
71

  
72
                                        // updates cannot run from within Eclipse IDE!!!
73
                                        if (provisioningJob == null) {
74
                                            logger.error("Trying to update from the Eclipse IDE? This won't work!"); //$NON-NLS-1$
75
                                            return Status.CANCEL_STATUS;
76
                                        }
77
                                        configureProvisioningJob(provisioningJob, shell, sync, workbench);
78
                                        provisioningJob.schedule();
79
                                        return Status.OK_STATUS;
80
                                    }
81
                                };
82
                                installUpdateJob.schedule();
83
                            }
84
                        }
85
                    });
86
                }
87
            }
88
        });
48 89
    }
49 90

  
50 91
    private IStatus checkForUpdates(final IProvisioningAgent agent, final Shell shell, final UISynchronize sync,
51
            final IWorkbench workbench, IProgressMonitor monitor) {
92
            IProgressMonitor monitor) {
52 93

  
53 94
        // configure update operation
54 95
        final ProvisioningSession session = new ProvisioningSession(agent);
55
        final UpdateOperation operation = new UpdateOperation(session);
96
        operation = new UpdateOperation(session);
56 97
        configureUpdate(operation);
57 98

  
58 99
        // check for updates, this causes I/O
......
63 104
            showMessage(shell, sync);
64 105
            return Status.CANCEL_STATUS;
65 106
        }
66

  
67
        // run installation
68
        final ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
69

  
70
        // updates cannot run from within Eclipse IDE!!!
71
        if (provisioningJob == null) {
72
            System.err.println("Trying to update from the Eclipse IDE? This won't work!");
73
            return Status.CANCEL_STATUS;
74
        }
75
        configureProvisioningJob(provisioningJob, shell, sync, workbench);
76

  
77
        provisioningJob.schedule();
78 107
        return Status.OK_STATUS;
79

  
80 108
    }
81 109

  
82 110
    private void configureProvisioningJob(ProvisioningJob provisioningJob, final Shell shell, final UISynchronize sync,
......
92 120

  
93 121
                        @Override
94 122
                        public void run() {
95
                            boolean restart = MessageDialog.openQuestion(shell, "Updates installed, restart?",
96
                                    "Updates have been installed. Do you want to restart?");
123
                            boolean restart = MessageDialog.openQuestion(shell, Messages.UpdateHandler_UPDATE_INSTALLED_TITLE,
124
                                    Messages.UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE);
97 125
                            if (restart) {
98 126
                                workbench.restart();
99 127
                            }
100 128
                        }
101 129
                    });
102

  
103 130
                }
104 131
                super.done(event);
105 132
            }
......
108 135
    }
109 136

  
110 137
    private void showMessage(final Shell parent, final UISynchronize sync) {
111
        sync.syncExec(new Runnable() {
112

  
113
            @Override
114
            public void run() {
115
                MessageDialog.openWarning(parent, "No update",
116
                        "No updates for the current installation have been found.");
117
            }
118
        });
138
        sync.syncExec(()->
139
        MessageDialog.openWarning(parent, Messages.UpdateHandler_NO_UPDATE_TITLE,
140
                        Messages.UpdateHandler_NO_UPDATE_MESSAGE)
141
        );
119 142
    }
120 143

  
121 144
    private UpdateOperation configureUpdate(final UpdateOperation operation) {
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
70 70
    public static String ChangeConnectionHandler_REALLY_CREATE_DATAMODEL;
71 71
    public static String ChangeConnectionHandler_DATASOURCE_NOT_AVAILABLE;
72 72
    public static String ChangeConnectionHandler_NOT_AVAILABLE_REASONS;
73
    public static String UpdateHandler_CHECK_UPDATE_JOB;
74

  
75

  
76
    public static String UpdateHandler_INSTALL_JOB;
77

  
78

  
79
    public static String UpdateHandler_NO_UPDATE_MESSAGE;
80

  
81

  
82
    public static String UpdateHandler_NO_UPDATE_TITLE;
83

  
84

  
85
    public static String UpdateHandler_UPDATE_INSTALLED_TITLE;
86

  
87

  
88
    public static String UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE;
89

  
90

  
91
    public static String UpdateHandler_UPDATES_FOUND_MESSAGE;
92

  
93

  
94
    public static String UpdateHandler_UPDATES_FOUND_TITLE;
95

  
96

  
73 97
    public static String UriWithLabelElement_COULD_NOT_OPEN_BROWSER;
74 98
    public static String UriWithLabelElement_INVALID_URL;
75 99
    public static String UriWithLabelElement_OPEN_EXTERNAL_BROWSER;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
33 33
DatabaseRepairPage_TeamOrPerson=Persons and Teams
34 34
DatabaseRepairPage_toolTip_teamOrPerson=Caches of all Persons and Teams are recalculated.
35 35

  
36
UpdateHandler_CHECK_UPDATE_JOB=Check Update Job
37
UpdateHandler_INSTALL_JOB=Install Update Job
38
UpdateHandler_NO_UPDATE_MESSAGE=No updates for the current installation have been found.
39
UpdateHandler_NO_UPDATE_TITLE=No updates found
40
UpdateHandler_UPDATE_INSTALLED_TITLE=Updates installed
41
UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE=Updates have been installed. Do you want to restart?
42
UpdateHandler_UPDATES_FOUND_MESSAGE=Do you want to install the updates now?
43
UpdateHandler_UPDATES_FOUND_TITLE=Updates found
36 44
UriWithLabelElement_URL_NOT_SAVED=URI won't be saved\! 
37 45
UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Could not open external browser. URI is invalid.
38 46
UriWithLabelElement_INVALID_URL=Invalid URI
......
197 205
ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip=Please choose a vocabulary for the used areas.
198 206
ExcelDistributionUpdateWizard_ConfiguratorWizard_label=Configure Excel distribution update
199 207
AbstractImportWizard_ConfigurationLabel=Configure the Import
200
TCSImportWizard_ConfiguratorWizard_label=Konfiguration des TCS Imports
208
TCSImportWizard_ConfiguratorWizard_label=Configure the TCS import
201 209
FeatureTreeEditorComposite_ADD_FEATURE=Add a feature to this feature tree.
202 210
FeatureTreeEditorComposite_FEATURE_TREE=Feature Tree
203 211
FeatureTreeEditorComposite_OPEN_TREE=Open Tree
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
33 33
DatabaseRepairPage_TeamOrPerson=Personen und Teams
34 34
DatabaseRepairPage_toolTip_teamOrPerson=Die Caches aller Personen und Teams werden aktualisiert.
35 35

  
36
UpdateHandler_CHECK_UPDATE_JOB=Check Update Job
37
UpdateHandler_INSTALL_JOB=Install Update Job
38
UpdateHandler_NO_UPDATE_MESSAGE=Es wurden keine Updates f?r diese Installation gefunden.
39
UpdateHandler_NO_UPDATE_TITLE=Keine Updates vorhanden
40
UpdateHandler_UPDATE_INSTALLED_TITLE=Updates installed
41
UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE=Updates wurden installiert. Wollen Sie neu starten?
42
UpdateHandler_UPDATES_FOUND_MESSAGE=Wollen Sie die Updates jetzt installieren?
43
UpdateHandler_UPDATES_FOUND_TITLE=Updates gefunden
36 44
UriWithLabelElement_URL_NOT_SAVED=URI wird nicht gespeichert\! 
37 45
UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Externer Browser konnte nicht ge?ffnet werden. URI ist ung\u00FCtlig.
38 46
UriWithLabelElement_INVALID_URL=Ung\u00FCltige URI
......
169 177
DatabasePreferncesPage_Determination_only_for_field_unnits=Determinations nur f?r Field Units
170 178
DatabasePreferncesPage_Show_Collecting_Areas_in_general_section=Zeige Sammelgebiete im allgemeinen Teil
171 179
DatabasePreferncesPage_Taxon_Associations=Zeige Taxon Assoziationen eines Specimen im Details View
172
DatabasePreferncesPage_Life_Form=Zeige Life-Form im Details-View von Field Units an
173 180

  
174 181
DatabasePreferencesPage_Biocase_Provider=Biocase Provider
175 182
DatabasePreferencesPage_details_view_configuration=Details View
......
191 198
DatabasePreferencesPage_Define_Default_NomenclaturalCode=Nomenklatorischer Standard Code
192 199
DatabasePreferencesPage_UseLocalPreferences=Erlaube das lokale ?berschreiben
193 200
DatabasePreferencesPage_Specimen_Or_Observation=Belege und Observationen
201
DatabasePreferncesPage_Life_Form=Zeige Life-Form im Details-View von Field Units an
194 202
DatabasePreferencesPage_SetPublishFlag=Konfiguriere das Handling des Publish Flags bei neuen Taxa
195 203

  
196 204
ImportFromFileAndChooseVocIdWizardPage_AreaVoc=Gebiets Vokabular
197 205
ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip=Bitte w?hlen Sie ein Vokabular f?r die genutzten Areas aus.
198 206
ExcelDistributionUpdateWizard_ConfiguratorWizard_label=Konfiguration des Excel Distribution Updates
199 207
AbstractImportWizard_ConfigurationLabel=Konfiguration des Imports
200

  
201 208
TCSImportWizard_ConfiguratorWizard_label=Konfiguration des TCS Imports
202 209
FeatureTreeEditorComposite_ADD_FEATURE=Merkmal zum Merkmalsbaum hinzuf?gen
203 210
FeatureTreeEditorComposite_FEATURE_TREE=Merkmalsbaum
......
235 242

  
236 243
SetPublishConfiguration_Publish=Setze das Publish Flag
237 244
SetPublishConfiguration_Publish_tooltip=Wenn das Publish Flag gesetzt ist, werden die Taxa ver?ffentlicht, sowohl im Datenportal als auch bei Print Publikationen
238

  
239 245
SetPublishConfiguration_Description_Configurator=Konfigurieren Sie, wie das Setzen des Publish Flags durchgef?hrt werden soll.
240 246
SetPublishConfiguration_IncludeAcceptedTaxa=Akzeptierte Taxa
241 247
SetPublishConfiguration_IncludeSharedtaxa=Mehrfach verwendete Taxa mit einbeziehen

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)