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
.view
.propertysheetsupport
.namerelationswizard
;
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
.taxeditor
.model
.CdmUtil
;
28 public class NameRelationWizardModel
{
29 private static final Logger logger
= Logger
30 .getLogger(NameRelationWizardModel
.class);
32 protected static final String RELATEDNAME
= "relatedname";
33 protected static final String RELATIONTYPE
= "relationtype";
35 private TaxonNameBase baseName
;
36 private TaxonNameBase relatedName
;
38 private TaxonNameBase fromName
;
39 private TaxonNameBase toName
;
40 private NameRelationshipType type
;
42 // Stores pre-existing relation, if any exists
43 private NameRelationship nameRelationship
;
44 // List of the base name's relations
45 private List
<NameRelationship
> nameRelationsList
;
47 private PropertyChangeSupport propertyChangeSupport
;
50 public NameRelationWizardModel(TaxonNameBase baseName
) {
51 this.baseName
= baseName
;
52 this.propertyChangeSupport
= new PropertyChangeSupport(this);
55 private void firePropertyChange(String propertyName
, Object oldValue
,
57 propertyChangeSupport
.firePropertyChange(propertyName
, oldValue
,
61 public void addPropertyChangeListener(String propertyName
,
62 PropertyChangeListener listener
) {
63 propertyChangeSupport
.addPropertyChangeListener(propertyName
, listener
);
66 public void addPropertyChangeListener(PropertyChangeListener listener
) {
67 propertyChangeSupport
.addPropertyChangeListener(listener
);
70 public TaxonNameBase
getBaseName() {
74 public void setBaseName(TaxonNameBase baseName
) {
75 this.baseName
= baseName
;
78 public TaxonNameBase
getRelatedName() {
82 public void setRelatedName(TaxonNameBase relatedName
) {
83 this.relatedName
= relatedName
;
84 firePropertyChange(RELATEDNAME
, null, relatedName
);
87 public TaxonNameBase
getFromName() {
91 public void setFromName(TaxonNameBase fromName
) {
92 this.fromName
= fromName
;
93 logger
.warn("Setting from name: " + CdmUtil
.getDisplayName(fromName
));
96 public TaxonNameBase
getToName() {
100 public void setToName(TaxonNameBase toName
) {
101 this.toName
= toName
;
102 logger
.warn("Setting to name: " + CdmUtil
.getDisplayName(toName
));
105 public NameRelationshipType
getType() {
109 public void setType(NameRelationshipType type
) {
111 firePropertyChange(RELATIONTYPE
, null, type
);
114 public void setRelation(NameRelationship nameRelationship
) {
115 this.nameRelationship
= nameRelationship
;
118 public NameRelationship
getRelation() {
119 return nameRelationship
;
122 public void setNameRelationsList(List
<NameRelationship
> nameRelationsList
) {
123 this.nameRelationsList
= nameRelationsList
;
126 public List
<NameRelationship
> getNameRelationsList() {
127 return nameRelationsList
;