Project

General

Profile

Revision b0ad8fba

IDb0ad8fbaf40bc2c7ef602fcb9bdda6e9afed36f6
Parent 4d231867
Child b32ea08b

Added by Patrick Plitzner almost 2 years ago

i18n + code clean up

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
14 14
import org.eclipse.core.runtime.IProgressMonitor;
15 15
import org.eclipse.core.runtime.IStatus;
16 16
import org.eclipse.core.runtime.Status;
17
import org.eclipse.jface.dialogs.MessageDialog;
18 17

  
19 18
import eu.etaxonomy.cdm.api.service.DeleteResult;
20 19
import eu.etaxonomy.cdm.api.service.ITermService;
......
23 22
import eu.etaxonomy.cdm.model.common.TermBase;
24 23
import eu.etaxonomy.cdm.model.common.TermVocabulary;
25 24
import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
25
import eu.etaxonomy.taxeditor.l10n.Messages;
26 26
import eu.etaxonomy.taxeditor.model.MessagingUtils;
27 27
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
28 28
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
55 55
			throws ExecutionException {
56 56
		if (termBase instanceof TermVocabulary) {
57 57
			if (((TermVocabulary)termBase).getCreatedBy() == null) {
58
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This is a CDM system vocabulary");
59
				MessagingUtils.warningDialog("Cannot delete vocabulary", termBase, status);
58
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_SYSTEM_VOC);
59
				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_CANNOT_DELETE_VOC, termBase, status);
60 60
				return status;
61 61
			}
62 62

  
63 63
			if (!((TermVocabulary)termBase).getTerms().isEmpty()) {
64
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "Delete all terms from this vocaulary before deleting the vocabulary.");
65
				MessagingUtils.warningDialog("Vocabulary not empty", termBase, status);
64
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE);
65
				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_VOC_NOT_EMPTY, termBase, status);
66 66
				return status;
67 67
			}
68 68

  
......
70 70

  
71 71
			DeleteResult result =	CdmStore.getService(IVocabularyService.class).delete(termBase.getUuid());
72 72
			if (!result.isOk()){
73
                StringBuffer errorString = new StringBuffer();
74
                for (Exception e:result.getExceptions()){
75
                    errorString.append(e.getMessage() + System.lineSeparator());
76
                }
77
                if (result.isAbort()){
78
                    MessageDialog.openWarning(null, "Delete failed", errorString.toString());
79
                }else{
80
                    if (result.getExceptions().iterator().hasNext()){
81
                        MessagingUtils.errorDialog("Delete failed", this.getClass(),null, TaxeditorStorePlugin.PLUGIN_ID, result.getExceptions().iterator().next(), true);
82
                    }else{
83
                        MessageDialog.openWarning(null, "Delete failed", errorString.toString());
84
                    }
85
                }
86
            }
73
			    return showErrorMessage(result);
74
			}
87 75

  
88 76
		} else if (termBase instanceof DefinedTermBase) {
89 77

  
......
91 79
			DefinedTermBase definedTermBase = (DefinedTermBase) termBase;
92 80

  
93 81
			if (((DefinedTermBase)termBase).getCreatedBy() == null) {
94
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This is a CDM system defined term");
95
				MessagingUtils.warningDialog("Cannot delete defined term", termBase, status);
82
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_SYSTEM_TERM);
83
				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_CANNOT_DELETE_TERM, termBase, status);
96 84
				return status;
97 85
			}
98 86
			if(!definedTermBase.getIncludes().isEmpty()){
99
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), "This term includes other terms. Please delete the included terms before deleting this term.");
100
				MessagingUtils.warningDialog("Term has included terms", termBase, status);
87
				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_TERM_INCLUDES_OTHERS);
88
				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_TERM_INLCUDES, termBase, status);
101 89
				return status;
102 90
			}
103 91

  
104 92
			DeleteResult result =	CdmStore.getService(ITermService.class).delete(termBase.getUuid());
105

  
106 93
			if (!result.isOk()){
107
                StringBuffer errorString = new StringBuffer();
108
                for (Exception e:result.getExceptions()){
109
                    errorString.append(e.getMessage() + System.lineSeparator());
110
                }
111
                if (result.isAbort()){
112
                    MessageDialog.openWarning(null, "Delete failed", errorString.toString());
113
                }else{
114
                    if (result.getExceptions().iterator().hasNext()){
115
                        MessagingUtils.errorDialog("Delete failed", this.getClass(),null, TaxeditorStorePlugin.PLUGIN_ID, result.getExceptions().iterator().next(), true);
116
                    }else{
117
                        MessageDialog.openWarning(null, "Delete failed", errorString.toString());
118
                    }
119
                }
94
			    return showErrorMessage(result);
120 95
            }
121 96
		}
122 97

  
123 98
		return postExecute(termBase);
124 99
	}
125 100

  
126
	@Override
101
	private IStatus showErrorMessage(DeleteResult result) {
102
	    StringBuffer errorString = new StringBuffer();
103
        for (Exception e:result.getExceptions()){
104
            errorString.append(e.getMessage() + System.lineSeparator());
105
        }
106
        IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), errorString.toString());
