Project

General

Profile

Revision f13ee832

IDf13ee83283d374d07509fa7de1e9c893395a8fa2
Parent 25429db9
Child f07a4d44

Added by Katja Luther 4 months ago

ref #9340, #9734, #9668: further improvements for configurable sec handling during taxon(base) operations

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java
36 36
    public static String ChangeSynonymToAcceptedTaxonOperation_DifferentSec_Message;
37 37
    public static String ChangeSynonymToAcceptedHandler_Different_Publish_Flag;
38 38
    public static String SwapSynonymToAcceptedHandler_Different_Publish_Flag;
39
    public static String SwapSynonymToAcceptedHandler_Delete_Secundum;
39 40
    public static String CharacterEditor_CANNOT_PERFORM_MESSAGE;
40 41
    public static String CharacterEditor_CANNOT_PERFORM_TITLE;
41 42
    public static String CharacterEditor_CANNOT_PERFORM_RATIO_TO_MESSAGE;
......
328 329
    public static String CharacterMatrix_ONLY_REMOVE;
329 330
    public static String CharacterMatrix_DELETE_DESCRIPTION;
330 331
    public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message;
332
    public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message_always_select;
331 333
    public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title;
332 334
    public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent;
333 335
    public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select;
334 336
    public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep;
337
    public static String ChangeSynonymToAcceptedHandler_Different_Secundum_references;
335 338
    public static String MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message;
339
    public static String SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Delete;
340
    public static String SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Select;
341
    public static String SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Taxon;
342
    public static String SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Synonym;
343
    public static String SecundumReference;
336 344

  
337 345

  
338 346
    static {
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
180 180
MoveSynonymToAnotherAcceptedTaxonHandler_Different_Publish_Flag=The new accepted taxon and the synonym have different pubish flags. Maybe one of them should be adapted.
181 181
SwapSynonymAndAcceptedHandler_COULD_NOT_OPEN=Could not open editor for taxon
182 182
SwapSynonymAndAcceptedOperation_DIFFERENT_PUBLISH=The accepted taxon and the synonym have different pubish flags. Maybe one of them should be adapted.
183
SwapSynonymToAcceptedHandler_Delete_Secundum=The secundum references will be removed from taxon and synonym.
184
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Delete=Remove secundum references
185
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Select=Select secundum references
186
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Taxon=Select secundum reference for new accepted taxon
187
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Synonym=Select secundum reference for new synonym
183 188
ChangeConceptRelationshipTypeOperation_NOT_IMPLEMENTED=Not implemented yet. See developer documentation for details
184 189
ChangeConceptToSynonymOperation_MULTI_REPS=Multiple relations between taxa
185 190
ChangeConceptToSynonymOperation_MULTI_REPS_MESSAGE=There are multiple relations between the accepted and the related taxon. This case is not handled by the software yet.
......
306 311
DeleteDescriptiveDatasetHandler_Warning_Message=Deletion was successful but with warnings. 
307 312
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title=Select secundum reference
308 313
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message=The secundum reference of the selected parent taxon is different to the secundum of the synonym. Please select which secundum should be used for the accepted taxon.
314
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message_always_select=Please select which secundum should be used for the accepted taxon
309 315
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent=Parent secundum
310 316
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select=Select new
311 317
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep=Keep secundum
312 318
ChangeSynonymToAcceptedHandler_Different_Publish_Flag=The selected parent taxon and the new taxon have different publish flags. Maybe one of them should be adapted.
319
ChangeSynonymToAcceptedHandler_Different_Secundum_references=The selected parent taxon and the new taxon have different secundum references. Maybe this should be adapted.
313 320
SwapSynonymToAcceptedHandler_Different_Publish_Flag=The selected parent taxon, the new taxon and the new synonym have different publish flags. Maybe one of them should be adapted.
314
MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message= Secundum reference of synonym (or synonyms of the homotypic group) and new accepted taxon are different. Please select the reference used as secundum.
321
MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message= Secundum reference of synonym (or synonyms of the homotypic group) and new accepted taxon are different. Please select the reference used as secundum.
322
SecundumReference=Secundum reference
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties
179 179
MoveSynonymToAnotherAcceptedTaxonHandler_Different_Publish_Flag=Das neue akzeptierte Taxon und das Synonym haben unterschiedliche Publikationsstatus. Eventuell sollten sie angepasst werden.
180 180
SwapSynonymAndAcceptedHandler_COULD_NOT_OPEN=Konnte Editor f?r Taxon nicht ?ffnen
181 181
SwapSynonymAndAcceptedOperation_DIFFERENT_PUBLISH=Das akzeptierte Taxon und das Synonym haben unterschiedliche Publikationsstatus. Eventuell sollten sie angepasst werden.
182
SwapSynonymToAcceptedHandler_Delete_Secundum=Die Secundum Referenzen werden von Taxon und Synonym entfernt. 
183
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Delete=Entferne die Secundum Referenzen
184
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Select=Auswahl der Secundum Referenzen
185
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Taxon=Auswahl der Secundum Referenz des neuen akzeptierten Taxons
186
SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Synonym=Auswahl der Secundum Referenz des neuen Synonyms
182 187
ChangeConceptRelationshipTypeOperation_NOT_IMPLEMENTED=Noch nicht implementiert. F?r Details bitte in die Entwickler-Dokumentation schauen
183 188
ChangeConceptToSynonymOperation_MULTI_REPS=Mehrere Verkn?pfungen zwischen Taxa
184 189
ChangeConceptToSynonymOperation_MULTI_REPS_MESSAGE=Es gibt mehrere Verkn?pfungen zwischen dem akzeptierten und dem verkn?pften Taxon. Dieser Fall wird noch nicht von der Software unterst?tzt.
......
304 309
DeleteDescriptiveDatasetHandler_Exception_Message=Das Descriptive Dataset konnte nicht gel?scht werden.
305 310
DeleteDescriptiveDatasetHandler_Warning_Message=Das L?schen war erfolgreich, es gibt aber Warnungen.
306 311
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message=Die Secundum Referenzen des gew?hlten Elterntaxons und des Synonyms unterscheiden sich. Bitte w?hlen Sie welche Secundum Referenz f?r das neue akzeptierte Taxon verwendet werden soll
312
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message_always_select=Bitte w?hlen Sie welche Secundum Referenz f?r das neue akzeptierte Taxon verwendet werden soll
307 313
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title=Auswahl der Secundum Referenz
308 314
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent=Eltern Secundum
309 315
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select=Neue ausw?hlen
310 316
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep=Secundum beibehalten
311 317
ChangeSynonymToAcceptedHandler_Different_Publish_Flag=Das gew?hlte Elterntaxon und das neue Taxon haben unterschiedliche Publikationsstatus. Eventuell sollten sie angepasst werden.
318
ChangeSynonymToAcceptedHandler_Different_Secundum_references=Das gew?hlte Elterntaxon und das neue Taxon haben unterschiedliche Secundum Referenzen. Eventuell sollten sie angepasst werden.
312 319
SwapSynonymToAcceptedHandler_Different_Publish_Flag=Das gew?hlte Elterntaxon, das neue Taxon und das Synonym haben unterschiedliche Publikationsstatus. Eventuell sollten sie angepasst werden.
313
MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message=Die Secundum Referenz des Synonyms oder der Synonyme der homotypischen Gruppe und des neuen akzeptierten Taxons unterscheiden sich, bitte w?hlen Sie, welche Referenz verwendet werden soll.
320
MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message=Die Secundum Referenz des Synonyms oder der Synonyme der homotypischen Gruppe und des neuen akzeptierten Taxons unterscheiden sich, bitte w?hlen Sie, welche Referenz verwendet werden soll.
321
SecundumReference=Secundum Referenzen
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/dnd/NameEditorDropTargetListenerE4.java
164 164
        UUID newSecUuid = null;
165 165
        SecReferenceHandlingEnum secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
166 166
        Reference parentSecRef = ((AbstractHomotypicalGroupContainerE4) target).getEditor().getTaxon() != null? ((AbstractHomotypicalGroupContainerE4) target).getEditor().getTaxon().getSec():null;
167
        if ((synSecRef != parentSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
167
        if ((synSecRef != parentSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn) )|| secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect)){
168 168

  
169
            if ((parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
169
            if ((parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn) )|| secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect)){
170 170
                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title, Messages.MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message,
171 171
                        new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select});
172 172
                if (result == 2){
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeSynonymToAcceptedTaxonHandlerE4.java
119 119
			//compare parentSec and synSec and ask for handling.
120 120
			SecReferenceHandlingEnum secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
121 121
			UUID newSecUuid = null;
122
			if (((synSecRef != parentSecRef || secRefs.size()>1)  && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
122
			if (((synSecRef != parentSecRef || secRefs.size()>1)  && (secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect) || secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn)))|| secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect)){
123

  
124
	            if (secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect) || secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect)){
125
	                String message = null;
126
	                String[] options = null;
127
	                if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) && synSecRef == parentSecRef){
128
	                    message = Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message_always_select;
129
	                    options = new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select};
