2 package eu
.etaxonomy
.taxeditor
.view
.propertysheetsupport
;
4 import java
.util
.Collection
;
6 import org
.apache
.log4j
.Logger
;
8 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
9 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
11 public class NameRelationsPropertySource
extends CollectionPropertySource
{
12 private static final Logger logger
= Logger
13 .getLogger(NameRelationsPropertySource
.class);
15 private TaxonNameBase name
;
17 public NameRelationsPropertySource(TaxonNameBase name
, Collection collection
) {
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();
30 itemDisplayName
= "Relation has no type";
33 return itemDisplayName
;
34 // TODO sort out difference b/w to and from rels
38 public Object
getPropertyValue(Object id
) {
39 if (id
instanceof NameRelationship
) {
40 TaxonNameBase
<TaxonNameBase
> relatedName
;
42 if (((NameRelationship
) id
).getFromName().equals(name
)) {
43 relatedName
= ((NameRelationship
) id
).getToName();
44 nameValue
= "to " + relatedName
.getTitleCache();
46 relatedName
= ((NameRelationship
) id
).getFromName();
47 nameValue
= relatedName
.getTitleCache();
55 public void setPropertyValue(Object id
, Object value
) {
56 // Fields not editable in property sheet view
60 public String
toString() {
61 // "Name Relations" header has no value