Project

General

Profile

Download (1.48 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2022 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.view.concept.e4;
10

    
11
import java.util.ArrayList;
12
import java.util.Iterator;
13
import java.util.List;
14
import java.util.Map.Entry;
15

    
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.ListViewer;
19
import org.eclipse.jface.viewers.StructuredSelection;
20
import org.eclipse.swt.widgets.Composite;
21

    
22
import eu.etaxonomy.cdm.model.taxon.Taxon;
23
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
24

    
25
class ConceptRelationViewer extends ListViewer {
26

    
27
    public ConceptRelationViewer(Composite parent) {
28
		super(parent);
29
	}
30

    
31
	@Override
32
	public ISelection getSelection() {
33
		ISelection selection = super.getSelection();
34
		List<TaxonRelationship> relationships = new ArrayList<>();
35
		if(selection instanceof IStructuredSelection && !selection.isEmpty()){
36
		    for(Iterator<?> iter = ((IStructuredSelection) selection).iterator();iter.hasNext();){
37
		        Object object = iter.next();
38
		        relationships.add(((Entry<TaxonRelationship, Taxon>)object).getKey());
39
		    }
40
		    return new StructuredSelection(relationships);
41
		}
42
		return selection;
43
	}
44

    
45
	@Override
46
	public void setSelection(ISelection selection) {
47
		super.setSelection(selection);
48
	}
49
}
(1-1/3)