import java.net.URI;
+import org.apache.log4j.Logger;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
/**
* UpdateHandler invokes the check for updates UI
*
*/
public class UpdateHandler {
+ private Logger logger = Logger.getLogger(getClass());
+
+ private UpdateOperation operation;
+
@Execute
public void execute(final IProvisioningAgent agent, final Shell shell, final UISynchronize sync,
final IWorkbench workbench) {
- Job updateJob = new Job("Update Job") {
+ Job checkUpdateJob = new Job(Messages.UpdateHandler_CHECK_UPDATE_JOB) {
@Override
protected IStatus run(final IProgressMonitor monitor) {
- return checkForUpdates(agent, shell, sync, workbench, monitor);
+ return checkForUpdates(agent, shell, sync, monitor);
}
};
- updateJob.schedule();
+ checkUpdateJob.schedule();
+
+
+ checkUpdateJob.addJobChangeListener(new JobChangeAdapter() {
+ @Override
+ public void done(IJobChangeEvent event) {
+ if (event.getResult().isOK()) {
+ sync.syncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ if(MessageDialog.openConfirm(shell, Messages.UpdateHandler_UPDATES_FOUND_TITLE, Messages.UpdateHandler_UPDATES_FOUND_MESSAGE)){
+ Job installUpdateJob = new Job(Messages.UpdateHandler_INSTALL_JOB) {
+ @Override
+ protected IStatus run(final IProgressMonitor monitor) {
+ // run installation
+ ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
+
+ // updates cannot run from within Eclipse IDE!!!
+ if (provisioningJob == null) {
+ logger.error("Trying to update from the Eclipse IDE? This won't work!"); //$NON-NLS-1$
+ return Status.CANCEL_STATUS;
+ }
+ configureProvisioningJob(provisioningJob, shell, sync, workbench);
+ provisioningJob.schedule();
+ return Status.OK_STATUS;
+ }
+ };
+ installUpdateJob.schedule();
+ }
+ }
+ });
+ }
+ }
+ });
}
private IStatus checkForUpdates(final IProvisioningAgent agent, final Shell shell, final UISynchronize sync,
- final IWorkbench workbench, IProgressMonitor monitor) {
+ IProgressMonitor monitor) {
// configure update operation
final ProvisioningSession session = new ProvisioningSession(agent);
- final UpdateOperation operation = new UpdateOperation(session);
+ operation = new UpdateOperation(session);
configureUpdate(operation);
// check for updates, this causes I/O
showMessage(shell, sync);
return Status.CANCEL_STATUS;
}
-
- // run installation
- final ProvisioningJob provisioningJob = operation.getProvisioningJob(monitor);
-
- // updates cannot run from within Eclipse IDE!!!
- if (provisioningJob == null) {
- System.err.println("Trying to update from the Eclipse IDE? This won't work!");
- return Status.CANCEL_STATUS;
- }
- configureProvisioningJob(provisioningJob, shell, sync, workbench);
-
- provisioningJob.schedule();
return Status.OK_STATUS;
-
}
private void configureProvisioningJob(ProvisioningJob provisioningJob, final Shell shell, final UISynchronize sync,
@Override
public void run() {
- boolean restart = MessageDialog.openQuestion(shell, "Updates installed, restart?",
- "Updates have been installed. Do you want to restart?");
+ boolean restart = MessageDialog.openQuestion(shell, Messages.UpdateHandler_UPDATE_INSTALLED_TITLE,
+ Messages.UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE);
if (restart) {
workbench.restart();
}
}
});
-
}
super.done(event);
}
}
private void showMessage(final Shell parent, final UISynchronize sync) {
- sync.syncExec(new Runnable() {
-
- @Override
- public void run() {
- MessageDialog.openWarning(parent, "No update",
- "No updates for the current installation have been found.");
- }
- });
+ sync.syncExec(()->
+ MessageDialog.openWarning(parent, Messages.UpdateHandler_NO_UPDATE_TITLE,
+ Messages.UpdateHandler_NO_UPDATE_MESSAGE)
+ );
}
private UpdateOperation configureUpdate(final UpdateOperation operation) {
DatabaseRepairPage_TeamOrPerson=Persons and Teams
DatabaseRepairPage_toolTip_teamOrPerson=Caches of all Persons and Teams are recalculated.
+UpdateHandler_CHECK_UPDATE_JOB=Check Update Job
+UpdateHandler_INSTALL_JOB=Install Update Job
+UpdateHandler_NO_UPDATE_MESSAGE=No updates for the current installation have been found.
+UpdateHandler_NO_UPDATE_TITLE=No updates found
+UpdateHandler_UPDATE_INSTALLED_TITLE=Updates installed
+UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE=Updates have been installed. Do you want to restart?
+UpdateHandler_UPDATES_FOUND_MESSAGE=Do you want to install the updates now?
+UpdateHandler_UPDATES_FOUND_TITLE=Updates found
UriWithLabelElement_URL_NOT_SAVED=URI won't be saved\!
UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Could not open external browser. URI is invalid.
UriWithLabelElement_INVALID_URL=Invalid URI
ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip=Please choose a vocabulary for the used areas.
ExcelDistributionUpdateWizard_ConfiguratorWizard_label=Configure Excel distribution update
AbstractImportWizard_ConfigurationLabel=Configure the Import
-TCSImportWizard_ConfiguratorWizard_label=Konfiguration des TCS Imports
+TCSImportWizard_ConfiguratorWizard_label=Configure the TCS import
FeatureTreeEditorComposite_ADD_FEATURE=Add a feature to this feature tree.
FeatureTreeEditorComposite_FEATURE_TREE=Feature Tree
FeatureTreeEditorComposite_OPEN_TREE=Open Tree
DatabaseRepairPage_TeamOrPerson=Personen und Teams
DatabaseRepairPage_toolTip_teamOrPerson=Die Caches aller Personen und Teams werden aktualisiert.
+UpdateHandler_CHECK_UPDATE_JOB=Check Update Job
+UpdateHandler_INSTALL_JOB=Install Update Job
+UpdateHandler_NO_UPDATE_MESSAGE=Es wurden keine Updates für diese Installation gefunden.
+UpdateHandler_NO_UPDATE_TITLE=Keine Updates vorhanden
+UpdateHandler_UPDATE_INSTALLED_TITLE=Updates installed
+UpdateHandler_UPDATE_INSTALLED_TITLE_MESSAGE=Updates wurden installiert. Wollen Sie neu starten?
+UpdateHandler_UPDATES_FOUND_MESSAGE=Wollen Sie die Updates jetzt installieren?
+UpdateHandler_UPDATES_FOUND_TITLE=Updates gefunden
UriWithLabelElement_URL_NOT_SAVED=URI wird nicht gespeichert\!
UriWithLabelElement_COULD_NOT_OPEN_BROWSER=Externer Browser konnte nicht geöffnet werden. URI ist ung\u00FCtlig.
UriWithLabelElement_INVALID_URL=Ung\u00FCltige URI
DatabasePreferncesPage_Determination_only_for_field_unnits=Determinations nur für Field Units
DatabasePreferncesPage_Show_Collecting_Areas_in_general_section=Zeige Sammelgebiete im allgemeinen Teil
DatabasePreferncesPage_Taxon_Associations=Zeige Taxon Assoziationen eines Specimen im Details View
-DatabasePreferncesPage_Life_Form=Zeige Life-Form im Details-View von Field Units an
DatabasePreferencesPage_Biocase_Provider=Biocase Provider
DatabasePreferencesPage_details_view_configuration=Details View
DatabasePreferencesPage_Define_Default_NomenclaturalCode=Nomenklatorischer Standard Code
DatabasePreferencesPage_UseLocalPreferences=Erlaube das lokale Überschreiben
DatabasePreferencesPage_Specimen_Or_Observation=Belege und Observationen
+DatabasePreferncesPage_Life_Form=Zeige Life-Form im Details-View von Field Units an
DatabasePreferencesPage_SetPublishFlag=Konfiguriere das Handling des Publish Flags bei neuen Taxa
ImportFromFileAndChooseVocIdWizardPage_AreaVoc=Gebiets Vokabular
ImportFromFileAndChooseVocIdWizardOage_AreaVoc_toolTip=Bitte wählen Sie ein Vokabular für die genutzten Areas aus.
ExcelDistributionUpdateWizard_ConfiguratorWizard_label=Konfiguration des Excel Distribution Updates
AbstractImportWizard_ConfigurationLabel=Konfiguration des Imports
-
TCSImportWizard_ConfiguratorWizard_label=Konfiguration des TCS Imports
FeatureTreeEditorComposite_ADD_FEATURE=Merkmal zum Merkmalsbaum hinzufügen
FeatureTreeEditorComposite_FEATURE_TREE=Merkmalsbaum
SetPublishConfiguration_Publish=Setze das Publish Flag
SetPublishConfiguration_Publish_tooltip=Wenn das Publish Flag gesetzt ist, werden die Taxa veröffentlicht, sowohl im Datenportal als auch bei Print Publikationen
-
SetPublishConfiguration_Description_Configurator=Konfigurieren Sie, wie das Setzen des Publish Flags durchgeführt werden soll.
SetPublishConfiguration_IncludeAcceptedTaxa=Akzeptierte Taxa
SetPublishConfiguration_IncludeSharedtaxa=Mehrfach verwendete Taxa mit einbeziehen