Project

General

Profile

Revision c5cfeefd

IDc5cfeefde69828735b910d91075f0d7bdb42464f
Parent 9da648a0
Child de550782

Added by Katja Luther over 3 years ago

fix #7500: for misapplied names related to different taxa use chooseAcceptedTaxonDialog

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/ChooseFromMultipleAcceptedTaxaDialog.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;
10

  
11
import java.util.Set;
12

  
13
import org.eclipse.core.runtime.IStatus;
14
import org.eclipse.swt.widgets.Shell;
15
import org.eclipse.ui.dialogs.ListDialog;
16

  
17
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
18
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
19
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
20
import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
21

  
22
/**
23
 * @author k.luther
24
 * @since 28.08.2018
25
 *
26
 */
27
public class ChooseFromMultipleAcceptedTaxaDialog extends ListDialog{
28

  
29
        public static TaxonNode choose(Set<TaxonNode> taxonNodes){
30
            ChooseFromMultipleAcceptedTaxaDialog dialog = new ChooseFromMultipleAcceptedTaxaDialog(EditorUtil.getShell());
31
            dialog.setInput(taxonNodes);
32
            int result = dialog.open();
33

  
34
            if(result == IStatus.OK){
35
                TaxonNode selectedTaxonNode = (TaxonNode) dialog.getResult()[0];
36

  
37
                return selectedTaxonNode;
38

  
39
            }
40
            return null;
41
        }
42

  
43
        public ChooseFromMultipleAcceptedTaxaDialog(Shell parent) {
44
            super(parent);
45
            setTitle(Messages.ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON);
46
            setMessage(Messages.ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON_MESSAGE);
47
            setContentProvider(new TaxonTreeNodeContentProvider());
48
            setLabelProvider(new TaxonTreeNodeLabelProvider());
49
        }
50

  
51
//        private class ClassificationLabelProvider extends LabelProvider{
52
//            @Override
53
//            public String getText(Object element) {
54
//                return super.getText(((Classification) element).getTitleCache());
55
//            }
56
//        }
57

  
58
//        private class ClassificationContentProvider implements IStructuredContentProvider{
59
//
60
//            @Override
61
//            public Object[] getElements(Object inputElement) {
62
//                Set<TaxonNode> taxonNodes = (Set<TaxonNode>) inputElement;
63
//
64
//                    List<Classification> classifications = new ArrayList<Classification>();
65
//
66
//                    for(TaxonNode node : taxonNodes){
67
//                        classifications.add(node.getClassification());
68
//                    }
69
//
70
//                    return classifications.toArray();
71
//            }
72
//
73
//            @Override
74
//            public void dispose() {
75
//
76
//            }
77
//
78
//            @Override
79
//            public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
80
//
81
//            }
82
//        }
83
 //   }
84

  
85
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
13 13
import java.util.Arrays;
14 14
import java.util.HashMap;
15 15
import java.util.HashSet;
16
import java.util.Iterator;
16 17
import java.util.List;
17 18
import java.util.Map;
18 19
import java.util.Map.Entry;
......
42 43
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
43 44
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
44 45
import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput;
46
import eu.etaxonomy.taxeditor.editor.ChooseFromMultipleAcceptedTaxaDialog;
45 47
import eu.etaxonomy.taxeditor.editor.ChooseFromMultipleTaxonNodesDialog;
46 48
import eu.etaxonomy.taxeditor.editor.EditorUtil;
47 49
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
......
145 147
                            acceptedTaxa.add(relation.getToTaxon());
146 148
                        }
147 149
                    }
148
                    setInputForMultipleTaxa(conversation, acceptedTaxa);
150
                    setInputForRelatedTaxa(conversation, acceptedTaxa);
