From b0ad8fbaf40bc2c7ef602fcb9bdda6e9afed36f6 Mon Sep 17 00:00:00 2001
From: Patrick Plitzner
Date: Mon, 22 Oct 2018 08:25:17 +0200
Subject: [PATCH] i18n + code clean up
---
.../operation/DeleteTermBaseOperation.java | 72 +++++++++----------
.../eu/etaxonomy/taxeditor/l10n/Messages.java | 29 +++++++-
.../taxeditor/l10n/messages.properties | 9 +++
.../taxeditor/l10n/messages_de.properties | 9 +++
4 files changed, 78 insertions(+), 41 deletions(-)
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
index 88ad2da27..91da3303c 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
@@ -14,7 +14,6 @@ import org.eclipse.core.runtime.IAdaptable;
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 eu.etaxonomy.cdm.api.service.DeleteResult;
import eu.etaxonomy.cdm.api.service.ITermService;
@@ -23,6 +22,7 @@ import eu.etaxonomy.cdm.model.common.DefinedTermBase;
import eu.etaxonomy.cdm.model.common.TermBase;
import eu.etaxonomy.cdm.model.common.TermVocabulary;
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
+import eu.etaxonomy.taxeditor.l10n.Messages;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -55,14 +55,14 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation {
throws ExecutionException {
if (termBase instanceof TermVocabulary) {
if (((TermVocabulary)termBase).getCreatedBy() == null) {
- IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This is a CDM system vocabulary");
- MessagingUtils.warningDialog("Cannot delete vocabulary", termBase, status);
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_SYSTEM_VOC);
+ MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_CANNOT_DELETE_VOC, termBase, status);
return status;
}
if (!((TermVocabulary)termBase).getTerms().isEmpty()) {
- IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "Delete all terms from this vocaulary before deleting the vocabulary.");
- MessagingUtils.warningDialog("Vocabulary not empty", termBase, status);
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE);
+ MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_VOC_NOT_EMPTY, termBase, status);
return status;
}
@@ -70,20 +70,8 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation {
DeleteResult result = CdmStore.getService(IVocabularyService.class).delete(termBase.getUuid());
if (!result.isOk()){
- StringBuffer errorString = new StringBuffer();
- for (Exception e:result.getExceptions()){
- errorString.append(e.getMessage() + System.lineSeparator());
- }
- if (result.isAbort()){
- MessageDialog.openWarning(null, "Delete failed", errorString.toString());
- }else{
- if (result.getExceptions().iterator().hasNext()){
- MessagingUtils.errorDialog("Delete failed", this.getClass(),null, TaxeditorStorePlugin.PLUGIN_ID, result.getExceptions().iterator().next(), true);
- }else{
- MessageDialog.openWarning(null, "Delete failed", errorString.toString());
- }
- }
- }
+ return showErrorMessage(result);
+ }
} else if (termBase instanceof DefinedTermBase) {
@@ -91,49 +79,53 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation {
DefinedTermBase definedTermBase = (DefinedTermBase) termBase;
if (((DefinedTermBase)termBase).getCreatedBy() == null) {
- IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This is a CDM system defined term");
- MessagingUtils.warningDialog("Cannot delete defined term", termBase, status);
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_SYSTEM_TERM);
+ MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_CANNOT_DELETE_TERM, termBase, status);
return status;
}
if(!definedTermBase.getIncludes().isEmpty()){
- IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This term includes other terms. Please delete the included terms before deleting this term.");
- MessagingUtils.warningDialog("Term has included terms", termBase, status);
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_TERM_INCLUDES_OTHERS);
+ MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_TERM_INLCUDES, termBase, status);
return status;
}
DeleteResult result = CdmStore.getService(ITermService.class).delete(termBase.getUuid());
-
if (!result.isOk()){
- StringBuffer errorString = new StringBuffer();
- for (Exception e:result.getExceptions()){
- errorString.append(e.getMessage() + System.lineSeparator());
- }
- if (result.isAbort()){
- MessageDialog.openWarning(null, "Delete failed", errorString.toString());
- }else{
- if (result.getExceptions().iterator().hasNext()){
- MessagingUtils.errorDialog("Delete failed", this.getClass(),null, TaxeditorStorePlugin.PLUGIN_ID, result.getExceptions().iterator().next(), true);
- }else{
- MessageDialog.openWarning(null, "Delete failed", errorString.toString());
- }
- }
+ return showErrorMessage(result);
}
}
return postExecute(termBase);
}
- @Override
+ private IStatus showErrorMessage(DeleteResult result) {
+ StringBuffer errorString = new StringBuffer();
+ for (Exception e:result.getExceptions()){
+ errorString.append(e.getMessage() + System.lineSeparator());
+ }
+ IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), errorString.toString());
+ String delete_failed = Messages.DeleteTermBaseOperation_DELETE_FAILED;
+ if (result.isAbort()){
+ MessagingUtils.warningDialog(delete_failed, this, status);
+ }else{
+ if (result.getExceptions().iterator().hasNext()){
+ MessagingUtils.errorDialog(delete_failed, this.getClass(),null, TaxeditorStorePlugin.PLUGIN_ID, result.getExceptions().iterator().next(), true);
+ }else{
+ MessagingUtils.warningDialog(delete_failed, this, status);
+ }
+ }
+ return status;
+ }
+
+ @Override
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- // TODO Auto-generated method stub
return null;
}
@Override
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {
- // TODO Auto-generated method stub
return null;
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
index 5e057c228..c832de57e 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
@@ -208,7 +208,34 @@ public class Messages extends NLS {
public static String DeleteResultMessagingUtils_SUCCES;
- public static String NewGrantedAuthority_AlreadyInDb;
+ public static String DeleteTermBaseOperation_CANNOT_DELETE_TERM;
+
+
+ public static String DeleteTermBaseOperation_CANNOT_DELETE_VOC;
+
+
+ public static String DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE;
+
+
+ public static String DeleteTermBaseOperation_DELETE_FAILED;
+
+
+ public static String DeleteTermBaseOperation_SYSTEM_TERM;
+
+
+ public static String DeleteTermBaseOperation_SYSTEM_VOC;
+
+
+ public static String DeleteTermBaseOperation_TERM_INCLUDES_OTHERS;
+
+
+ public static String DeleteTermBaseOperation_TERM_INLCUDES;
+
+
+ public static String DeleteTermBaseOperation_VOC_NOT_EMPTY;
+
+
+ public static String NewGrantedAuthority_AlreadyInDb;
public static String SetSecundumConfiguration_IncludeAcceptedTaxa;
public static String SetSecundumConfiguration_IncludeSynonyms;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
index 3b63d006c..b43d3f4d5 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
@@ -162,6 +162,15 @@ DeleteConfiguration_media_deleteIfUsedSomeWhereElse=Delete the media also if it
DeleteConfiguration_media_delete=Remove the media from the image gallery and delete the media completely, if possible
DeleteResultMessagingUtils_ABORT=Delete was aborted
DeleteResultMessagingUtils_SUCCES=Delete was successful
+DeleteTermBaseOperation_CANNOT_DELETE_TERM=Cannot delete defined term
+DeleteTermBaseOperation_CANNOT_DELETE_VOC=Cannot delete vocabulary
+DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE=Delete all terms from this vocaulary before deleting the vocabulary.
+DeleteTermBaseOperation_DELETE_FAILED=Delete failed
+DeleteTermBaseOperation_SYSTEM_TERM=This is a CDM system defined term
+DeleteTermBaseOperation_SYSTEM_VOC=This is a CDM system vocabulary
+DeleteTermBaseOperation_TERM_INCLUDES_OTHERS=This term includes other terms. Please delete the included terms before deleting this term.
+DeleteTermBaseOperation_TERM_INLCUDES=Term has included terms
+DeleteTermBaseOperation_VOC_NOT_EMPTY=Vocabulary not empty
NewGrantedAuthority_AlreadyInDb=The granted authority already exists.
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
index ac6cdac8e..2b9608cdd 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
@@ -162,6 +162,15 @@ DeleteConfiguration_media_deleteIfUsedSomeWhereElse=L
DeleteConfiguration_media_delete=Entferne die Mediendaten aus der Gallerie und lösche sie aus der Datenbank, wenn sie nicht anderweitig verwendet werden.
DeleteResultMessagingUtils_ABORT=Löschen wurde abgebrochen
DeleteResultMessagingUtils_SUCCES=Löschen war erfolgreich
+DeleteTermBaseOperation_CANNOT_DELETE_TERM=Term konnte nicht gelöscht werden
+DeleteTermBaseOperation_CANNOT_DELETE_VOC=Vokabular konnte nicht gelöscht werden
+DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE=Es müssen alle Terme dieses Vokabulars gelöscht werden, bevor das Vokabular gelöscht werden kann.
+DeleteTermBaseOperation_DELETE_FAILED=Löschen fehlgeschlagen
+DeleteTermBaseOperation_SYSTEM_TERM=Das ist ein CDM system-interner Term
+DeleteTermBaseOperation_SYSTEM_VOC=Das ist ein CDM system-internes Vokabular
+DeleteTermBaseOperation_TERM_INCLUDES_OTHERS=Der Term enthält weitere Terme. Es müssen zuerst alle enthaltenen Terme gelöscht werden.
+DeleteTermBaseOperation_TERM_INLCUDES=Der Term enthält weitere Terme
+DeleteTermBaseOperation_VOC_NOT_EMPTY=Vokabular ist nicht leer
NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
--
2.34.1