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
|
*/
|
26
|
public class CommonNameReferenceSelectionElement extends EntitySelectionElement<Reference> {
|
27
|
|
28
|
/**
|
29
|
* @param formFactory
|
30
|
* @param parentElement
|
31
|
* @param clazz
|
32
|
* @param labelString
|
33
|
* @param entity
|
34
|
* @param mode
|
35
|
* @param style
|
36
|
*/
|
37
|
public CommonNameReferenceSelectionElement(CdmFormFactory formFactory, ICdmFormElement parentElement,
|
38
|
String labelString, Reference entity, int mode, int style) {
|
39
|
super(formFactory, parentElement, Reference.class, labelString, entity, mode, style);
|
40
|
|
41
|
}
|
42
|
|
43
|
|
44
|
@Override
|
45
|
public void widgetSelected(SelectionEvent e) {
|
46
|
if (e.getSource().equals(button_selection) ){
|
47
|
Reference selection = SelectionDialogFactory.getSelectionFromDialog(Reference.class, getShell(), //getConversationHolder(),
|
48
|
getEntity(), getParentElement());
|
49
|
boolean alreadyMarked = false;
|
50
|
if (selection != null){
|
51
|
for (Marker marker: selection.getMarkers()){
|
52
|
if (marker.getMarkerType().equals(MarkerType.COMMON_NAME_REFERENCE())){
|
53
|
alreadyMarked = true;
|
54
|
break;
|
55
|
}
|
56
|
}
|
57
|
if (!alreadyMarked){
|
58
|
selection.addMarker(Marker.NewInstance(MarkerType.COMMON_NAME_REFERENCE(), true));
|
59
|
}
|
60
|
|
61
|
setSelectionInternal(selection);
|
62
|
}
|
63
|
StoreUtil.reflowParentScrolledForm(getLayoutComposite(), true);
|
64
|
}else{
|
65
|
Reference selection = SelectionDialogFactory.getSelectionFromExtDialog(Reference.class, getShell(),//null,
|
66
|
getParentElement());
|
67
|
setSelectionInternal(selection);
|
68
|
}
|
69
|
|
70
|
}
|
71
|
}
|