107
        String delete_failed = Messages.DeleteTermBaseOperation_DELETE_FAILED;
108
        if (result.isAbort()){
109
            MessagingUtils.warningDialog(delete_failed, this, status);
110
        }else{
111
            if (result.getExceptions().iterator().hasNext()){
112
                MessagingUtils.errorDialog(delete_failed, this.getClass(),null, TaxeditorStorePlugin.PLUGIN_ID, result.getExceptions().iterator().next(), true);
113
            }else{
114
                MessagingUtils.warningDialog(delete_failed, this, status);
115
            }
116
        }
117
        return status;
118
    }
119

  
120
    @Override
127 121
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
128 122
			throws ExecutionException {
129
		// TODO Auto-generated method stub
130 123
		return null;
131 124
	}
132 125

  
133 126
	@Override
134 127
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
135 128
			throws ExecutionException {
136
		// TODO Auto-generated method stub
137 129
		return null;
138 130
	}
139 131

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
208 208

  
209 209

  
210 210
    public static String DeleteResultMessagingUtils_SUCCES;
211
	public static String NewGrantedAuthority_AlreadyInDb;
211
	public static String DeleteTermBaseOperation_CANNOT_DELETE_TERM;
212

  
213

  
214
    public static String DeleteTermBaseOperation_CANNOT_DELETE_VOC;
215

  
216

  
217
    public static String DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE;
218

  
219

  
220
    public static String DeleteTermBaseOperation_DELETE_FAILED;
221

  
222

  
223
    public static String DeleteTermBaseOperation_SYSTEM_TERM;
224

  
225

  
226
    public static String DeleteTermBaseOperation_SYSTEM_VOC;
227

  
228

  
229
    public static String DeleteTermBaseOperation_TERM_INCLUDES_OTHERS;
230

  
231

  
232
    public static String DeleteTermBaseOperation_TERM_INLCUDES;
233

  
234

  
235
    public static String DeleteTermBaseOperation_VOC_NOT_EMPTY;
236

  
237

  
238
    public static String NewGrantedAuthority_AlreadyInDb;
212 239

  
213 240
    public static String SetSecundumConfiguration_IncludeAcceptedTaxa;
214 241
    public static String SetSecundumConfiguration_IncludeSynonyms;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
162 162
DeleteConfiguration_media_delete=Remove the media from the image gallery and delete the media completely, if possible
163 163
DeleteResultMessagingUtils_ABORT=Delete was aborted
164 164
DeleteResultMessagingUtils_SUCCES=Delete was successful
165
DeleteTermBaseOperation_CANNOT_DELETE_TERM=Cannot delete defined term
166
DeleteTermBaseOperation_CANNOT_DELETE_VOC=Cannot delete vocabulary
167
DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE=Delete all terms from this vocaulary before deleting the vocabulary.
168
DeleteTermBaseOperation_DELETE_FAILED=Delete failed
169
DeleteTermBaseOperation_SYSTEM_TERM=This is a CDM system defined term
170
DeleteTermBaseOperation_SYSTEM_VOC=This is a CDM system vocabulary
171
DeleteTermBaseOperation_TERM_INCLUDES_OTHERS=This term includes other terms. Please delete the included terms before deleting this term.
172
DeleteTermBaseOperation_TERM_INLCUDES=Term has included terms
173
DeleteTermBaseOperation_VOC_NOT_EMPTY=Vocabulary not empty
165 174

  
166 175
NewGrantedAuthority_AlreadyInDb=The granted authority already exists.
167 176

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
162 162
DeleteConfiguration_media_delete=Entferne die Mediendaten aus der Gallerie und l?sche sie aus der Datenbank, wenn sie nicht anderweitig verwendet werden.
163 163
DeleteResultMessagingUtils_ABORT=L?schen wurde abgebrochen
164 164
DeleteResultMessagingUtils_SUCCES=L?schen war erfolgreich
165
DeleteTermBaseOperation_CANNOT_DELETE_TERM=Term konnte nicht gel?scht werden
166
DeleteTermBaseOperation_CANNOT_DELETE_VOC=Vokabular konnte nicht gel?scht werden
167
DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE=Es m?ssen alle Terme dieses Vokabulars gel?scht werden, bevor das Vokabular gel?scht werden kann.
168
DeleteTermBaseOperation_DELETE_FAILED=L?schen fehlgeschlagen
169
DeleteTermBaseOperation_SYSTEM_TERM=Das ist ein CDM system-interner Term
170
DeleteTermBaseOperation_SYSTEM_VOC=Das ist ein CDM system-internes Vokabular
171
DeleteTermBaseOperation_TERM_INCLUDES_OTHERS=Der Term enth?lt weitere Terme. Es m?ssen zuerst alle enthaltenen Terme gel?scht werden.
172
DeleteTermBaseOperation_TERM_INLCUDES=Der Term enth?lt weitere Terme
173
DeleteTermBaseOperation_VOC_NOT_EMPTY=Vokabular ist nicht leer
165 174

  
166 175
NewGrantedAuthority_AlreadyInDb=Die GrantedAuthority ist bereits in der DB enthalten.
167 176

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)