Merge branch 'release/5.18.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / view / search / facet / occurrence / OccurrenceSearchResultComposite.java
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.occurrence;
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.ControlAdapter;
15 import org.eclipse.swt.events.ControlEvent;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Label;
20
21 import eu.etaxonomy.cdm.api.service.dto.DerivedUnitDTO;
22 import eu.etaxonomy.taxeditor.view.search.facet.CheckBoxSearchResultComposite;
23
24 /**
25 * @author pplitzner
26 * @since Jan 23, 2019
27 *
28 */
29 public class OccurrenceSearchResultComposite extends CheckBoxSearchResultComposite<DerivedUnitDTO, OccurrenceSearchResult> {
30
31 private Label label;
32
33 public OccurrenceSearchResultComposite(OccurrenceSearchResult result, Composite parent, int style) {
34 super(result, parent, style);
35 }
36
37 @Override
38 public Composite createContent(Composite parent) {
39 Composite content = new Composite(this, SWT.NONE);
40 content.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
41 GridLayout layout = new GridLayout(1, false);
42 content.setLayout(layout);
43 label = new Label(content, SWT.WRAP);
44 label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
45 label.setText(result.getContent().getLabel());
46 label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
47 GridDataFactory.fillDefaults().applyTo(label);
48
49 Label lblDescription = new Label(content, SWT.WRAP);
50 GridData layoutData = new GridData();
51 lblDescription.setLayoutData(layoutData);
52 parent.addControlListener(new ControlAdapter() {
53 @Override
54 public void controlResized(ControlEvent e) {
55 layoutData.widthHint = parent.getClientArea().width - (6*layout.marginWidth);
56 parent.layout(true);
57 }
58 });
59 String representation_L10n_text = result.getContent().getCitation();
60 if(representation_L10n_text!=null){
61 lblDescription.setText(representation_L10n_text);
62 }
63 return content;
64 }
65
66 }