Revision af7cddc3
Added by Pepe Ciardelli about 16 years ago
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/Activator.java | ||
---|---|---|
23 | 23 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
24 | 24 |
import eu.etaxonomy.cdm.model.common.init.TermNotFoundException; |
25 | 25 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
26 |
import eu.etaxonomy.cdm.model.name.NameRelationshipType; |
|
27 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
|
28 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
|
26 | 29 |
import eu.etaxonomy.cdm.model.name.Rank; |
27 | 30 |
import eu.etaxonomy.cdm.model.reference.ReferenceBase; |
28 | 31 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
... | ... | |
119 | 122 |
childTaxon2.setSec(null); |
120 | 123 |
childTaxon2.setTaxonomicParent(genusTaxon, null, null); |
121 | 124 |
|
125 |
// Add some name relations to botSpecies2 |
|
126 |
botSpecies2.addRelationshipFromName(botSpecies, NameRelationshipType.BASIONYM(), null); |
|
127 |
botSpecies2.addRelationshipToName(botSpecies, NameRelationshipType.REPLACED_SYNONYM(), null); |
|
128 |
logger.warn("Name relations created"); |
|
129 |
// |
|
130 |
// // Add name status to botSpecies2 |
|
131 |
botSpecies2.addStatus(NomenclaturalStatus.NewInstance(NomenclaturalStatusType.NOVUM())); |
|
132 |
logger.warn("Nom. status created"); |
|
133 |
|
|
122 | 134 |
cdmApp.getTaxonService().saveTaxon(genusTaxon); |
123 | 135 |
|
124 | 136 |
// System.exit(-1); |
... | ... | |
230 | 242 |
public static final String ACCEPTED_TAXON = "accepted"; |
231 | 243 |
public static final String HOMOTYPIC_SYN = "homotypic_syn"; |
232 | 244 |
public static final String HETEROTYPIC_SYN = "heterotypic_syn"; |
245 |
public static final String MISAPPLIED_NAME = "misapplied"; |
|
233 | 246 |
public static final String DB = "db"; |
234 | 247 |
protected void initializeImageRegistry(ImageRegistry registry) { |
235 | 248 |
registerImage(registry, ACCEPTED_TAXON, "accepted_small.gif"); //$NON-NLS-1$ |
236 | 249 |
registerImage(registry, HOMOTYPIC_SYN, "homosyn_no_bg.gif"); //$NON-NLS-1$ |
237 | 250 |
registerImage(registry, HETEROTYPIC_SYN, "heterosyn_no_bg.gif"); //$NON-NLS-1$ |
251 |
registerImage(registry, MISAPPLIED_NAME, "misapplied_no_bg.gif"); //$NON-NLS-1$ |
|
238 | 252 |
registerImage(registry, DB, "db.gif"); //$NON-NLS-1$ |
239 | 253 |
} |
240 | 254 |
private void registerImage(ImageRegistry registry, String key, |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/Application.java | ||
---|---|---|
17 | 17 |
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) |
18 | 18 |
*/ |
19 | 19 |
public Object start(IApplicationContext context) { |
20 |
logger.error("application starting"); |
|
21 | 20 |
Display display = PlatformUI.createDisplay(); |
22 | 21 |
try { |
23 | 22 |
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/ActionSaveTaxon.java | ||
---|---|---|
3 | 3 |
import org.apache.log4j.Logger; |
4 | 4 |
import org.eclipse.jface.action.Action; |
5 | 5 |
|
6 |
import eu.etaxonomy.cdm.api.service.TaxonServiceImpl; |
|
7 | 6 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
8 | 7 |
import eu.etaxonomy.taxeditor.Activator; |
9 | 8 |
|
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/IterableSynonymyList.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package eu.etaxonomy.taxeditor.view; |
3 | 3 |
|
4 |
import java.util.ArrayList; |
|
4 | 5 |
import java.util.Iterator; |
5 | 6 |
import java.util.List; |
7 |
import java.util.Set; |
|
6 | 8 |
|
7 | 9 |
import org.apache.log4j.Logger; |
8 | 10 |
|
9 | 11 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
10 | 12 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
11 | 13 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
14 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
12 | 15 |
|
13 | 16 |
/** |
14 |
* Provides a way to retrieve the elements of a taxon's synonymy list
|
|
15 |
* using an iterator. Note: does not return the taxon itself. |
|
17 |
* Retrieves the elements of a taxon's synonymy list, including misapplied names,
|
|
18 |
* using an iterator. Note: does not return an entry for the taxon itself.
|
|
16 | 19 |
* |
17 | 20 |
* @author p.ciardelli |
18 | 21 |
* @created 09.05.2008 |
19 | 22 |
* @version 1.0 |
20 | 23 |
*/ |
21 |
public class IterableSynonymyList implements Iterable { |
|
24 |
public class IterableSynonymyList implements Iterable<TaxonBase> {
|
|
22 | 25 |
private static final Logger logger = Logger |
23 | 26 |
.getLogger(IterableSynonymyList.class); |
24 | 27 |
|
... | ... | |
29 | 32 |
} |
30 | 33 |
|
31 | 34 |
@Override |
32 |
public Iterator iterator() { |
|
33 |
Iterator<?> iterator = new Iterator() { |
|
34 |
|
|
35 |
boolean returnedHomotypicSynonyms = false; |
|
36 |
boolean returnedHeterotypicSynonyms = false; |
|
37 |
boolean returnedMisappliedNames = false; |
|
35 |
public Iterator<TaxonBase> iterator() { |
|
36 |
return new TaxonIterator(taxon); |
|
37 |
} |
|
38 |
|
|
39 |
class TaxonIterator implements Iterator<TaxonBase> { |
|
38 | 40 |
|
39 |
int indexHomotypicSynonyms = 0; |
|
40 |
int indexHeterotypicSynonymyGroups = 0; |
|
41 |
int indexCurrentHeterotypicGroup = 0; |
|
42 |
int indexHeterotypicSynonyms = 0; |
|
43 |
int indexMisappliedNames = 0; |
|
41 |
List<TaxonBase> synonymyList; |
|
42 |
int index = 0; |
|
43 |
|
|
44 |
public TaxonIterator(Taxon taxon) { |
|
45 |
synonymyList = new ArrayList<TaxonBase>(); |
|
46 |
HomotypicalGroup homotypicGroup = taxon.getHomotypicGroup(); |
|
44 | 47 |
|
45 |
List<Synonym> homotypicSynonyms = null; |
|
46 |
List<HomotypicalGroup> heterotypicGroups = null; |
|
47 |
List<Synonym> currentHeterotypicGroup = null; |
|
48 |
|
|
49 |
@Override |
|
50 |
public boolean hasNext() { |
|
51 |
boolean returnedAll = returnedHomotypicSynonyms |
|
52 |
&& returnedHeterotypicSynonyms |
|
53 |
&& returnedMisappliedNames; |
|
54 |
return !returnedAll; |
|
55 |
} |
|
56 |
|
|
57 |
@Override |
|
58 |
public Object next() { |
|
59 |
if (!returnedHomotypicSynonyms) { |
|
60 |
if (homotypicSynonyms == null) { |
|
61 |
HomotypicalGroup homotypicGroup = taxon.getHomotypicGroup(); |
|
62 |
List<Synonym> homotypicSynonyms = homotypicGroup.getSynonymsInGroup(taxon.getSec()); |
|
63 |
} |
|
64 |
if (homotypicSynonyms.size() == indexHomotypicSynonyms) { |
|
65 |
returnedHomotypicSynonyms = true; |
|
66 |
} else { |
|
67 |
Synonym synonym = homotypicSynonyms.get(indexHomotypicSynonyms); |
|
68 |
indexHomotypicSynonyms++; |
|
69 |
return synonym; |
|
70 |
} |
|
71 |
|
|
48 |
if (homotypicGroup != null) { |
|
49 |
List<Synonym> homotypicSynonyms = homotypicGroup.getSynonymsInGroup(taxon.getSec()); |
|
50 |
for (Synonym synonym : homotypicSynonyms) { |
|
51 |
synonymyList.add(synonym); |
|
72 | 52 |
} |
53 |
} |
|
54 |
|
|
55 |
List<HomotypicalGroup> heterotypicGroups = taxon.getHeterotypicSynonymyGroups(); |
|
56 |
for (HomotypicalGroup heterotypicGroup : heterotypicGroups) { |
|
73 | 57 |
|
74 |
if (!returnedHeterotypicSynonyms) { |
|
75 |
if (heterotypicGroups == null) { |
|
76 |
heterotypicGroups = taxon.getHeterotypicSynonymyGroups(); |
|
77 |
} |
|
78 |
// Check if current heterotypic group has next |
|
79 |
boolean getNewGroup = false; |
|
80 |
if (currentHeterotypicGroup != null && currentHeterotypicGroup.size() == indexCurrentHeterotypicGroup) { |
|
81 |
indexHeterotypicSynonymyGroups++; |
|
82 |
getNewGroup = true; |
|
83 |
} |
|
84 |
if (heterotypicGroups.size() == indexHeterotypicSynonymyGroups) { |
|
85 |
returnedHeterotypicSynonyms = true; |
|
86 |
} else { |
|
87 |
|
|
88 |
if (currentHeterotypicGroup == null || getNewGroup) { |
|
89 |
indexCurrentHeterotypicGroup = 0; |
|
90 |
currentHeterotypicGroup = (List<Synonym>) heterotypicGroups.get(indexCurrentHeterotypicGroup); |
|
91 |
} |
|
92 |
|
|
93 |
indexCurrentHeterotypicGroup++; |
|
58 |
// Make sure this is not the taxon's homotypic group |
|
59 |
if (!heterotypicGroup.equals(homotypicGroup)) { |
|
60 |
|
|
61 |
List<Synonym> heterotypicSynonyms = heterotypicGroup. |
|
62 |
getSynonymsInGroup(taxon.getSec()); |
|
63 |
for (Synonym synonym : heterotypicSynonyms) { |
|
64 |
synonymyList.add(synonym); |
|
94 | 65 |
} |
95 | 66 |
} |
96 |
return null; |
|
97 | 67 |
} |
68 |
|
|
69 |
Set<Taxon> misappliedNames = taxon.getMisappliedNames(); |
|
70 |
for (Taxon misappliedName : misappliedNames) { |
|
71 |
synonymyList.add(misappliedName); |
|
72 |
} |
|
73 |
} |
|
98 | 74 |
|
99 |
@Override
|
|
100 |
public void remove() {
|
|
101 |
// TODO Auto-generated method stub
|
|
102 |
|
|
75 |
@Override |
|
76 |
public boolean hasNext() {
|
|
77 |
if (synonymyList.size() == index) {
|
|
78 |
return false; |
|
103 | 79 |
} |
104 |
|
|
105 |
}; |
|
106 |
return iterator; |
|
80 |
return true; |
|
81 |
} |
|
82 |
|
|
83 |
@Override |
|
84 |
public TaxonBase next() { |
|
85 |
TaxonBase next = synonymyList.get(index); |
|
86 |
index++; |
|
87 |
return next; |
|
88 |
} |
|
89 |
|
|
90 |
@Override |
|
91 |
public void remove() {} |
|
107 | 92 |
} |
108 | 93 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/NameEditorView.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.beans.PropertyChangeEvent; |
4 | 4 |
import java.beans.PropertyChangeListener; |
5 |
import java.util.List; |
|
6 | 5 |
|
7 | 6 |
import org.apache.log4j.Logger; |
8 | 7 |
import org.eclipse.core.runtime.IAdaptable; |
... | ... | |
32 | 31 |
import eu.etaxonomy.cdm.model.name.HomotypicalGroup; |
33 | 32 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
34 | 33 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
34 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
35 | 35 |
import eu.etaxonomy.taxeditor.Activator; |
36 | 36 |
import eu.etaxonomy.taxeditor.controller.WidgetTransfer; |
37 | 37 |
import eu.etaxonomy.taxeditor.view.nameviewersupport.GroupComposite; |
... | ... | |
62 | 62 |
@Override |
63 | 63 |
public void doSave(IProgressMonitor monitor) { |
64 | 64 |
// TODO Auto-generated method stub |
65 |
|
|
66 | 65 |
} |
67 | 66 |
|
68 | 67 |
@Override |
... | ... | |
76 | 75 |
throws PartInitException { |
77 | 76 |
if (!(input instanceof IEditorInput)) |
78 | 77 |
throw new PartInitException( |
79 |
"Invalid Input: Must be IFileEditorInput");
|
|
78 |
"Invalid Input: Must be IFileEditorInput"); |
|
80 | 79 |
|
81 | 80 |
if (input.getAdapter(Taxon.class) != null) { |
82 | 81 |
taxon = (Taxon) input.getAdapter(Taxon.class); |
... | ... | |
153 | 152 |
// Add accepted taxon to the group |
154 | 153 |
taxonCompositeFactory.createAcceptedNameComposite(homotypicComposite, taxon); |
155 | 154 |
|
156 |
// Add composites for any homotypic synonyms to the group |
|
157 |
if (homotypicGroup != null) { |
|
158 |
List<Synonym> homotypicSynonyms = homotypicGroup.getSynonymsInGroup(taxon.getSec()); |
|
159 |
for (Synonym synonym : homotypicSynonyms) { |
|
160 |
taxonCompositeFactory.createHomotypicSynonymComposite(homotypicComposite, synonym); |
|
161 |
} |
|
162 |
} |
|
163 |
|
|
164 |
// Create composites for any heterotypic groups |
|
165 |
List<HomotypicalGroup> heterotypicGroups = taxon.getHeterotypicSynonymyGroups(); |
|
166 |
logger.warn(heterotypicGroups.size() + " heterotypic groups"); |
|
167 |
for (HomotypicalGroup heterotypicGroup : heterotypicGroups) { |
|
168 |
|
|
169 |
// Make sure this is not the taxon's homotypic group |
|
170 |
if (!heterotypicGroup.equals(homotypicGroup)) { |
|
171 |
|
|
172 |
GroupComposite heterotypicComposite = |
|
173 |
taxonCompositeFactory.createGroupComposite(parent, heterotypicGroup); |
|
174 |
|
|
175 |
// Add composites for any homotypic synonyms to the group |
|
176 |
List<Synonym> heterotypicSynonyms = heterotypicGroup. |
|
177 |
getSynonymsInGroup(taxon.getSec()); |
|
178 |
for (Synonym synonym : heterotypicSynonyms) { |
|
179 |
taxonCompositeFactory.createHeterotypicSynonymComposite(heterotypicComposite, synonym); |
|
155 |
IterableSynonymyList synonymyList = new IterableSynonymyList(taxon); |
|
156 |
HomotypicalGroup lastHeterotypicGroup = null; |
|
157 |
HomotypicalGroup currentHeterotypicGroup = null; |
|
158 |
GroupComposite heterotypicGroupComposite = null; |
|
159 |
GroupComposite misappliedNameGroupComposite = null; |
|
160 |
for (TaxonBase synonymOrMisName : synonymyList) { |
|
161 |
if (synonymOrMisName instanceof Synonym) { |
|
162 |
|
|
163 |
Synonym synonym = (Synonym) synonymOrMisName; |
|
164 |
currentHeterotypicGroup = synonym.getHomotypicGroup(); |
|
165 |
|
|
166 |
if (currentHeterotypicGroup.equals(homotypicGroup)) { |
|
167 |
|
|
168 |
taxonCompositeFactory.createHomotypicSynonymComposite(homotypicComposite, synonym); |
|
169 |
|
|
170 |
} else { |
|
171 |
// Create a new group composite? |
|
172 |
if (!currentHeterotypicGroup.equals(lastHeterotypicGroup)) { |
|
173 |
heterotypicGroupComposite = |
|
174 |
taxonCompositeFactory.createGroupComposite(parent, currentHeterotypicGroup); |
|
175 |
lastHeterotypicGroup = currentHeterotypicGroup; |
|
176 |
} |
|
177 |
|
|
178 |
taxonCompositeFactory.createHeterotypicSynonymComposite(heterotypicGroupComposite, synonym); |
|
179 |
} |
|
180 |
} else { |
|
181 |
|
|
182 |
Taxon misappliedName = (Taxon) synonymOrMisName; |
|
183 |
if (misappliedNameGroupComposite == null) { |
|
184 |
misappliedNameGroupComposite = |
|
185 |
taxonCompositeFactory.createGroupComposite(parent, null); |
|
180 | 186 |
} |
187 |
taxonCompositeFactory.createMisappliedNameComposite(misappliedNameGroupComposite, misappliedName); |
|
181 | 188 |
} |
182 | 189 |
} |
183 | 190 |
|
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/TaxonomicTreeViewer.java | ||
---|---|---|
47 | 47 |
import com.swtdesigner.ResourceManager; |
48 | 48 |
|
49 | 49 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
50 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
|
50 | 51 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
52 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
51 | 53 |
import eu.etaxonomy.cdm.strategy.parser.TaxonNameParserBotanicalNameImpl; |
52 | 54 |
import eu.etaxonomy.taxeditor.Activator; |
53 | 55 |
import eu.etaxonomy.taxeditor.controller.ActionAddQuickName; |
... | ... | |
477 | 479 |
label.setForeground (Display.getCurrent().getSystemColor (SWT.COLOR_INFO_FOREGROUND)); |
478 | 480 |
label.setBackground (Display.getCurrent().getSystemColor (SWT.COLOR_INFO_BACKGROUND)); |
479 | 481 |
label.setData ("_TABLEITEM", item); |
480 |
// label.setText (item.getText ()); |
|
481 |
// label.setText ("Joe mama"); |
|
482 |
label.setText (item.getText ()); |
|
483 |
if (item.getData() instanceof Taxon) { |
|
484 |
Taxon taxon = (Taxon) item.getData(); |
|
485 |
IterableSynonymyList synonymyList = new IterableSynonymyList(taxon); |
|
486 |
String synonymyListDisplay = taxon.getName().getTitleCache(); |
|
487 |
for (TaxonBase synonymOrMisName : synonymyList) { |
|
488 |
TaxonNameBase name = synonymOrMisName.getName(); |
|
489 |
if (name != null) { |
|
490 |
synonymyListDisplay += "\n " + name.getTitleCache(); |
|
491 |
} |
|
492 |
} |
|
493 |
label.setText (synonymyListDisplay); |
|
494 |
} |
|
495 |
// label.setText (""); |
|
482 | 496 |
label.addListener (SWT.MouseExit, labelListener); |
483 | 497 |
label.addListener (SWT.MouseDown, labelListener); |
484 | 498 |
Point size = tip.computeSize (SWT.DEFAULT, SWT.DEFAULT); |
... | ... | |
490 | 504 |
} |
491 | 505 |
} |
492 | 506 |
} |
493 |
}; |
|
494 |
|
|
495 |
} |
|
496 |
|
|
497 |
|
|
507 |
}; |
|
508 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/nameviewersupport/CompositeBorderDecorator.java | ||
---|---|---|
15 | 15 |
* |
16 | 16 |
*/ |
17 | 17 |
public class CompositeBorderDecorator { |
18 |
private final Composite composite; |
|
19 | 18 |
private FormToolkit toolkit; |
20 | 19 |
private ScrolledForm scrolledForm; |
20 |
private Composite borderedComposite; |
|
21 |
|
|
22 |
private FocusListener listener = new PaintBorderListener(); |
|
21 | 23 |
|
22 | 24 |
public CompositeBorderDecorator(Composite composite, IManagedForm form) { |
23 |
this.composite = composite;
|
|
25 |
this.borderedComposite = composite;
|
|
24 | 26 |
this.toolkit = form.getToolkit(); |
25 | 27 |
this.scrolledForm = form.getForm(); |
26 | 28 |
|
27 | 29 |
toolkit.adapt(composite); |
28 | 30 |
|
29 |
composite.addFocusListener(new FocusListener() { |
|
30 |
|
|
31 |
@Override |
|
32 |
public void focusGained(FocusEvent e) { |
|
33 |
String border = FormToolkit.TEXT_BORDER; |
|
34 |
paintBorder(border); |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public void focusLost(FocusEvent e) { |
|
39 |
String border = null; |
|
40 |
paintBorder(border); |
|
41 |
} |
|
42 |
|
|
43 |
}); |
|
31 |
composite.addFocusListener(listener); |
|
44 | 32 |
} |
45 | 33 |
|
46 | 34 |
private void paintBorder(String border) { |
47 |
composite.setData(FormToolkit.KEY_DRAW_BORDER, border);
|
|
48 |
toolkit.paintBordersFor(composite.getParent());
|
|
35 |
borderedComposite.setData(FormToolkit.KEY_DRAW_BORDER, border);
|
|
36 |
toolkit.paintBordersFor(borderedComposite.getParent());
|
|
49 | 37 |
scrolledForm.reflow(false); |
50 | 38 |
} |
39 |
|
|
40 |
/** |
|
41 |
* If the border should actually be drawn elsewhere when |
|
42 |
* the main Composite gets focus, i.e. the textviewer should |
|
43 |
* get a border when its Composite has focus, set the |
|
44 |
* Composite here. |
|
45 |
* |
|
46 |
* @param composite |
|
47 |
*/ |
|
48 |
public void setBorderedComposite(Composite composite) { |
|
49 |
this.borderedComposite = composite; |
|
50 |
borderedComposite.addFocusListener(listener); |
|
51 |
} |
|
52 |
|
|
53 |
class PaintBorderListener implements FocusListener { |
|
54 |
@Override |
|
55 |
public void focusGained(FocusEvent e) { |
|
56 |
String border = FormToolkit.TEXT_BORDER; |
|
57 |
paintBorder(border); |
|
58 |
} |
|
59 |
|
|
60 |
@Override |
|
61 |
public void focusLost(FocusEvent e) { |
|
62 |
String border = null; |
|
63 |
paintBorder(border); |
|
64 |
} |
|
65 |
} |
|
51 | 66 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/nameviewersupport/EditableGroupedComposite.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.view.nameviewersupport; |
2 | 2 |
|
3 |
import org.apache.log4j.Logger; |
|
3 | 4 |
import org.eclipse.jface.text.TextViewer; |
4 | 5 |
import org.eclipse.swt.SWT; |
5 |
import org.eclipse.swt.custom.StyledText; |
|
6 | 6 |
import org.eclipse.swt.graphics.Font; |
7 | 7 |
import org.eclipse.swt.graphics.Image; |
8 | 8 |
import org.eclipse.swt.widgets.Composite; |
9 | 9 |
import org.eclipse.swt.widgets.Display; |
10 | 10 |
import org.eclipse.swt.widgets.Label; |
11 |
import org.eclipse.swt.widgets.Menu; |
|
11 | 12 |
import org.eclipse.ui.forms.widgets.TableWrapData; |
12 | 13 |
import org.eclipse.ui.forms.widgets.TableWrapLayout; |
13 | 14 |
|
14 | 15 |
abstract public class EditableGroupedComposite extends GroupedComposite { |
16 |
private static final Logger logger = Logger.getLogger(TaxonCompositeFactory.class); |
|
15 | 17 |
|
16 | 18 |
private TextViewer textViewer; |
17 | 19 |
protected TableWrapLayout layout; |
... | ... | |
72 | 74 |
public void setSelectionWrapper (ISelectionWrapper selectionWrapper) { |
73 | 75 |
this.selectionWrapper = selectionWrapper; |
74 | 76 |
} |
77 |
|
|
78 |
public Menu getMenu () { |
|
79 |
|
|
80 |
Menu menu = draggableLabel.getMenu(); |
|
81 |
if (menu == null) { |
|
82 |
menu = new Menu(draggableLabel); |
|
83 |
draggableLabel.setMenu(menu); |
|
84 |
} |
|
85 |
return menu; |
|
86 |
} |
|
75 | 87 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/nameviewersupport/GroupedComposite.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
if (draggable) { |
44 | 44 |
|
45 |
if (dragger != null) { |
|
46 |
// Already initalized |
|
47 |
return; |
|
48 |
} |
|
49 |
|
|
45 | 50 |
if (draggableControl == null) { |
46 | 51 |
throw new NullPointerException( |
47 | 52 |
"Draggable control must be set to add draggability"); |
... | ... | |
58 | 63 |
dragger = null; |
59 | 64 |
} |
60 | 65 |
} |
61 |
|
|
62 |
// public void removeDraggability() { |
|
63 |
// dragger = null; |
|
64 |
// } |
|
65 | 66 |
|
66 | 67 |
/** |
67 | 68 |
* Drag listener which passes the Composite as the data in |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/nameviewersupport/NameComposite.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
public static final int ACCEPTED_INDENT = 0; |
15 | 15 |
public static final int SYNONYM_INDENT = 15; |
16 |
public static final int MISAPPLIEDNAME_INDENT = 5; |
|
16 | 17 |
|
17 | 18 |
public static final Font ACCEPTED_FONT = SWTResourceManager.getFont("Georgia", 12, SWT.NONE); |
18 | 19 |
public static final Font SYNONYM_FONT = SWTResourceManager.getFont("Georgia", 10, SWT.NONE); |
20 |
public static final Font MISAPPLIEDNAME_FONT = SWTResourceManager.getFont("Georgia", 10, SWT.NONE);; |
|
19 | 21 |
|
20 | 22 |
public static final Image ACCEPTED_ICON = Activator.getDefault().getImageRegistry().get(Activator.ACCEPTED_TAXON); |
21 | 23 |
public static final Image HOMOTYPIC_SYNONYM_ICON = Activator.getDefault().getImageRegistry().get(Activator.HOMOTYPIC_SYN); |
22 | 24 |
public static final Image HETEROTYPIC_SYNONYM_ICON = Activator.getDefault().getImageRegistry().get(Activator.HETEROTYPIC_SYN); |
25 |
public static final Image MISAPPLIEDNAME_ICON = Activator.getDefault().getImageRegistry().get(Activator.MISAPPLIED_NAME); |
|
23 | 26 |
|
24 | 27 |
public NameComposite(Composite parent) { |
25 | 28 |
super(parent); |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/nameviewersupport/TaxonCompositeFactory.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.view.nameviewersupport; |
2 | 2 |
|
3 | 3 |
import org.apache.log4j.Logger; |
4 |
import org.eclipse.jface.text.TextViewer; |
|
4 | 5 |
import org.eclipse.jface.viewers.ISelectionProvider; |
5 | 6 |
import org.eclipse.jface.viewers.StructuredSelection; |
7 |
import org.eclipse.swt.SWT; |
|
6 | 8 |
import org.eclipse.swt.events.FocusAdapter; |
7 | 9 |
import org.eclipse.swt.events.FocusEvent; |
10 |
import org.eclipse.swt.events.SelectionAdapter; |
|
11 |
import org.eclipse.swt.events.SelectionEvent; |
|
8 | 12 |
import org.eclipse.swt.widgets.Composite; |
13 |
import org.eclipse.swt.widgets.Menu; |
|
14 |
import org.eclipse.swt.widgets.MenuItem; |
|
9 | 15 |
import org.eclipse.ui.forms.IManagedForm; |
10 | 16 |
|
11 | 17 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
... | ... | |
35 | 41 |
private IManagedForm managedForm; |
36 | 42 |
private ISelectionProvider selectionProvider; |
37 | 43 |
|
44 |
private Composite misappliedNameGroupComposite; |
|
45 |
|
|
38 | 46 |
public GroupComposite createGroupComposite(Composite parent, HomotypicalGroup data) { |
39 | 47 |
final GroupComposite groupComposite = new GroupComposite(parent); |
40 |
groupComposite.setData(data); |
|
48 |
if (data != null) { |
|
49 |
groupComposite.setData(data); |
|
50 |
} |
|
41 | 51 |
// groupComposite.setDataDisposer(new IDataDisposer() { |
42 | 52 |
// @Override |
43 | 53 |
// public void disposeData() { |
... | ... | |
46 | 56 |
// } |
47 | 57 |
// }); |
48 | 58 |
createBorderSupport(groupComposite); |
59 |
if (misappliedNameGroupComposite != null) { |
|
60 |
groupComposite.moveAbove(misappliedNameGroupComposite); |
|
61 |
} |
|
49 | 62 |
return groupComposite; |
50 | 63 |
} |
51 | 64 |
|
... | ... | |
57 | 70 |
nameComposite.setFocus(); |
58 | 71 |
|
59 | 72 |
// When name composite is moved to another group composite ... |
60 |
|
|
61 | 73 |
nameComposite.setParentDataAdapter(new IParentDataAdapter() { |
62 | 74 |
@Override |
63 | 75 |
public void adaptParentData() { |
64 | 76 |
Object parentData = nameComposite.getParent().getData(); |
77 |
if (nameComposite.getParent().equals(misappliedNameGroupComposite)) { |
|
78 |
createMisappliedNameComposite(nameComposite); |
|
79 |
return; |
|
80 |
} |
|
65 | 81 |
if (parentData instanceof HomotypicalGroup) { |
66 | 82 |
try { |
67 | 83 |
TaxonNameBase name = data.getName(); |
... | ... | |
95 | 111 |
} else { |
96 | 112 |
createHeterotypicSynonymComposite(nameComposite); |
97 | 113 |
} |
98 |
|
|
99 | 114 |
} |
100 | 115 |
} |
101 | 116 |
}); |
... | ... | |
134 | 149 |
nameComposite.setIndent(NameComposite.ACCEPTED_INDENT); |
135 | 150 |
return nameComposite; |
136 | 151 |
} |
152 |
|
|
153 |
public NameComposite createMisappliedNameComposite(Composite parent, TaxonBase data) { |
|
154 |
if (!misappliedNameGroupComposite.equals(parent)) { |
|
155 |
misappliedNameGroupComposite = parent; |
|
156 |
} |
|
157 |
NameComposite nameComposite = createNameComposite(parent, null); |
|
158 |
return createMisappliedNameComposite(nameComposite); |
|
159 |
} |
|
160 |
|
|
161 |
public NameComposite createMisappliedNameComposite(NameComposite nameComposite) { |
|
162 |
nameComposite.setDraggable(true); |
|
163 |
nameComposite.setIcon(NameComposite.MISAPPLIEDNAME_ICON); |
|
164 |
nameComposite.setFont(NameComposite.MISAPPLIEDNAME_FONT); |
|
165 |
nameComposite.setIndent(NameComposite.MISAPPLIEDNAME_INDENT); |
|
166 |
return nameComposite; |
|
167 |
} |
|
137 | 168 |
|
138 | 169 |
public NameComposite createHomotypicSynonymComposite(Composite parent, TaxonBase data) { |
139 | 170 |
NameComposite nameComposite = createSynonymComposite(parent, data); |
... | ... | |
155 | 186 |
return nameComposite; |
156 | 187 |
} |
157 | 188 |
|
158 |
private NameComposite createSynonymComposite(Composite composite, TaxonBase data) {
|
|
159 |
NameComposite nameComposite = createNameComposite(composite, data);
|
|
189 |
private NameComposite createSynonymComposite(Composite parent, TaxonBase data) {
|
|
190 |
NameComposite nameComposite = createNameComposite(parent, data);
|
|
160 | 191 |
nameComposite.setDraggable(true); |
161 | 192 |
nameComposite.setFont(NameComposite.SYNONYM_FONT); |
162 | 193 |
nameComposite.setIndent(NameComposite.SYNONYM_INDENT); |
194 |
|
|
195 |
createSynonymMenu(nameComposite); |
|
196 |
|
|
163 | 197 |
return nameComposite; |
164 | 198 |
} |
199 |
|
|
200 |
private Menu createSynonymMenu(final NameComposite nameComposite) { |
|
201 |
|
|
202 |
Menu menu = nameComposite.getMenu(); |
|
203 |
|
|
204 |
MenuItem menuItem = new MenuItem(menu, SWT.NONE); |
|
205 |
menuItem.setImage(NameComposite.MISAPPLIEDNAME_ICON); |
|
206 |
menuItem.setText("Change to misapplied name"); |
|
207 |
menuItem.addSelectionListener(new SelectionAdapter() { |
|
208 |
@Override |
|
209 |
public void widgetSelected(SelectionEvent e) { |
|
210 |
|
|
211 |
// Object data = nameComposite.getData(); |
|
212 |
// |
|
213 |
// if (data instanceof Synonym) { |
|
214 |
// Synonym synonym = (Synonym) data; |
|
215 |
// TaxonNameBase name = synonym.getName(); |
|
216 |
// |
|
217 |
// // Delete synonym from taxon |
|
218 |
// taxon.removeSynonym(synonym); |
|
219 |
// synonym.setName(null); |
|
220 |
// |
|
221 |
// // Use name to create new taxon |
|
222 |
// Taxon toTaxon = Taxon.NewInstance(name, null); |
|
223 |
// taxon.addMisappliedName(toTaxon, null, null); |
|
224 |
// |
|
225 |
// } |
|
226 |
|
|
227 |
Composite groupComposite = nameComposite.getParent(); |
|
228 |
Composite groupParentComposite = groupComposite.getParent(); |
|
229 |
|
|
230 |
if (misappliedNameGroupComposite == null) { |
|
231 |
misappliedNameGroupComposite = createGroupComposite(groupParentComposite, null); |
|
232 |
} |
|
233 |
createMisappliedNameComposite(nameComposite).setParent(misappliedNameGroupComposite); |
|
234 |
} |
|
235 |
}); |
|
236 |
|
|
237 |
return menu; |
|
238 |
} |
|
165 | 239 |
|
166 | 240 |
private NameViewer createNameViewer(final NameComposite nameComposite, final TaxonBase data) { |
167 | 241 |
final NameViewer nameViewer = new NameViewer(nameComposite); |
... | ... | |
223 | 297 |
|
224 | 298 |
public void createBorderSupport(Composite composite) { |
225 | 299 |
if (managedForm != null) { |
226 |
new CompositeBorderDecorator(composite, managedForm); |
|
300 |
CompositeBorderDecorator borderDecorator = new CompositeBorderDecorator(composite, managedForm); |
|
301 |
if (composite instanceof NameComposite) { |
|
302 |
TextViewer textViewer = ((NameComposite) composite).getTextViewer(); |
|
303 |
if (textViewer != null) { |
|
304 |
borderDecorator.setBorderedComposite(textViewer.getTextWidget()); |
|
305 |
} |
|
306 |
} |
|
227 | 307 |
} else { |
228 | 308 |
// TODO add warning that border support can't be added without a managed form |
229 | 309 |
} |
230 | 310 |
} |
231 |
|
|
232 | 311 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/AnnotationPropertySource.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor.view.propertysheetsupport; |
2 | 2 |
|
3 |
import java.util.Set; |
|
4 |
import java.util.Vector; |
|
3 |
import java.util.Collection; |
|
5 | 4 |
|
6 | 5 |
import org.apache.log4j.Logger; |
7 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
|
8 |
import org.eclipse.ui.views.properties.IPropertySource; |
|
9 |
import org.eclipse.ui.views.properties.PropertyDescriptor; |
|
10 | 6 |
|
11 | 7 |
import eu.etaxonomy.cdm.model.common.Annotation; |
12 | 8 |
|
13 |
public class AnnotationPropertySource implements IPropertySource {
|
|
9 |
public class AnnotationPropertySource extends CollectionPropertySource {
|
|
14 | 10 |
private static final Logger logger = Logger |
15 | 11 |
.getLogger(AnnotationPropertySource.class); |
16 | 12 |
|
17 |
private Set<Annotation> annotations; |
|
18 |
|
|
19 |
private Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>(); |
|
20 |
|
|
21 |
@Override |
|
22 |
public Object getEditableValue() { |
|
23 |
return this; |
|
24 |
} |
|
25 |
|
|
26 |
public AnnotationPropertySource(Set<Annotation> annotations) { |
|
27 |
this.annotations = annotations; |
|
28 |
for (Annotation annotation : annotations) { |
|
29 |
addDescriptor(annotation); |
|
30 |
} |
|
13 |
public AnnotationPropertySource(Collection collection) { |
|
14 |
super(collection); |
|
31 | 15 |
} |
32 | 16 |
|
33 |
private void addDescriptor(Annotation annotation) { |
|
34 |
descriptors.addElement( |
|
35 |
new PropertyDescriptor(annotation, "")); |
|
36 |
} |
|
37 |
|
|
38 | 17 |
@Override |
39 |
public IPropertyDescriptor[] getPropertyDescriptors() {
|
|
40 |
return (IPropertyDescriptor[]) descriptors.toArray(
|
|
41 |
new IPropertyDescriptor[descriptors.size()]);
|
|
18 |
protected String getItemDisplayName(Object item) {
|
|
19 |
// No display names on individual annotations
|
|
20 |
return "";
|
|
42 | 21 |
} |
43 | 22 |
|
44 | 23 |
@Override |
... | ... | |
47 | 26 |
return ((Annotation) id).getText(); |
48 | 27 |
} |
49 | 28 |
return null; |
50 |
|
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
public boolean isPropertySet(Object id) { |
|
55 |
return false; |
|
56 | 29 |
} |
57 | 30 |
|
58 |
@Override |
|
59 |
public void resetPropertyValue(Object id) {} |
|
60 |
|
|
61 | 31 |
@Override |
62 | 32 |
public void setPropertyValue(Object id, Object value) { |
63 |
// only for editable fields
|
|
33 |
// Fields not editable in property sheet view
|
|
64 | 34 |
} |
65 |
|
|
35 |
|
|
66 | 36 |
@Override |
67 |
public String toString() { |
|
37 |
public String toString() { |
|
38 |
// "Annotations" header has no value |
|
68 | 39 |
return ""; |
69 | 40 |
} |
70 | 41 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/BotanicalNamePropertySource.java | ||
---|---|---|
14 | 14 |
super(name); |
15 | 15 |
// TODO Auto-generated constructor stub |
16 | 16 |
} |
17 |
|
|
18 |
|
|
19 | 17 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/CollectionPropertySource.java | ||
---|---|---|
8 | 8 |
import org.eclipse.ui.views.properties.IPropertySource; |
9 | 9 |
import org.eclipse.ui.views.properties.PropertyDescriptor; |
10 | 10 |
|
11 |
/** |
|
12 |
* @author p.ciardelli |
|
13 |
* @created 08.05.2008 |
|
14 |
* @version 1.0 |
|
15 |
*/ |
|
16 | 11 |
/** |
17 | 12 |
* @author p.ciardelli |
18 | 13 |
* @created 08.05.2008 |
... | ... | |
22 | 17 |
private static final Logger logger = Logger |
23 | 18 |
.getLogger(CollectionPropertySource.class); |
24 | 19 |
|
25 |
private Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>(); |
|
26 |
|
|
27 |
private Collection collection; |
|
20 |
protected Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>(); |
|
21 |
protected Collection collection; |
|
28 | 22 |
|
29 | 23 |
public CollectionPropertySource(Collection collection) { |
30 | 24 |
this.collection = collection; |
... | ... | |
33 | 27 |
} |
34 | 28 |
} |
35 | 29 |
|
36 |
private void addDescriptor(Object item) {
|
|
37 |
String itemLabel = getItemLabel(item);
|
|
30 |
protected void addDescriptor(Object item) {
|
|
31 |
String itemDisplayName = getItemDisplayName(item);
|
|
38 | 32 |
descriptors.addElement( |
39 |
new PropertyDescriptor(item, itemLabel));
|
|
33 |
new PropertyDescriptor(item, itemDisplayName));
|
|
40 | 34 |
} |
41 | 35 |
|
42 | 36 |
/** |
... | ... | |
46 | 40 |
* @param item |
47 | 41 |
* @return |
48 | 42 |
*/ |
49 |
abstract protected String getItemLabel(Object item);
|
|
43 |
abstract protected String getItemDisplayName(Object item);
|
|
50 | 44 |
|
51 | 45 |
@Override |
52 | 46 |
public Object getEditableValue() { |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/NameRelationsPropertySource.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package eu.etaxonomy.taxeditor.view.propertysheetsupport; |
3 | 3 |
|
4 |
import java.util.Set; |
|
5 |
import java.util.Vector; |
|
4 |
import java.util.Collection; |
|
6 | 5 |
|
7 | 6 |
import org.apache.log4j.Logger; |
8 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
|
9 |
import org.eclipse.ui.views.properties.IPropertySource; |
|
10 |
import org.eclipse.ui.views.properties.PropertyDescriptor; |
|
11 | 7 |
|
12 | 8 |
import eu.etaxonomy.cdm.model.name.NameRelationship; |
13 | 9 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
14 | 10 |
|
15 |
public class NameRelationsPropertySource implements IPropertySource {
|
|
11 |
public class NameRelationsPropertySource extends CollectionPropertySource {
|
|
16 | 12 |
private static final Logger logger = Logger |
17 | 13 |
.getLogger(NameRelationsPropertySource.class); |
18 |
|
|
19 |
private Set<NameRelationship> nameRelations; |
|
20 |
private TaxonNameBase name; |
|
21 |
|
|
22 |
private Vector<PropertyDescriptor> descriptors = new Vector<PropertyDescriptor>(); |
|
23 | 14 |
|
24 |
@Override |
|
25 |
public Object getEditableValue() { |
|
26 |
return this; |
|
27 |
} |
|
15 |
private TaxonNameBase name; |
|
28 | 16 |
|
29 |
public NameRelationsPropertySource(TaxonNameBase name, Set<NameRelationship> nameRelations) { |
|
17 |
public NameRelationsPropertySource(TaxonNameBase name, Collection collection) { |
|
18 |
super(collection); |
|
30 | 19 |
this.name = name; |
31 |
this.nameRelations = nameRelations; |
|
32 |
for (NameRelationship nameRelation : nameRelations) { |
|
33 |
addDescriptor(nameRelation); |
|
34 |
} |
|
35 | 20 |
} |
36 | 21 |
|
37 |
private void addDescriptor(NameRelationship nameRelation) { |
|
38 |
|
|
39 |
// Make a displayName for the property sheet entry |
|
40 |
String displayName = ""; |
|
41 |
if (nameRelation.getType() != null) { |
|
42 |
displayName = nameRelation.getType().getLabel(); |
|
22 |
@Override |
|
23 |
protected String getItemDisplayName(Object item) { |
|
24 |
String itemDisplayName = ""; |
|
25 |
if (item instanceof NameRelationship) { |
|
26 |
NameRelationship nameRelation = (NameRelationship) item; |
|
27 |
if (nameRelation.getType() != null) { |
|
28 |
itemDisplayName = nameRelation.getType().getLabel(); |
|
29 |
} else { |
|
30 |
itemDisplayName = "Relation has no type"; |
|
31 |
} |
|
43 | 32 |
} |
44 |
|
|
33 |
return itemDisplayName; |
|
45 | 34 |
// TODO sort out difference b/w to and from rels |
46 |
|
|
47 |
descriptors.addElement( |
|
48 |
new PropertyDescriptor(nameRelation, displayName)); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
public IPropertyDescriptor[] getPropertyDescriptors() { |
|
53 |
return (IPropertyDescriptor[]) descriptors.toArray( |
|
54 |
new IPropertyDescriptor[descriptors.size()]); |
|
55 | 35 |
} |
56 | 36 |
|
57 | 37 |
@Override |
... | ... | |
66 | 46 |
return (relatedName.getTitleCache()); |
67 | 47 |
} |
68 | 48 |
return null; |
69 |
|
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public boolean isPropertySet(Object id) { |
|
74 |
return false; |
|
75 | 49 |
} |
76 | 50 |
|
77 |
@Override |
|
78 |
public void resetPropertyValue(Object id) {} |
|
79 |
|
|
80 | 51 |
@Override |
81 | 52 |
public void setPropertyValue(Object id, Object value) { |
82 |
// only for editable fields
|
|
53 |
// Fields not editable in property sheet view
|
|
83 | 54 |
} |
84 |
|
|
55 |
|
|
85 | 56 |
@Override |
86 |
public String toString() { |
|
57 |
public String toString() { |
|
58 |
// "Name Relations" header has no value |
|
87 | 59 |
return ""; |
88 | 60 |
} |
89 |
}
|
|
61 |
} |
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/view/propertysheetsupport/NonViralNamePropertySource.java | ||
---|---|---|
4 | 4 |
import java.beans.PropertyChangeEvent; |
5 | 5 |
import java.beans.PropertyChangeListener; |
6 | 6 |
import java.util.ArrayList; |
7 |
import java.util.Date; |
|
7 | 8 |
import java.util.List; |
9 |
import java.util.Set; |
|
8 | 10 |
import java.util.Vector; |
9 | 11 |
|
10 | 12 |
import org.apache.log4j.Logger; |
13 |
import org.eclipse.jface.viewers.CellEditor; |
|
14 |
import org.eclipse.jface.viewers.DialogCellEditor; |
|
15 |
import org.eclipse.swt.widgets.Composite; |
|
16 |
import org.eclipse.swt.widgets.Control; |
|
17 |
import org.eclipse.swt.widgets.Dialog; |
|
11 | 18 |
import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor; |
12 | 19 |
import org.eclipse.ui.views.properties.IPropertyDescriptor; |
13 | 20 |
import org.eclipse.ui.views.properties.IPropertySource; |
14 | 21 |
import org.eclipse.ui.views.properties.PropertyDescriptor; |
15 | 22 |
import org.eclipse.ui.views.properties.TextPropertyDescriptor; |
16 | 23 |
|
24 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
17 | 25 |
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; |
18 | 26 |
import eu.etaxonomy.cdm.model.name.NonViralName; |
19 | 27 |
import eu.etaxonomy.cdm.model.name.Rank; |
... | ... | |
33 | 41 |
public static final String P_ID_RANK = "rank"; |
34 | 42 |
public static final String P_ID_TITLECACHE = "titlecache"; |
35 | 43 |
public static final String P_ID_UNINOMIAL = "uninomial"; |
44 |
public static final String P_ID_INFRAGENERICEP = "infragenericep"; |
|
36 | 45 |
public static final String P_ID_SPECIESEP = "speciesep"; |
46 |
public static final String P_ID_INFRASPECIFICEP = "infraspecificep"; |
|
47 |
public static final String P_ID_APPENDEDPHRASE = "appendedphrase"; |
|
37 | 48 |
public static final String P_ID_HOMOTYPICALGROUP = "homogroup"; |
38 | 49 |
public static final String P_ID_AUTHORSHIPCACHE = "authorshipcache"; |
50 |
public static final String P_ID_NAMERELATIONS = "namerelations"; |
|
51 |
public static final String P_ID_ANNOTATIONS = "annotations"; |
|
52 |
public static final String P_ID_NOMSTATUS = "nomstatus"; |
|
39 | 53 |
public static final String P_ID_UUID = "uuid"; |
40 | 54 |
public static final String P_ID_NUM_OF_BASES = "numberofbases"; |
55 |
public static final String P_ID_MARKERS = "markers"; |
|
41 | 56 |
public static final String P_ID_CREATED = "created"; |
42 | 57 |
public static final String P_ID_CREATEDBY = "createdby"; |
43 | 58 |
|
... | ... | |
45 | 60 |
// Note: for an explanation of the sorting prefixes ("04:"), |
46 | 61 |
// @see eu.etaxonomy.taxeditor.view.propertysheetsupport.CustomSortPropertySheetEntry |
47 | 62 |
public static final String P_PARSED = "00:Parsing Status"; |
48 |
public static final String P_RANK = "04:Rank";
|
|
63 |
public static final String P_RANK = "08:Rank";
|
|
49 | 64 |
public static final String P_TITLECACHE = "01:Title Cache"; |
50 | 65 |
public static final String P_UNINOMIAL = "02:Uninomial"; |
51 |
public static final String P_SPECIESEP = "03:Specific Epithet"; |
|
52 |
public static final String P_HOMOTYPICALGROUP = "05:Homotypical Group"; |
|
66 |
public static final String P_INFRAGENERICEP = "03:Infrageneric Epithet"; |
|
67 |
public static final String P_SPECIESEP = "04:Specific Epithet"; |
|
68 |
public static final String P_INFRASPECIFICEP = "05:Infraspecific Epithet"; |
|
69 |
public static final String P_APPENDEDPHRASE = "07:Appended Phrase"; |
|
70 |
public static final String P_HOMOTYPICALGROUP = "09:Homotypical Group"; |
|
53 | 71 |
public static final String P_AUTHORSHIPCACHE = "06:Authorship"; |
54 |
public static final String P_UUID = "07:UUID"; |
|
55 |
public static final String P_NUM_OF_BASES = "08:Number of Bases"; |
|
72 |
public static final String P_NAMERELATIONS = "11:Name Relations"; |
|
73 |
public static final String P_ANNOTATIONS = "10:Annotations"; |
|
74 |
public static final String P_NOMSTATUS = "11:Nomenclatural Status"; |
|
75 |
public static final String P_UUID = "11:UUID"; |
|
76 |
public static final String P_NUM_OF_BASES = "12:Number of Bases"; |
|
77 |
public static final String P_MARKERS = "12:Markers"; |
|
56 | 78 |
public static final String P_CREATED = "98:Created"; |
57 | 79 |
public static final String P_CREATEDBY = "99:Created By"; |
58 | 80 |
|
59 |
// Rank[] ranks = new Rank[] {null, Rank.GENUS(), Rank.SPECIES(), Rank.SUBSPECIES()}; |
|
60 | 81 |
OrderedTermVocabulary<Rank> rankVocabulary = Activator.getDefault().getRankVocabulary(); |
61 | 82 |
static Rank[] ranks = null; |
62 | 83 |
static String[] P_RANK_MENU = null; |
... | ... | |
123 | 144 |
descriptors.addElement( |
124 | 145 |
new TextPropertyDescriptor(P_ID_UNINOMIAL, P_UNINOMIAL)); |
125 | 146 |
} |
147 |
if (id.equals(P_ID_INFRAGENERICEP)) { |
|
148 |
descriptors.addElement( |
|
149 |
new TextPropertyDescriptor(P_ID_INFRAGENERICEP, P_INFRAGENERICEP)); |
|
150 |
} |
|
126 | 151 |
if (id.equals(P_ID_SPECIESEP)) { |
127 | 152 |
descriptors.addElement( |
128 | 153 |
new TextPropertyDescriptor(P_ID_SPECIESEP, P_SPECIESEP)); |
129 | 154 |
} |
155 |
if (id.equals(P_ID_INFRASPECIFICEP)) { |
|
156 |
descriptors.addElement( |
|
157 |
new TextPropertyDescriptor(P_ID_INFRASPECIFICEP, P_INFRASPECIFICEP)); |
|
158 |
} |
|
159 |
if (id.equals(P_ID_APPENDEDPHRASE)) { |
|
160 |
descriptors.addElement( |
|
161 |
new TextPropertyDescriptor(P_ID_APPENDEDPHRASE, P_APPENDEDPHRASE)); |
|
162 |
} |
|
130 | 163 |
if (id.equals(P_ID_AUTHORSHIPCACHE)) { |
131 | 164 |
descriptors.addElement( |
132 | 165 |
new TextPropertyDescriptor(P_ID_AUTHORSHIPCACHE, P_AUTHORSHIPCACHE)); |
... | ... | |
135 | 168 |
descriptors.addElement( |
136 | 169 |
new PropertyDescriptor(P_ID_HOMOTYPICALGROUP, P_HOMOTYPICALGROUP)); |
137 | 170 |
} |
171 |
if (id.equals(P_ID_NAMERELATIONS)) { |
|
172 |
descriptors.addElement( |
|
173 |
new PropertyDescriptor(P_ID_NAMERELATIONS, P_NAMERELATIONS)); |
|
174 |
} |
|
175 |
if (id.equals(P_ID_ANNOTATIONS)) { |
|
176 |
descriptors.addElement( |
|
177 |
new PropertyDescriptor(P_ID_ANNOTATIONS, P_ANNOTATIONS) { |
|
178 |
public CellEditor createPropertyEditor(Composite parent) { |
|
179 |
CellEditor editor = new DialogCellEditor(parent) { |
|
180 |
|
|
181 |
@Override |
|
182 |
protected Object openDialogBox( |
|
183 |
Control cellEditorWindow) { |
|
184 |
Dialog dialog = new AnnotationsDialog(cellEditorWindow.getShell(), name.getAnnotations()); |
|
185 |
Object value = ((AnnotationsDialog) dialog).open(); |
|
186 |
if (value instanceof Set) { |
|
187 |
logger.warn("Dialog returned set with " + ((Set) value).size() + " elements."); |
|
188 |
setPropertyValue(P_ID_ANNOTATIONS, value); |
|
189 |
} |
|
190 |
return null; |
|
191 |
} |
|
192 |
|
|
193 |
}; |
|
194 |
if (getValidator() != null) { |
|
195 |
editor.setValidator(getValidator()); |
|
196 |
} |
|
197 |
return editor; |
|
198 |
} |
|
199 |
}); |
|
200 |
} |
|
201 |
if (id.equals(P_ID_NOMSTATUS)) { |
|
202 |
descriptors.addElement( |
|
203 |
new PropertyDescriptor(P_ID_NOMSTATUS, P_NOMSTATUS)); |
|
204 |
} |
|
138 | 205 |
if (id.equals(P_ID_UUID)) { |
139 | 206 |
descriptors.addElement( |
140 | 207 |
new PropertyDescriptor(P_ID_UUID, P_UUID)); |
141 | 208 |
} |
209 |
if (id.equals(P_ID_MARKERS)) { |
|
210 |
descriptors.addElement( |
|
211 |
new PropertyDescriptor(P_ID_MARKERS, P_MARKERS)); |
|
212 |
} |
|
142 | 213 |
if (id.equals(P_ID_NUM_OF_BASES)) { |
143 | 214 |
descriptors.addElement( |
144 | 215 |
new PropertyDescriptor(P_ID_NUM_OF_BASES, P_NUM_OF_BASES)); |
145 |
}
|
|
216 |
} |
|
146 | 217 |
if (id.equals(P_ID_CREATED)) { |
147 | 218 |
descriptors.addElement( |
148 | 219 |
new PropertyDescriptor(P_ID_CREATED, P_CREATED)); |
... | ... | |
150 | 221 |
if (id.equals(P_ID_CREATEDBY)) { |
151 | 222 |
descriptors.addElement( |
152 | 223 |
new PropertyDescriptor(P_ID_CREATEDBY, P_CREATEDBY)); |
153 |
}
|
|
224 |
} |
|
154 | 225 |
} |
155 | 226 |
|
156 | 227 |
private PropertyChangeListener taxonChangeListener = new PropertyChangeListener() { |
... | ... | |
177 | 248 |
* @param name |
178 | 249 |
*/ |
179 | 250 |
public NonViralNamePropertySource(NonViralName name) { |
180 |
this(name, null, new String[] {P_ID_PARSED, P_ID_RANK, P_ID_TITLECACHE, P_ID_HOMOTYPICALGROUP, |
|
181 |
P_ID_UUID, P_ID_NUM_OF_BASES, P_ID_CREATED, P_ID_CREATEDBY }); |
|
251 |
this(name, null, new String[] {P_ID_PARSED, P_ID_RANK, P_ID_TITLECACHE, |
|
252 |
P_ID_HOMOTYPICALGROUP, P_ID_ANNOTATIONS, P_ID_NOMSTATUS, P_ID_NAMERELATIONS, P_ID_UUID, |
|
253 |
P_ID_MARKERS, P_ID_NUM_OF_BASES, P_ID_CREATED, P_ID_CREATEDBY }); |
|
182 | 254 |
} |
183 | 255 |
|
184 | 256 |
public NonViralNamePropertySource(NonViralName name, |
... | ... | |
217 | 289 |
} |
218 | 290 |
return 0; |
219 | 291 |
} |
220 |
if (id.equals(P_ID_TITLECACHE)) |
|
221 |
return new NonViralNamePropertySource(name, |
|
222 |
P_ID_TITLECACHE, |
|
223 |
new String[] {P_ID_UNINOMIAL, P_ID_SPECIESEP, P_ID_AUTHORSHIPCACHE}); |
|
224 |
if (id.equals(P_ID_UNINOMIAL)) |
|
292 |
if (id.equals(P_ID_TITLECACHE)) { |
|
293 |
|
|
294 |
// The fields displayed under the title cache are dependent on rank. |
|
295 |
// List<String> nameFields = new ArrayList<String>(); |
|
296 |
// nameFields.add(P_ID_UNINOMIAL); |
|
297 |
// nameFields.add(P_ID_SPECIESEP); |
|
298 |
// String[] nameFields = null; |
|
299 |
// if (name.isSupraGeneric() || name.isGenus()) { // Rank is higher than GENUS or equals GENUS |
|
300 |
// nameFields = new String[] {P_ID_UNINOMIAL, P_ID_AUTHORSHIPCACHE}; |
|
301 |
// } |
|
302 |
// else if (name.isInfraGeneric()) { // lower than GENUS and higher than SPECIES |
|
303 |
// nameFields = new String[] {P_ID_UNINOMIAL, P_ID_INFRAGENERICEP, P_ID_AUTHORSHIPCACHE}; |
|
304 |
// } |
|
305 |
// else if (name.isSpecies()) { // Rank equals SPECIES |
|
306 |
// nameFields = new String[] {P_ID_UNINOMIAL, P_ID_SPECIESEP, P_ID_AUTHORSHIPCACHE}; |
|
307 |
// } |
|
308 |
// else if (name.isInfraSpecific()) { // Rank is lower than SPECIES |
|
309 |
// nameFields = new String[] {P_ID_UNINOMIAL, P_ID_SPECIESEP, P_ID_INFRASPECIFICEP, P_ID_AUTHORSHIPCACHE}; |
|
310 |
// } else { |
|
311 |
// nameFields = new String[] {P_ID_UNINOMIAL, P_ID_SPECIESEP, P_ID_AUTHORSHIPCACHE}; |
|
312 |
// } |
|
313 |
// TODO put this in a method to be extended by bot / zoo names |
|
314 |
|
|
315 |
return new NonViralNamePropertySource(name, P_ID_TITLECACHE, getNameFields()); |
|
316 |
} |
|
317 |
if (id.equals(P_ID_UNINOMIAL)) { |
|
225 | 318 |
return subEmptyForNull(name.getGenusOrUninomial()); |
226 |
if (id.equals(P_ID_SPECIESEP)) |
|
319 |
} |
|
320 |
if (id.equals(P_ID_INFRAGENERICEP)) { |
|
321 |
return subEmptyForNull(name.getInfraGenericEpithet()); |
|
322 |
} |
|
323 |
if (id.equals(P_ID_SPECIESEP)) { |
|
227 | 324 |
return subEmptyForNull(name.getSpecificEpithet()); |
228 |
if (id.equals(P_ID_AUTHORSHIPCACHE)) |
|
325 |
} |
|
326 |
if (id.equals(P_ID_INFRASPECIFICEP)) { |
|
327 |
return subEmptyForNull(name.getInfraSpecificEpithet()); |
|
328 |
} |
|
329 |
if (id.equals(P_ID_APPENDEDPHRASE)) { |
|
330 |
return subEmptyForNull(name.getAppendedPhrase()); |
|
331 |
} |
|
332 |
if (id.equals(P_ID_AUTHORSHIPCACHE)) { |
|
229 | 333 |
return subEmptyForNull(name.getAuthorshipCache()); |
230 |
if (id.equals(P_ID_HOMOTYPICALGROUP)) |
|
334 |
} |
|
335 |
if (id.equals(P_ID_HOMOTYPICALGROUP)) { |
|
231 | 336 |
return subEmptyForNull(name.getHomotypicalGroup().getUuid().toString()); |
232 |
if (id.equals(P_ID_UUID)) |
|
337 |
} |
|
338 |
if (id.equals(P_ID_ANNOTATIONS)) { |
|
339 |
return new AnnotationPropertySource(name.getAnnotations()); |
|
340 |
} |
|
341 |
if (id.equals(P_ID_NOMSTATUS)) { |
|
342 |
return new NomStatusPropertySource(name.getStatus()); |
|
343 |
} |
|
344 |
if (id.equals(P_ID_NAMERELATIONS)) { |
|
345 |
return new NameRelationsPropertySource(name, name.getNameRelations()); |
|
346 |
} |
|
347 |
if (id.equals(P_ID_UUID)) { |
|
233 | 348 |
return subEmptyForNull(name.getUuid().toString()); |
234 |
if (id.equals(P_ID_NUM_OF_BASES)) |
|
349 |
} |
|
350 |
if (id.equals(P_ID_MARKERS)) { |
|
351 |
return new MarkersPropertySource(name.getMarkers()); |
|
352 |
} |
|
353 |
if (id.equals(P_ID_NUM_OF_BASES)) { |
|
235 | 354 |
return name.getTaxonBases().size(); |
236 |
if (id.equals(P_ID_CREATED)) |
|
237 |
// if (name.getCreated() == null) { |
|
238 |
// return ""; |
|
239 |
// } else { |
|
240 |
// return subEmptyForNull(name.getCreated().getTime()); |
|
241 |
// } |
|
242 |
return subEmptyForNull(name.getCreated().toString()); |
|
355 |
} |
|
356 |
if (id.equals(P_ID_CREATED)) { |
|
357 |
if (name.getCreated() == null) { |
|
358 |
return ""; |
|
359 |
} else { |
|
360 |
return formatDate(name.getCreated().getTime()); |
|
361 |
} |
|
362 |
} |
|
243 | 363 |
if (id.equals(P_ID_CREATEDBY)) { |
244 | 364 |
if (name.getCreatedBy() == null) { |
245 | 365 |
return ""; |
... | ... | |
250 | 370 |
return null; |
251 | 371 |
} |
252 | 372 |
|
373 |
private String[] getNameFields() { |
|
374 |
List<String> nameFields = new ArrayList<String>(); |
|
375 |
nameFields.add(P_ID_UNINOMIAL); |
|
376 |
if (name.isSupraGeneric() || name.isGenus()) { // Rank is higher than GENUS or equals GENUS |
|
377 |
} |
|
378 |
else if (name.isInfraGeneric()) { // lower than GENUS and higher than SPECIES |
|
379 |
nameFields.add(P_ID_INFRAGENERICEP); |
|
380 |
} |
|
381 |
else if (name.isSpecies()) { // Rank equals SPECIES |
|
382 |
nameFields.add(P_ID_SPECIESEP); |
|
383 |
} |
|
384 |
else if (name.isInfraSpecific()) { // Rank is lower than SPECIES |
|
385 |
nameFields.add(P_ID_SPECIESEP); |
|
386 |
nameFields.add(P_ID_INFRASPECIFICEP); |
|
387 |
} else { |
|
388 |
nameFields.add(P_ID_SPECIESEP); |
|
389 |
} |
|
390 |
nameFields.add(P_ID_AUTHORSHIPCACHE); |
|
391 |
nameFields.add(P_ID_APPENDEDPHRASE); |
|
392 |
return nameFields.toArray(new String[nameFields.size()]); |
|
393 |
} |
|
394 |
|
|
395 |
private Object formatDate(Date date) { |
|
396 |
return String.format("%1$tm-%1$td-%1$tY %1$tH:%1$tM:%1$tS", date); |
|
397 |
} |
|
398 |
|
|
253 | 399 |
/** |
254 | 400 |
* If the value of a TextPropertyDescriptor is initialized with NULL, |
255 | 401 |
* the user can't edit it; such values need to be set to "". |
... | ... | |
283 | 429 |
int index = ((Integer) value).intValue(); |
284 | 430 |
name.setRank(ranks[index]); |
285 | 431 |
} |
286 |
if (id.equals(P_ID_UNINOMIAL)) |
|
432 |
if (id.equals(P_ID_UNINOMIAL)) {
|
|
287 | 433 |
name.setGenusOrUninomial((String) value); |
288 |
if (id.equals(P_ID_SPECIESEP)) |
|
434 |
} |
|
435 |
if (id.equals(P_ID_INFRAGENERICEP)) { |
|
436 |
name.setInfraGenericEpithet((String) value); |
|
437 |
} |
|
438 |
if (id.equals(P_ID_SPECIESEP)) { |
|
289 | 439 |
name.setSpecificEpithet((String) value); |
290 |
if (id.equals(P_ID_AUTHORSHIPCACHE)) |
|
440 |
} |
|
441 |
if (id.equals(P_ID_INFRASPECIFICEP)) { |
|
442 |
name.setInfraSpecificEpithet((String) value); |
|
443 |
} |
|
444 |
if (id.equals(P_ID_APPENDEDPHRASE)) { |
|
445 |
name.setAppendedPhrase((String) value); |
|
446 |
} |
|
447 |
if (id.equals(P_ID_AUTHORSHIPCACHE)) { |
|
291 | 448 |
name.setAuthorshipCache((String) value); |
449 |
} |
|
450 |
if (id.equals(P_ID_ANNOTATIONS)) { |
|
451 |
Set annotations = name.getAnnotations(); |
|
452 |
if (value instanceof Set) { |
|
453 |
for (Object object: (Set) value) { |
|
454 |
if (object instanceof Annotation && !annotations.contains(object)) { |
|
455 |
logger.warn("Adding annotation"); |
|
456 |
name.addAnnotation((Annotation) object); |
|
457 |
} |
|
458 |
} |
|
459 |
} |
|
460 |
} |
|
461 |
if (id.equals(P_ID_NAMERELATIONS)) { |
|
462 |
// TODO set name relations |
|
463 |
} |
|
464 |
if (id.equals(P_ID_NOMSTATUS)) { |
|
465 |
// TODO set nom status |
|
466 |
} |
|
467 |
if (id.equals(P_ID_MARKERS)) { |
|
468 |
// TODO set markers |
|
469 |
} |
|
292 | 470 |
} |
293 | 471 |
|
294 | 472 |
/** |
... | ... | |
303 | 481 |
return name.getTitleCache(); |
304 | 482 |
return super.toString(); |
305 | 483 |
} |
306 |
|
|
307 | 484 |
} |
Also available in: Unified diff
Pfingsten commit. Added rudimentary misapplied names, still very buggy.