Project

General

Profile

Download (3.14 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2019 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.view.search.facet.term;
10

    
11
import org.eclipse.jface.layout.GridDataFactory;
12
import org.eclipse.jface.resource.JFaceResources;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.DragDetectEvent;
15
import org.eclipse.swt.events.DragDetectListener;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Label;
21

    
22
/**
23
 * @author pplitzner
24
 * @since Jan 23, 2019
25
 *
26
 */
27
public class TermSearchResultComposite extends Composite {
28

    
29
    private Label label;
30
    private boolean isSelected;
31
    private TermSearchResult result;
32
    private Button btnCheck;
33
    private Composite composite_1;
34

    
35
    /**
36
     * Create the composite.
37
     * @param result
38
     * @param parent
39
     * @param style
40
     */
41
    public TermSearchResultComposite(TermSearchResult result, Composite parent, int style) {
42
        super(parent, style);
43
        this.result = result;
44
        setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
45
        GridLayout gridLayout = new GridLayout();
46
        gridLayout.marginWidth = 0;
47
        gridLayout.horizontalSpacing = 0;
48
        gridLayout.numColumns = 2;
49
        setLayout(gridLayout);
50

    
51
        Composite composite = new Composite(this, SWT.NONE);
52
        composite.setLayout(new GridLayout(1, false));
53
        composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
54

    
55
        btnCheck = new Button(composite, SWT.CHECK);
56
        btnCheck.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
57

    
58
        composite_1 = new Composite(this, SWT.NONE);
59
        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
60
        composite_1.setLayout(new GridLayout(1, false));
61
        label = new Label(composite_1, SWT.NONE);
62
        label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
63
        label.setText(result.getContent().getRepresentation_L10n());
64
        label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
65
        GridDataFactory.fillDefaults().applyTo(label);
66
        label.addDragDetectListener(new DragDetectListener() {
67

    
68
            @Override
69
            public void dragDetected(DragDetectEvent e) {
70
                System.out.println("dragDetected");
71
            }
72
        });
73

    
74
        Label lblDescription = new Label(composite_1, SWT.NONE);
75
        String representation_L10n_text = result.getContent().getRepresentation_L10n_text();
76
        if(representation_L10n_text!=null){
77
            lblDescription.setText(representation_L10n_text);
78
        }
79
    }
80

    
81
    public TermSearchResult getResult() {
82
        return result;
83
    }
84

    
85
    @Override
86
    protected void checkSubclass() {
87
        // Disable the check that prevents subclassing of SWT components
88
    }
89
    public Button getBtnCheck() {
90
        return btnCheck;
91
    }
92
}
(5-5/5)