9 |
9 |
|
10 |
10 |
package eu.etaxonomy.taxeditor.editor.name.container;
|
11 |
11 |
|
|
12 |
import javax.persistence.GenerationType;
|
|
13 |
|
12 |
14 |
import org.eclipse.swt.graphics.Font;
|
13 |
15 |
|
14 |
16 |
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
|
17 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
|
|
18 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
15 |
19 |
import eu.etaxonomy.taxeditor.editor.EditorUtil;
|
16 |
20 |
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
|
21 |
import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
|
|
22 |
import eu.etaxonomy.taxeditor.model.NameHelper;
|
17 |
23 |
import eu.etaxonomy.taxeditor.preference.Resources;
|
18 |
24 |
|
19 |
25 |
/**
|
... | ... | |
24 |
30 |
* @version 1.0
|
25 |
31 |
*/
|
26 |
32 |
public class MisapplicationContainer extends AbstractGroupedContainer<Taxon> {
|
|
33 |
TaxonRelationship misapplication;
|
27 |
34 |
|
28 |
35 |
/**
|
29 |
36 |
* <p>Constructor for MisapplicationContainer.</p>
|
... | ... | |
34 |
41 |
*/
|
35 |
42 |
public MisapplicationContainer(AbstractGroup group, Taxon misappliedName) {
|
36 |
43 |
super(misappliedName);
|
|
44 |
|
37 |
45 |
}
|
38 |
46 |
|
39 |
47 |
|
... | ... | |
45 |
53 |
protected void initializeComposite() {
|
46 |
54 |
setIsDraggable(true);
|
47 |
55 |
setFont(getViewerFont());
|
48 |
|
|
|
56 |
TaxonNameEditor editor = getEditor();
|
|
57 |
Taxon taxon = editor.getTaxon();
|
|
58 |
for (TaxonRelationship rel: taxon.getTaxonRelations(getMisappliedName())){
|
|
59 |
if (rel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
|
|
60 |
misapplication = rel;
|
|
61 |
break;
|
|
62 |
}
|
|
63 |
}
|
49 |
64 |
showSec();
|
50 |
65 |
|
51 |
66 |
initTextViewer();
|
... | ... | |
60 |
75 |
if (getMisappliedName() == null) {
|
61 |
76 |
return;
|
62 |
77 |
}
|
63 |
|
|
64 |
|
if (getMisappliedName().getSec() == null) {
|
|
78 |
String title = "";
|
|
79 |
if (getMisappliedName().getName().getAuthorshipCache() != null && getMisappliedName().getAppendedPhrase() == null){
|
|
80 |
title += "non " + getMisappliedName().getName().getAuthorshipCache();
|
|
81 |
}
|
|
82 |
if (misapplication.getCitation() == null) {
|
65 |
83 |
if (getMisappliedName().getAppendedPhrase() != null ){
|
66 |
84 |
setNonEditableInfo(getMisappliedName().getAppendedPhrase(), false);
|
67 |
85 |
}else{
|
68 |
|
setNonEditableInfo("sec. ???", false); //$NON-NLS-1$
|
|
86 |
setNonEditableInfo("auct.", false); //$NON-NLS-1$
|
69 |
87 |
}
|
70 |
88 |
} else {
|
71 |
|
String title = getMisappliedName().getSec().getTitleCache();
|
72 |
|
title = title.replace("&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$
|
73 |
|
String sec = "sec. "; //$NON-NLS-1$
|
|
89 |
String sec = " sensu "; //$NON-NLS-1$
|
74 |
90 |
if (getMisappliedName().getAppendedPhrase() != null ){
|
75 |
91 |
sec = getMisappliedName().getAppendedPhrase() + " "+sec; //$NON-NLS-1$
|
76 |
92 |
}
|
77 |
|
setNonEditableInfo(sec + title, false);
|
|
93 |
title += sec + misapplication.getCitation().getTitleCache();
|
|
94 |
title = title.replace("&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
95 |
|
|
96 |
|
|
97 |
setNonEditableInfo(title, false);
|
78 |
98 |
}
|
79 |
99 |
}
|
80 |
100 |
|
... | ... | |
120 |
140 |
protected void updateIndent() {
|
121 |
141 |
setIndent(MISAPPLIEDNAME_INDENT);
|
122 |
142 |
}
|
|
143 |
|
|
144 |
/**
|
|
145 |
* <p>
|
|
146 |
* initTextViewer
|
|
147 |
* </p>
|
|
148 |
*/
|
|
149 |
@Override
|
|
150 |
protected void initTextViewer() {
|
|
151 |
|
|
152 |
// showNameRelations();
|
|
153 |
|
|
154 |
updateIndent();
|
|
155 |
|
|
156 |
updateIcon();
|
|
157 |
|
|
158 |
String text = NameHelper.getDisplayNameCache(getData());
|
|
159 |
|
|
160 |
if (text.length() == 0) {
|
|
161 |
initEmptyText();
|
|
162 |
} else {
|
|
163 |
getNameViewer().setText(text);
|
|
164 |
placeCursor();
|
|
165 |
}
|
|
166 |
calculateAnnotations();
|
|
167 |
}
|
|
168 |
|
|
169 |
@Override
|
|
170 |
public void refresh() {
|
|
171 |
// showNameRelations();
|
|
172 |
|
|
173 |
String text = NameHelper.getDisplayNameCache(getData());
|
|
174 |
|
|
175 |
if (getNameViewer().getTextWidget() == null) {
|
|
176 |
// we might get here via dnd. Look slike it can be ignored
|
|
177 |
return;
|
|
178 |
}
|
|
179 |
|
|
180 |
if (text.length() == 0) {
|
|
181 |
initEmptyText();
|
|
182 |
} else if (!getNameViewer().getTextWidget().getText().equals(text)) {
|
|
183 |
removeListener();
|
|
184 |
getNameViewer().getTextWidget().setText(text);
|
|
185 |
addListener();
|
|
186 |
}
|
|
187 |
|
|
188 |
updateNonEditableInfo();
|
|
189 |
|
|
190 |
updateIcon();
|
|
191 |
// placeCursor();
|
|
192 |
updateIndent();
|
|
193 |
|
|
194 |
enableFreeText();
|
|
195 |
}
|
123 |
196 |
|
124 |
197 |
}
|
ref #6390: missed to commit the changes for NameEditor