Project

General

Profile

Revision 8e0e024c

ID8e0e024c985ffbbe2ce2421270927059c9abf0cc
Parent 35f94062
Child b7299e98

Added by Katja Luther about 2 years ago

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

View differences:

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
        }
741 744

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

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

  
761 771
    }
762 772

  
763 773
    @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;
21 22
import eu.etaxonomy.cdm.strategy.cache.TaggedCacheHelper;
22 23
import eu.etaxonomy.cdm.strategy.cache.TaggedText;
23 24
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
24 25
import eu.etaxonomy.taxeditor.editor.name.container.EditorAnnotation;
25 26
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
27
import eu.etaxonomy.taxeditor.editor.name.e4.container.MisappliedGroupE4.ConceptType;
26 28
import eu.etaxonomy.taxeditor.model.AbstractUtility;
27 29
import eu.etaxonomy.taxeditor.model.NameHelper;
28 30
import eu.etaxonomy.taxeditor.preference.Resources;
......
37 39
public class ConceptContainerE4 extends AbstractGroupedContainerE4<Taxon> {
38 40
	TaxonRelationship relationship;
39 41
	TaxonRelationshipFormatter misappliedFormatter;
42
	ConceptType conceptType;
40 43

  
41
	private boolean isMisapplication;
42 44

  
43
	public ConceptContainerE4(AbstractGroupE4 group, Taxon misappliedName, boolean isMisapplication) {
45

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

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

  
65 72
		}
66 73
		showSec();
67 74

  
......
70 77

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

  
82 87
	private void showSec() {
......
86 91
		List<Language> languages = new ArrayList<>();
87 92
		languages.add(CdmStore.getDefaultLanguage());
88 93
		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
		}
89 99

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

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

  
133 140
		updateIcon();
134 141
		String text;
135
		if (isMisapplication){
142
		if (!conceptType.equals(ConceptType.Synonym) ){
136 143
		    text = NameHelper.getDisplayNameCache(getData());
137 144
		}else{
138 145
		    text = NameHelper.getDisplayName(getData());
......
151 158
    public void refresh() {
152 159
		// showNameRelations();
153 160
	    if (relationship.getType().isAnyMisappliedName()){
154
	        isMisapplication = true;
155
	    }else{
156
	        isMisapplication = false;
161
	        conceptType = ConceptType.Misapplication;
162
	    }else if (relationship.getType().isAnySynonym()){
163
	        conceptType = ConceptType.Synonym;
164
	    } else{
165
	        conceptType = ConceptType.InvalidDesignation;
157 166
	    }
158 167
		String text;
159
		if (isMisapplication){
168
		if (!conceptType.equals(ConceptType.Synonym) ){
160 169
            text = NameHelper.getDisplayNameCache(getData());
161 170
        }else{
162 171
            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()){
82
		if(taxon.getMisappliedNames(true).isEmpty() && taxon.getProParteAndPartialSynonyms().isEmpty() && taxon.getInvalidDesignations().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

  
26 32
	public MisappliedGroupE4(TaxonNameEditorE4 editor) {
27 33
		super(editor);
28 34

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

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

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

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

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

  
71
		concepts.addAll(getEditor().getTaxon().getInvalidDesignations());
66 72
		Set<Taxon> presentConcepts = new HashSet<>();
67 73

  
68 74
		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.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
        }
56
		Object selectedElement = selection.getFirstElement();
53
        Object selectedElement = selection.getFirstElement();
57 54

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

  
68

  
64
        if (!EditorUtil.forceUserSaveE4Editor(editor, shell)){
65
            return ;
66
        }
67
        //editor.getEditorInput().addOperation(operation);
69 68
        AbstractUtility.executeOperation(operation, sync);
70 69
	}
71 70

  
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/view/concept/operation/CreateConceptRelationOperation.java
58 58
		this(label, undoContext, taxon, concept, new TaxonRelationshipTypeInverseContainer(taxonRelationshipType, false), postOperationEnabled);
59 59
	}
60 60

  
61

  
62

  
61 63
	/* (non-Javadoc)
62 64
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
63 65
	 */
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);
48 51
        }
49 52
        populateTerms(relTypes);
50 53
        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()){
203
                    if (taxon.isMisapplication() || taxon.isProparteSynonym() || taxon.isInvalidDesignation()){
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().isAnyMisappliedName() || rel.getType().isAnySynonym())&& !rel.getFromTaxon().equals(((ITaxonEditor) part).getTaxon())){
211
                                if ((rel.getType().isAnySynonym() || rel.getType().isMisappliedNameOrInvalidDesignation())&& !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())){
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

Add picture from clipboard (Maximum size: 40 MB)