149 151

  
150 152
                }else{
151 153
                    setInputForMultipleNodes(conversation, taxon.getTaxonNodes());
......
185 187
            taxonNode = getCdmEntitySession().remoteLoad(CdmStore.getService(ITaxonNodeService.class), taxonNode.getUuid(), getTaxonNodePropertyPaths());
186 188
            init(taxonNode);
187 189
        }else if(taxonNodes.size() > 1){
190

  
188 191
            TaxonNode taxonNode = ChooseFromMultipleTaxonNodesDialog.choose(taxonNodes);
189 192
            if(taxonNode != null){
190 193
                taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid(), getTaxonNodePropertyPaths());
......
215 218
        }
216 219
    }
217 220

  
221
    private void setInputForRelatedTaxa(ConversationHolder conversation, Set<Taxon> taxa){
222
        if(taxa.size() == 1){
223
            Taxon taxon = taxa.iterator().next();
224
            Set<TaxonNode> nodes = taxon.getTaxonNodes();
225
            TaxonNode taxonNode = ChooseFromMultipleTaxonNodesDialog.choose(nodes);
226
            init(taxonNode);
227
        }else if(taxa.size() > 1){
228
            Iterator<Taxon> taxonIterator = taxa.iterator();
229
            Set<TaxonNode> nodes = new HashSet<>();
230
            while (taxonIterator.hasNext()){
231

  
232
                nodes.addAll(taxonIterator.next().getTaxonNodes());
233
            }
234
            TaxonNode taxonNode = ChooseFromMultipleAcceptedTaxaDialog.choose(nodes);
235
            if(taxonNode != null){
236
                taxonNode = CdmStore.getService(ITaxonNodeService.class).load(taxonNode.getUuid(), getTaxonNodePropertyPaths());
237
            }
238
            if(taxonNode != null){
239
                init(taxonNode);
240
            }
241
        } else if (taxa.size() == 0) {
242
            // this is an undesired state
243
            MessagingUtils.warningDialog(INCORRECT_STATE,TaxonEditorInputE4.class,Messages.TaxonEditorInput_TAXON_NOT_IN_CLASSIFICATION);
244
        }
245
    }
246

  
218 247
    public static TaxonEditorInputE4 NewInstance(UUID taxonNodeUuid) {
219 248
        return new TaxonEditorInputE4(taxonNodeUuid, CdmType.TAXON_NODE);
220 249

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/Messages.java
74 74
    public static String ChecklistEditor_UNKNOWN;
75 75
    public static String ChooseFromMultipleTaxonNodesDialog_CHOOSE_CLASSIFICATION;
76 76
    public static String ChooseFromMultipleTaxonNodesDialog_CHOOSE_CLASSIFICATION_MESSAGE;
77
    public static String ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON;
78
    public static String ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON_MESSAGE;
77 79
    public static String ConceptContainer_SEC_REQUIRED;
78 80
    public static String ConceptGraphView_VIEWER_NAME;
79 81
	public static String ConceptViewPart_VIEWER_NAME;
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages.properties
264 264
DescriptiveDataSetComposite_TAXON_FILTER=Taxon filter
265 265
DescriptiveDataSetEditor_DELETE_FAIL_MESSAGE=You can only select top level elements
266 266
DescriptiveDataSetEditor_DELETE_FAIL_TITLE=Could not delete
267
ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON=Choose accepted taxon
268
ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON_MESSAGE=The taxon is related to different accepted taxa. Please choose the one you want to open.
269

  
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/l10n/messages_de.properties
264 264
DescriptiveDataSetComposite_TAXON_FILTER=Taxonfilter
265 265
DescriptiveDataSetEditor_DELETE_FAIL_MESSAGE=Es k?nnen nur Elemente auf erster Ebene ausgew?hlt werden
266 266
DescriptiveDataSetEditor_DELETE_FAIL_TITLE=L?schen fehlgesschlagen
267
ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON=Akzeptiertes Taxon w?hlen
268
ChooseFromMultipleAcceptedTaxaDialog_CHOOSE_ACCEPTED_TAXON_MESSAGE=Das Taxon ist ?ber eine Taxonrelation mit mehreren akzeptierten Taxa verkn?pft. Bitte w?hlen sie, welche sie ?ffnen m?chten.
269

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)