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.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.EditorUtil;
|
20
|
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
|
21
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
22
|
|
23
|
/**
|
24
|
* @author n.hoffmann
|
25
|
* @created Jan 20, 2011
|
26
|
* @version 1.0
|
27
|
*/
|
28
|
public class AcceptedGroup extends AbstractHomotypicalGroupContainer {
|
29
|
|
30
|
private AcceptedNameContainer acceptedContainer;
|
31
|
|
32
|
/**
|
33
|
* @param editor
|
34
|
* @param group
|
35
|
*/
|
36
|
public AcceptedGroup(TaxonNameEditor editor, HomotypicalGroup group) {
|
37
|
super(editor, group);
|
38
|
}
|
39
|
|
40
|
/* (non-Javadoc)
|
41
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#dragEntered()
|
42
|
*/
|
43
|
@Override
|
44
|
public void dragEntered() {
|
45
|
Color color = EditorUtil.getColor(Resources.COLOR_DRAG_ENTER);
|
46
|
acceptedContainer.setBackground(color);
|
47
|
super.dragEntered();
|
48
|
}
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#dragLeft()
|
52
|
*/
|
53
|
@Override
|
54
|
public void dragLeft() {
|
55
|
acceptedContainer.restoreColor();
|
56
|
super.dragLeft();
|
57
|
}
|
58
|
|
59
|
/* (non-Javadoc)
|
60
|
* @see eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup#getGroupedContainers()
|
61
|
*/
|
62
|
@Override
|
63
|
public List<AbstractGroupedContainer> getGroupedContainers() {
|
64
|
List<AbstractGroupedContainer> containers = new ArrayList<AbstractGroupedContainer>();
|
65
|
containers.add(getAcceptedNameContainer());
|
66
|
containers.addAll(super.getGroupedContainers());
|
67
|
return containers;
|
68
|
}
|
69
|
|
70
|
/**
|
71
|
*
|
72
|
*/
|
73
|
protected void createContainers() {
|
74
|
this.acceptedContainer = new AcceptedNameContainer(getEditor().getTaxon());
|
75
|
acceptedContainer.setGroup(this);
|
76
|
|
77
|
acceptedContainer.createContent();
|
78
|
|
79
|
createSynonymContainer();
|
80
|
}
|
81
|
|
82
|
protected void createSynonymContainer(){
|
83
|
for(Synonym synonym : getSynonyms()){
|
84
|
SynonymContainer container = new SynonymContainer(this, synonym);
|
85
|
this.add(container);
|
86
|
container.createContent();
|
87
|
}
|
88
|
}
|
89
|
|
90
|
/**
|
91
|
* @param acceptedNameContainer
|
92
|
*/
|
93
|
public void setAcceptedNameContainer(AcceptedNameContainer acceptedNameContainer) {
|
94
|
this.acceptedContainer = acceptedNameContainer;
|
95
|
acceptedContainer.setGroup(this);
|
96
|
}
|
97
|
|
98
|
public AcceptedNameContainer getAcceptedNameContainer(){
|
99
|
return acceptedContainer;
|
100
|
}
|
101
|
|
102
|
/* (non-Javadoc)
|
103
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#emptyGroup()
|
104
|
*/
|
105
|
@Override
|
106
|
protected void emptyGroup() {
|
107
|
acceptedContainer.dispose();
|
108
|
acceptedContainer = null;
|
109
|
super.emptyGroup();
|
110
|
}
|
111
|
|
112
|
/* (non-Javadoc)
|
113
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractHomotypicalGroupContainer#redrawNeeded(eu.etaxonomy.cdm.model.name.HomotypicalGroup)
|
114
|
*/
|
115
|
@Override
|
116
|
protected boolean redrawNeeded(HomotypicalGroup homotypicalGroup) {
|
117
|
if(! acceptedContainer.getData().equals(getEditor().getTaxon())){
|
118
|
return true;
|
119
|
}
|
120
|
return super.redrawNeeded(homotypicalGroup);
|
121
|
}
|
122
|
}
|