Revision 44000ac1
Added by Katja Luther about 3 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java | ||
---|---|---|
324 | 324 |
public static String DeleteDescriptiveDatasetHandler_Exception_Message; |
325 | 325 |
public static String CharacterMatrix_ONLY_REMOVE; |
326 | 326 |
public static String CharacterMatrix_DELETE_DESCRIPTION; |
327 |
public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message; |
|
328 |
public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title; |
|
329 |
public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent; |
|
330 |
public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select; |
|
331 |
public static String ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep; |
|
327 | 332 |
|
328 | 333 |
|
329 | 334 |
static { |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties | ||
---|---|---|
302 | 302 |
FactualDataView_Lable=Factual Data |
303 | 303 |
NameFactsDataView_Lable=Name Facts |
304 | 304 |
DeleteDescriptiveDatasetHandler_Exception_Message=Descriptive Dataset could not be deleted. |
305 |
DeleteDescriptiveDatasetHandler_Warning_Message=Deletion was successful but with warnings. |
|
305 |
DeleteDescriptiveDatasetHandler_Warning_Message=Deletion was successful but with warnings. |
|
306 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message=Select secundum reference |
|
307 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title=The secundum reference of the selected parent is different to the secundum of the synonym. Please select which secundum should be used for the accepted taxon. |
|
308 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent=Parent secundum |
|
309 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select=Select new |
|
310 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep=Keep secundum |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties | ||
---|---|---|
301 | 301 |
FactualDataView_Lable=Faktendaten |
302 | 302 |
NameFactsDataView_Lable=Namensfaktendaten |
303 | 303 |
DeleteDescriptiveDatasetHandler_Exception_Message=Das Descriptive Dataset konnte nicht gel?scht werden. |
304 |
DeleteDescriptiveDatasetHandler_Warning_Message=Das L?schen war erfolgreich, es gibt aber Warnungen. |
|
304 |
DeleteDescriptiveDatasetHandler_Warning_Message=Das L?schen war erfolgreich, es gibt aber Warnungen. |
|
305 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_message=Auswahl der Sekundum Referenz |
|
306 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Handling_title=Die Sekundum Referenzen des gew?hlten Eltern und des alten akzeptierten Taxons unterscheiden sich, bitte w?hlen Sie welche Sekundum Referenz f?r das neue Synonym verwendet werden soll |
|
307 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Parent=Eltern Secundum |
|
308 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Select=Neue ausw?hlen |
|
309 |
ChangeSynonymToAcceptedHandler_Select_Sec_Reference_Keep=Secundum beibehalten |
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 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.editor.name.operation; |
11 | 11 |
|
12 | 12 |
import java.util.Set; |
13 |
import java.util.UUID; |
|
13 | 14 |
|
14 | 15 |
import org.eclipse.core.commands.ExecutionException; |
15 | 16 |
import org.eclipse.core.commands.operations.IUndoContext; |
... | ... | |
23 | 24 |
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException; |
24 | 25 |
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum; |
25 | 26 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
26 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
27 | 27 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
28 | 28 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
29 | 29 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
47 | 47 |
private final ITaxonTreeNode parentNode; |
48 | 48 |
|
49 | 49 |
private TaxonNode newNode; |
50 |
private Reference newSecRef;
|
|
50 |
private UUID newSecRefUuid;
|
|
51 | 51 |
private SecReferenceHandlingEnum secHandling; |
52 | 52 |
|
53 | 53 |
//private final Set<TaxonName> namesInHomotypicGroup; |
... | ... | |
70 | 70 |
ITaxonTreeNode parentNode, |
71 | 71 |
Synonym synonym, |
72 | 72 |
Set<TaxonName> namesInHomotypicalGroup, |
73 |
Reference newSec,
|
|
73 |
UUID newSecUuid,
|
|
74 | 74 |
SecReferenceHandlingEnum secHandling, |
75 | 75 |
IPostOperationEnabled postOperationEnabled, |
76 | 76 |
IConversationEnabled conversationEnabled, |
... | ... | |
80 | 80 |
this.element = taxon; |
81 | 81 |
this.parentNode = parentNode; |
82 | 82 |
this.synonym = synonym; |
83 |
this.newSecRef = newSec;
|
|
83 |
this.newSecRefUuid = newSecUuid;
|
|
84 | 84 |
this.secHandling = secHandling; |
85 | 85 |
//this.namesInHomotypicGroup = namesInHomotypicalGroup; |
86 | 86 |
} |
... | ... | |
95 | 95 |
result = CdmStore.getService(ITaxonService.class).changeSynonymToAcceptedTaxon(synonym.getUuid(), |
96 | 96 |
element.getUuid(), |
97 | 97 |
parentNode.getUuid(), |
98 |
newSecRef != null? newSecRef.getUuid(): null, null, secHandling,
|
|
98 |
newSecRefUuid, null, secHandling,
|
|
99 | 99 |
true); |
100 | 100 |
if (result.isAbort()){ |
101 | 101 |
|
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/Messages.java | ||
---|---|---|
93 | 93 |
public static String RefreshPolytomousKeyNodesHandler_REFRESHING; |
94 | 94 |
public static String RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON; |
95 | 95 |
public static String RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP; |
96 |
public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title; |
|
97 |
public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message; |
|
98 |
public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep; |
|
99 |
public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent; |
|
100 |
public static String RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select; |
|
96 | 101 |
public static String RemotingDeletePolytomousKeyOperation_DELETE_OP; |
97 | 102 |
public static String RemotingDeleteTaxonNodeHandler_NODE_DELETED; |
98 | 103 |
public static String RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE; |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/messages.properties | ||
---|---|---|
74 | 74 |
RefreshPolytomousKeyNodesHandler_REFRESHING=Refreshing Polytomous Key Nodes |
75 | 75 |
RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON=Choose the accepted taxon |
76 | 76 |
RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP=Change Accepted Taxon to Synonym operation |
77 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title=Select secundum reference |
|
78 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message=The secundum reference of the new and the old accepted taxa are not the same. Please select which reference should be used for the new synonym |
|
79 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep=Keep |
|
80 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent=Take from accepted |
|
81 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select=Select new |
|
77 | 82 |
RemotingDeletePolytomousKeyOperation_DELETE_OP=Delete Polytomous Key operation |
78 | 83 |
RemotingDeleteTaxonNodeHandler_NODE_DELETED=Node already deleted |
79 | 84 |
RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE=The taxon node was already deleted. Please reopen the taxon navigator to refresh the view. |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/l10n/messages_de.properties | ||
---|---|---|
74 | 74 |
RefreshPolytomousKeyNodesHandler_REFRESHING=Polytome Schl?ssel aktualisieren |
75 | 75 |
RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON=W?hlen Sie das akzeptierte Taxon |
76 | 76 |
RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP=Akzeptiertes Taxon in Synonym umwandeln |
77 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title=Auswahl der Sekundum Referenz |
|
78 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message=Die Sekundum Referenzen des neuen und des alten akzeptierten Taxons unterscheiden sich, bitte w?hlen Sie welche Sekundum Referenz f?r das neue Synonym verwendet werden soll |
|
79 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep=Beibehalten |
|
80 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent=?bernehme vom akzeptierten |
|
81 |
RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select=Neue ausw?hlen |
|
77 | 82 |
RemotingDeletePolytomousKeyOperation_DELETE_OP=Polytomen Schl?ssel l?schen |
78 | 83 |
RemotingDeleteTaxonNodeHandler_NODE_DELETED=Taxonknoten schon gel?scht |
79 | 84 |
RemotingDeleteTaxonNodeHandler_NODE_DELETED_MESSAGE=Der Taxonknoten wurde schon gel?scht. Bitte ?ffnen Sie den Taxonnavigator erneut um die Anzeige zu aktualisieren. |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingChangeAcceptedTaxonToSynonymHandlerE4.java | ||
---|---|---|
22 | 22 |
import org.eclipse.swt.widgets.Shell; |
23 | 23 |
|
24 | 24 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
25 |
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum; |
|
26 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
25 | 27 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
26 | 28 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
27 | 29 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
28 | 30 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
31 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
|
29 | 32 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
30 | 33 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels; |
31 | 34 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingChangeAcceptedTaxonToSynonymOperation; |
32 | 35 |
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4; |
36 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
33 | 37 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
38 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.ReferenceSelectionDialog; |
|
34 | 39 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
35 | 40 |
|
36 | 41 |
/** |
... | ... | |
44 | 49 |
|
45 | 50 |
private Set<TaxonNodeDto> oldTaxonNodes = new HashSet(); |
46 | 51 |
private Classification classification; |
52 |
protected boolean isSetSource = false; |
|
47 | 53 |
|
48 | 54 |
public RemotingChangeAcceptedTaxonToSynonymHandlerE4() { |
49 | 55 |
super(TaxonNavigatorLabels.CHANGE_ACCEPTED_TAXON_TO_SYNONYM_LABEL); |
... | ... | |
114 | 120 |
MPart activePart, |
115 | 121 |
MHandledMenuItem menuItem) { |
116 | 122 |
Set<UUID> excludeTaxa = new HashSet<>(); |
123 |
Set<UUID> secUuids = new HashSet<>(); |
|
124 |
Set<UUID> nodeUuids = new HashSet(); |
|
125 |
|
|
117 | 126 |
for (TaxonNodeDto oldNode:oldTaxonNodes){ |
118 | 127 |
excludeTaxa.add(oldNode.getTaxonUuid()); |
128 |
secUuids.add(oldNode.getSecUuid()); |
|
129 |
nodeUuids.add(oldNode.getUuid()); |
|
119 | 130 |
} |
120 | 131 |
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell, |
121 | 132 |
// new ConversationHolderMock(), |
... | ... | |
127 | 138 |
if (newAcceptedTaxonNode == null) { |
128 | 139 |
return null; |
129 | 140 |
} |
130 |
Set<UUID> nodeUuids = new HashSet(); |
|
131 |
for (TaxonNodeDto node: oldTaxonNodes){ |
|
132 |
nodeUuids.add(node.getUuid()); |
|
141 |
|
|
142 |
SecReferenceHandlingEnum secHandling = PreferencesUtil.getSecReferenceHandlingPreference(); |
|
143 |
UUID newSecUuid = null; |
|
144 |
UUID newTaxonUuid = newAcceptedTaxonNode.getTaxon() != null && newAcceptedTaxonNode.getTaxon().getSec() != null ? newAcceptedTaxonNode.getTaxon().getSec().getUuid(): null; |
|
145 |
if (secUuids.size() > 1 && !(secHandling.equals(SecReferenceHandlingEnum.KeepAlways) || secHandling.equals(SecReferenceHandlingEnum.AlwaysDelete))){ |
|
146 |
int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message, |
|
147 |
new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select}); |
|
148 |
if (result == 2){ |
|
149 |
Reference sec = ReferenceSelectionDialog.select(shell, null); |
|
150 |
newSecUuid = sec != null? sec.getUuid(): null; |
|
151 |
}else if (result == 1){ |
|
152 |
newSecUuid = newTaxonUuid; |
|
153 |
}else if (result == 0){ |
|
154 |
secHandling = SecReferenceHandlingEnum.UseNewParentSec; |
|
155 |
}else{ |
|
156 |
return null; |
|
157 |
} |
|
158 |
|
|
159 |
}else{ |
|
160 |
|
|
161 |
|
|
162 |
UUID oldSecUuid = secUuids.iterator().next(); |
|
163 |
if ((secUuids.size() > 0 && newTaxonUuid != oldSecUuid && secHandling.equals(SecReferenceHandlingEnum.KeepWhenSame) )|| secHandling.equals(SecReferenceHandlingEnum.WarningSelect)){ |
|
164 |
int result = MessagingUtils.confirmDialog(Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_title, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Handling_message, |
|
165 |
new String[]{Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Keep, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Parent, Messages.RemotingChangeAcceptedTaxonToSynonymHandler_Select_Sec_Reference_Select}); |
|
166 |
if (result == 2){ |
|
167 |
Reference sec = ReferenceSelectionDialog.select(shell, null); |
|
168 |
newSecUuid = sec != null? sec.getUuid(): null; |
|
169 |
}else if (result == 1){ |
|
170 |
newSecUuid = newTaxonUuid; |
|
171 |
}else if (result == 0){ |
|
172 |
newSecUuid = oldSecUuid; |
|
173 |
}else{ |
|
174 |
return null; |
|
175 |
} |
|
176 |
|
|
177 |
} |
|
133 | 178 |
} |
179 |
|
|
180 |
|
|
134 | 181 |
RemotingChangeAcceptedTaxonToSynonymOperation rcattso = |
135 | 182 |
new RemotingChangeAcceptedTaxonToSynonymOperation(getTrigger(), |
136 | 183 |
false, |
137 | 184 |
nodeUuids, |
138 |
newAcceptedTaxonNode.getUuid(), partService, activePart, application, false);
|
|
185 |
newAcceptedTaxonNode.getUuid(), newSecUuid, secHandling, partService, activePart, application, isSetSource);
|
|
139 | 186 |
|
140 | 187 |
return rcattso; |
141 | 188 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/RemotingChangeAcceptedTaxonToSynonymSetNameInSourceHandlerE5.java | ||
---|---|---|
3 | 3 |
*/ |
4 | 4 |
package eu.etaxonomy.taxeditor.navigation.navigator.e4.handler; |
5 | 5 |
|
6 |
import java.util.HashSet; |
|
7 |
import java.util.Iterator; |
|
8 |
import java.util.Set; |
|
9 |
import java.util.UUID; |
|
10 |
|
|
11 |
import javax.inject.Named; |
|
12 |
|
|
13 |
import org.eclipse.core.commands.operations.AbstractOperation; |
|
14 |
import org.eclipse.core.runtime.IStatus; |
|
15 |
import org.eclipse.core.runtime.Status; |
|
16 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
17 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
18 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
19 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
20 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
21 |
import org.eclipse.jface.viewers.TreeSelection; |
|
22 |
import org.eclipse.swt.widgets.Shell; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
25 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
26 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
27 |
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto; |
|
28 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
29 |
import eu.etaxonomy.taxeditor.navigation.l10n.Messages; |
|
30 |
import eu.etaxonomy.taxeditor.navigation.navigator.TaxonNavigatorLabels; |
|
31 |
import eu.etaxonomy.taxeditor.navigation.navigator.operation.RemotingChangeAcceptedTaxonToSynonymOperation; |
|
32 |
import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4; |
|
33 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
34 |
import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog; |
|
35 |
|
|
36 | 6 |
/** |
37 | 7 |
* |
38 | 8 |
* @author pplitzner |
39 | 9 |
* @since Sep 6, 2017 |
40 | 10 |
* |
41 | 11 |
*/ |
42 |
public class RemotingChangeAcceptedTaxonToSynonymSetNameInSourceHandlerE5 extends RemotingCdmHandlerE4 { |
|
43 |
|
|
12 |
public class RemotingChangeAcceptedTaxonToSynonymSetNameInSourceHandlerE5 extends RemotingChangeAcceptedTaxonToSynonymHandlerE4 { |
|
44 | 13 |
|
45 |
private Set<TaxonNodeDto> oldTaxonNodes = new HashSet(); |
|
46 |
private Classification classification; |
|
47 | 14 |
|
48 | 15 |
public RemotingChangeAcceptedTaxonToSynonymSetNameInSourceHandlerE5() { |
49 |
super(TaxonNavigatorLabels.CHANGE_ACCEPTED_TAXON_TO_SYNONYM_LABEL); |
|
16 |
super(); |
|
17 |
isSetSource = true; |
|
50 | 18 |
} |
51 | 19 |
|
52 |
@Override |
|
53 |
public IStatus allowOperations(IStructuredSelection selection, |
|
54 |
Shell shell, |
|
55 |
MPart activePart, |
|
56 |
MHandledMenuItem menuItem) { |
|
57 |
// check that only a single taxon tree node has been selected |
|
58 |
// if(selection.size() > 1) { |
|
59 |
// return new Status(IStatus.ERROR, |
|
60 |
// "unknown", //$NON-NLS-1$ |
|
61 |
// TaxonNavigatorLabels.SINGLE_TAXON_SELECTION_MESSAGE); |
|
62 |
// } |
|
63 |
|
|
64 |
// check for no taxon tree node selected |
|
65 |
if(selection.size() == 0) { |
|
66 |
return new Status(IStatus.ERROR, |
|
67 |
"unknown", //$NON-NLS-1$ |
|
68 |
TaxonNavigatorLabels.NO_TAXON_SELECTION_MESSAGE); |
|
69 |
} |
|
70 |
|
|
71 |
// check that selected object is a taxon node |
|
72 |
Iterator it = selection.iterator(); |
|
73 |
Classification nextClassification; |
|
74 |
oldTaxonNodes = new HashSet<>(); |
|
75 |
while(it.hasNext()){ |
|
76 |
Object obj = it.next(); |
|
77 |
if(obj instanceof TaxonNodeDto) { |
|
78 |
oldTaxonNodes.add((TaxonNodeDto)obj); |
|
79 |
nextClassification = CdmStore.getService(IClassificationService.class).find(((TaxonNodeDto)obj).getClassificationUUID()); |
|
80 |
if (classification == null){ |
|
81 |
classification = nextClassification; |
|
82 |
}else if (!classification.equals(nextClassification)){ |
|
83 |
return new Status(IStatus.ERROR, |
|
84 |
"unknown", //$NON-NLS-1$ |
|
85 |
TaxonNavigatorLabels.ACCEPTED_TAXA_NEED_TO_BE_FROM_SAME_CLASSIFICATION); |
|
86 |
} |
|
87 |
} else { |
|
88 |
if (obj instanceof TaxonNode && !((TaxonNode)obj).hasTaxon()){ |
|
89 |
return new Status(IStatus.ERROR, |
|
90 |
"Operation not available for Classifications", //$NON-NLS-1$ |
|
91 |
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE); |
|
92 |
} |
|
93 |
return new Status(IStatus.ERROR, |
|
94 |
"unknown", //$NON-NLS-1$ |
|
95 |
TaxonNavigatorLabels.SELECTED_OBJECT_NOT_TREE_NODE_MESSAGE); |
|
96 |
} |
|
97 |
// check that the source taxon node does not have children |
|
98 |
if(((TaxonNodeDto)obj).getTaxonomicChildrenCount() > 0) { |
|
99 |
return new Status(IStatus.ERROR, |
|
100 |
"unknown", //$NON-NLS-1$ |
|
101 |
TaxonNavigatorLabels.SOURCE_TAXON_HAS_CHILDREN_MESSAGE); |
|
102 |
|
|
103 |
} |
|
104 |
|
|
105 |
// check if corresponding name editor is closed |
|
106 |
EditorUtil.closeObsoleteEditor((TaxonNodeDto)obj, partService); |
|
107 |
} |
|
108 |
return Status.OK_STATUS; |
|
109 |
} |
|
110 | 20 |
|
111 |
@Override |
|
112 |
public AbstractOperation prepareOperation(IStructuredSelection selection, |
|
113 |
Shell shell, |
|
114 |
MPart activePart, |
|
115 |
MHandledMenuItem menuItem) { |
|
116 |
Set<UUID> excludeTaxa = new HashSet<>(); |
|
117 |
for (TaxonNodeDto oldNode:oldTaxonNodes){ |
|
118 |
excludeTaxa.add(oldNode.getTaxonUuid()); |
|
119 |
} |
|
120 |
TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(shell, |
|
121 |
// new ConversationHolderMock(), |
|
122 |
Messages.RemotingChangeAcceptedTaxonToSynonymHandler_CHOOSE_TAXON, |
|
123 |
excludeTaxa, |
|
124 |
null, |
|
125 |
classification.getUuid()); |
|
126 |
|
|
127 |
if (newAcceptedTaxonNode == null) { |
|
128 |
return null; |
|
129 |
} |
|
130 |
Set<UUID> nodeUuids = new HashSet(); |
|
131 |
for (TaxonNodeDto node: oldTaxonNodes){ |
|
132 |
nodeUuids.add(node.getUuid()); |
|
133 |
} |
|
134 |
RemotingChangeAcceptedTaxonToSynonymOperation rcattso = |
|
135 |
new RemotingChangeAcceptedTaxonToSynonymOperation(getTrigger(), |
|
136 |
false, |
|
137 |
nodeUuids, |
|
138 |
newAcceptedTaxonNode.getUuid(), partService, activePart, application, true); |
|
139 |
|
|
140 |
return rcattso; |
|
141 |
} |
|
142 |
|
|
143 |
@CanExecute |
|
144 |
private boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)TreeSelection selection, MHandledMenuItem menuItem){ |
|
145 |
boolean canExecute = !selection.isEmpty(); |
|
146 |
Object[] array = selection.toArray(); |
|
147 |
for (Object object : array) { |
|
148 |
canExecute &= (object instanceof TaxonNodeDto) && ((TaxonNodeDto)selection.getFirstElement()).getTaxonUuid() != null; |
|
149 |
} |
|
150 |
menuItem.setVisible(canExecute); |
|
151 |
return canExecute; |
|
152 |
} |
|
153 |
|
|
154 |
@Override |
|
155 |
public void onComplete() { |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* {@inheritDoc} |
|
160 |
*/ |
|
161 |
@Override |
|
162 |
protected Object getTrigger() { |
|
163 |
return this; |
|
164 |
} |
|
165 | 21 |
} |
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/RemotingChangeAcceptedTaxonToSynonymOperation.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action; |
24 | 24 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
25 | 25 |
import eu.etaxonomy.cdm.api.service.UpdateResult; |
26 |
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum; |
|
26 | 27 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
27 | 28 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
28 | 29 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
... | ... | |
39 | 40 |
|
40 | 41 |
private Set<UUID> oldTaxonNodeUuids = new HashSet(); |
41 | 42 |
private final UUID newAcceptedTaxonNodeUuid; |
43 |
private UUID secundumUuid; |
|
42 | 44 |
private boolean setNameInSource ; |
45 |
private SecReferenceHandlingEnum secHandling; |
|
43 | 46 |
|
44 | 47 |
|
45 | 48 |
private final static String LABEL = Messages.RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP; |
... | ... | |
51 | 54 |
boolean async, |
52 | 55 |
Set<UUID> oldTaxonNodeUuids, |
53 | 56 |
UUID newAcceptedTaxonNodeUuid, |
57 |
UUID newSecUuid, |
|
58 |
SecReferenceHandlingEnum secHandling, |
|
54 | 59 |
EPartService partService, |
55 | 60 |
MPart activePart, |
56 | 61 |
MApplication application, |
... | ... | |
59 | 64 |
this.oldTaxonNodeUuids.addAll(oldTaxonNodeUuids); |
60 | 65 |
this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid; |
61 | 66 |
this.setNameInSource = setNameInSource; |
67 |
this.secundumUuid = newSecUuid; |
|
68 |
this.secHandling = secHandling; |
|
62 | 69 |
|
63 | 70 |
} |
64 | 71 |
|
... | ... | |
69 | 76 |
boolean async, |
70 | 77 |
UUID oldTaxonNodeUuid, |
71 | 78 |
UUID newAcceptedTaxonNodeUuid, |
79 |
UUID newSecUuid, |
|
80 |
SecReferenceHandlingEnum secHandling, |
|
72 | 81 |
EPartService partService, |
73 | 82 |
MPart activePart, |
74 | 83 |
MApplication application, |
... | ... | |
77 | 86 |
this.oldTaxonNodeUuids.add(oldTaxonNodeUuid); |
78 | 87 |
this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid; |
79 | 88 |
this.setNameInSource = setNameInSource; |
89 |
this.secundumUuid = newSecUuid; |
|
90 |
this.secHandling = secHandling; |
|
80 | 91 |
} |
81 | 92 |
|
82 | 93 |
/** |
... | ... | |
86 | 97 |
boolean async, |
87 | 98 |
UUID oldTaxonNodeUuid, |
88 | 99 |
UUID newAcceptedTaxonNodeUuid, |
100 |
UUID newSecUuid, |
|
101 |
SecReferenceHandlingEnum secHandling, |
|
89 | 102 |
boolean setNameInSource) { |
90 | 103 |
super(LABEL, Action.Update, source, async); |
91 | 104 |
this.oldTaxonNodeUuids.add(oldTaxonNodeUuid); |
92 | 105 |
this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid; |
93 | 106 |
this.setNameInSource = setNameInSource; |
107 |
this.secundumUuid = newSecUuid; |
|
108 |
this.secHandling = secHandling; |
|
94 | 109 |
} |
95 | 110 |
|
96 | 111 |
/* (non-Javadoc) |
... | ... | |
103 | 118 |
updateResult = CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuids.iterator().next(), |
104 | 119 |
newAcceptedTaxonNodeUuid, |
105 | 120 |
null, |
121 |
secundumUuid, |
|
106 | 122 |
null, |
107 |
null,
|
|
123 |
secHandling,
|
|
108 | 124 |
setNameInSource);//TODO |
109 | 125 |
}else{ |
110 | 126 |
updateResult = CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeSynonymsOfAnotherTaxonNode(oldTaxonNodeUuids, |
111 | 127 |
newAcceptedTaxonNodeUuid, |
112 | 128 |
null, |
129 |
secundumUuid, |
|
113 | 130 |
null, |
114 |
null,
|
|
131 |
secHandling,
|
|
115 | 132 |
setNameInSource);//TODO |
116 | 133 |
} |
117 | 134 |
updateNameEditor(); |
... | ... | |
131 | 148 |
if (part == activePart){ |
132 | 149 |
setFocus = true; |
133 | 150 |
} |
134 |
if (object instanceof TaxonNameEditorE4){ |
|
151 |
if (part.getContributionURI().endsWith("TaxonNameEditorE4")){ |
|
152 |
|
|
153 |
} |
|
154 |
if (object instanceof TaxonNameEditorE4 ){ |
|
135 | 155 |
Set<TaxonNode> nodes = ((TaxonNameEditorE4)object).getTaxon().getTaxonNodes(); |
136 | 156 |
for (TaxonNode node: nodes){ |
137 |
if (node.getTaxon().getUuid().equals(newAcceptedTaxonNodeUuid)){
|
|
157 |
if (node.getUuid().equals(newAcceptedTaxonNodeUuid)){ |
|
138 | 158 |
EditorUtil.updateEditor(node, (TaxonNameEditorE4)object); |
139 | 159 |
} |
140 | 160 |
|
eu.etaxonomy.taxeditor.store/plugin.xml | ||
---|---|---|
118 | 118 |
type="org.eclipse.jface.viewers.IStructuredSelection"> |
119 | 119 |
</propertyTester> |
120 | 120 |
<propertyTester |
121 |
class="eu.etaxonomy.taxeditor.featuretree.FeatureTreePropertyTester"
|
|
122 |
id="eu.etaxonomy.taxeditor.featuretree.FeatureTreePropertyTester"
|
|
123 |
namespace="eu.etaxonomy.taxeditor.featuretree.FeatureTreePropertyTester"
|
|
124 |
properties="isFeatureTree"
|
|
121 |
class="eu.etaxonomy.taxeditor.featuretree.TermTreePropertyTester"
|
|
122 |
id="eu.etaxonomy.taxeditor.featuretree.TermTreePropertyTester"
|
|
123 |
namespace="eu.etaxonomy.taxeditor.featuretree.TermTreePropertyTester"
|
|
124 |
properties="isTermTree"
|
|
125 | 125 |
type="org.eclipse.jface.viewers.IStructuredSelection"> |
126 | 126 |
</propertyTester> |
127 | 127 |
</extension> |
... | ... | |
408 | 408 |
selection="eu.etaxonomy.cdm.model.taxon.TaxonNode" |
409 | 409 |
viewerName="%viewCommandMapping.viewerName.TAXON_NODE_WIZARD"> |
410 | 410 |
</viewCommandMapping> |
411 |
<viewCommandMapping |
|
412 |
commandId="eu.etaxonomy.taxeditor.store.openDefinedTermEditor" |
|
413 |
selection="eu.etaxonomy.cdm.persistence.dto.TermNodeDto" |
|
414 |
viewerName="Vocabulary"> |
|
415 |
</viewCommandMapping> |
|
411 | 416 |
</extension> |
412 | 417 |
<extension |
413 | 418 |
id="eu.etaxonomy.taxeditor.store.workbench.model" |
... | ... | |
738 | 743 |
id="eu.etaxonomy.taxeditor.preferences.taxonPreferences" |
739 | 744 |
name="%page.name.52"> |
740 | 745 |
</page> |
741 |
<page
|
|
746 |
<page |
|
742 | 747 |
category="eu.etaxonomy.taxeditor.preferences.taxonPreferences" |
743 | 748 |
class="eu.etaxonomy.taxeditor.preference.PublishFlagLocalPreference" |
744 | 749 |
id="eu.etaxonomy.taxeditor.preferences.publishFlagPreference" |
745 | 750 |
name="%page.name.46"> |
746 | 751 |
</page> |
747 | 752 |
<page |
753 |
category="eu.etaxonomy.taxeditor.preferences.taxonPreferences" |
|
754 |
class="eu.etaxonomy.taxeditor.preference.SecundumReferenceHandling" |
|
755 |
id="eu.etaxonomy.taxeditor.preferences.secundumPreference" |
|
756 |
name="Secundum Reference"> |
|
757 |
</page> |
|
758 |
<page |
|
748 | 759 |
category="eu.etaxonomy.taxeditor.preferences.general" |
749 | 760 |
class="eu.etaxonomy.taxeditor.preference.UIPreferences" |
750 | 761 |
id="eu.etaxonomy.taxeditor.preference.UIPreferences" |
... | ... | |
918 | 929 |
name="%page.name.42"> |
919 | 930 |
</page> |
920 | 931 |
<page |
921 |
category="eu.etaxonomy.taxeditor.preferences.general" |
|
932 |
category="eu.etaxonomy.taxeditor.preferences.general" |
|
933 |
class="eu.etaxonomy.taxeditor.preference.TaxonPreferences" |
|
934 |
id="eu.etaxonomy.taxeditor.preferences.taxonPreferences" |
|
935 |
name="%page.name.52"> |
|
936 |
</page> |
|
937 |
<page |
|
938 |
category="eu.etaxonomy.taxeditor.preferences.taxonPreferences" |
|
922 | 939 |
class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.PublishFlagPreference" |
923 | 940 |
id="eu.etaxonomy.taxeditor.preferences.publishFlagPreference" |
924 | 941 |
name="%page.name.46"> |
925 | 942 |
</page> |
943 |
<page |
|
944 |
category="eu.etaxonomy.taxeditor.preferences.taxonPreferences" |
|
945 |
class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.SecundumReferenceHandlingAdmin" |
|
946 |
id="eu.etaxonomy.taxeditor.preferences.secRefHandling" |
|
947 |
name="Secundum Reference"> |
|
948 |
</page> |
|
926 | 949 |
<page |
927 | 950 |
category="eu.etaxonomy.taxeditor.preferences.namePreferences" |
928 | 951 |
class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.RankAdminPreference" |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/SecundumReferenceHandlingAdmin.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2020 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage; |
|
10 |
|
|
11 |
import eu.etaxonomy.cdm.api.application.ICdmRepository; |
|
12 |
import eu.etaxonomy.cdm.api.service.IPreferenceService; |
|
13 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
|
14 |
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum; |
|
15 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
16 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
17 |
import eu.etaxonomy.taxeditor.preference.SecundumReferenceHandling; |
|
18 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
19 |
|
|
20 |
/** |
|
21 |
* @author k.luther |
|
22 |
* @since Dec 1, 2020 |
|
23 |
*/ |
|
24 |
public class SecundumReferenceHandlingAdmin extends SecundumReferenceHandling { |
|
25 |
|
|
26 |
@Override |
|
27 |
public void init() { |
|
28 |
super.init(); |
|
29 |
|
|
30 |
|
|
31 |
} |
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
@Override |
|
36 |
public boolean performOk() { |
|
37 |
if (!isApply()){ |
|
38 |
return true; |
|
39 |
} |
|
40 |
ICdmRepository controller = CdmStore.getCurrentApplicationConfiguration(); |
|
41 |
if (controller == null){ |
|
42 |
return false; |
|
43 |
} |
|
44 |
IPreferenceService service = controller.getPreferenceService(); |
|
45 |
String textCombo = synonymSecundumBehaviour.getText(); |
|
46 |
String text = null; |
|
47 |
// default -> delete preference |
|
48 |
if(textCombo.startsWith(Messages.Preference_Use_Default) && allowOverride){ |
|
49 |
service.remove(pref.getKey()); |
|
50 |
PreferencesUtil.updateDBPreferences(); |
|
51 |
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 |
} |
|
62 |
CdmPreference preference = CdmPreference.NewInstance(pref.getKey(), text); |
|
63 |
preference.setAllowOverride(allowOverride); |
|
64 |
|
|
65 |
service.set(preference); |
|
66 |
PreferencesUtil.updateDBPreferences(); |
|
67 |
|
|
68 |
return true; |
|
69 |
} |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
@Override |
|
74 |
public void getValues() { |
|
75 |
super.getValues(); |
|
76 |
isAdminPreference = true; |
|
77 |
|
|
78 |
|
|
79 |
} |
|
80 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages.properties | ||
---|---|---|
612 | 612 |
CdmLightPreference_distributionString=Export of condensed distribution string |
613 | 613 |
CdmLightPreference_distributionString_tooltip=Distributions of a taxon are exported as condensed string, created by the selected algorithm. |
614 | 614 |
|
615 |
SecundumPreference_description=Default settings of secundum reference handling for move synonym to accepted taxon.
|
|
615 |
SecundumPreference_description=Default settings of secundum reference handling for change synonym to accepted taxon and changing an accepted taxon to synonym.
|
|
616 | 616 |
Tree= Tree |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/l10n/messages_de.properties | ||
---|---|---|
612 | 612 |
CdmLightPreference_distributionString=Export eines Condensed Distribution Strings |
613 | 613 |
CdmLightPreference_distributionString_tooltip=F?r jedes Taxon wird aus den Verbreitungsdaten ein kompakter String exportiert, der entsprechend dem ausgew?hlten Algorithmus erzeugt wird. |
614 | 614 |
|
615 |
SecundumPreference_description=Default Einstellungen f?r das Setzen der Secundum Referenz beim Verschieben eines Synonyms zu einem akzeptierten Taxon.
|
|
615 |
SecundumPreference_description=Default Einstellungen f?r das Setzen der Secundum Referenz beim ?ndern eines Synonyms in ein akzeptierten Taxon und anders herum.
|
|
616 | 616 |
Tree=-Baum |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SecundumReferenceHandling.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2020 EDIT |
|
3 |
* European Distributed Institute of Taxonomy |
|
4 |
* http://www.e-taxonomy.eu |
|
5 |
* |
|
6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
8 |
*/ |
|
9 |
package eu.etaxonomy.taxeditor.preference; |
|
10 |
|
|
11 |
import org.eclipse.swt.SWT; |
|
12 |
import org.eclipse.swt.custom.CLabel; |
|
13 |
import org.eclipse.swt.events.SelectionAdapter; |
|
14 |
import org.eclipse.swt.events.SelectionEvent; |
|
15 |
import org.eclipse.swt.events.SelectionListener; |
|
16 |
import org.eclipse.swt.widgets.Button; |
|
17 |
import org.eclipse.swt.widgets.Combo; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
import org.eclipse.swt.widgets.Control; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
|
22 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey; |
|
23 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
24 |
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject; |
|
25 |
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum; |
|
26 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
27 |
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author k.luther |
|
31 |
* @since Dec 1, 2020 |
|
32 |
*/ |
|
33 |
public class SecundumReferenceHandling extends CdmPreferencePage { |
|
34 |
|
|
35 |
protected SecReferenceHandlingEnum secundumBehaviour; |
|
36 |
|
|
37 |
protected Combo synonymSecundumBehaviour; |
|
38 |
protected CdmPreference pref = null; |
|
39 |
Button allowOverrideButton; |
|
40 |
|
|
41 |
protected boolean allowOverride; |
|
42 |
private boolean override = true; |
|
43 |
|
|
44 |
|
|
45 |
@Override |
|
46 |
public void init() { |
|
47 |
super.init(); |
|
48 |
|
|
49 |
|
|
50 |
} |
|
51 |
/** |
|
52 |
* {@inheritDoc} |
|
53 |
*/ |
|
54 |
@Override |
|
55 |
protected Control createContents(Composite parent) { |
|
56 |
getValues(); |
|
57 |
|
|
58 |
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 |
synonymSecundumBehaviour = createCombo(composite, SecReferenceHandlingEnum.values(), PreferencePredicate.DefaultBehaviourForSecundum, Messages.SecundumPreference_description, isAdminPreference); |
|
68 |
synonymSecundumBehaviour.addSelectionListener(new SelectionListener() { |
|
69 |
|
|
70 |
@Override |
|
71 |
public void widgetSelected(SelectionEvent e) { |
|
72 |
setApply(true); |
|
73 |
if (!synonymSecundumBehaviour.getText().startsWith(Messages.Preference_Use_Default)){ |
|
74 |
secundumBehaviour = (SecReferenceHandlingEnum)synonymSecundumBehaviour.getData(synonymSecundumBehaviour.getText()); |
|
75 |
}else{ |
|
76 |
secundumBehaviour = null; |
|
77 |
} |
|
78 |
|
|
79 |
} |
|
80 |
|
|
81 |
@Override |
|
82 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
83 |
// TODO Auto-generated method stub |
|
84 |
|
|
85 |
} |
|
86 |
}); |
|
87 |
if (this.isAdminPreference){ |
|
88 |
allowOverrideButton = createAllowOverrideButton(composite); |
|
89 |
allowOverrideButton.setSelection(allowOverride); |
|
90 |
allowOverrideButton.addSelectionListener(new SelectionAdapter(){ |
|
91 |
@Override |
|
92 |
public void widgetSelected(SelectionEvent e) { |
|
93 |
allowOverride = !allowOverride; |
|
94 |
setApply(true); |
|
95 |
} |
|
96 |
}); |
|
97 |
} |
|
98 |
int index = 0; |
|
99 |
|
|
100 |
if(secundumBehaviour==null){ |
|
101 |
synonymSecundumBehaviour.select(0); |
|
102 |
} |
|
103 |
else{ |
|
104 |
for (String itemLabel : synonymSecundumBehaviour.getItems()){ |
|
105 |
if (itemLabel.startsWith(secundumBehaviour.getLabel())){ |
|
106 |
synonymSecundumBehaviour.select(index); |
|
107 |
break; |
|
108 |
} |
|
109 |
index++; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
return composite; |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
@Override |
|
119 |
public boolean performOk() { |
|
120 |
if (isApply()){ |
|
121 |
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 |
} |
|
129 |
PreferencesUtil.setStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey(), text); |
|
130 |
if (pref == null || !pref.getValue().equals(text)){ |
|
131 |
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()), true); |
|
132 |
} |
|
133 |
}else{ |
|
134 |
PreferencesUtil.setBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()), false); |
|
135 |
} |
|
136 |
} |
|
137 |
return true; |
|
138 |
} |
|
139 |
|
|
140 |
@Override |
|
141 |
public void getValues(){ |
|
142 |
secundumBehaviour = null; |
|
143 |
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewInstance("/MoveSynToAccepted/"), PreferencePredicate.DefaultBehaviourForSecundum); |
|
144 |
pref = PreferencesUtil.getPreferenceFromDB(key); |
|
145 |
if (pref == null){ |
|
146 |
pref = CdmPreference.NewInstance(key, PreferencePredicate.DefaultBehaviourForSecundum.getDefaultValue().toString()); |
|
147 |
} |
|
148 |
allowOverride = pref.isAllowOverride(); |
|
149 |
try{ |
|
150 |
String secundumString = PreferencesUtil.getStringValue(PreferencePredicate.DefaultBehaviourForSecundum.getKey(), true); |
|
151 |
|
|
152 |
if (secundumString != null){ |
|
153 |
secundumBehaviour = SecReferenceHandlingEnum.valueOf(secundumString); |
|
154 |
} |
|
155 |
}catch (IllegalArgumentException e){ |
|
156 |
secundumBehaviour = SecReferenceHandlingEnum.KeepWhenSame; |
|
157 |
} |
|
158 |
String prefString = PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()); |
|
159 |
override = PreferencesUtil.getBooleanValue(PreferencesUtil.prefOverrideKey(PreferencePredicate.DefaultBehaviourForSecundum.getKey()), true); |
|
160 |
if (!override){ |
|
161 |
secundumBehaviour = null; |
|
162 |
} |
|
163 |
} |
|
164 |
|
|
165 |
@Override |
|
166 |
protected void performDefaults() { |
|
167 |
secundumBehaviour = null; |
|
168 |
allowOverride = true; |
|
169 |
int index = 0; |
|
170 |
|
|
171 |
for (String itemLabel : synonymSecundumBehaviour.getItems()){ |
|
172 |
if (itemLabel.startsWith(Messages.Preference_Use_Default)){ |
|
173 |
synonymSecundumBehaviour.select(index); |
|
174 |
break; |
|
175 |
} |
|
176 |
index++; |
|
177 |
} |
|
178 |
if (isAdminPreference){ |
|
179 |
allowOverrideButton.setSelection(allowOverride); |
|
180 |
} |
|
181 |
setApply(true); |
|
182 |
super.performDefaults(); |
|
183 |
} |
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
} |
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/operation/TaxonNavigatorTest.java | ||
---|---|---|
76 | 76 |
operation = new RemotingChangeAcceptedTaxonToSynonymOperation(sessionOwner, |
77 | 77 |
false, |
78 | 78 |
oldTaxonNode.getUuid(), |
79 |
newAcceptedTaxonNode.getUuid(), true); |
|
79 |
newAcceptedTaxonNode.getUuid(), null, null, true);
|
|
80 | 80 |
operation.execute(monitor, info); |
81 | 81 |
newAcceptedTaxonNode = taxonNodeService.load(newAcceptedTaxonNodeUuid); |
82 | 82 |
oldTaxonNode = taxonNodeService.load(oldTaxonNodeNodeUuid); |
Also available in: Unified diff
ref #9340: workflow for changing synonym to acc and acc to synonym