Changeset 2563 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
- Timestamp:
- 03.12.2009 19:02:25 (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
r2512 r2563 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.beans.PropertyChangeListener; 7 import java.beans.PropertyChangeSupport; 6 8 import java.lang.reflect.Constructor; 7 9 import java.lang.reflect.Method; … … 16 18 17 19 public abstract class RelationEditor extends ExtendedDialog { 20 /** the property name for the current relation. 21 * @see #setRelation(Relation) 22 * @see #getRelation() 23 */ 24 static public final String RELATION_PROP = RelationEditor.class.getName() + ".relation"; 25 26 /** the property name for the current relation snapshot 27 * @see #getRelationSnapshot() 28 */ 29 static public final String RELATION_SNAPSHOT_PROP = RelationEditor.class.getName() + ".relationSnapshot"; 18 30 19 31 /** the list of registered relation editor classes */ … … 62 74 * then an instance of that class will be used. 63 75 * 76 * @param layer the data layer the relation is a member of 64 77 * @param r the relation to be edited 78 * @param selectedMembers a collection of relation members which shall be selected when the 79 * editor is first launched 65 80 * @return an instance of RelationEditor suitable for editing that kind of relation 66 81 */ … … 139 154 */ 140 155 protected void setRelation(Relation relation) { 141 this.relationSnapshot = (relation == null) ? null : new Relation(relation); 156 setRelationSnapshot((relation == null) ? null : new Relation(relation)); 157 Relation oldValue = this.relation; 142 158 this.relation = relation; 159 if (this.relation != oldValue) { 160 support.firePropertyChange(RELATION_PROP, oldValue, this.relation); 161 } 143 162 updateTitle(); 144 163 } … … 164 183 } 165 184 185 protected void setRelationSnapshot(Relation snapshot) { 186 Relation oldValue = relationSnapshot; 187 relationSnapshot = snapshot; 188 if (relationSnapshot != oldValue) { 189 support.firePropertyChange(RELATION_SNAPSHOT_PROP, oldValue, relationSnapshot); 190 } 191 } 192 166 193 /** 167 194 * Replies true if the currently edited relation has been changed elsewhere. … … 175 202 return ! relation.hasEqualSemanticAttributes(relationSnapshot); 176 203 } 204 205 206 /* ----------------------------------------------------------------------- */ 207 /* property change support */ 208 /* ----------------------------------------------------------------------- */ 209 final private PropertyChangeSupport support = new PropertyChangeSupport(this); 210 211 @Override 212 public void addPropertyChangeListener(PropertyChangeListener listener) { 213 this.support.addPropertyChangeListener(listener); 214 } 215 216 @Override 217 public void removePropertyChangeListener(PropertyChangeListener listener) { 218 this.support.removePropertyChangeListener(listener); 219 } 177 220 }
Note: See TracChangeset
for help on using the changeset viewer.
