1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.taxeditor.editor.name.e4.container;
|
11
|
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.eclipse.swt.graphics.Color;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
18
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
19
|
import eu.etaxonomy.taxeditor.editor.name.e4.TaxonNameEditorE4;
|
20
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
21
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
22
|
|
23
|
/**
|
24
|
*
|
25
|
* @author pplitzner
|
26
|
* @date Aug 24, 2017
|
27
|
*
|
28
|
*/
|
29
|
public class AcceptedGroupE4 extends AbstractHomotypicalGroupContainerE4 {
|
30
|
|
31
|
private AcceptedNameContainerE4 acceptedContainer;
|
32
|
|
33
|
public AcceptedGroupE4(TaxonNameEditorE4 editor, HomotypicalGroup group) {
|
34
|
super(editor, group);
|
35
|
}
|
36
|
|
37
|
@Override
|
38
|
public void dragEntered() {
|
39
|
Color color = AbstractUtility.getColor(Resources.COLOR_DRAG_ENTER);
|
40
|
acceptedContainer.setBackground(color);
|
41
|
super.dragEntered();
|
42
|
}
|
43
|
|
44
|
@Override
|
45
|
public void dragLeft() {
|
46
|
acceptedContainer.restoreColor();
|
47
|
super.dragLeft();
|
48
|
}
|
49
|
|
50
|
@Override
|
51
|
public List<AbstractGroupedContainerE4> getGroupedContainers() {
|
52
|
List<AbstractGroupedContainerE4> containers = new ArrayList<>();
|
53
|
containers.add(getAcceptedNameContainer());
|
54
|
containers.addAll(super.getGroupedContainers());
|
55
|
return containers;
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
protected void createContainers() {
|
60
|
this.acceptedContainer = new AcceptedNameContainerE4(this, getEditor().getTaxon());
|
61
|
acceptedContainer.createContent();
|
62
|
createSynonymContainer();
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
protected void createSynonymContainer(){
|
67
|
for(Synonym synonym : getSynonyms()){
|
68
|
SynonymContainerE4 container = new SynonymContainerE4(this, synonym);
|
69
|
this.add(container);
|
70
|
container.createContent();
|
71
|
}
|
72
|
}
|
73
|
|
74
|
public AcceptedNameContainerE4 getAcceptedNameContainer(){
|
75
|
return acceptedContainer;
|
76
|
}
|
77
|
|
78
|
@Override
|
79
|
protected void emptyGroup() {
|
80
|
if (acceptedContainer != null){
|
81
|
acceptedContainer.dispose();
|
82
|
acceptedContainer = null;
|
83
|
}
|
84
|
|
85
|
super.emptyGroup();
|
86
|
}
|
87
|
|
88
|
@Override
|
89
|
protected boolean redrawNeeded(HomotypicalGroup homotypicalGroup) {
|
90
|
if(acceptedContainer != null && ! acceptedContainer.getData().equals(getEditor().getTaxon())){
|
91
|
return true;
|
92
|
}
|
93
|
return super.redrawNeeded(homotypicalGroup);
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
protected void setMenuToGroup(){
|
98
|
super.setMenuToGroup();
|
99
|
acceptedContainer.setMenu();
|
100
|
}
|
101
|
}
|