Project

General

Profile

« Previous | Next » 

Revision 4e956294

Added by Andreas Müller over 5 years ago

Revert "ref #7761: invalid designations are displayed in name editor and details view like MAN"

This reverts commit 8e0e024c985ffbbe2ce2421270927059c9abf0cc.

View differences:

eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin.properties
34 34
command.label.12 = Accepted Taxon
35 35
command.label.13 = Synonym
36 36
command.label.14 = Misapplication
37
command.label.61 = Pro Parte Synonym
38 37
command.label.15 = Delete
39 38
command.label.16 = Delete All Empty Names
40 39
command.label.17 = Swap Synonym With Accepted
......
132 131
command.label.60 = Pro Parte Synonym
133 132
command.name.36 = Create Misapplication
134 133
command.name.60 = Create Pro Parte Synonym
135
command.name.61 = Pro Parte Synonym
136

  
137 134
command.name.37 = Use Existing Image
138 135
command.name.38 = Open Distribution Editor
139 136
command.name.39 = New Datasource
......
252 249
handledmenuitem.tooltip.4 = Character Editor
253 250
handledmenuitem.label.17 = Remove Taxon
254 251
command.commandname.21 = Remove taxon
255

  
256
handledmenuitem.label.18 = Invalid Designation
257
command.commandname.22 = Create Invalid Designation
258

  
259
handledmenuitem.label.19 = Invalid Designation
260
command.commandname.23 = Change To Invalid Designation
eu.etaxonomy.taxeditor.editor/OSGI-INF/l10n/plugin_de.properties
251 251
handledmenuitem.label.16 = Character-Editor
252 252
handledmenuitem.tooltip.4 = Character-Editor
253 253
handledmenuitem.label.17 = Taxon entfernen
254
command.commandname.21 = Taxon entfernen
255

  
256
handledmenuitem.label.18 = Invalid Designation
257
command.commandname.22 = Erstelle Invalid Designation
258

  
259
handledmenuitem.label.19 = Invalid Designation
260
command.commandname.23 = ?ndere zu Invalid Designation
254
command.commandname.21 = Taxon entfernen
eu.etaxonomy.taxeditor.editor/fragment.e4xmi
155 155
      <handlers xmi:id="_lv9GYIvQEee7R4eqeQiXZg" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.MoveSynonymToAnotherAcceptedTaxonHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.MoveSynonymToAnotherAcceptedTaxonHandlerE4" command="_jNvBQIvQEee7R4eqeQiXZg"/>
156 156
      <handlers xmi:id="_g8QScFgWEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateProParteSynonymHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateProParteSynonymHandlerE4" command="_HSKdYFgXEeiQk_eTMvMviQ"/>
157 157
      <handlers xmi:id="_442rEFj-EeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.ChangeToMisapplicationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.ChangeToProParteSynonymHandlerE5" command="_BgX6gFj_EeiQk_eTMvMviQ"/>
158
      <handlers xmi:id="_cOqzoLfqEeiWg83GVEbqbA" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateInvalidDesignationHandlerE4" contributionURI="bundleclass://eu.etaxonomy.taxeditor.editor/eu.etaxonomy.taxeditor.editor.name.e4.handler.CreateInvalidDesignationHandlerE4" command="_t064oLfqEeiWg83GVEbqbA"/>
159
      <handlers xmi:id="_9ja8YLfrEeiWg83GVEbqbA" elementId="eu.etaxonomy.taxeditor.editor.name.e4.handler.ChangeToInvalidDesignationHandlerE4" command="_DfwX8LfsEeiWg83GVEbqbA"/>
160 158
      <menus xsi:type="menu:PopupMenu" xmi:id="_tLceQYl4Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.popupmenu.nameeditor">
161 159
        <children xsi:type="menu:Menu" xmi:id="_R6buoIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menu.new" label="%menu.label">
162
          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_X1lWsEoREeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
160
          <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_X1lWsEoREeiEhr9v9h_MoA" coreExpressionId="isNotMisapplication"/>
