Revision 7ccb7304
Added by Katja Luther over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java | ||
---|---|---|
213 | 213 |
} |
214 | 214 |
|
215 | 215 |
public void createOrUpdateNameComposites(boolean accepted, boolean heterotypicGroups, boolean misappliedNames) { |
216 |
|
|
217 |
|
|
216 | 218 |
if (accepted){ |
217 |
ContainerFactoryE4.createOrUpdateAcceptedTaxonsHomotypicGroup(this); |
|
218 |
} |
|
219 |
if (heterotypicGroups){ |
|
220 |
ContainerFactoryE4.createOrUpdateHeterotypicSynonymyGroups(this); |
|
221 |
} |
|
222 |
if (misappliedNames){ |
|
223 |
ContainerFactoryE4.createOrUpdateMisapplicationsGroup(this); |
|
224 |
} |
|
219 |
ContainerFactoryE4.createOrUpdateAcceptedTaxonsHomotypicGroup(this); |
|
220 |
} |
|
221 |
if (heterotypicGroups){ |
|
222 |
ContainerFactoryE4.createOrUpdateHeterotypicSynonymyGroups(this); |
|
223 |
} |
|
224 |
if (misappliedNames){ |
|
225 |
ContainerFactoryE4.createOrUpdateMisapplicationsGroup(this); |
|
226 |
} |
|
227 |
ContainerFactoryE4.setMenuToAllContainers(this); |
|
228 |
|
|
225 | 229 |
|
226 | 230 |
|
227 | 231 |
// Redraw composite |
... | ... | |
336 | 340 |
*/ |
337 | 341 |
public boolean checkForEmptyNames() { |
338 | 342 |
for (AbstractGroupedContainerE4 container : getGroupedContainers()) { |
339 |
if (container.getName() == null |
|
340 |
|| StringUtils.isEmpty(container.getName().getTitleCache())) { |
|
343 |
if (container != null && (container.getName() == null
|
|
344 |
|| StringUtils.isEmpty(container.getName().getTitleCache()))) {
|
|
341 | 345 |
return true; |
342 | 346 |
} |
343 | 347 |
} |
... | ... | |
677 | 681 |
container.refresh(); |
678 | 682 |
} |
679 | 683 |
} |
684 |
|
|
680 | 685 |
if (element instanceof TaxonRelationship) { |
681 | 686 |
AbstractGroupedContainerE4 container = getContainer(((TaxonRelationship) element).getFromTaxon()); |
682 | 687 |
if (container != null) { |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AbstractGroupE4.java | ||
---|---|---|
157 | 157 |
} |
158 | 158 |
|
159 | 159 |
public void redraw(){ |
160 |
emptyGroup(); |
|
160 |
emptyGroup(); |
|
161 |
|
|
161 | 162 |
createContainers(); |
162 | 163 |
} |
163 | 164 |
|
... | ... | |
175 | 176 |
|
176 | 177 |
public void dispose(){ |
177 | 178 |
if(getControl() != null){ |
179 |
getControl().setMenu(null); |
|
178 | 180 |
for(AbstractGroupedContainerE4 container : getGroupedContainers()){ |
179 | 181 |
container.dispose(); |
180 | 182 |
} |
181 |
getControl().setMenu(null); |
|
182 | 183 |
getControl().dispose(); |
183 | 184 |
} |
184 | 185 |
} |
185 | 186 |
|
186 | 187 |
protected void emptyGroup(){ |
187 | 188 |
for(AbstractGroupedContainerE4 container : groupedContainers){ |
189 |
container.getControl().setMenu(null); |
|
188 | 190 |
container.dispose(); |
189 | 191 |
} |
190 | 192 |
groupedContainers.clear(); |
191 | 193 |
} |
194 |
|
|
195 |
protected void setMenuToGroup(){ |
|
196 |
for(AbstractGroupedContainerE4 container : groupedContainers){ |
|
197 |
container.setMenu(); |
|
198 |
|
|
199 |
} |
|
200 |
|
|
201 |
} |
|
192 | 202 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AbstractGroupedContainerE4.java | ||
---|---|---|
323 | 323 |
updateIcon(); |
324 | 324 |
// placeCursor(); |
325 | 325 |
updateIndent(); |
326 |
|
|
326 |
setDelayedSelection(); |
|
327 | 327 |
enableFreeText(); |
328 | 328 |
} |
329 | 329 |
|
... | ... | |
570 | 570 |
backgroundColor = AbstractUtility.getColor(colorString); |
571 | 571 |
|
572 | 572 |
setBackground(backgroundColor); |
573 |
}else{ |
|
574 |
System.err.println("disposed"); |
|
573 | 575 |
} |
574 | 576 |
} |
575 | 577 |
|
... | ... | |
898 | 900 |
@Override |
899 | 901 |
public void dispose() { |
900 | 902 |
if (getControl() != null) { |
901 |
setMenu(); |
|
903 |
|
|
902 | 904 |
getControl().dispose(); |
903 | 905 |
} |
904 | 906 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AbstractHomotypicalGroupContainerE4.java | ||
---|---|---|
50 | 50 |
if(redrawNeeded(homotypicalGroup)){ |
51 | 51 |
setGroup(homotypicalGroup); |
52 | 52 |
redraw(); |
53 |
}else{ |
|
54 |
setMenuToGroup(); |
|
53 | 55 |
} |
54 | 56 |
} |
55 | 57 |
|
... | ... | |
59 | 61 |
List<Synonym> synonyms = taxon.getSynonymsInGroup(homotypicalGroup); |
60 | 62 |
|
61 | 63 |
List<Synonym> presentSynonyms = new ArrayList<Synonym>(); |
62 |
|
|
64 |
List<AbstractGroupedContainerE4> containers = getGroupedContainers(); |
|
65 |
if (containers == null || containers.isEmpty() || (containers.get(0) == null && containers.size() == 1)){ |
|
66 |
return true; |
|
67 |
} |
|
63 | 68 |
for(AbstractGroupedContainerE4 container : getGroupedContainers()){ |
64 | 69 |
if(container.getData() instanceof Synonym){ |
65 | 70 |
presentSynonyms.add((Synonym) container.getData()); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/AcceptedGroupE4.java | ||
---|---|---|
58 | 58 |
@Override |
59 | 59 |
protected void createContainers() { |
60 | 60 |
this.acceptedContainer = new AcceptedNameContainerE4(this, getEditor().getTaxon()); |
61 |
|
|
62 | 61 |
acceptedContainer.createContent(); |
63 |
|
|
64 | 62 |
createSynonymContainer(); |
65 | 63 |
} |
66 | 64 |
|
... | ... | |
79 | 77 |
|
80 | 78 |
@Override |
81 | 79 |
protected void emptyGroup() { |
82 |
acceptedContainer.dispose(); |
|
83 |
acceptedContainer = null; |
|
80 |
if (acceptedContainer != null){ |
|
81 |
acceptedContainer.dispose(); |
|
82 |
acceptedContainer = null; |
|
83 |
} |
|
84 |
|
|
84 | 85 |
super.emptyGroup(); |
85 | 86 |
} |
86 | 87 |
|
87 | 88 |
@Override |
88 | 89 |
protected boolean redrawNeeded(HomotypicalGroup homotypicalGroup) { |
89 |
if(! acceptedContainer.getData().equals(getEditor().getTaxon())){ |
|
90 |
if(acceptedContainer != null && ! acceptedContainer.getData().equals(getEditor().getTaxon())){
|
|
90 | 91 |
return true; |
91 | 92 |
} |
92 | 93 |
return super.redrawNeeded(homotypicalGroup); |
93 | 94 |
} |
95 |
|
|
96 |
@Override |
|
97 |
protected void setMenuToGroup(){ |
|
98 |
super.setMenuToGroup(); |
|
99 |
acceptedContainer.setMenu(); |
|
100 |
} |
|
94 | 101 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/ConceptContainerE4.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages; |
24 | 24 |
import eu.etaxonomy.taxeditor.editor.name.container.EditorAnnotation; |
25 | 25 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
26 |
import eu.etaxonomy.taxeditor.editor.name.e4.container.MisappliedGroupE4.ConceptType; |
|
26 | 27 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
27 | 28 |
import eu.etaxonomy.taxeditor.model.NameHelper; |
28 | 29 |
import eu.etaxonomy.taxeditor.preference.Resources; |
... | ... | |
37 | 38 |
public class ConceptContainerE4 extends AbstractGroupedContainerE4<Taxon> { |
38 | 39 |
TaxonRelationship relationship; |
39 | 40 |
TaxonRelationshipFormatter misappliedFormatter; |
41 |
ConceptType conceptType; |
|
40 | 42 |
|
41 |
private boolean isMisapplication; |
|
42 |
|
|
43 |
public ConceptContainerE4(AbstractGroupE4 group, Taxon misappliedName, boolean isMisapplication) { |
|
43 |
public ConceptContainerE4(AbstractGroupE4 group, Taxon misappliedName, ConceptType conceptType) { |
|
44 | 44 |
super(group, misappliedName); |
45 |
this.isMisapplication = isMisapplication;
|
|
45 |
this.conceptType = conceptType;
|
|
46 | 46 |
misappliedFormatter = new TaxonRelationshipFormatter(); |
47 | 47 |
|
48 | 48 |
} |
... | ... | |
55 | 55 |
TaxonNameEditorE4 editor = getEditor(); |
56 | 56 |
Taxon taxon = editor.getTaxon(); |
57 | 57 |
for (TaxonRelationship rel: taxon.getTaxonRelations(getMisappliedName())){ |
58 |
if (rel.getType().isAnyMisappliedName() && isMisapplication){
|
|
58 |
if (rel.getType().isAnyMisappliedName() && this.conceptType.equals(ConceptType.Misapplication)){
|
|
59 | 59 |
relationship = rel; |
60 | 60 |
break; |
61 |
}else if (rel.getType().isAnySynonym() && !isMisapplication){
|
|
61 |
}else if (rel.getType().isAnySynonym() && this.conceptType.equals(ConceptType.Synonym)){
|
|
62 | 62 |
relationship = rel; |
63 | 63 |
break; |
64 |
} |
|
64 |
} else if (rel.getType().isInvalidDesignation() && this.conceptType.equals(ConceptType.InvalidDesignation)){ |
|
65 |
relationship = rel; |
|
66 |
break; |
|
67 |
} |
|
65 | 68 |
} |
66 | 69 |
showSec(); |
67 |
|
|
68 | 70 |
initTextViewer(); |
69 | 71 |
} |
70 | 72 |
|
71 | 73 |
@Override |
72 | 74 |
protected void updateIcon() { |
73 |
if (relationship.getType().isAnyMisappliedName()){ |
|
75 |
if (relationship.getType().isAnyMisappliedName() || relationship.getType().isInvalidDesignation()){
|
|
74 | 76 |
setIcon(MISAPPLIEDNAME_ICON); |
75 | 77 |
}else if (relationship.getType().isProParte()){ |
76 | 78 |
setIcon(PRO_PARTE_SYNONYM_ICON); |
77 |
}else { |
|
79 |
}else if (relationship.getType().isAnySynonym()){
|
|
78 | 80 |
setIcon(PARTIAL_SYNONYM_ICON); |
79 | 81 |
} |
80 | 82 |
} |
... | ... | |
128 | 130 |
|
129 | 131 |
@Override |
130 | 132 |
protected void initTextViewer() { |
131 |
|
|
132 |
// showNameRelations(); |
|
133 |
|
|
134 | 133 |
updateIndent(); |
135 | 134 |
|
136 | 135 |
updateIcon(); |
137 | 136 |
String text; |
138 |
if (isMisapplication){
|
|
137 |
if (!conceptType.equals(ConceptType.Synonym) ){
|
|
139 | 138 |
text = NameHelper.getDisplayNameCache(getData()); |
140 | 139 |
}else{ |
141 | 140 |
text = NameHelper.getDisplayName(getData()); |
... | ... | |
154 | 153 |
public void refresh() { |
155 | 154 |
// showNameRelations(); |
156 | 155 |
if (relationship.getType().isAnyMisappliedName()){ |
157 |
isMisapplication = true; |
|
158 |
}else{ |
|
159 |
isMisapplication = false; |
|
160 |
} |
|
156 |
conceptType = ConceptType.Misapplication; |
|
157 |
}else if (relationship.getType().isAnySynonym()){ |
|
158 |
conceptType = ConceptType.Synonym; |
|
159 |
}else{ |
|
160 |
conceptType = ConceptType.InvalidDesignation; |
|
161 |
} |
|
162 |
|
|
161 | 163 |
String text; |
162 |
if (isMisapplication){
|
|
164 |
if (!conceptType.equals(ConceptType.Synonym) ){
|
|
163 | 165 |
text = NameHelper.getDisplayNameCache(getData()); |
164 | 166 |
}else{ |
165 | 167 |
text = NameHelper.getDisplayName(getData()); |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/ContainerFactoryE4.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
} |
33 | 33 |
|
34 |
public static void emptyAcceptedTaxonsHomotypicGroup( |
|
35 |
TaxonNameEditorE4 taxonNameEditor) { |
|
36 |
|
|
37 |
if (taxonNameEditor.getAcceptedGroup() != null ){ |
|
38 |
taxonNameEditor.getAcceptedGroup().emptyGroup(); |
|
39 |
} |
|
40 |
|
|
41 |
} |
|
42 |
|
|
43 |
public static void emptyHeterotypicSynonymsGroups( |
|
44 |
TaxonNameEditorE4 taxonNameEditor) { |
|
45 |
for (HomotypicalSynonymGroupE4 group: taxonNameEditor.getHeterotypicSynonymGroups()){ |
|
46 |
|
|
47 |
group.emptyGroup(); |
|
48 |
|
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
public static void emptyMisappliedNameGroups( |
|
53 |
TaxonNameEditorE4 taxonNameEditor) { |
|
54 |
if (taxonNameEditor.getMisappliedGroup() != null){ |
|
55 |
taxonNameEditor.getMisappliedGroup().emptyGroup(); |
|
56 |
} |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
|
|
34 | 61 |
public static void createOrUpdateHeterotypicSynonymyGroups( |
35 | 62 |
TaxonNameEditorE4 taxonNameEditor) { |
36 | 63 |
List<HomotypicalSynonymGroupE4> retainedGroups = new ArrayList<>(); |
... | ... | |
79 | 106 |
TaxonNameEditorE4 taxonNameEditor) { |
80 | 107 |
MisappliedGroupE4 group = taxonNameEditor.getMisappliedGroup(); |
81 | 108 |
Taxon taxon = HibernateProxyHelper.deproxy(taxonNameEditor.getTaxon(), Taxon.class); |
82 |
if(taxon.getMisappliedNames(true).isEmpty() && taxon.getProParteAndPartialSynonyms().isEmpty()){ |
|
109 |
if(taxon.getMisappliedNames(true).isEmpty() && taxon.getProParteAndPartialSynonyms().isEmpty() && taxon.getInvalidDesignations().isEmpty()){
|
|
83 | 110 |
taxonNameEditor.removeGroup(group); |
84 | 111 |
taxonNameEditor.setMisapplicationsGroup(null); |
85 | 112 |
}else{ |
... | ... | |
92 | 119 |
|
93 | 120 |
} |
94 | 121 |
|
122 |
public static void setMenuToAllContainers(TaxonNameEditorE4 taxonNameEditor){ |
|
123 |
taxonNameEditor.getAcceptedGroup().setMenuToGroup(); |
|
124 |
for(HomotypicalGroup homotypicalGroup : taxonNameEditor.getTaxon().getHeterotypicSynonymyGroups()){ |
|
125 |
homotypicalGroup = HibernateProxyHelper.deproxy(homotypicalGroup, HomotypicalGroup.class); |
|
126 |
HomotypicalSynonymGroupE4 group = taxonNameEditor.getHomotypicalGroupContainer(homotypicalGroup); |
|
127 |
group.setMenuToGroup(); |
|
128 |
} |
|
129 |
taxonNameEditor.getMisappliedGroup().setMenuToGroup(); |
|
130 |
} |
|
131 |
|
|
95 | 132 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/MisappliedGroupE4.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
public class MisappliedGroupE4 extends AbstractGroupE4{ |
25 | 25 |
|
26 |
protected enum ConceptType { |
|
27 |
Misapplication, |
|
28 |
Synonym, |
|
29 |
InvalidDesignation |
|
30 |
} |
|
31 |
|
|
32 |
|
|
26 | 33 |
public MisappliedGroupE4(TaxonNameEditorE4 editor) { |
27 | 34 |
super(editor); |
28 | 35 |
|
... | ... | |
32 | 39 |
@Override |
33 | 40 |
protected void createContainers() { |
34 | 41 |
|
35 |
for(Taxon misapplication : getEditor().getTaxon().getAllProParteSynonyms()){
|
|
36 |
ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, false);
|
|
42 |
for(Taxon proParteSynonym : getEditor().getTaxon().getAllProParteSynonyms()){
|
|
43 |
ConceptContainerE4 container = new ConceptContainerE4(this, proParteSynonym, ConceptType.Synonym);
|
|
37 | 44 |
this.add(container); |
38 | 45 |
container.createContent(); |
39 | 46 |
} |
40 | 47 |
for(Taxon invalidDes : getEditor().getTaxon().getInvalidDesignations()){ |
41 | 48 |
|
42 |
ConceptContainerE4 container = new ConceptContainerE4(this, invalidDes, true);
|
|
49 |
ConceptContainerE4 container = new ConceptContainerE4(this, invalidDes, ConceptType.InvalidDesignation);
|
|
43 | 50 |
this.add(container); |
44 | 51 |
container.createContent(); |
45 | 52 |
} |
46 | 53 |
|
47 | 54 |
for(Taxon misapplication : getEditor().getTaxon().getAllMisappliedNames()){ |
48 | 55 |
|
49 |
ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, true);
|
|
56 |
ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, ConceptType.Misapplication);
|
|
50 | 57 |
this.add(container); |
51 | 58 |
container.createContent(); |
52 | 59 |
} |
... | ... | |
56 | 63 |
public void redraw() { |
57 | 64 |
if(redrawNeeded()){ |
58 | 65 |
super.redraw(); |
66 |
}else{ |
|
67 |
super.setMenuToGroup(); |
|
59 | 68 |
} |
60 | 69 |
} |
61 | 70 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToInvalidDesignationHandlerE4.java | ||
---|---|---|
1 |
/** |
|
2 |
|
|
3 |
* Copyright (C) 2018 EDIT |
|
4 |
|
|
5 |
* European Distributed Institute of Taxonomy |
|
6 |
|
|
7 |
* http://www.e-taxonomy.eu |
|
8 |
|
|
9 |
* |
|
10 |
|
|
11 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
12 |
|
|
13 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
14 |
|
|
15 |
*/ |
|
16 |
|
|
17 |
package eu.etaxonomy.taxeditor.editor.name.e4.handler; |
|
18 |
|
|
19 |
import javax.inject.Named; |
|
20 |
|
|
21 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
22 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
23 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
24 |
import org.eclipse.e4.ui.model.application.ui.basic.MPart; |
|
25 |
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem; |
|
26 |
import org.eclipse.e4.ui.services.IServiceConstants; |
|
27 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
28 |
import org.eclipse.swt.widgets.Shell; |
|
29 |
|
|
30 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
31 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
32 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
|
33 |
import eu.etaxonomy.taxeditor.editor.EditorUtil; |
|
34 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
35 |
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester; |
|
36 |
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptRelationshipTypeOperation; |
|
37 |
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToConceptOperation; |
|
38 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
39 |
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; |
|
40 |
|
|
41 |
/** |
|
42 |
* @author k.luther |
|
43 |
* @since 14.09.2018 |
|
44 |
* |
|
45 |
*/ |
|
46 |
|
|
47 |
public class ChangeToInvalidDesignationHandlerE4 { |
|
48 |
private TaxonNameEditorE4 editor; |
|
49 |
|
|
50 |
@Execute |
|
51 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
52 |
@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
|
53 |
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell, |
|
54 |
MHandledMenuItem menuItem, |
|
55 |
UISynchronize sync) { |
|
56 |
|
|
57 |
editor = (TaxonNameEditorE4) activePart.getObject(); |
|
58 |
Object selectedElement = selection.getFirstElement(); |
|
59 |
AbstractPostTaxonOperation operation = null; |
|
60 |
|
|
61 |
if(selectedElement instanceof Taxon){ |
|
62 |
operation = new ChangeConceptRelationshipTypeOperation(menuItem.getLocalizedLabel(), |
|
63 |
editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, TaxonRelationshipType.INVALID_DESIGNATION_FOR(), editor); |
|
64 |
} |
|
65 |
|
|
66 |
if(selectedElement instanceof Synonym){ |
|
67 |
operation = new ChangeSynonymToConceptOperation(menuItem.getLocalizedLabel(), |
|
68 |
editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, TaxonRelationshipType.INVALID_DESIGNATION_FOR(), editor); |
|
69 |
} |
|
70 |
|
|
71 |
if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){ |
|
72 |
return ; |
|
73 |
} |
|
74 |
|
|
75 |
AbstractUtility.executeOperation(operation, sync); |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
@CanExecute |
|
80 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
|
81 |
MHandledMenuItem menuItem){ |
|
82 |
|
|
83 |
boolean canExecute = false; |
|
84 |
if(selection.size()==1){ |
|
85 |
Object selectedElement = selection.getFirstElement(); |
|
86 |
canExecute =!NameEditorMenuPropertyTester.isAccepted(selectedElement)&& !NameEditorMenuPropertyTester.isMisapplication(selectedElement); |
|
87 |
} |
|
88 |
menuItem.setVisible(canExecute); |
|
89 |
return canExecute; |
|
90 |
} |
|
91 |
|
|
92 |
} |
|
93 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToMisapplicationHandlerE4.java | ||
---|---|---|
29 | 29 |
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptRelationshipTypeOperation; |
30 | 30 |
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToMisapplicationOperation; |
31 | 31 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
32 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
32 |
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
|
33 | 33 |
|
34 | 34 |
/** |
35 | 35 |
* |
... | ... | |
50 | 50 |
|
51 | 51 |
editor = (TaxonNameEditorE4) activePart.getObject(); |
52 | 52 |
|
53 |
if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){ |
|
54 |
return ; |
|
55 |
} |
|
53 |
|
|
56 | 54 |
Object selectedElement = selection.getFirstElement(); |
57 | 55 |
|
58 |
AbstractPostOperation operation = null; |
|
56 |
AbstractPostTaxonOperation operation = null;
|
|
59 | 57 |
if(selectedElement instanceof Taxon){ |
60 | 58 |
operation = new ChangeConceptRelationshipTypeOperation(menuItem.getLocalizedLabel(), |
61 | 59 |
editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), editor); |
62 | 60 |
} |
63 | 61 |
if(selectedElement instanceof Synonym){ |
64 |
operation = new ChangeSynonymToMisapplicationOperation(menuItem.getLocalizedLabel(), |
|
65 |
editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor); |
|
62 |
if (((Synonym)selectedElement).getId() == 0){ |
|
63 |
//only create a new Taxon with name of synonym, create a taxonRelationship and remove the synonym |
|
64 |
}else{ |
|
65 |
operation = new ChangeSynonymToMisapplicationOperation(menuItem.getLocalizedLabel(), |
|
66 |
editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor); |
|
67 |
} |
|
68 |
|
|
66 | 69 |
} |
67 | 70 |
|
68 | 71 |
|
72 |
if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){ |
|
73 |
return ; |
|
74 |
} |
|
69 | 75 |
AbstractUtility.executeOperation(operation, sync); |
70 | 76 |
} |
71 | 77 |
|
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/CreateInvalidDesignationHandlerE4.java | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (C) 2018 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 |
|
|
10 |
package eu.etaxonomy.taxeditor.editor.name.e4.handler; |
|
11 |
|
|
12 |
import javax.inject.Named; |
|
13 |
|
|
14 |
import org.eclipse.e4.core.di.annotations.CanExecute; |
|
15 |
import org.eclipse.e4.core.di.annotations.Execute; |
|
16 |
import org.eclipse.e4.ui.di.UISynchronize; |
|
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 |
|
|
22 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
23 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
24 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
|
25 |
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4; |
|
26 |
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester; |
|
27 |
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation; |
|
28 |
import eu.etaxonomy.taxeditor.model.AbstractUtility; |
|
29 |
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation; |
|
30 |
import eu.etaxonomy.taxeditor.parser.ParseHandler; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author k.luther |
|
34 |
* @since 14.09.2018 |
|
35 |
* |
|
36 |
*/ |
|
37 |
|
|
38 |
public class CreateInvalidDesignationHandlerE4 { |
|
39 |
|
|
40 |
@Execute |
|
41 |
public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart, |
|
42 |
MHandledMenuItem menuItem, |
|
43 |
UISynchronize sync) { |
|
44 |
|
|
45 |
TaxonNameEditorE4 editor = (TaxonNameEditorE4) activePart.getObject(); |
|
46 |
TaxonName conceptName = ParseHandler.createEmptyName(); |
|
47 |
Taxon concept = Taxon.NewInstance(conceptName, null); |
|
48 |
TaxonRelationshipType type = TaxonRelationshipType.INVALID_DESIGNATION_FOR(); |
|
49 |
AbstractPostOperation<?> operation; |
|
50 |
operation = new CreateConceptRelationOperation(menuItem.getLocalizedLabel(), |
|
51 |
editor.getUndoContext(), editor.getTaxon(), concept, type, editor); |
|
52 |
|
|
53 |
AbstractUtility.executeOperation(operation, sync); |
|
54 |
} |
|
55 |
|
|
56 |
@CanExecute |
|
57 |
public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection, |
|
58 |
MHandledMenuItem menuItem){ |
|
59 |
|
|
60 |
boolean canExecute = false; |
|
61 |
Object selectedElement = selection.getFirstElement(); |
|
62 |
canExecute = NameEditorMenuPropertyTester.isAccepted(selectedElement) |
|
63 |
&& !NameEditorMenuPropertyTester.isMisapplication(selectedElement); |
|
64 |
return canExecute; |
|
65 |
} |
|
66 |
|
|
67 |
} |
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java | ||
---|---|---|
112 | 112 |
} |
113 | 113 |
else if (IS_ORPHANED.equals(property)){ |
114 | 114 |
return isOrphaned(selectedElement); |
115 |
} |
|
115 |
}else if (IS_NOT_INVALID_DESIGNATION.equals(property)){ |
|
116 |
return isNotInvalidDesignation(selectedElement); |
|
117 |
} |
|
116 | 118 |
|
117 | 119 |
} |
118 | 120 |
|
... | ... | |
210 | 212 |
} |
211 | 213 |
|
212 | 214 |
public static boolean isAccepted(Object selectedElement) { |
213 |
return (selectedElement instanceof Taxon && ! ((Taxon) selectedElement).isMisapplication() && ! ((Taxon) selectedElement).isProparteSynonym()) ? true : false;
|
|
215 |
return (selectedElement instanceof Taxon && !(((Taxon) selectedElement).isMisapplication()|| ((Taxon) selectedElement).isProparteSynonym() || ((Taxon) selectedElement).isInvalidDesignation())) ? true : false;
|
|
214 | 216 |
} |
215 | 217 |
|
216 | 218 |
public static boolean isOrphaned(Object selectedElement) { |
... | ... | |
233 | 235 |
} |
234 | 236 |
return false; |
235 | 237 |
} |
238 |
|
|
239 |
/** |
|
240 |
* @param selectedElement |
|
241 |
* @return |
|
242 |
*/ |
|
243 |
public static boolean isNotInvalidDesignation(Object selectedElement) { |
|
244 |
if((selectedElement instanceof Taxon) && ((Taxon) selectedElement).isInvalidDesignation()){ |
|
245 |
return false; |
|
246 |
} |
|
247 |
return true; |
|
248 |
} |
|
249 |
|
|
236 | 250 |
} |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonRelationshipDetailElement.java | ||
---|---|---|
67 | 67 |
@Override |
68 | 68 |
protected void createControls(ICdmFormElement formElement, |
69 | 69 |
TaxonRelationship entity, int style) { |
70 |
if ((entity.getType().isAnyMisappliedName()) ){
|
|
70 |
if ((entity.getType().isMisappliedNameOrInvalidDesignation()) ){
|
|
71 | 71 |
|
72 | 72 |
taxon = entity.getFromTaxon(); |
73 | 73 |
|
... | ... | |
75 | 75 |
taxonElement.setLayoutData(LayoutConstants.FILL_HORIZONTALLY(2, 1)); |
76 | 76 |
addControl(taxonElement); |
77 | 77 |
addElement(taxonElement); |
78 |
combo_misappliedRelationshipType = formFactory.createMisappliedRelationshipComboElement(formElement, "Misapplication Type", |
|
79 |
entity.getType(), style); |
|
80 |
|
|
81 |
combo_misappliedRelationshipType.setEnabled(true); |
|
78 |
String label; |
|
79 |
if (entity.getType().isAnyMisappliedName()) { |
|
80 |
label = "Sensu"; |
|
81 |
}else{ |
|
82 |
label = "Sec."; |
|
83 |
} |
|
82 | 84 |
|
83 | 85 |
sensuReference = formFactory.createSelectionElement(Reference.class,//getConversationHolder(), |
84 |
formElement, "Sensu",
|
|
86 |
formElement, label,
|
|
85 | 87 |
taxon.getSec(), EntitySelectionElement.ALL, |
86 | 88 |
style); |
87 | 89 |
|
... | ... | |
90 | 92 |
taxon.getSecMicroReference(),null, |
91 | 93 |
SWT.WRAP); |
92 | 94 |
|
95 |
if (entity.getType().isAnyMisappliedName()) { |
|
96 |
label = "Misapplication Type"; |
|
97 |
}else{ |
|
98 |
label = "Relationship Type"; |
|
99 |
} |
|
100 |
combo_misappliedRelationshipType = formFactory.createMisappliedRelationshipComboElement(formElement, label, |
|
101 |
entity.getType(), style); |
|
102 |
|
|
103 |
|
|
104 |
combo_misappliedRelationshipType.setEnabled(true); |
|
105 |
if (entity.getType().isAnyMisappliedName()) { |
|
106 |
label = "Misappl. Sec."; |
|
107 |
}else{ |
|
108 |
label = "Err. Sec."; |
|
109 |
} |
|
93 | 110 |
secReference = formFactory.createSelectionElement(Reference.class,//getConversationHolder(), |
94 |
formElement, "Misappl. Sec.",
|
|
111 |
formElement, label,
|
|
95 | 112 |
entity.getCitation(), EntitySelectionElement.ALL, |
96 | 113 |
style); |
97 | 114 |
|
... | ... | |
99 | 116 |
formElement, "Detail", |
100 | 117 |
entity.getCitationMicroReference(),null, |
101 | 118 |
SWT.WRAP); |
102 |
checkBoxDoubtful = formFactory.createCheckbox(formElement, "Misapplication Doubtful", entity.isDoubtful(), style); |
|
119 |
if (entity.getType().isAnyMisappliedName()) { |
|
120 |
label = "Misapplication Doubtful"; |
|
121 |
}else{ |
|
122 |
label = "Relationship Doubtful"; |
|
123 |
} |
|
124 |
checkBoxDoubtful = formFactory.createCheckbox(formElement, label, entity.isDoubtful(), style); |
|
103 | 125 |
}else if (entity.getType().isAnySynonym() ){ |
104 | 126 |
taxon = entity.getFromTaxon(); |
105 | 127 |
|
... | ... | |
168 | 190 |
|
169 | 191 |
@Override |
170 | 192 |
public void handleEvent(Object eventSource) { |
171 |
if (getEntity().getType().isAnyMisappliedName() || getEntity().getType().isAnySynonym()){
|
|
193 |
if (getEntity().getType().isMisappliedNameOrInvalidDesignation() || getEntity().getType().isAnySynonym()){
|
|
172 | 194 |
if (eventSource == secReference) { |
173 | 195 |
getEntity().setCitation(secReference.getSelection()); |
174 | 196 |
} else if (eventSource == text_secundum_microreference) { |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java | ||
---|---|---|
158 | 158 |
logger.debug("Something went wrong for viewer.getControl().setEnabled(true) in " + this.getClass().getSimpleName(), e); |
159 | 159 |
} |
160 | 160 |
|
161 |
}else{ |
|
162 |
System.out.println("viewer is not enabled"); |
|
161 | 163 |
} |
162 | 164 |
|
163 | 165 |
|
... | ... | |
200 | 202 |
if(selection.getFirstElement()!=null){ |
201 | 203 |
if (element instanceof Taxon){ |
202 | 204 |
Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class); |
203 |
if (taxon.isMisapplication() || taxon.isProparteSynonym()){ |
|
205 |
if (taxon.isMisapplication() || taxon.isProparteSynonym() || taxon.isInvalidDesignation()){
|
|
204 | 206 |
|
205 | 207 |
if(part instanceof ITaxonEditor){ |
206 | 208 |
Taxon accepted = ((ITaxonEditor) part).getTaxon(); |
... | ... | |
208 | 210 |
|
209 | 211 |
if (rels != null && rels.iterator().hasNext() && !taxon.equals(accepted)){ |
210 | 212 |
TaxonRelationship rel = rels.iterator().next(); |
211 |
if ((rel.getType().isAnyMisappliedName() || rel.getType().isAnySynonym())&& !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
|
|
213 |
if ((rel.getType().isMisappliedNameOrInvalidDesignation() || rel.getType().isAnySynonym()) && !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
|
|
212 | 214 |
viewer.setInput(rel); |
213 | 215 |
selectionProvidingPart = activePart; |
214 | 216 |
return; |
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java | ||
---|---|---|
368 | 368 |
} else if (input instanceof Group) { |
369 | 369 |
createGroupSection(rootElement); |
370 | 370 |
} else if (input instanceof TaxonRelationship && ((TaxonRelationship)input).getType()!=null |
371 |
&& (((TaxonRelationship)input).getType().isAnyMisappliedName() || ((TaxonRelationship)input).getType().isAnySynonym())){ |
|
371 |
&& (((TaxonRelationship)input).getType().isAnyMisappliedName() || ((TaxonRelationship)input).getType().isAnySynonym() || ((TaxonRelationship)input).getType().isMisappliedNameOrInvalidDesignation())){
|
|
372 | 372 |
createMisappliedNameSection(rootElement); |
373 | 373 |
}else if (input instanceof TaxonRelationship ) { |
374 | 374 |
createTaxonRelationshipSection(rootElement); |
Also available in: Unified diff
ref #7424: after updating name editor set menu to all containers to avoid missing menu