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.events.FocusEvent;
|
17
|
import org.eclipse.swt.events.FocusListener;
|
18
|
import org.eclipse.swt.events.MouseEvent;
|
19
|
import org.eclipse.swt.events.MouseListener;
|
20
|
import org.eclipse.swt.layout.GridData;
|
21
|
import org.eclipse.swt.layout.GridLayout;
|
22
|
import org.eclipse.swt.widgets.Button;
|
23
|
import org.eclipse.swt.widgets.Composite;
|
24
|
import org.eclipse.swt.widgets.Label;
|
25
|
|
26
|
/**
|
27
|
* @author pplitzner
|
28
|
* @since Jan 23, 2019
|
29
|
*
|
30
|
*/
|
31
|
public class TermSearchResultComposite extends Composite {
|
32
|
|
33
|
private Label label;
|
34
|
private boolean isSelected;
|
35
|
private TermSearchResult result;
|
36
|
private Button btnCheck;
|
37
|
private Composite composite_1;
|
38
|
|
39
|
/**
|
40
|
* Create the composite.
|
41
|
* @param result
|
42
|
* @param parent
|
43
|
* @param style
|
44
|
*/
|
45
|
public TermSearchResultComposite(TermSearchResult result, Composite parent, int style) {
|
46
|
super(parent, style);
|
47
|
this.result = result;
|
48
|
setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
|
49
|
GridLayout gridLayout = new GridLayout();
|
50
|
gridLayout.marginWidth = 0;
|
51
|
gridLayout.horizontalSpacing = 0;
|
52
|
gridLayout.numColumns = 2;
|
53
|
setLayout(gridLayout);
|
54
|
|
55
|
Composite composite = new Composite(this, SWT.NONE);
|
56
|
composite.setLayout(new GridLayout(1, false));
|
57
|
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
|
58
|
|
59
|
btnCheck = new Button(composite, SWT.CHECK);
|
60
|
btnCheck.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
|
61
|
|
62
|
composite_1 = new Composite(this, SWT.NONE);
|
63
|
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
|
64
|
composite_1.setLayout(new GridLayout(1, false));
|
65
|
label = new Label(composite_1, SWT.NONE);
|
66
|
label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
|
67
|
label.setText(result.getContent().getRepresentation_L10n());
|
68
|
label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
|
69
|
GridDataFactory.fillDefaults().applyTo(label);
|
70
|
label.addFocusListener(new FocusListener() {
|
71
|
|
72
|
@Override
|
73
|
public void focusLost(FocusEvent e) {
|
74
|
System.out.println("focusLost");
|
75
|
}
|
76
|
|
77
|
@Override
|
78
|
public void focusGained(FocusEvent e) {
|
79
|
System.out.println("focusGained");
|
80
|
}
|
81
|
});
|
82
|
label.addDragDetectListener(new DragDetectListener() {
|
83
|
|
84
|
@Override
|
85
|
public void dragDetected(DragDetectEvent e) {
|
86
|
System.out.println("dragDetected");
|
87
|
}
|
88
|
});
|
89
|
label.addMouseListener(new MouseListener() {
|
90
|
|
91
|
@Override
|
92
|
public void mouseUp(MouseEvent e) {
|
93
|
System.out.println("mouseUp");
|
94
|
isSelected = !isSelected;
|
95
|
}
|
96
|
|
97
|
|
98
|
@Override
|
99
|
public void mouseDown(MouseEvent e) {
|
100
|
}
|
101
|
|
102
|
@Override
|
103
|
public void mouseDoubleClick(MouseEvent e) {
|
104
|
System.out.println("mouseDoubleClick");
|
105
|
}
|
106
|
});
|
107
|
|
108
|
Label lblDescription = new Label(composite_1, SWT.NONE);
|
109
|
String representation_L10n_text = result.getContent().getRepresentation_L10n_text();
|
110
|
if(representation_L10n_text!=null){
|
111
|
lblDescription.setText(representation_L10n_text);
|
112
|
}
|
113
|
}
|
114
|
|
115
|
public boolean isSelected() {
|
116
|
return isSelected;
|
117
|
}
|
118
|
|
119
|
public TermSearchResult getResult() {
|
120
|
return result;
|
121
|
}
|
122
|
|
123
|
@Override
|
124
|
protected void checkSubclass() {
|
125
|
// Disable the check that prevents subclassing of SWT components
|
126
|
}
|
127
|
public Button getBtnCheck() {
|
128
|
return btnCheck;
|
129
|
}
|
130
|
}
|