130
	                }else {
131
	                    message = Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message;
132
	                    options = new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep,  Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent, };
133
	                }
134
	                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title, message, options);
123 135

  
124
	            if ((parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
125
	                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message,
126
	                        new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select});
136
//	                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message,
137
//	                        new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select});
127 138
	                if (result == 2){
128
	                    Reference sec = ReferenceSelectionDialog.select(shell, null);
129
	                    newSecUuid = sec != null? sec.getUuid(): null;
130
	                }else if (result == 1){
131 139
	                    newSecUuid = parentSecRef != null? parentSecRef.getUuid(): null;
140
	                }else if (result == 1){
141
	                    Reference sec = ReferenceSelectionDialog.select(shell, null);
142
                        newSecUuid = sec != null? sec.getUuid(): null;
132 143
	                }else if (result == 0){
133
	                    newSecUuid = null;
134
	                    secHandling = SecReferenceHandlingEnum.KeepAlways;
144
	                    secHandling = SecReferenceHandlingEnum.KeepOrWarn;
135 145
	                }else{
136 146
	                    return ;
137 147
	                }
138 148

  
139
	            }
149
	            }else if (parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn)){
150
	                MessagingUtils.warningDialog(Messages.SecundumReference,this, Messages.ChangeSynonymToAcceptedHandler_Different_Secundum_references);
140 151

  
152
	            }
141 153
			}
142 154
			if (synonym.isPublish() != newParentNode.getTaxon().isPublish()){
143 155
			    MessagingUtils.warningDialog("Publish flag",this, Messages.ChangeSynonymToAcceptedHandler_Different_Publish_Flag);
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/MoveSynonymToAnotherAcceptedTaxonHandlerE4.java
91 91

  
92 92
        Reference synSecRef = synonym.getSec();
93 93
        Reference parentSecRef = newParentNode.getTaxon() != null? newParentNode.getTaxon().getSec():null;
94
        if ((synSecRef != parentSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
94
        if ((synSecRef != parentSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn) )|| secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect)){
95 95

  
96
            if ((parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
96
            if ((parentSecRef != synSecRef && secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn) )|| secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect)){
97 97
                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title, Messages.MoveSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message,
98 98
                        new String[]{Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent, Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select});
99 99
                if (result == 2){
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/SwapSynonymAndAcceptedHandlerE4.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
10 10

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

  
11 15
import javax.inject.Named;
12 16

  
13 17
import org.eclipse.e4.core.di.annotations.CanExecute;
......
23 27
import org.eclipse.swt.widgets.Display;
24 28
import org.eclipse.swt.widgets.Shell;
25 29

  
30
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
31
import eu.etaxonomy.cdm.model.reference.Reference;
26 32
import eu.etaxonomy.cdm.model.taxon.Synonym;
27 33
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 34
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
37 43
import eu.etaxonomy.taxeditor.model.AbstractUtility;
38 44
import eu.etaxonomy.taxeditor.model.MessagingUtils;
39 45
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
46
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
47
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
40 48

  
41 49
/**
42 50
 * @author pplitzner
......
83 91
        if (synonym.isPublish() != editor.getTaxon().isPublish() || (isParentPublish != null && (isParentPublish.booleanValue() != synonym.isPublish() || isParentPublish.booleanValue() != synonym.isPublish()))){
84 92
            MessagingUtils.warningDialog("Publish flag", this, Messages.SwapSynonymToAcceptedHandler_Different_Publish_Flag);
85 93
        }
94

  
95
        Reference secRefAccepted = editor.getTaxon().getSec();
96
        Reference secRefSynonym = synonym.getSec();
97
        SecReferenceHandlingSwapEnum secHandling = PreferencesUtil.getSecReferenceHandlingSwapPreference();
98
        UUID newSecAcc = secRefAccepted != null? secRefAccepted.getUuid(): null;
99
        UUID newSecSyn = secRefSynonym != null? secRefSynonym.getUuid(): null;
100
        if (secHandling.equals(SecReferenceHandlingSwapEnum.AlwaysSelect) ||
101
                ((secHandling.equals(SecReferenceHandlingSwapEnum.KeepOrSelect) || secHandling.equals(SecReferenceHandlingSwapEnum.KeepOrWarn))
102
                        && (secRefAccepted != null && secRefSynonym != null &&!secRefAccepted.getUuid().equals(secRefSynonym.getUuid()))
103
                        || secRefAccepted != secRefSynonym)){
104
            if (secHandling.equals(SecReferenceHandlingSwapEnum.KeepOrWarn)){
105
                boolean doContinue = MessagingUtils.confirmDialog("Secundum Reference differ", Messages.ChangeSynonymToAcceptedHandler_Different_Secundum_references);
106
                if (!doContinue){
107
                   return;
108
                }
109
            }else{
110

  
111
                int result = MessagingUtils.confirmDialog(Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title,
112
                        Messages.ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message,
113
                        new String[]{Messages.SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Select, Messages.SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Delete});
114
                if (result == 0){
115
                    Set<Reference> oldSecs = new HashSet<>();
116
                    oldSecs.add(secRefAccepted);
117
                    oldSecs.add(secRefSynonym);
118
                    Reference sec = ReferenceSelectionDialog.select(shell, Messages.SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Taxon,null, oldSecs);
119
                    newSecAcc = sec != null? sec.getUuid(): null;
120
                    sec = ReferenceSelectionDialog.select(shell, Messages.SwapSynonymAndAcceptedHandler_Select_Sec_Reference_Synonym,null, oldSecs);
121
                    newSecSyn = sec != null? sec.getUuid(): null;
122
                } else if (result == 1){
123
                    newSecAcc = null;
124
                    newSecSyn = null;
125
                } else{
126
                    return ;
127
                }
128
            }
129
        }
130
        if (secHandling.equals(SecReferenceHandlingSwapEnum.AlwaysDelete)){
131
            boolean doContinue = MessagingUtils.confirmDialog("Secundum Reference Delete", Messages.SwapSynonymToAcceptedHandler_Delete_Secundum);
132
            if (!doContinue){
133
                return;
134
            }
135

  
136
            newSecAcc = null;
137
            newSecSyn = null;
138

  
139
        }
140

  
86 141
        SwapSynonymAndAcceptedOperation operation = new SwapSynonymAndAcceptedOperation(menuItem.getLocalizedLabel(),
87
                editor.getUndoContext(), editor.getTaxon(), synonym, this, editor.getEditorInput(), isSetNameInSource);
142
                editor.getUndoContext(), editor.getTaxon(), synonym, this, editor.getEditorInput(), isSetNameInSource, secHandling, newSecAcc, newSecSyn);
88 143

  
89 144
        AbstractUtility.executeOperation(operation, sync);
90 145
    }
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperation.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.editor.name.operation;
10 10

  
11
import java.util.ArrayList;
12
import java.util.HashSet;
13
import java.util.List;
14
import java.util.Set;
11
//=======
12
//import java.util.UUID;
13
//>>>>>>> Stashed changes
14
import java.util.UUID;
15 15

  
16 16
import org.eclipse.core.commands.ExecutionException;
17 17
import org.eclipse.core.commands.operations.IUndoContext;
......
21 21

  
22 22
import eu.etaxonomy.cdm.api.service.ITaxonService;
23 23
import eu.etaxonomy.cdm.api.service.UpdateResult;
24
import eu.etaxonomy.cdm.model.common.CdmBase;
25
import eu.etaxonomy.cdm.model.media.ExternalLink;
26
import eu.etaxonomy.cdm.model.reference.Reference;
24
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
25
//=======
26
//import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
27
//>>>>>>> Stashed changes
27 28
import eu.etaxonomy.cdm.model.taxon.Synonym;
28 29
import eu.etaxonomy.cdm.model.taxon.Taxon;
29
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
30 30
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
31 31
import eu.etaxonomy.taxeditor.model.MessagingUtils;
32 32
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
......
44 44

  
45 45
	private final Synonym synonym;
46 46

  
47
	private SecReferenceHandlingSwapEnum secHandling;
47 48
	private boolean setNameInSource;
48 49

  
50
	private UUID newSecAcc = null;
51
	private UUID newSecSyn = null;
52

  
49 53
	/**
50 54
	 * <p>Constructor for SwapSynonymAndAcceptedOperation.</p>
51 55
	 *
......
57 61
	 */
58 62
	public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext,
59 63
			Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled,
60
			ICdmEntitySessionEnabled cdmEntitySessionEnabled, boolean setNameInSource) {
64
			ICdmEntitySessionEnabled cdmEntitySessionEnabled, boolean setNameInSource, SecReferenceHandlingSwapEnum secHandling, UUID newSecAcc, UUID newSecSyn) {
61 65
		super(Messages.SwapSynonymAndAcceptedOperation_SWAP_SYN_ACC_TAXON, undoContext, taxon, postOperationEnabled, cdmEntitySessionEnabled);
62 66
		this.setNameInSource = setNameInSource;
67
		this.secHandling = secHandling;
63 68
		this.synonym = synonym;
69
		this.newSecAcc = newSecAcc;
70
		this.newSecSyn = newSecSyn;
64 71
	}
65 72

  
66 73
	@Override
......
68 75
			throws ExecutionException {
69 76

  
70 77
		monitor.worked(20);
71
		UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid(), setNameInSource, false);//TODO
78
/*<<<<<<< Updated upstream
79
//		UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid(), setNameInSource, false);//TODO
80
		UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid(), setNameInSource, false, secHandling, newSecAcc, newSecSyn);//TODO
72 81
		//note: without reload a multiple representations exceptions appears, not yet tested why
73 82
		Taxon newTaxon = (Taxon)CdmStore.getService(ITaxonService.class).load(result.getCdmEntity().getUuid());
74 83
		Synonym newSyn = null;
......
117 126
		List<TaxonBase> mergeList = new ArrayList<>();
118 127
		mergeList.add(newTaxon);
119 128
		mergeList.add(newSyn);
129
		*/
130
//=======
131
		UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid(), setNameInSource, false, secHandling, newSecAcc, newSecSyn);//TODO
132
//>>>>>>> Stashed changes
120 133

  
121
		CdmStore.getService(ITaxonService.class).merge(mergeList, true);
122 134
		monitor.worked(40);
123 135

  
124
		return postExecute(newTaxon);
136
		return postExecute(element);
125 137
	}
