Project

General

Profile

« Previous | Next » 

Revision 299adb56

Added by Katja Luther about 3 years ago

ref #9340: secundum ref workflow for synonym to taxon

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java
26 26
import org.eclipse.jface.viewers.IStructuredSelection;
27 27
import org.eclipse.swt.widgets.Shell;
28 28

  
29
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
29 30
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
30 31
import eu.etaxonomy.cdm.model.name.TaxonName;
32
import eu.etaxonomy.cdm.model.reference.Reference;
31 33
import eu.etaxonomy.cdm.model.taxon.Synonym;
32 34
import eu.etaxonomy.cdm.model.taxon.Taxon;
33 35
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
38 40
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
39 41
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToAcceptedTaxonOperation;
40 42
import eu.etaxonomy.taxeditor.model.AbstractUtility;
43
import eu.etaxonomy.taxeditor.model.MessagingUtils;
41 44
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
45
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
46
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
42 47
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
43 48

  
44 49
/**
......
75 80
		}
76 81

  
77 82
		Synonym synonym = (Synonym) selection.getFirstElement();
83
		Reference synSecRef = synonym.getSec();
78 84

  
79 85
		// Force user to save taxon - not really necessary though, is it?
80 86
		if (!EditorUtil.forceUserSaveE4Editor(editor, shell)) {
......
87 93
		TaxonNode newParentNode = TaxonNodeSelectionDialog.select(shell,// editor.getConversationHolder(),
88 94
		        Messages.ChangeSynonymToAcceptedTaxonHandler_SELECT_PARENT, null, null, input.getTaxonNode().getClassification().getUuid(), true);
89 95

  
90

  
96
		Reference parentSecRef = newParentNode.getTaxon() != null? newParentNode.getTaxon().getSec(): null;
91 97
		if(newParentNode != null){
92 98

  
93 99
			// TODO get synonyms from homotypical group and add them as homotypic synonyms to new accepted taxon
......
95 101
			HomotypicalGroup group = synonym.getHomotypicGroup();
96 102
			Set<TaxonName> namesInGroup = group.getTypifiedNames();
97 103
			// FIXME with this implementation we can not create a taxonNode that is a direct child of the classification node
104

  
105
			//compare parentSec and synSec and ask for handling.
106
			SecReferenceHandlingEnum secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
107
			Reference newSec = null;
108
			if ((synSecRef != parentSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
109
			    String message = null;
110
			    if (secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame)){
111
			        message = "The secundum reference of the former synonym is not the same as the secundum of the new parent, therefore please select the secundum reference for the new accepted taxon.";
112
			    }else{
113
			        message = "Please select the secundum reference for the new accepted taxon.";
114
			    }
115

  
116
			    int result = MessagingUtils.confirmDialog("Select secundum reference for accepted taxon", message, new String[]{"OK", "Cancel"});
117
			    if (result == 0){
118
			        newSec = ReferenceSelectionDialog.select(shell, null);
119
			    }else{
120
			        return;
121
			    }
122

  
123
			}
98 124
			ChangeSynonymToAcceptedTaxonOperation operation = new ChangeSynonymToAcceptedTaxonOperation(Messages.ChangeSynonymToAcceptedTaxonHandler_CHANGE_SYN_TO_ACC_TAXON, EditorUtil.getUndoContext(),
99
					taxon, newParentNode, synonym, namesInGroup, this, editor, editor.getEditorInput()); //$NON-NLS-1$
125
					taxon, newParentNode, synonym, namesInGroup,
126
					newSec, secHandling,
127
					this, editor, editor.getEditorInput()); //$NON-NLS-1$
100 128

  
101 129
			AbstractUtility.executeOperation(operation, sync);
102 130
		}

Also available in: Unified diff