1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.editor.name.container;
|
12
|
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
|
16
|
import org.eclipse.swt.graphics.Color;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
19
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
20
|
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
21
|
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
|
22
|
import eu.etaxonomy.taxeditor.preference.Resources;
|
23
|
|
24
|
/**
|
25
|
* @author n.hoffmann
|
26
|
* @created Jan 20, 2011
|
27
|
* @version 1.0
|
28
|
*/
|
29
|
public class AcceptedGroup extends AbstractHomotypicalGroupContainer {
|
30
|
|
31
|
private AcceptedNameContainer acceptedContainer;
|
32
|
|
33
|
/**
|
34
|
* @param editor
|
35
|
* @param group
|
36
|
*/
|
37
|
public AcceptedGroup(TaxonNameEditor editor, HomotypicalGroup group) {
|
38
|
super(editor, group);
|
39
|
}
|
40
|
|
41
|
/* (non-Javadoc)
|
42
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#dragEntered()
|
43
|
*/
|
44
|
@Override
|
45
|
public void dragEntered() {
|
46
|
Color color = EditorUtil.getColor(Resources.COLOR_DRAG_ENTER);
|
47
|
acceptedContainer.setBackground(color);
|
48
|
super.dragEntered();
|
49
|
}
|
50
|
|
51
|
/* (non-Javadoc)
|
52
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#dragLeft()
|
53
|
*/
|
54
|
@Override
|
55
|
public void dragLeft() {
|
56
|
acceptedContainer.restoreColor();
|
57
|
super.dragLeft();
|
58
|
}
|
59
|
|
60
|
/* (non-Javadoc)
|
61
|
* @see eu.etaxonomy.taxeditor.editor.name.container.AbstractGroup#getGroupedContainers()
|
62
|
*/
|
63
|
@Override
|
64
|
public List<AbstractGroupedContainer> getGroupedContainers() {
|
65
|
List<AbstractGroupedContainer> containers = new ArrayList<AbstractGroupedContainer>();
|
66
|
containers.add(getAcceptedNameContainer());
|
67
|
containers.addAll(super.getGroupedContainers());
|
68
|
return containers;
|
69
|
}
|
70
|
|
71
|
/**
|
72
|
*
|
73
|
*/
|
74
|
protected void createContainers() {
|
75
|
this.acceptedContainer = new AcceptedNameContainer(getEditor().getTaxon());
|
76
|
acceptedContainer.setGroup(this);
|
77
|
|
78
|
acceptedContainer.createContent();
|
79
|
|
80
|
createSynonymContainer();
|
81
|
}
|
82
|
|
83
|
protected void createSynonymContainer(){
|
84
|
for(Synonym synonym : getSynonyms()){
|
85
|
SynonymContainer container = new SynonymContainer(this, synonym);
|
86
|
this.add(container);
|
87
|
container.createContent();
|
88
|
}
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* @param acceptedNameContainer
|
93
|
*/
|
94
|
public void setAcceptedNameContainer(AcceptedNameContainer acceptedNameContainer) {
|
95
|
this.acceptedContainer = acceptedNameContainer;
|
96
|
acceptedContainer.setGroup(this);
|
97
|
}
|
98
|
|
99
|
public AcceptedNameContainer getAcceptedNameContainer(){
|
100
|
return acceptedContainer;
|
101
|
}
|
102
|
|
103
|
/* (non-Javadoc)
|
104
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractGroup#emptyGroup()
|
105
|
*/
|
106
|
@Override
|
107
|
protected void emptyGroup() {
|
108
|
acceptedContainer.dispose();
|
109
|
acceptedContainer = null;
|
110
|
super.emptyGroup();
|
111
|
}
|
112
|
|
113
|
/* (non-Javadoc)
|
114
|
* @see eu.etaxonomy.taxeditor.editor.name.AbstractHomotypicalGroupContainer#redrawNeeded(eu.etaxonomy.cdm.model.name.HomotypicalGroup)
|
115
|
*/
|
116
|
@Override
|
117
|
protected boolean redrawNeeded(HomotypicalGroup homotypicalGroup) {
|
118
|
if(! acceptedContainer.getData().equals(getEditor().getTaxon())){
|
119
|
return true;
|
120
|
}
|
121
|
return super.redrawNeeded(homotypicalGroup);
|
122
|
}
|
123
|
}
|