126 138

  
127 139
	@Override
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperationTest.java
17 17

  
18 18
import eu.etaxonomy.cdm.model.common.ICdmBase;
19 19
import eu.etaxonomy.cdm.model.description.TaxonDescription;
20
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
20 21
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
21 22
import eu.etaxonomy.cdm.model.name.INonViralName;
22 23
import eu.etaxonomy.cdm.model.name.TaxonNameFactory;
......
111 112
		taxon.addDescription(description);
112 113

  
113 114
		operation = new SwapSynonymAndAcceptedOperation
114
				(null, undoContext, taxon, oldHeterotypicSynonym, postOperation, cdmEntitySessionEnabled, true);
115
				(null, undoContext, taxon, oldHeterotypicSynonym, postOperation, cdmEntitySessionEnabled, true, SecReferenceHandlingSwapEnum.AlwaysDelete, null, null);
115 116
	}
116 117

  
117 118

  
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/Messages.java
95 95
    public static String RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP;
96 96
    public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title;
97 97
    public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message;
98
    public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message_always_select;
98 99
    public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep;
99 100
    public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent;
100 101
    public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select;
102
    public static String SecundumReference;
103
    public static String ChangeAcceptedTaxonToSynonymHandler_Different_Secundum_references;
101 104
    public static String RemotingChangeAcceptedTaxonToSynonym_warning_publish;
102 105
    public static String RemotingDeletePolytomousKeyOperation_DELETE_OP;
103 106
    public static String RemotingDeleteTaxonNodeHandler_NODE_DELETED;
......
188 191
    public static String TreeNodeDropAdapter_TARGET_NODE;
189 192
    public static String TreeNodeDropAdapter_UNSAVED_PARENT;
190 193
    public static String TreeNodeDropAdapter_UNSAVED_PARENT_MESSAGE;
194
    public static String TreeNodeDropAdapter_Select_Sec_Reference_Handling_message_always_select;
195
    public static String TreeNodeDropAdapter_Select_Sec_Reference_Handling_message;
196
    public static String TreeNodeDropAdapter_Select_Sec_Reference_Parent;
197

  
191 198
    public static String SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP;
192 199
    public static String TaxonNavigatorLabels_SET_PUBLISH_FOR_CHILDREN;
193 200
	public static String TaxonNavigatorLabels_ACCEPTED_TAXA_NEED_TO_BE_FROM_SAME_CLASSIFICATION;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/messages.properties
