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
;
37 public Object
getPropertyValue(Object id
) {
38 if (id
instanceof NameRelationship
) {
39 TaxonNameBase relatedName
;
41 if (((NameRelationship
) id
).getFromName().equals(name
)) {
42 relatedName
= ((NameRelationship
) id
).getToName();
43 nameValue
= "to " + relatedName
.getTitleCache();
45 relatedName
= ((NameRelationship
) id
).getFromName();
46 nameValue
= relatedName
.getTitleCache();
54 public void setPropertyValue(Object id
, Object value
) {
55 // Fields not editable in property sheet view
59 public String
toString() {
60 // "Name Relations" header has no value