1
|
/**
|
2
|
* Copyright (C) 2018 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.selection;
|
10
|
|
11
|
import org.eclipse.swt.events.SelectionEvent;
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.Marker;
|
14
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
15
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
16
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
17
|
import eu.etaxonomy.taxeditor.ui.dialog.selection.SelectionDialogFactory;
|
18
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
19
|
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
|
20
|
|
21
|
/**
|
22
|
* @author k.luther
|
23
|
* @since 17.09.2018
|
24
|
*/
|
25
|
public class CommonNameReferenceSelectionElement extends EntitySelectionElement<Reference> {
|
26
|
|
27
|
public CommonNameReferenceSelectionElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
|
28
|
String labelString, Reference entity, int mode, int style) {
|
29
|
super(formFactory, parentElement, Reference.class, labelString, entity, mode, style);
|
30
|
|
31
|
}
|
32
|
|
33
|
@Override
|
34
|
public void widgetSelected(SelectionEvent e) {
|
35
|
if (e.getSource().equals(button_selection) ){
|
36
|
Reference selection = SelectionDialogFactory.getSelectionFromDialog(Reference.class, getShell(),
|
37
|
getEntity(), getParentElement());
|
38
|
boolean alreadyMarked = false;
|
39
|
if (selection != null){
|
40
|
for (Marker marker: selection.getMarkers()){
|
41
|
if (marker.getMarkerType().equals(MarkerType.COMMON_NAME_REFERENCE())){
|
42
|
alreadyMarked = true;
|
43
|
break;
|
44
|
}
|
45
|
}
|
46
|
if (!alreadyMarked){
|
47
|
selection.addMarker(Marker.NewInstance(MarkerType.COMMON_NAME_REFERENCE(), true));
|
48
|
}
|
49
|
|
50
|
setSelectionInternal(selection);
|
51
|
}
|
52
|
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
53
|
}else{
|
54
|
Reference selection = SelectionDialogFactory.getSelectionFromExtDialog(Reference.class, getShell(),
|
55
|
getParentElement());
|
56
|
setSelectionInternal(selection);
|
57
|
}
|
58
|
}
|
59
|
}
|