Revision f13ee832
Added by Katja Luther over 2 years ago
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 |
} |
Also available in: Unified diff
ref #9340, #9734, #9668: further improvements for configurable sec handling during taxon(base) operations