Project

General

Profile

« Previous | Next » 

Revision 44000ac1

Added by Katja Luther about 3 years ago

ref #9340: workflow for changing synonym to acc and acc to synonym

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java
10 10
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
11 11

  
12 12
import java.util.Set;
13
import java.util.UUID;
13 14

  
14 15
import javax.inject.Named;
15 16

  
......
33 34
import eu.etaxonomy.cdm.model.taxon.Synonym;
34 35
import eu.etaxonomy.cdm.model.taxon.Taxon;
35 36
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
37
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
36 38
import eu.etaxonomy.taxeditor.editor.EditorUtil;
37 39
import eu.etaxonomy.taxeditor.editor.e4.TaxonEditorInputE4;
38 40
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
39 41
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
40 42
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
41 43
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToAcceptedTaxonOperation;
44
import eu.etaxonomy.taxeditor.event.EventUtility;
45
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
42 46
import eu.etaxonomy.taxeditor.model.AbstractUtility;
43 47
import eu.etaxonomy.taxeditor.model.MessagingUtils;
44 48
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
......
104 108

  
105 109
			//compare parentSec and synSec and ask for handling.
106 110
			SecReferenceHandlingEnum secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
107
			Reference newSec = null;
111
			UUID newSecUuid = null;
108 112
			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
			    }
113

  
114
	            if ((parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
115
	                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message,
116
	                        new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select});
117
	                if (result == 2){
118
	                    Reference sec = ReferenceSelectionDialog.select(shell, null);
119
	                    newSecUuid = sec != null? sec.getUuid(): null;
120
	                }else if (result == 1){
121
	                    newSecUuid = parentSecRef != null? parentSecRef.getUuid(): null;
122
	                }else if (result == 0){
123
	                    newSecUuid = synSecRef != null? synSecRef.getUuid(): null;
124
	                }else{
125
	                    return ;
126
	                }
127

  
128
	            }
129
			    //			    String message = null;
130
//			    if (secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame)){
131
//			        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.";
132
//			    }else{
133
//			        message = "Please select the secundum reference for the new accepted taxon.";
134
//			    }
135
//
136
//			    int result = MessagingUtils.confirmDialog("Select secundum reference for accepted taxon", message, new String[]{"OK", "Cancel"});
137
//			    if (result == 0){
138
//			        newSec = ReferenceSelectionDialog.select(shell, null);
139
//			    }else{
140
//			        return;
141
//			    }
122 142

  
123 143
			}
124 144
			ChangeSynonymToAcceptedTaxonOperation operation = new ChangeSynonymToAcceptedTaxonOperation(Messages.ChangeSynonymToAcceptedTaxonHandler_CHANGE_SYN_TO_ACC_TAXON, EditorUtil.getUndoContext(),
125 145
					taxon, newParentNode, synonym, namesInGroup,
126
					newSec, secHandling,
146
					newSecUuid, secHandling,
127 147
					this, editor, editor.getEditorInput()); //$NON-NLS-1$
128 148

  
129 149
			AbstractUtility.executeOperation(operation, sync);
......
138 158

  
139 159
		editor.save(AbstractUtility.getMonitor());
140 160

  
141
		if (objectAffectedByOperation instanceof TaxonNode) {
142 161

  
143
			// Open new unsaved editor with existing taxon's parent as temporary parent
162
		if (objectAffectedByOperation instanceof TaxonNode) {
144 163
			TaxonNode newNode = (TaxonNode) objectAffectedByOperation;
145

  
146
			EditorUtil.openTaxonNodeE4(newNode.getUuid(), modelService, partService, application);
164
			EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(newNode));
165
//			EditorUtil.openTaxonNodeE4(newNode.getUuid(), modelService, partService, application);
147 166
		}
148 167
		return true;
149 168
	}

Also available in: Unified diff