76 76
RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP=Change Accepted Taxon to Synonym operation
77 77
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title=Select secundum reference
78 78
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message=The secundum reference of the new and the old accepted taxa or the synonyms of the homotypical group are not the same. Please select which reference should be used for the new synonym
79
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message_always_select=Please select which reference should be used for the new synonym
79 80
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep=Keep
80 81
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent=From accepted taxon
81 82
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select=Select new
......
165 166
TreeNodeDropAdapter_TARGET_NODE=Target node
166 167
TreeNodeDropAdapter_UNSAVED_PARENT=Unsaved Parent Taxon
167 168
TreeNodeDropAdapter_UNSAVED_PARENT_MESSAGE=There are unsaved changes in the parent taxon. Please save first.
169
TreeNodeDropAdapter_Select_Sec_Reference_Handling_message_always_select=Please select which reference should be used for the moved taxon/taxa
170
TreeNodeDropAdapter_Select_Sec_Reference_Handling_message=The secundum reference of the new parent and/or the moved taxa are not the same. Please select which reference should be used for the moved taxa/taxon
171
TreeNodeDropAdapter_Select_Sec_Reference_Parent=From new parent
172

  
168 173
SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP=Change publish flag for all children
169 174
TaxonNavigatorLabels_SET_PUBLISH_FOR_CHILDREN=Change publish flag for all children
170 175
TaxonNavigatorLabels_SET_UNPLACED=Set unplaced flag for taxonnode(s)
......
172 177
YES=Yes
173 178
SetPublishFlagForSubtreeHandlerE4_UnsavedChanges=There are unsaved changes
174 179
SetPublishFlagForSubtreeHandlerE4_UnsavedChangesQuestion=There are changes, do you want to save them? \nIf you do not save, the changes may be overwritten.
180
SecundumReference=Secundum reference
181
ChangeAcceptedTaxonToSynonymHandler_Different_Secundum_references=The selected accepted taxon and the new synonym have different secundum references, maybe they should be adapted.
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/messages_de.properties
76 76
RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP=Akzeptiertes Taxon in Synonym umwandeln
77 77
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title=Auswahl der Secundum Referenz
78 78
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message=Die Secundum Referenzen des neuen und des alten akzeptierten Taxons oder der Synonyme der Homotypischen Gruppe unterscheiden sich, bitte w?hlen Sie welche Secundum Referenz f?r das neue Synonym verwendet werden soll
79
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message_always_select=Bitte w?hlen Sie welche Secundum Referenz f?r das neue Synonym verwendet werden soll.
79 80
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep=Beibehalten
80 81
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent=Vom akzeptierten Taxon
81 82
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select=Neue ausw?hlen
......
165 166
TreeNodeDropAdapter_TARGET_NODE=Zielknoten
166 167
TreeNodeDropAdapter_UNSAVED_PARENT=Ungespeichertes Eltern-Taxon
167 168
TreeNodeDropAdapter_UNSAVED_PARENT_MESSAGE=Es gibt ?nderungen in dem Eltern-Taxon. Bitte speichern Sie erst.
169
TreeNodeDropAdapter_Select_Sec_Reference_Handling_message_always_select=Bitte w?hlen Sie welche Secundum Referenz f?r das/die verschobene(n) Taxon/Taxa verwendet werden soll.
170
TreeNodeDropAdapter_Select_Sec_Reference_Handling_message=Die beteiligten Secundum Referenzen unterscheiden sich, bitte w?hlen Sie welche Referenz f?r die/das verschobene(n) Taxa/Taxon verwendet werden soll.
171
TreeNodeDropAdapter_Select_Sec_Reference_Parent=Vom neuen Parent
168 172

  
169 173
SetPublishForSubtreeOperation_CHANGE_PUBLISH_OP=Publish Flag f?r alle Kinder ?ndern
170 174
TaxonNavigatorLabels_SET_PUBLISH_FOR_CHILDREN=?ndere Publish Flag f?r alle Kinder
......
175 179

  
176 180
SetPublishFlagForSubtreeHandlerE4_UnsavedChanges=Es gibt ungespeicherte ?nderungen
177 181
SetPublishFlagForSubtreeHandlerE4_UnsavedChangesQuestion=Es gibt ?nderungen, wollen Sie diese speichern? \nWenn Sie nicht speichern, k?nnten diese ?nderungen verloren gehen.
182
SecundumReference=Secundum Referenz
183
ChangeAcceptedTaxonToSynonymHandler_Different_Secundum_references=Das ausgew?hlte akzeptierte Taxon und das neue Synonym haben unterschiedliche Secundum Referenzen, diese m?ssten eventuell angepasst werden.
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/TreeNodeDropAdapterE4.java
35 35
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
36 36
import eu.etaxonomy.cdm.api.service.UpdateResult;
37 37
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
38
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
38 39
import eu.etaxonomy.cdm.model.permission.CRUD;
40
import eu.etaxonomy.cdm.model.reference.Reference;
39 41
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
40 42
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
41 43
import eu.etaxonomy.taxeditor.event.EventUtility;
42 44
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
43 45
import eu.etaxonomy.taxeditor.model.AbstractUtility;
46
import eu.etaxonomy.taxeditor.model.MessagingUtils;
44 47
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
45 48
import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
46 49
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
47 50
import eu.etaxonomy.taxeditor.store.CdmStore;
51
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
48 52

  
49 53
/**
50 54
 * @author k.luther
......
67 71
    UpdateResult result;
68 72
    TaxonNodeDto targetITaxonTreeNode;
69 73
    HashSet<TaxonNodeDto> taxonNodes;
74
    SecReferenceHandlingEnum secHandling;
75
    UUID newSecUuid;
70 76
	public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator.dropassistant"; //$NON-NLS-1$
71 77

  
72 78
	private static final EnumSet<CRUD> UPDATE = EnumSet.of(CRUD.UPDATE);
......
186 192
	private boolean moveTaxon(Set<TaxonNodeDto> taxonNodes, TaxonNodeDto targetITaxonTreeNode) {
187 193
		Iterator<TaxonNodeDto> taxIterator = taxonNodes.iterator();
188 194
		this.targetITaxonTreeNode = targetITaxonTreeNode;
195
		UUID parentSecUuid = targetITaxonTreeNode.getSecUuid();
189 196
        Set<UUID> uuids = new HashSet<UUID>();
190 197
        TaxonNodeDto node = null;
191 198
        boolean targetIsPublish = targetITaxonTreeNode.isPublish();
192 199
        boolean isPublishEqual = true;
200
        Set<UUID> secReferences = new HashSet<>();
193 201
        while(taxIterator.hasNext()){
194 202
            node = taxIterator.next();
195 203
            uuids.add(node.getUuid());
196 204
            isPublishEqual &= targetIsPublish == node.isPublish();
205
            secReferences.add(node.getSecUuid());
197 206
        }
207

  
198 208
        if (!isPublishEqual){
199 209
            MessageDialog.openWarning(null, "Publish status differ", Messages.RemotingChangeAcceptedTaxonToSynonym_warning_publish);
200 210
        }
211
        secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
212
        newSecUuid = null;
213
        if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) || (secReferences.size() > 1 && secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect)) || (secReferences.size() == 1 && secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect) && !secReferences.contains(parentSecUuid))){
214
            //The moved nodes have different secundum references
215
            String message = null;
216
            String[] options = null;
217
            if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) && (parentSecUuid != null && secReferences.contains(parentSecUuid))){
218
                message = Messages.TreeNodeDropAdapter_Select_Sec_Reference_Handling_message_always_select;
219
                options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select};
220
            }else {
221
                message = Messages.TreeNodeDropAdapter_Select_Sec_Reference_Handling_message;
222
                options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep,  Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select, Messages.TreeNodeDropAdapter_Select_Sec_Reference_Parent, };
223
            }
224
            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, message, options);
225

  
226
//            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message,
227
//                    new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select});
228
            if (result == 1){
229
                //select new reference
230
                Reference sec = ReferenceSelectionDialog.select(AbstractUtility.getShell(), null);
231
                newSecUuid = sec != null? sec.getUuid(): null;
232
            }else if (result == 2){
233
                //use parent sec
234
                secHandling = SecReferenceHandlingEnum.UseNewParentSec;
235
                newSecUuid = parentSecUuid;
236
            }else if (result == 0){
237
                //keep sec (also homotypic synonyms with different sec will keep the secundum)
238
                secHandling = SecReferenceHandlingEnum.KeepOrWarn;
239
            }else{
240
                return false;
241
            }
242
        }
201 243

  
202 244
        IUndoContext workspaceUndoContext = taxonNavigator.getUndoContext();
203 245
         int movingTypeInt = 0;
......
230 272

  
231 273
	private void moveNodes(Set<UUID> taxonNodesToMoveUuid, UUID newParentTreeNodeUuid, int movingTypeInt){
232 274
	    UUID uuid = CdmApplicationState.getLongRunningTasksService().monitLongRunningTask(taxonNodesToMoveUuid,
233
                newParentTreeNodeUuid, movingTypeInt);
275
                newParentTreeNodeUuid, movingTypeInt, secHandling, newSecUuid);
234 276

  
235 277
        Display.getDefault().asyncExec(new Runnable() {
236 278
            @Override
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/ChangeAcceptedTaxonToSynonymHandlerE4.java
145 145

  
146 146
        SecReferenceHandlingEnum secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
147 147
        UUID newSecUuid = null;
148
        UUID newTaxonUuid = newAcceptedTaxonNode.getTaxon() != null && newAcceptedTaxonNode.getTaxon().getSec() != null ? newAcceptedTaxonNode.getTaxon().getSec().getUuid(): null;
148
        UUID newTaxonSecUuid = newAcceptedTaxonNode.getTaxon() != null && newAcceptedTaxonNode.getTaxon().getSec() != null ? newAcceptedTaxonNode.getTaxon().getSec().getUuid(): null;
149
        if (newTaxonSecUuid != null){
150
            secUuids.add(newTaxonSecUuid);
151
        }
149 152
        //the moved taxa have different secundum references
150
        if (secUuids.size() > 1 && !(secHandling.equals(SecReferenceHandlingEnum.KeepAlways) || secHandling.equals(SecReferenceHandlingEnum.AlwaysDelete))){
151
            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message,
152
                    new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select});
153
            if (result == 2){
153
        if (secUuids.size() > 1 && secHandling.equals(SecReferenceHandlingEnum.KeepOrWarn)){
154
            MessagingUtils.warningDialog(Messages.SecundumReference,this, Messages.ChangeAcceptedTaxonToSynonymHandler_Different_Secundum_references);
155
        }else if (secUuids.size() > 1 && !(secHandling.equals(SecReferenceHandlingEnum.AlwaysDelete) || secHandling.equals(SecReferenceHandlingEnum.UseNewParentSec))){
156
            String message = null;
157
            String[] options = null;
158
            if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) && (newTaxonSecUuid != null && secUuids.contains(newTaxonSecUuid))){
159
                message = Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message_always_select;
160
                options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select};
161
            }else {
162
                message = Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message;
163
                options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep,  Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, };
164
            }
165
            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, message, options);
166

  
167
//            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message,
168
//                    new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select});
169
            if (result == 1){
154 170
                //select new reference
155 171
                Reference sec = ReferenceSelectionDialog.select(shell, null);
156 172
                newSecUuid = sec != null? sec.getUuid(): null;
157
            }else if (result == 1){
173
            }else if (result == 2){
158 174
                //use parent sec
159
                newSecUuid = newTaxonUuid;
175
                newSecUuid = newTaxonSecUuid;
160 176
            }else if (result == 0){
161 177
                //keep sec (also homotypic synonyms with different sec will keep the secundum)
162
                secHandling = SecReferenceHandlingEnum.KeepAlways;
178
                secHandling = SecReferenceHandlingEnum.KeepOrWarn;
163 179
            }else{
164 180
                return null;
165 181
            }
......
167 183
            UUID oldSecUuid = secUuids.iterator().next();
168 184
            //the nodes moved have all the same sec, but the accepted taxon has a different one
169 185
            if ((secUuids.size() > 0 &&
170
                    ((newTaxonUuid != null && oldSecUuid != null && !newTaxonUuid.equals(oldSecUuid))
171
                            || (newTaxonUuid != null && oldSecUuid == null) ||(newTaxonUuid == null && oldSecUuid != null))
172
                    && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){
173
                int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message,
174
                        new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select});
186
                    ((newTaxonSecUuid != null && oldSecUuid != null && !newTaxonSecUuid.equals(oldSecUuid))
187
                            || (newTaxonSecUuid != null && oldSecUuid == null) ||(newTaxonSecUuid == null && oldSecUuid != null))
188
                    && secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect) )|| secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect)){
189
                String message = null;
190
                String[] options = null;
191
                // always select but all secundum references are the same
192
                if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) && (newTaxonSecUuid != null && secUuids.contains(newTaxonSecUuid))){
193
                    message = Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message_always_select;
194
                    options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select};
195
                }else {
196
                    message = Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message;
197
                    options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep,  Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, };
198
                }
199
                int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, message, options);
175 200
                if (result == 2){
201
                    newSecUuid = newTaxonSecUuid;
202
                }else if (result == 1){
176 203
                    Reference sec = ReferenceSelectionDialog.select(shell, null);
177 204
                    newSecUuid = sec != null? sec.getUuid(): null;
178
                }else if (result == 1){
179
                    newSecUuid = newTaxonUuid;
180 205
                }else if (result == 0){
181
                    secHandling = SecReferenceHandlingEnum.KeepAlways;
182

  
206
                    secHandling = SecReferenceHandlingEnum.KeepOrWarn;
183 207
                }else{
184 208
                    return null;
185 209
                }
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/MoveTaxonNodeHandlerE4.java
27 27
import org.eclipse.jface.viewers.TreeSelection;
28 28
import org.eclipse.swt.widgets.Shell;
29 29

  
30
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
31
import eu.etaxonomy.cdm.model.reference.Reference;
30 32
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
31 33
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
34
import eu.etaxonomy.taxeditor.model.AbstractUtility;
35
import eu.etaxonomy.taxeditor.model.MessagingUtils;
32 36
import eu.etaxonomy.taxeditor.navigation.NavigationUtil;
33 37
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
34 38
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels;
......
37 41
import eu.etaxonomy.taxeditor.navigation.navigator.operation.MoveTaxonOperation;
38 42
import eu.etaxonomy.taxeditor.operation.e4.CdmHandlerE4;
39 43
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
44
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog;
40 45
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
41 46

  
42 47
/**
......
50 55
    private TaxonNavigatorE4 navigator;
51 56
    private UUID classificationUuid = null;
52 57
    boolean isPublish = true;
58
    SecReferenceHandlingEnum secHandling;
59
    UUID newSecUuid;
60
    private Set<UUID> oldTaxonSecUUIDs = new HashSet<>();
53 61

  
54 62
    public MoveTaxonNodeHandlerE4() {
55 63
        super(TaxonNavigatorLabels.MOVE_TAXON_LABEL);
......
76 84
            obj = iter.next();
77 85
            if(obj instanceof TaxonNodeDto) {
78 86
                oldTaxonNodeUUIDs.add(((TaxonNodeDto)obj).getUuid());
87
                oldTaxonSecUUIDs.add(((TaxonNodeDto)obj).getSecUuid());
79 88
                isPublish &= ((TaxonNodeDto)obj).isPublish();
80 89
                if (classificationUuid == null){
81 90
                    classificationUuid = ((TaxonNodeDto)obj).getClassificationUUID();
......
126 135
                    Messages.RemotingMoveTaxonNodeHandler_DIFFERENT_PUBLISH_MESSAGE);
127 136
        }
128 137

  
138
        secHandling = PreferencesUtil.getSecReferenceHandlingPreference();
139
        newSecUuid = null;
140
        UUID parentTaxonSecUuid= parentTaxonNode.getTaxon() != null && parentTaxonNode.getTaxon().getSec() != null ? parentTaxonNode.getTaxon().getSec().getUuid(): null;
141
        if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) || (oldTaxonSecUUIDs.size() > 1 && secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect)) || (oldTaxonSecUUIDs.size() == 1 && secHandling.equals(SecReferenceHandlingEnum.KeepOrSelect) && !oldTaxonSecUUIDs.contains(parentTaxonSecUuid))){
142
            //The moved nodes have different secundum references
143
            String message = null;
144
            String[] options = null;
145
            if (secHandling.equals(SecReferenceHandlingEnum.AlwaysSelect) && (parentTaxonSecUuid != null && oldTaxonSecUUIDs.contains(parentTaxonSecUuid))){
146
                message = Messages.TreeNodeDropAdapter_Select_Sec_Reference_Handling_message_always_select;
147
                options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select};
148
            }else {
149
                message = Messages.TreeNodeDropAdapter_Select_Sec_Reference_Handling_message;
150
                options = new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep,  Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select, Messages.TreeNodeDropAdapter_Select_Sec_Reference_Parent, };
151
            }
152
            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, message, options);
153

  
154
//            int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message,
155
//                    new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select});
156
            if (result == 1){
157
                //select new reference
158
                Reference sec = ReferenceSelectionDialog.select(AbstractUtility.getShell(), null);
159
                newSecUuid = sec != null? sec.getUuid(): null;
160
            }else if (result == 2){
161
                //use parent sec
162
                secHandling = SecReferenceHandlingEnum.UseNewParentSec;
163
                newSecUuid = parentTaxonSecUuid;
164
            }else if (result == 0){
165
                //keep sec (also homotypic synonyms with different sec will keep the secundum)
166
                secHandling = SecReferenceHandlingEnum.KeepOrWarn;
167
            }else{
168
                return null;
169
            }
170
        }
171

  
129 172

  
130 173

  
131 174
        if(parentTaxonNode != null){
......
140 183
                    false,
141 184
                    oldTaxonNodeUUIDs,
142 185
                    parentTaxonNode.getUuid(),
143
                    moveToNewParent);
186
                    moveToNewParent,
187
                    secHandling,
188
                    newSecUuid);
144 189
        }
145 190

  
146 191
        return null;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/ChangeAcceptedTaxonToSynonymOperation.java
48 48
    private UUID secundumUuid;
49 49
    private boolean setNameInSource ;
50 50
    private SecReferenceHandlingEnum secHandling;
51
    private DeleteResult deleteResult;
51 52

  
52 53

  
53 54
    private final static String LABEL = Messages.RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP;
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/MoveTaxonOperation.java
20 20
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21 21
import eu.etaxonomy.cdm.api.service.UpdateResult;
22 22
import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
23
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
23 24
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
24 25
import eu.etaxonomy.taxeditor.event.EventUtility;
25 26
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
......
41 42
    private Set<UUID> taxonNodesToMoveUuid;
42 43
    private final UUID newParentTreeNodeUuid;
43 44
    private final MovingType moveToParentNode;
45
    private SecReferenceHandlingEnum secHandling;
46
    private UUID secUuid;
44 47

  
45 48
    public MoveTaxonOperation(Object source,
46 49
            boolean async,
47 50
            Set<UUID> taxonNodeToMoveUuid,
48 51
            UUID newParentTreeNodeUuid,
49
            MovingType moveToParentNode) {
52
            MovingType moveToParentNode,
53
            SecReferenceHandlingEnum secHandling,
54
            UUID secUuid) {
50 55
        super(LABEL, Action.Update, source,async);
51 56
        taxonNodesToMoveUuid = taxonNodeToMoveUuid;
52 57
        this.newParentTreeNodeUuid = newParentTreeNodeUuid;
53 58
        this.moveToParentNode = moveToParentNode;
59
        this.secHandling = secHandling;
60
        this.secUuid = secUuid;
54 61
    }
55 62

  
56 63
    @Override
......
73 80

  
74 81
        if (movingTypeInt >-1){
75 82
            uuid = CdmApplicationState.getLongRunningTasksService().monitLongRunningTask(taxonNodesToMoveUuid,
76
                newParentTreeNodeUuid, movingTypeInt);
83
                newParentTreeNodeUuid, movingTypeInt, secHandling, secUuid);
77 84

  
78 85
                Display.getDefault().asyncExec(()->{
79 86
                        AbstractUtility.executeMoniteredOperation("Move Taxon to new parent: ",
eu.etaxonomy.taxeditor.navigation/src/test/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/MoveTaxonOperationTest.java
17 17
import org.junit.BeforeClass;
18 18
import org.junit.Test;
19 19

  
20
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
20 21
import eu.etaxonomy.cdm.model.taxon.Classification;
21 22
import eu.etaxonomy.cdm.model.taxon.Taxon;
22 23
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
56 57
		Set<UUID> taxonNodeUuidSet = new HashSet<>();
57 58
		//TODO ??
58 59
		taxonNodeUuidSet.add(taxonNode.getUuid());
59
		navigatorOperation = new MoveTaxonOperation(null, true, taxonNodeUuidSet, newParentTaxonNode.getUuid(),  MovingType.CHILD);
60
		navigatorOperation = new MoveTaxonOperation(null, true, taxonNodeUuidSet, newParentTaxonNode.getUuid(),  MovingType.CHILD, SecReferenceHandlingEnum.KeepOrWarn, null);
60 61
	}
61 62

  
62 63
	/**
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SecundumReferenceHandlingAdmin.java
11 11
import eu.etaxonomy.cdm.api.application.ICdmRepository;
12 12
import eu.etaxonomy.cdm.api.service.IPreferenceService;
13 13
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
14
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
15
import eu.etaxonomy.taxeditor.l10n.Messages;
16 14
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
17 15
import eu.etaxonomy.taxeditor.preference.SecundumReferenceHandling;
18 16
import eu.etaxonomy.taxeditor.store.CdmStore;
......
26 24
    @Override
27 25
    public void init() {
28 26
        super.init();
29

  
27
        isAdminPreference = true;
30 28

  
31 29
    }
32 30

  
......
42 40
             return false;
43 41
         }
44 42
         IPreferenceService service = controller.getPreferenceService();
45
         String textCombo = synonymSecundumBehaviour.getText();
46
         String text = null;
43
//         String textCombo = synonymSecundumBehaviour.getText();
44
         String text = secundumBehaviour != null? secundumBehaviour.getKey(): null;
47 45
         // default -> delete preference
48
         if(textCombo.startsWith(Messages.Preference_Use_Default) && allowOverride){
46
         if(text == null && allowOverride){
49 47
             service.remove(pref.getKey());
50 48
             PreferencesUtil.updateDBPreferences();
51 49
             return true;
52
         }else if (textCombo.startsWith(Messages.Preference_Use_Default)){
53
             text = null;
54
         }else{
55
             for (SecReferenceHandlingEnum display: SecReferenceHandlingEnum.values()){
56
                 if (display.getLabel().equals(textCombo)){
57
                     text = display.getKey();
58
                     break;
59
                 }
60
             }
61 50
         }
51
//         }else if (textCombo.startsWith(Messages.Preference_Use_Default)){
52
//             text = null;
53
//         }else{
54
//             for (SecReferenceHandlingEnum display: SecReferenceHandlingEnum.values()){
55
//                 if (display.getLabel().equals(textCombo)){
56
//                     text = display.getKey();
57
//                     break;
58
//                 }
59
//             }
60
//         }
62 61
         CdmPreference preference = CdmPreference.NewInstance(pref.getKey(), text);
63 62
         preference.setAllowOverride(allowOverride);
64 63

  
65 64
         service.set(preference);
65

  
66
         text = secundumSwapBehaviour != null? secundumSwapBehaviour.getKey(): null;
67
         // default -> delete preference
68
         if(text == null && allowOverrideSwap){
69
             service.remove(prefSwap.getKey());
70
             PreferencesUtil.updateDBPreferences();
71
             return true;
72
         }
73

  
74
         CdmPreference preferenceSwap = CdmPreference.NewInstance(prefSwap.getKey(), text);
75
         preferenceSwap.setAllowOverride(allowOverrideSwap);
76

  
77
         service.set(preferenceSwap);
66 78
         PreferencesUtil.updateDBPreferences();
67 79

  
68 80
         return true;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/Messages.java
753 753
    public static String CdmLightPreference_distributionString_tooltip;
754 754

  
755 755
    public static String SecundumPreference_description;
756
    public static String SecundumPreferenceSwap_description;
756 757

  
757 758

  
758 759
    public static String Tree;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties
614 614
CdmLightPreference_distributionString=Export of condensed distribution string
615 615
CdmLightPreference_distributionString_tooltip=Distributions of a taxon are exported as condensed string, created by the selected algorithm. 
616 616

  
617
SecundumPreference_description=Default settings of secundum reference handling for change synonym to taxon and changing an taxon to synonym.
617
SecundumPreference_description=Default settings of secundum reference handling for moving synonym or taxon.
618
SecundumPreferenceSwap_description=Default settings of secundum reference handling for swap synonym and taxon.
618 619
Tree= Tree
619 620
Computed_factualData_handling_description=This preference defines whether computed factual data should be editable, disabled or not shown
620 621
FactualData_EnableComputedFactualData=Handling of computed factual data
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties
614 614
CdmLightPreference_distributionString=Export eines Condensed Distribution Strings
615 615
CdmLightPreference_distributionString_tooltip=F?r jedes Taxon wird aus den Verbreitungsdaten ein kompakter String exportiert, der entsprechend dem ausgew?hlten Algorithmus erzeugt wird.
616 616

  
617
SecundumPreference_description=Default Einstellungen f?r das Setzen der Secundum Referenz beim ?ndern eines Synonyms in ein Taxon und anders herum.
617
SecundumPreference_description=Default Einstellungen f?r das Setzen der Secundum Referenz beim Wechesel eines Synonyms zu einem akzeptierten Taxon oder umgekehrt.
618
SecundumPreferenceSwap_description=Default Einstellungen f?r das Setzen der Secundum Referenz beim Tauschen eines Synonyms mit dem akzeptierten Taxon.
618 619
Tree=-Baum
619 620
Computed_factualData_handling_description=Diese Einstellung gibt an, ob berechnete Faktendaten bearbeitbar, ausgeblendet oder nur angezeigt werden sollen.
620 621
FactualData_EnableComputedFactualData=Umgang mit berechneten Faktendaten
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
63 63
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
64 64
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
65 65
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
66
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
66 67
import eu.etaxonomy.cdm.model.metadata.TermDisplayEnum;
67 68
import eu.etaxonomy.cdm.model.metadata.TermOrder;
68 69
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
......
1854 1855
    }
1855 1856

  
1856 1857
    public static SecReferenceHandlingEnum getSecReferenceHandlingPreference(){
1858

  
1857 1859
        String defaultBehaviour = getStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey());
1858
        SecReferenceHandlingEnum handling = SecReferenceHandlingEnum.valueOf(defaultBehaviour);
1860
        SecReferenceHandlingEnum handling = null;
1861
        try{
1862
            handling = SecReferenceHandlingEnum.valueOf(defaultBehaviour);
1863
        }catch(IllegalArgumentException e){
1864
            handling = (SecReferenceHandlingEnum)PreferencePredicate.DefaultBehaviourForSecundum.getDefaultValue();
1865
        }
1866
        return handling;
1867

  
1868
    }
1869

  
1870
    public static SecReferenceHandlingSwapEnum getSecReferenceHandlingSwapPreference(){
1871
        String defaultBehaviour = getStringValue(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey());
1872
        SecReferenceHandlingSwapEnum handling = null;
1873
        try{
1874
            handling = SecReferenceHandlingSwapEnum.valueOf(defaultBehaviour);
1875
        }catch (IllegalArgumentException e){
1876
            handling = (SecReferenceHandlingSwapEnum)PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getDefaultValue();
1877
        }
1859 1878
        return handling;
1860 1879

  
1861 1880
    }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SecundumReferenceHandling.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.preference;
10 10

  
11
import org.eclipse.swt.SWT;
12
import org.eclipse.swt.custom.CLabel;
13 11
import org.eclipse.swt.events.SelectionAdapter;
14 12
import org.eclipse.swt.events.SelectionEvent;
15 13
import org.eclipse.swt.events.SelectionListener;
......
23 21
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
24 22
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
25 23
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
24
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
26 25
import eu.etaxonomy.taxeditor.l10n.Messages;
27 26
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
28 27

  
......
33 32
public class SecundumReferenceHandling extends CdmPreferencePage {
34 33

  
35 34
    protected SecReferenceHandlingEnum secundumBehaviour;
35
    protected SecReferenceHandlingSwapEnum secundumSwapBehaviour;
36

  
36 37

  
37 38
    protected Combo synonymSecundumBehaviour;
38 39
    protected CdmPreference pref = null;
......
41 42
    protected boolean allowOverride;
42 43
    private boolean override = true;
43 44

  
45
    protected Combo synonymSecundumSwapBehaviour;
46
    protected CdmPreference prefSwap = null;
47
    Button allowOverrideSwapButton;
48

  
49
    protected boolean allowOverrideSwap;
50
    private boolean overrideSwap = true;
51

  
44 52

  
45 53
   @Override
46 54
   public void init() {
47 55
       super.init();
56
       isAdminPreference = false;
48 57

  
49 58

  
50 59
   }
......
56 65
        getValues();
57 66

  
58 67
        Composite composite = createComposite(parent);
59

  
60
        if (!allowOverride && !isAdminPreference){
61
            final CLabel description = new CLabel(composite, SWT.NULL);
62
            description.setText(Messages.PublishFlagPreference_description_not_allowed);
63
            description.setLayoutData(createTextGridData());
64
            return composite;
65
        }
66

  
67 68
        synonymSecundumBehaviour = createCombo(composite, SecReferenceHandlingEnum.values(), PreferencePredicate.DefaultBehaviourForSecundum, Messages.SecundumPreference_description, isAdminPreference);
69

  
68 70
        synonymSecundumBehaviour.addSelectionListener(new SelectionListener() {
69 71

  
70 72
            @Override
......
78 80

  
79 81
            }
80 82

  
83

  
84

  
81 85
            @Override
82 86
            public void widgetDefaultSelected(SelectionEvent e) {
83 87
                // TODO Auto-generated method stub
......
109 113
                    index++;
110 114
                }
111 115
            }
116
            //swap secundum behaviour
117
            synonymSecundumSwapBehaviour = createCombo(composite, SecReferenceHandlingSwapEnum.values(), PreferencePredicate.DefaultBehaviourForSecundumWhenSwap, Messages.SecundumPreferenceSwap_description, isAdminPreference);
118

  
119
            synonymSecundumSwapBehaviour.addSelectionListener(new SelectionListener() {
120

  
121
                @Override
122
                public void widgetSelected(SelectionEvent e) {
123
                    setApply(true);
124
                    if (!synonymSecundumSwapBehaviour.getText().startsWith(Messages.Preference_Use_Default)){
125
                        secundumSwapBehaviour = (SecReferenceHandlingSwapEnum)synonymSecundumSwapBehaviour.getData(synonymSecundumSwapBehaviour.getText());
126
                    }else{
127
                        secundumSwapBehaviour = null;
128
                    }
129

  
130
                }
131

  
132
                @Override
133
                public void widgetDefaultSelected(SelectionEvent e) {
134
                    // TODO Auto-generated method stub
112 135

  
136
                    }
137
                });
138
                if (this.isAdminPreference){
139
                    allowOverrideSwapButton = createAllowOverrideButton(composite);
140
                    allowOverrideSwapButton.setSelection(allowOverrideSwap);
141
                    allowOverrideSwapButton.addSelectionListener(new SelectionAdapter(){
142
                        @Override
143
                        public void widgetSelected(SelectionEvent e) {
144
                            allowOverrideSwap = !allowOverrideSwap;
145
                            setApply(true);
146
                            }
147
                    });
148
                }
149
                index = 0;
150

  
151
                if(secundumSwapBehaviour==null){
152
                    synonymSecundumSwapBehaviour.select(0);
153
                }
154
                else{
155
                    for (String itemLabel : synonymSecundumSwapBehaviour.getItems()){
156
                        if (itemLabel.startsWith(secundumSwapBehaviour.getLabel())){
157
                            synonymSecundumSwapBehaviour.select(index);
158
                            break;
159
                        }
160
                        index++;
161
                    }
162
                }
163
                if (!allowOverride && !isAdminPreference){
164
                    synonymSecundumBehaviour.setEnabled(false);
165
                }
166
                if (!allowOverrideSwap && !isAdminPreference){
167
                    synonymSecundumSwapBehaviour.setEnabled(false);
168
                }
113 169
            return composite;
114 170

  
115 171
        }
......
119 175
        public boolean performOk() {
120 176
            if (isApply()){
121 177
                if (secundumBehaviour != null){
122
                    String text = synonymSecundumBehaviour.getText();
123
                    for (SecReferenceHandlingEnum display: SecReferenceHandlingEnum.values()){
124
                        if (text.startsWith(display.getLabel())){
125
                            text = display.getKey();
126
                            break;
127
                        }
128
                    }
178
                    String text = secundumBehaviour.getKey();
129 179
                    PreferencesUtil.setStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey(), text);
130 180
                    if (pref == null || !pref.getValue().equals(text)){
131 181
                        PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()), true);
......
133 183
                }else{
134 184
                    PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()), false);
135 185
                }
186

  
187
                //for swap operations
188
                if (secundumSwapBehaviour != null){
189
                    String text = secundumSwapBehaviour.getKey();
190
                    PreferencesUtil.setStringValue(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey(), text);
191
                    if (prefSwap == null || !prefSwap.getValue().equals(text)){
192
                        PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey()), true);
193
                    }
194
                }else{
195
                    PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey()), false);
196
                }
136 197
            }
137 198
            return true;
138 199
        }
......
140 201
        @Override
141 202
        public void getValues(){
142 203
            secundumBehaviour = null;
143
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewInstance("/MoveSynToAccepted/"), PreferencePredicate.DefaultBehaviourForSecundum);
204
            PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewInstance("/MoveSynOrAccepted/"), PreferencePredicate.DefaultBehaviourForSecundum);
144 205
            pref = PreferencesUtil.getPreferenceFromDB(key);
145 206
            if (pref == null){
146 207
                pref = CdmPreference.NewInstance(key, PreferencePredicate.DefaultBehaviourForSecundum.getDefaultValue().toString());
147 208
            }
148 209
            allowOverride = pref.isAllowOverride();
149 210
            try{
150
                String secundumString = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey(), true);
151

  
152
                if (secundumString != null){
153
                    secundumBehaviour = SecReferenceHandlingEnum.valueOf(secundumString);
211
                if (!isAdminPreference && allowOverride){
212
                    String secundumString = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey(), true);
213
                    if (secundumString != null){
214
                        secundumBehaviour = SecReferenceHandlingEnum.valueOf(secundumString);
215
                    }
216
                }else{
217
                    secundumBehaviour = SecReferenceHandlingEnum.valueOf(pref.getValue());
154 218
                }
219

  
220

  
155 221
            }catch (IllegalArgumentException e){
156
                secundumBehaviour = SecReferenceHandlingEnum.KeepWhenSame;
222
                secundumBehaviour = SecReferenceHandlingEnum.KeepOrWarn;
157 223
            }
158 224
            String prefString = PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey());
159 225
            override = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()), true);
160
            if (!override){
226
            if (!override && !isAdminPreference){
161 227
                secundumBehaviour = null;
162 228
            }
229

  
230
            //for swap operation
231

  
232
            secundumSwapBehaviour = null;
233
            key = CdmPreference.NewKey(PreferenceSubject.NewInstance("/SwapSynToAccepted/"), PreferencePredicate.DefaultBehaviourForSecundumWhenSwap);
234

  
235
            prefSwap = PreferencesUtil.getPreferenceFromDB(key);
236
            if (prefSwap == null){
237
                prefSwap = CdmPreference.NewInstance(key, PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getDefaultValue().toString());
238
            }
239
            allowOverrideSwap = prefSwap.isAllowOverride();
240
            try{
241
                if (!isAdminPreference && allowOverrideSwap){
242
                    String secundumString = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey(), !isAdminPreference);
243

  
244
                    if (secundumString != null){
245
                        secundumSwapBehaviour = SecReferenceHandlingSwapEnum.valueOf(secundumString);
246
                    }
247
                }else{
248
                    secundumSwapBehaviour = SecReferenceHandlingSwapEnum.valueOf(prefSwap.getValue());
249
                }
250

  
251

  
252
            }catch (IllegalArgumentException e){
253
                secundumSwapBehaviour = SecReferenceHandlingSwapEnum.KeepOrWarn;
254
            }
255
            prefString = PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey());
256
            overrideSwap = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundumWhenSwap.getKey()), true);
257
            if (!overrideSwap){
258
                secundumSwapBehaviour = null;
259
            }
163 260
        }
164 261

  
165 262
        @Override
......
178 275
            if (isAdminPreference){
179 276
                allowOverrideButton.setSelection(allowOverride);
180 277
            }
278

  
279
            //for swap operation
280

  
281
            secundumSwapBehaviour = null;
282
            allowOverrideSwap = true;
283
            index = 0;
284

  
285
            for (String itemLabel : synonymSecundumSwapBehaviour.getItems()){
286
                if (itemLabel.startsWith(Messages.Preference_Use_Default)){
287
                    synonymSecundumSwapBehaviour.select(index);
288
                    break;
289
                }
290
                index++;
291
            }
292
            if (isAdminPreference){
293
                allowOverrideSwapButton.setSelection(allowOverrideSwap);
294
            }
295

  
181 296
            setApply(true);
182 297
            super.performDefaults();
183 298
        }
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/ReferenceSelectionDialog.java
170 170
	        }
171 171
	        if (preSelectedReferences != null){
172 172
    	        for (Reference ref: preSelectedReferences){
173
                    uuids.add(ref.getUuid());
173
    	            if (ref != null){
174
    	                uuids.add(ref.getUuid());
175
    	            }
174 176
                }
175 177
	        }
176 178
	        if (!uuids.isEmpty()){
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/reference/SecundumSourceElement.java
48 48
    @Override
49 49
    protected void createControls(ICdmFormElement formElement, SecundumSource entity,  int style) {
50 50

  
51
        entity = HibernateProxyHelper.deproxy(entity);
51
        setEntityWithoutUpdate(HibernateProxyHelper.deproxy(entity));
52 52

  
53 53
        this.selection_Ref = formFactory.createSelectionElement(Reference.class, formElement, "Secundum", null, EntitySelectionElement.ALL, style);
54 54

  
55
        if (entity != null){
56
            selection_Ref.setEntity(entity.getCitation());
55
        if (getEntity() != null){
56
            selection_Ref.setEntity(getEntity().getCitation());
57 57
        }
58 58
        selection_Ref.setBackground(this.getPersistentBackground());
59 59
        for (ICdmFormElement element: selection_Ref.getElements()){
60 60
            element.setBackground(getPersistentBackground());
61 61
        }
62 62

  
63
        microReference = formFactory.createTextWithLabelElement(formElement, "Detail", entity != null? entity.getCitationMicroReference(): "", style);
63
        microReference = formFactory.createTextWithLabelElement(formElement, "Detail", getEntity() != null? getEntity().getCitationMicroReference(): "", style);
64 64

  
65 65
        Label sep = formFactory.createLabel(formElement.getLayoutComposite(), "");
66 66
        sep.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1));
......
69 69
        externalLinks = formFactory.createExternalLinksSection(getConversationHolder(), formElement, "Links", false, StoreUtil.getSectionStyle(ExternalLinksSection.class, DescriptionElementSource.class.getCanonicalName()));
70 70
        externalLinks.setEmptySectionString("No links yet.");
71 71
        externalLinks.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 3));
72
        externalLinks.setEntity(entity);
72
        externalLinks.setEntity(getEntity());
73 73
        externalLinks.setFont(AbstractUtility.getFont(Resources.COLOR_FONT_DEFAULT));
74 74

  
75 75

  
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/operation/TaxonNameEditorTest.java
31 31
import eu.etaxonomy.cdm.model.description.Feature;
32 32
import eu.etaxonomy.cdm.model.description.TaxonDescription;
33 33
import eu.etaxonomy.cdm.model.description.TextData;
34
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingSwapEnum;
34 35
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
35 36
import eu.etaxonomy.cdm.model.name.INonViralName;
36 37
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
......
185 186
        Synonym synonym = (Synonym)taxonService.load(synonymUuid);
186 187
        TaxonName synonymName = synonym.getName();
187 188

  
188
        UpdateResult result = taxonService.swapSynonymAndAcceptedTaxon(synonym.getUuid(), taxon.getUuid(), false, false);
189
        UpdateResult result = taxonService.swapSynonymAndAcceptedTaxon(synonym.getUuid(), taxon.getUuid(), false, false, SecReferenceHandlingSwapEnum.KeepOrWarn, null, null);
189 190
        taxon = (Taxon)result.getCdmEntity();
190 191
        Set<TaxonName> synNames = taxon.getSynonymNames();
191 192
        Iterator<TaxonName> iterator = synNames.iterator();
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/operation/TaxonNavigatorTest.java
30 30
import eu.etaxonomy.cdm.model.common.CdmBase;
31 31
import eu.etaxonomy.cdm.model.common.Language;
32 32
import eu.etaxonomy.cdm.model.description.TaxonDescription;
33
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
33 34
import eu.etaxonomy.cdm.model.name.TaxonName;
34 35
import eu.etaxonomy.cdm.model.taxon.Classification;
35 36
import eu.etaxonomy.cdm.model.taxon.Taxon;
......
107 108
                false,
108 109
                uuids,
109 110
                newParentTreeNode.getUuid(),
110
                moveToParentNode);
111
                moveToParentNode, SecReferenceHandlingEnum.KeepOrWarn, null);
111 112
        operation.execute(monitor, info);
112 113
        //TODO: fix this, because move taxon is now a longrunning task
113 114
//        Assert.assertEquals(childCount-1, oldParent.getCountChildren());

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)