2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.propertysheet
.namerelations
.wizard
;
12 import java
.beans
.PropertyChangeListener
;
13 import java
.beans
.PropertyChangeSupport
;
14 import java
.util
.List
;
16 import org
.apache
.log4j
.Logger
;
18 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationship
;
19 import eu
.etaxonomy
.cdm
.model
.name
.NameRelationshipType
;
20 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
21 import eu
.etaxonomy
.cdm
.model
.name
.ZoologicalName
;
22 import eu
.etaxonomy
.taxeditor
.model
.CdmUtil
;
29 public class NameRelationWizardModel
{
30 private static final Logger logger
= Logger
31 .getLogger(NameRelationWizardModel
.class);
33 protected static final String RELATEDNAME
= "relatedname";
34 protected static final String RELATIONTYPE
= "relationtype";
36 private TaxonNameBase baseName
;
37 private TaxonNameBase relatedName
;
38 private TaxonNameBase fromName
;
39 private TaxonNameBase toName
;
40 private NameRelationshipType type
;
41 private boolean isZoological
= false;
43 // Stores pre-existing relation, if any exists
44 private NameRelationship nameRelationship
;
45 // List of the base name's relations
46 private List
<NameRelationship
> nameRelationsList
;
48 private PropertyChangeSupport propertyChangeSupport
;
51 public NameRelationWizardModel(TaxonNameBase baseName
) {
52 this.baseName
= baseName
;
53 if (baseName
instanceof ZoologicalName
) {
56 this.propertyChangeSupport
= new PropertyChangeSupport(this);
59 private void firePropertyChange(String propertyName
, Object oldValue
,
61 propertyChangeSupport
.firePropertyChange(propertyName
, oldValue
,
65 public void addPropertyChangeListener(String propertyName
,
66 PropertyChangeListener listener
) {
67 propertyChangeSupport
.addPropertyChangeListener(propertyName
, listener
);
70 public void addPropertyChangeListener(PropertyChangeListener listener
) {
71 propertyChangeSupport
.addPropertyChangeListener(listener
);
74 public TaxonNameBase
getBaseName() {
78 public void setBaseName(TaxonNameBase baseName
) {
79 this.baseName
= baseName
;
82 public TaxonNameBase
getRelatedName() {
86 public void setRelatedName(TaxonNameBase relatedName
) {
87 this.relatedName
= relatedName
;
88 firePropertyChange(RELATEDNAME
, null, relatedName
);
91 public TaxonNameBase
getFromName() {
95 public void setFromName(TaxonNameBase fromName
) {
96 this.fromName
= fromName
;
97 logger
.warn("Setting from name: " + CdmUtil
.getDisplayName(fromName
));
100 public TaxonNameBase
getToName() {
104 public void setToName(TaxonNameBase toName
) {
105 this.toName
= toName
;
106 logger
.warn("Setting to name: " + CdmUtil
.getDisplayName(toName
));
109 public NameRelationshipType
getType() {
113 public void setType(NameRelationshipType type
) {
115 firePropertyChange(RELATIONTYPE
, null, type
);
118 public void setRelation(NameRelationship nameRelationship
) {
119 this.nameRelationship
= nameRelationship
;
122 public NameRelationship
getRelation() {
123 return nameRelationship
;
126 public void setNameRelationsList(List
<NameRelationship
> nameRelationsList
) {
127 this.nameRelationsList
= nameRelationsList
;
130 public List
<NameRelationship
> getNameRelationsList() {
131 return nameRelationsList
;
134 public boolean isZoological() {