Project

General

Profile

« Previous | Next » 

Revision 32504fef

Added by Katja Luther over 6 years ago

dialog to avoid lost data while change nc

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/NonViralNameDetailElement.java
17 17
import eu.etaxonomy.cdm.model.name.INonViralName;
18 18
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19 19
import eu.etaxonomy.cdm.model.name.TaxonName;
20
import eu.etaxonomy.taxeditor.l10n.Messages;
21
import eu.etaxonomy.taxeditor.model.MessagingUtils;
20 22
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
21 23
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22 24
import eu.etaxonomy.taxeditor.ui.combo.EnumComboElement;
......
186 188
		} else if(eventSource==textLsid){
187 189
		    getEntity().setLsid(textLsid.parseText());
188 190
		} else if (eventSource == combo_nomenclaturalCode){
189
			getEntity().setNameType(combo_nomenclaturalCode.getSelection());
190
			this.updateContent();
191
			section_hybrid.setEntity(getEntity());
192
			section_author.setEntity(getEntity());
193
			section_name.setEntity(getEntity());
191
			boolean change = checkForDeletableParts(combo_nomenclaturalCode.getSelection());
192
			if (change){
193
				getEntity().setNameType(combo_nomenclaturalCode.getSelection());
194
				
195
				this.updateContent();
196
				section_hybrid.setEntity(getEntity());
197
				section_author.setEntity(getEntity());
198
				section_name.setEntity(getEntity());
199
			}else{
200
				combo_nomenclaturalCode.setSelection(getEntity().getNameType());
201
			}
194 202
		} else if(eventSource == this.text_nameApprobation){
195 203
            ((IBacterialName)getEntity()).setNameApprobation(text_nameApprobation.getText());
196 204
        }
197 205
	}
206
	private boolean checkForDeletableParts(NomenclaturalCode selection) {
207
		NomenclaturalCode actualCode =  getEntity().getNameType();
208
		if (selection.equals(actualCode)){
209
			return true;
210
		}
211
		if (actualCode.equals(NomenclaturalCode.ICZN) ){
212
			if(getEntity().getOriginalPublicationYear() != null || getEntity().getPublicationYear() != null || getEntity().getBreed() != null){
213
				if (MessagingUtils.confirmDialog(Messages.NonViralNameDetails_confirmDeleteOfZoologicalNameParts, Messages.NonViralNameDetails_descriptionDeleteZoologicalNameParts)){
214
					getEntity().setOriginalPublicationYear(null);
215
					getEntity().setPublicationYear(null);
216
					getEntity().setBreed(null);
217
					return true;
218
				}
219
			}else {
220
				return true;
221
			}
222
			
223
		}
224
		if (actualCode.equals(NomenclaturalCode.ICNB)){
225
			if (getEntity().getNameApprobation() != null){
226
				if (MessagingUtils.confirmDialog(Messages.NonViralNameDetails_confirmDeleteOfBacterialNameParts, Messages.NonViralNameDetails_desciptionDeleteOfBacterialNameParts)){
227
					getEntity().setNameApprobation(null);
228
					return true;
229
				}
230
			}else{
231
				return true;
232
			}
233
			
234
		}
235
		if (actualCode.equals(NomenclaturalCode.Fungi)){
236
			if (!getEntity().isAnamorphic() ){
237
				if (MessagingUtils.confirmDialog(Messages.NonViralNameDetails_confirmDeleteOfFungiNameParts, Messages.NonViralNameDetails_descriptionDeleteOfFungiNameParts)){
238
					getEntity().setAnamorphic(false);
239
					return true;
240
				}
241
			}else{
242
				return true;
243
			}
244
		}
245
		if (actualCode.equals(NomenclaturalCode.ICNCP)){
246
			if (getEntity().getCultivarName() != null){
247
				if (MessagingUtils.confirmDialog(Messages.NonViralNameDetails_confirmDeleteOfCultivarNameParts, Messages.NonViralNameDetails_descriptionDeleteOfCultivarNameParts)){
248
					getEntity().setCultivarName(null);
249
					return true;
250
				}
251
			}else{
252
				return true;
253
			}
254
			
255
		}
256
		if (actualCode.equals(NomenclaturalCode.ICNAFP)){
257
			return true;
258
		}
259
		return false;
260
	}
261

  
198 262
	@Override
199 263
	protected void handleToggleableCacheField() {
200 264
        boolean pushedState = toggleable_cache.getState();

Also available in: Unified diff