1) Re-arranged packages:
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / view / propertysheetsupport / namerelationswizard / NameRelationWizardModel.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.view.propertysheetsupport.namerelationswizard;
11
12 import java.beans.PropertyChangeListener;
13 import java.beans.PropertyChangeSupport;
14 import java.util.List;
15
16 import org.apache.log4j.Logger;
17
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;
22
23 /**
24 * @author p.ciardelli
25 * @created 05.06.2008
26 * @version 1.0
27 */
28 public class NameRelationWizardModel {
29 private static final Logger logger = Logger
30 .getLogger(NameRelationWizardModel.class);
31
32 protected static final String RELATEDNAME = "relatedname";
33 protected static final String RELATIONTYPE = "relationtype";
34
35 private TaxonNameBase baseName;
36 private TaxonNameBase relatedName;
37
38 private TaxonNameBase fromName;
39 private TaxonNameBase toName;
40 private NameRelationshipType type;
41
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;
46
47 private PropertyChangeSupport propertyChangeSupport;
48
49
50 public NameRelationWizardModel(TaxonNameBase baseName) {
51 this.baseName = baseName;
52 this.propertyChangeSupport = new PropertyChangeSupport(this);
53 }
54
55 private void firePropertyChange(String propertyName, Object oldValue,
56 Object newValue) {
57 propertyChangeSupport.firePropertyChange(propertyName, oldValue,
58 newValue);
59 }
60
61 public void addPropertyChangeListener(String propertyName,
62 PropertyChangeListener listener) {
63 propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
64 }
65
66 public void addPropertyChangeListener(PropertyChangeListener listener) {
67 propertyChangeSupport.addPropertyChangeListener(listener);
68 }
69
70 public TaxonNameBase getBaseName() {
71 return baseName;
72 }
73
74 public void setBaseName(TaxonNameBase baseName) {
75 this.baseName = baseName;
76 }
77
78 public TaxonNameBase getRelatedName() {
79 return relatedName;
80 }
81
82 public void setRelatedName(TaxonNameBase relatedName) {
83 this.relatedName = relatedName;
84 firePropertyChange(RELATEDNAME, null, relatedName);
85 }
86
87 public TaxonNameBase getFromName() {
88 return fromName;
89 }
90
91 public void setFromName(TaxonNameBase fromName) {
92 this.fromName = fromName;
93 logger.warn("Setting from name: " + CdmUtil.getDisplayName(fromName));
94 }
95
96 public TaxonNameBase getToName() {
97 return toName;
98 }
99
100 public void setToName(TaxonNameBase toName) {
101 this.toName = toName;
102 logger.warn("Setting to name: " + CdmUtil.getDisplayName(toName));
103 }
104
105 public NameRelationshipType getType() {
106 return type;
107 }
108
109 public void setType(NameRelationshipType type) {
110 this.type = type;
111 firePropertyChange(RELATIONTYPE, null, type);
112 }
113
114 public void setRelation(NameRelationship nameRelationship) {
115 this.nameRelationship = nameRelationship;
116 }
117
118 public NameRelationship getRelation() {
119 return nameRelationship;
120 }
121
122 public void setNameRelationsList(List<NameRelationship> nameRelationsList) {
123 this.nameRelationsList = nameRelationsList;
124 }
125
126 public List<NameRelationship> getNameRelationsList() {
127 return nameRelationsList;
128 }
129
130 }