163 161
          <children xsi:type="menu:HandledMenuItem" xmi:id="_FjdDgIl8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newHeterotypicSynonym" label="%command.label.9" command="_ult4EIvOEee7R4eqeQiXZg">
164 162
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="__6Cq8EoNEeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
165 163
          </children>
......
176 174
          <children xsi:type="menu:HandledMenuItem" xmi:id="_MCsX0Il8Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.newMisapplication" label="%command.label.49" command="_c0byUIvPEee7R4eqeQiXZg">
177 175
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_G1zjMEoOEeiEhr9v9h_MoA" coreExpressionId="isAcceptedTaxon"/>
178 176
          </children>
179
          <children xsi:type="menu:HandledMenuItem" xmi:id="_HBY9kLfqEeiWg83GVEbqbA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.invaliddesignation" label="%handledmenuitem.label.18" command="_t064oLfqEeiWg83GVEbqbA">
180
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_Kg5xYLfqEeiWg83GVEbqbA" coreExpressionId="isAcceptedTaxon"/>
181
          </children>
182 177
        </children>
183 178
        <children xsi:type="menu:MenuSeparator" xmi:id="_bxjbgE3LEeiplYSgvvNXRQ" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.23"/>
184 179
        <children xsi:type="menu:DynamicMenuContribution" xmi:id="_drYq8E3LEeiplYSgvvNXRQ" elementId="eu.etaxonomy.taxeditor.editor.dynamicmenucontribution.nameEditor.openInCdmViewer" contributionURI="bundleclass://eu.etaxonomy.taxeditor.store/eu.etaxonomy.taxeditor.view.CdmViewerContextMenuE4"/>
......
199 194
          <children xsi:type="menu:HandledMenuItem" xmi:id="_F0EH0FkAEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.changeToProparteSynonym" label="%command.label.61" command="_BgX6gFj_EeiQk_eTMvMviQ">
200 195
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_Lc4KcFkAEeiQk_eTMvMviQ" coreExpressionId="isNotProparteSynonym"/>
201 196
          </children>
202
          <children xsi:type="menu:HandledMenuItem" xmi:id="_oYHcQLfrEeiWg83GVEbqbA" elementId="eu.etaxonomy.taxeditor.editor.handledmenuitem.changeToInvalidDesignation" label="%handledmenuitem.label.19" command="_DfwX8LfsEeiWg83GVEbqbA">
203
            <visibleWhen xsi:type="ui:CoreExpression" xmi:id="_vrBCILfrEeiWg83GVEbqbA" coreExpressionId="isNotInvalidDesignation"/>
204
          </children>
205 197
        </children>
206 198
        <children xsi:type="menu:MenuSeparator" xmi:id="_a0anEIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.menuseparator.13"/>
207 199
        <children xsi:type="menu:HandledMenuItem" xmi:id="_bu3dIIl5Eeeox7omhvOBWg" elementId="eu.etaxonomy.taxeditor.editor.nameEditor.menuItem.delete" label="%command.label.15" command="_CoVcYIvQEee7R4eqeQiXZg"/>
......
377 369
    <elements xsi:type="commands:Command" xmi:id="_c3wW8FeBEeiJAP3GTkE0aQ" elementId="eu.etaxonomy.taxeditor.editor.command.descriptivedataseteditor.removeTaxon" commandName="%command.commandname.21"/>
378 370
    <elements xsi:type="commands:Command" xmi:id="_HSKdYFgXEeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.name.createProParteSynonym" commandName="%command.name.60"/>
379 371
    <elements xsi:type="commands:Command" xmi:id="_BgX6gFj_EeiQk_eTMvMviQ" elementId="eu.etaxonomy.taxeditor.editor.command.changeToProParteSynonym" commandName="%command.name.61"/>
380
    <elements xsi:type="commands:Command" xmi:id="_t064oLfqEeiWg83GVEbqbA" elementId="eu.etaxonomy.taxeditor.editor.name.createInvalidDesignation" commandName="%command.commandname.22"/>
