Project

General

Profile

Download (1.46 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 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.ui.combo;
10

    
11
import org.eclipse.jface.viewers.ComboViewer;
12
import org.eclipse.jface.viewers.IStructuredSelection;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.custom.CCombo;
15
import org.eclipse.swt.layout.FillLayout;
16
import org.eclipse.swt.widgets.Composite;
17

    
18
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
19

    
20
/**
21
 * @author pplitzner
22
 * @since Nov 24, 2017
23
 *
24
 */
25
public class TermUuidComboViewer extends Composite{
26

    
27
    private ComboViewer viewer;
28

    
29
    public TermUuidComboViewer(Composite parent, int style){
30
        super(parent, style);
31
        setLayout(new FillLayout());
32
        viewer = new ComboViewer(new CCombo(this, SWT.READ_ONLY | SWT.SINGLE));
33
        viewer.setContentProvider(new TermUuidContentProvider());
34
        viewer.setLabelProvider(new TermUuidLabelProvider());
35
    }
36

    
37
    public void setInput(Object input){
38
        viewer.setInput(input);
39
    }
40

    
41
    public DefinedTermBase getSelection(){
42
        IStructuredSelection structuredSelection = viewer.getStructuredSelection();
43
        if(structuredSelection!=null && !structuredSelection.isEmpty()){
44
            return (DefinedTermBase) structuredSelection.getFirstElement();
45
        }
46
        return null;
47
    }
48

    
49
}
(4-4/7)