381
    <elements xsi:type="commands:Command" xmi:id="_DfwX8LfsEeiWg83GVEbqbA" elementId="eu.etaxonomy.taxeditor.editor.command.changeToInvalidDesignation" commandName="%command.commandname.23"/>
382 372
  </fragments>
383 373
  <fragments xsi:type="fragment:StringModelFragment" xmi:id="_pZmusEalEeeXMc6kSYO7Xg" featurename="children" parentElementId="eu.etaxonomy.taxeditor.menu.showView" positionInList="after:eu.etaxonomy.taxeditor.workbench.menuseparator.navigation">
384 374
    <elements xsi:type="menu:HandledMenuItem" xmi:id="_FPIHQKNwEeebGZ23ERGMGw" elementId="eu.etaxonomy.taxeditor.editor.showViewMenu.conceptGraph" label="%view.name.3" iconURI="" tooltip="%view.name.3" command="_WPjpoDSnEeek0dKsFNy--Q">
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
738 738
    @Inject
739 739
    @Optional
740 740
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)CdmBase cdmbase){
741
        if (cdmbase == null){
742
            return;
743
        }
744 741

  
745
        if (EventUtility.getTaxonEditor() == null){
746
            return;
747
        }
748
        if (this.taxon == null){
749
            return;
750
        }
751 742
        if (EventUtility.getTaxonEditor().equals(this) || (this.taxon.equals(cdmbase) || this.taxon.getName().equals(cdmbase))){
752 743
            this.redraw(false, true, true, true);
753 744
            this.setDirty();
......
763 754
    @Optional
764 755
    private void updateView(@UIEventTopic(WorkbenchEventConstants.REFRESH_NAME_EDITOR)UUID cdmbaseUuid){
765 756

  
766
        if (this.taxon.getUuid().equals(cdmbaseUuid) ){
757
        if (this.taxon.getUuid().equals(cdmbaseUuid)){
767 758
            TaxonEditorInputE4 input = TaxonEditorInputE4.NewInstanceFromTaxonBase(cdmbaseUuid);
768 759
            init(input);
769 760
        }
770

  
771 761
    }
772 762

  
773 763
    @Inject
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/ConceptContainerE4.java
18 18
import eu.etaxonomy.cdm.model.common.Language;
19 19
import eu.etaxonomy.cdm.model.taxon.Taxon;
20 20
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
21
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
22 21
import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper;
23 22
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
24 23
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
25 24
import eu.etaxonomy.taxeditor.editor.name.container.EditorAnnotation;
26 25
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
27
import eu.etaxonomy.taxeditor.editor.name.e4.container.MisappliedGroupE4.ConceptType;
28 26
import eu.etaxonomy.taxeditor.model.AbstractUtility;
29 27
import eu.etaxonomy.taxeditor.model.NameHelper;
30 28
import eu.etaxonomy.taxeditor.preference.Resources;
......
39 37
public class ConceptContainerE4 extends AbstractGroupedContainerE4<Taxon> {
40 38
	TaxonRelationship relationship;
41 39
	TaxonRelationshipFormatter misappliedFormatter;
42
	ConceptType conceptType;
43 40

  
41
	private boolean isMisapplication;
44 42

  
45

  
46
	public ConceptContainerE4(AbstractGroupE4 group, Taxon misappliedName, ConceptType conceptType) {
43
	public ConceptContainerE4(AbstractGroupE4 group, Taxon misappliedName, boolean isMisapplication) {
47 44
		super(group, misappliedName);
48
		this.conceptType = conceptType;
45
		this.isMisapplication = isMisapplication;
49 46
		misappliedFormatter = new TaxonRelationshipFormatter();
50 47

  
51 48
	}
......
58 55
		TaxonNameEditorE4 editor = getEditor();
59 56
		Taxon taxon = editor.getTaxon();
60 57
		for (TaxonRelationship rel: taxon.getTaxonRelations(getMisappliedName())){
61
			if (rel.getType().isAnyMisappliedName() && this.conceptType.equals(ConceptType.Misapplication)){
58
			if (rel.getType().isAnyMisappliedName() && isMisapplication){
62 59
			    relationship = rel;
63 60
				break;
64
			}else if (rel.getType().isAnySynonym() && this.conceptType.equals(ConceptType.Synonym)){
61
			}else if (rel.getType().isAnySynonym() && !isMisapplication){
65 62
			    relationship = rel;
66 63
                break;
67
			}else if (rel.getType().equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR()) && this.conceptType.equals(ConceptType.InvalidDesignation)){
68
                relationship = rel;
69
                break;
70
            }
71

  
64
			}
72 65
		}
73 66
		showSec();
74 67

  
......
77 70

  
78 71
	@Override
79 72
	protected void updateIcon() {
80
	    if (relationship.getType().isMisappliedNameOrInvalidDesignation()){
73
	    if (relationship.getType().isAnyMisappliedName()){
81 74
	        setIcon(MISAPPLIEDNAME_ICON);
82 75
	    }else if (relationship.getType().isProParte()){
83 76
	        setIcon(PRO_PARTE_SYNONYM_ICON);
84
	    }
77
	    }else {
78
            setIcon(PARTIAL_SYNONYM_ICON);
79
        }
85 80
	}
86 81

  
87 82
	private void showSec() {
......
91 86
		List<Language> languages = new ArrayList<>();
92 87
		languages.add(CdmStore.getDefaultLanguage());
93 88
		List<TaggedText> taggedText = misappliedFormatter.getTaggedText(relationship, true, languages, true);
94
		if (taggedText != null){
95
		    String title = TaggedCacheHelper.createString(taggedText);
96
		    title = title.replace("&", "&&");
97
		    setNonEditableInfo(title, false);
98
		}
99 89

  
90
		String title = TaggedCacheHelper.createString(taggedText);
91
		title = title.replace("&", "&&");
92
		setNonEditableInfo(title, false);
100 93
	}
101 94

  
102 95
	public Taxon getMisappliedName() {
......
139 132

  
140 133
		updateIcon();
141 134
		String text;
142
		if (!conceptType.equals(ConceptType.Synonym) ){
135
		if (isMisapplication){
143 136
		    text = NameHelper.getDisplayNameCache(getData());
144 137
		}else{
145 138
		    text = NameHelper.getDisplayName(getData());
......
158 151
    public void refresh() {
159 152
		// showNameRelations();
160 153
	    if (relationship.getType().isAnyMisappliedName()){
161
	        conceptType = ConceptType.Misapplication;
162
	    }else if (relationship.getType().isAnySynonym()){
163
	        conceptType = ConceptType.Synonym;
164
	    } else{
165
	        conceptType = ConceptType.InvalidDesignation;
154
	        isMisapplication = true;
155
	    }else{
156
	        isMisapplication = false;
166 157
	    }
167 158
		String text;
168
		if (!conceptType.equals(ConceptType.Synonym) ){
159
		if (isMisapplication){
169 160
            text = NameHelper.getDisplayNameCache(getData());
170 161
        }else{
171 162
            text = NameHelper.getDisplayName(getData());
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/container/ContainerFactoryE4.java
79 79
	        TaxonNameEditorE4 taxonNameEditor) {
80 80
		MisappliedGroupE4 group = taxonNameEditor.getMisappliedGroup();
81 81
		Taxon taxon = HibernateProxyHelper.deproxy(taxonNameEditor.getTaxon(), Taxon.class);
82
		if(taxon.getMisappliedNames(true).isEmpty() && taxon.getProParteAndPartialSynonyms().isEmpty() && taxon.getInvalidDesignations().isEmpty()){
82
		if(taxon.getMisappliedNames(true).isEmpty() && taxon.getProParteAndPartialSynonyms().isEmpty()){
83 83
			taxonNameEditor.removeGroup(group);
84 84
			taxonNameEditor.setMisapplicationsGroup(null);
85 85
		}else{
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
	public MisappliedGroupE4(TaxonNameEditorE4 editor) {
33 27
		super(editor);
34 28

  
......
38 32
	@Override
39 33
	protected void createContainers() {
40 34

  
41
		for(Taxon misapplication : getEditor().getTaxon().getAllMisappliedNames()){
42
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, ConceptType.Misapplication);
35
		for(Taxon misapplication : getEditor().getTaxon().getAllProParteSynonyms()){
36
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, false);
43 37
            this.add(container);
44 38
            container.createContent();
45 39
        }
46 40
		for(Taxon invalidDes : getEditor().getTaxon().getInvalidDesignations()){
47 41

  
48
            ConceptContainerE4 container = new ConceptContainerE4(this, invalidDes, ConceptType.InvalidDesignation);
42
            ConceptContainerE4 container = new ConceptContainerE4(this, invalidDes, true);
49 43
            this.add(container);
50 44
            container.createContent();
51 45
        }
52 46

  
53
		for(Taxon misapplication : getEditor().getTaxon().getAllProParteSynonyms()){
47
		for(Taxon misapplication : getEditor().getTaxon().getAllMisappliedNames()){
54 48

  
55
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, ConceptType.Synonym);
49
            ConceptContainerE4 container = new ConceptContainerE4(this, misapplication, true);
56 50
            this.add(container);
57 51
            container.createContent();
58 52
        }
......
68 62
	private boolean redrawNeeded() {
69 63
		Set<Taxon> concepts = getEditor().getTaxon().getMisappliedNames(true);
70 64
		concepts.addAll(getEditor().getTaxon().getProParteAndPartialSynonyms());
71
		concepts.addAll(getEditor().getTaxon().getInvalidDesignations());
65

  
72 66
		Set<Taxon> presentConcepts = new HashSet<>();
73 67

  
74 68
		for (AbstractGroupedContainerE4<Taxon> container  : getGroupedContainers()){
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/handler/ChangeToInvalidDesignationHandlerE4.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
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
10

  
11
import javax.inject.Named;
12

  
13
import org.eclipse.e4.core.di.annotations.CanExecute;
14
import org.eclipse.e4.core.di.annotations.Execute;
15
import org.eclipse.e4.ui.di.UISynchronize;
16
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
17
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
18
import org.eclipse.e4.ui.services.IServiceConstants;
19
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.swt.widgets.Shell;
21

  
22
import eu.etaxonomy.cdm.model.taxon.Synonym;
23
import eu.etaxonomy.cdm.model.taxon.Taxon;
24
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
25
import eu.etaxonomy.taxeditor.editor.EditorUtil;
26
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
27
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
28
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptRelationshipTypeOperation;
29
import eu.etaxonomy.taxeditor.editor.name.operation.ChangeSynonymToConceptOperation;
30
import eu.etaxonomy.taxeditor.model.AbstractUtility;
31
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
32
/**
33
 * @author k.luther
34
 * @since 14.09.2018
35
 *
36
 */
37
public class ChangeToInvalidDesignationHandlerE4 {
38
    private TaxonNameEditorE4 editor;
39

  
40
    @Execute
41
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
42
            @Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
43
            @Named(IServiceConstants.ACTIVE_SHELL)Shell shell,
44
            MHandledMenuItem menuItem,
45
            UISynchronize sync) {
46

  
47
        editor = (TaxonNameEditorE4) activePart.getObject();
48

  
49
        Object selectedElement = selection.getFirstElement();
50

  
51
        AbstractPostTaxonOperation operation = null;
52
        if(selectedElement instanceof Taxon){
53
            operation = new ChangeConceptRelationshipTypeOperation(menuItem.getLocalizedLabel(),
54
                                    editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, TaxonRelationshipType.INVALID_DESIGNATION_FOR(), editor);
55
        }
56
        if(selectedElement instanceof Synonym){
57
            operation = new ChangeSynonymToConceptOperation(menuItem.getLocalizedLabel(),
58
                    editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, TaxonRelationshipType.INVALID_DESIGNATION_FOR(), editor);
59
        }
60
        if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){
61
            return ;
62
        }
63
        //editor.getEditorInput().addOperation(operation);
64
        AbstractUtility.executeOperation(operation, sync);
65
    }
66

  
67
    @CanExecute
68
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
69
            MHandledMenuItem menuItem){
70
        boolean canExecute = false;
71
        if(selection.size()==1){
72
            Object selectedElement = selection.getFirstElement();
73
            canExecute =
74
                    !NameEditorMenuPropertyTester.isAccepted(selectedElement)
75
                    && !NameEditorMenuPropertyTester.isMisapplication(selectedElement);
76
        }
77
        menuItem.setVisible(canExecute);
78
        return canExecute;
79
    }
80

  
81
}
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.AbstractPostTaxonOperation;
32
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
33 33

  
34 34
/**
35 35
 *
......
50 50

  
51 51
        editor = (TaxonNameEditorE4) activePart.getObject();
52 52

  
53
        Object selectedElement = selection.getFirstElement();
53
		if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){
54
            return ;
55
        }
56
		Object selectedElement = selection.getFirstElement();
54 57

  
55
        AbstractPostTaxonOperation operation = null;
58
		AbstractPostOperation operation = null;
56 59
		if(selectedElement instanceof Taxon){
57 60
        	operation = new ChangeConceptRelationshipTypeOperation(menuItem.getLocalizedLabel(),
58 61
        							editor.getUndoContext(), editor.getTaxon(), (Taxon) selectedElement, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), editor);
59 62
        }
60 63
        if(selectedElement instanceof Synonym){
61
            operation = new ChangeSynonymToMisapplicationOperation(menuItem.getLocalizedLabel(),
62
                    editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
63
        }
64
        if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){
65
            return ;
64
        	operation = new ChangeSynonymToMisapplicationOperation(menuItem.getLocalizedLabel(),
65
        			editor.getUndoContext(), editor.getTaxon(), (Synonym) selectedElement, editor);
66 66
        }
67
        //editor.getEditorInput().addOperation(operation);
67

  
68

  
68 69
        AbstractUtility.executeOperation(operation, sync);
69 70
	}
70 71

  
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
package eu.etaxonomy.taxeditor.editor.name.e4.handler;
10
import javax.inject.Named;
11

  
12
import org.eclipse.e4.core.di.annotations.CanExecute;
13
import org.eclipse.e4.core.di.annotations.Execute;
14
import org.eclipse.e4.ui.di.UISynchronize;
15
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
16
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
17
import org.eclipse.e4.ui.services.IServiceConstants;
18
import org.eclipse.jface.viewers.IStructuredSelection;
19

  
20
import eu.etaxonomy.cdm.model.name.TaxonName;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
24
import eu.etaxonomy.taxeditor.editor.name.handler.NameEditorMenuPropertyTester;
25
import eu.etaxonomy.taxeditor.editor.view.concept.operation.CreateConceptRelationOperation;
26
import eu.etaxonomy.taxeditor.model.AbstractUtility;
27
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
28
import eu.etaxonomy.taxeditor.parser.ParseHandler;
29

  
30
/**
31
 * @author k.luther
32
 * @since 14.09.2018
33
 *
34
 */
35
public class CreateInvalidDesignationHandlerE4 {
36

  
37
    @Execute
38
    public void execute(@Named(IServiceConstants.ACTIVE_PART)MPart activePart,
39
            MHandledMenuItem menuItem,
40
            UISynchronize sync) {
41

  
42
        TaxonNameEditorE4 editor = (TaxonNameEditorE4) activePart.getObject();
43

  
44
        TaxonName conceptName = ParseHandler.createEmptyName();
45
        Taxon concept = Taxon.NewInstance(conceptName, null);
46

  
47
        TaxonRelationshipType type = TaxonRelationshipType.INVALID_DESIGNATION_FOR();
48

  
49
        AbstractPostOperation<?> operation;
50

  
51

  
52

  
53
        operation = new CreateConceptRelationOperation(menuItem.getLocalizedLabel(),
54
                editor.getUndoContext(), editor.getTaxon(), concept, type, editor);
55
        AbstractUtility.executeOperation(operation, sync);
56
    }
57

  
58

  
59
    @CanExecute
60
    public boolean canExecute(@Named(IServiceConstants.ACTIVE_SELECTION)IStructuredSelection selection,
61
            MHandledMenuItem menuItem){
62
        boolean canExecute = false;
63
        Object selectedElement = selection.getFirstElement();
64
        canExecute = NameEditorMenuPropertyTester.isAccepted(selectedElement)
65
                && !NameEditorMenuPropertyTester.isMisapplication(selectedElement);
66
        return canExecute;
67
    }
68

  
69
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
209 209
    }
210 210

  
211 211
	public static boolean isAccepted(Object selectedElement) {
212
	    return (selectedElement instanceof Taxon) ? true : false;
212
		return (selectedElement instanceof Taxon  && ! ((Taxon) selectedElement).isMisapplication() && ! ((Taxon) selectedElement).isProparteSynonym()) ? true : false;
213 213
	}
214 214

  
215 215
	public static boolean isOrphaned(Object selectedElement) {
......
232 232
        }
233 233
        return false;
234 234
    }
235

  
236
    /**
237
     * @param selectedElement
238
     * @return
239
     */
240
    public static boolean isNotInvalidDesignation(Object selectedElement) {
241
        if((selectedElement instanceof Taxon) && !((Taxon) selectedElement).isInvalidDesignation()){
242
            return true;
243
        }
244
        return false;
245
    }
246 235
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/concept/operation/CreateConceptRelationOperation.java
58 58
		this(label, undoContext, taxon, concept, new TaxonRelationshipTypeInverseContainer(taxonRelationshipType, false), postOperationEnabled);
59 59
	}
60 60

  
61

  
62

  
63 61
	/* (non-Javadoc)
64 62
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
65 63
	 */
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/MisappliedRelationshipComboElement.java
45 45
        }else if (selection.isAnySynonym()){
46 46
            relTypes.add(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR());
47 47
            relTypes.add(TaxonRelationshipType.PARTIAL_SYNONYM_FOR());
48
        }else if (selection.equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR())){
49
            relTypes.add(TaxonRelationshipType.INVALID_DESIGNATION_FOR());
50
            this.setEnabled(false);
51 48
        }
52 49
        populateTerms(relTypes);
53 50
        setSelection(selection);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
200 200
            if(selection.getFirstElement()!=null){
201 201
                if (element instanceof Taxon){
202 202
                    Taxon taxon = HibernateProxyHelper.deproxy(element, Taxon.class);
203
                    if (taxon.isMisapplication() || taxon.isProparteSynonym() || taxon.isInvalidDesignation()){
203
                    if (taxon.isMisapplication() || taxon.isProparteSynonym()){
204 204

  
205 205
                        if(part instanceof ITaxonEditor){
206 206
                            Taxon accepted = ((ITaxonEditor) part).getTaxon();
......
208 208

  
209 209
                            if (rels != null && rels.iterator().hasNext() && !taxon.equals(accepted)){
210 210
                                TaxonRelationship rel = rels.iterator().next();
211
                                if ((rel.getType().isAnySynonym() || rel.getType().isMisappliedNameOrInvalidDesignation())&& !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
211
                                if ((rel.getType().isAnyMisappliedName() || rel.getType().isAnySynonym())&& !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
212 212
                                    viewer.setInput(rel);
213 213
                                    selectionProvidingPart = activePart;
214 214
                                    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())|| ((TaxonRelationship)input).getType().isMisappliedNameOrInvalidDesignation()){
371
                && (((TaxonRelationship)input).getType().isAnyMisappliedName() || ((TaxonRelationship)input).getType().isAnySynonym())){
372 372
            createMisappliedNameSection(rootElement);
373 373
        }else if (input instanceof TaxonRelationship ) {
374 374
            createTaxonRelationshipSection(rootElement);

Also available in: Unified diff