001 // License: GPL. For details, see LICENSE file.
002 package org.openstreetmap.josm.gui.io;
003
004 import java.util.Observable;
005
006 /**
007 * ChangesetCommentModel is an observable model for the changeset comment edited
008 * in the {@link UploadDialog}.
009 *
010 */
011 public class ChangesetCommentModel extends Observable {
012 private String comment = "";
013
014 /**
015 * Sets the current changeset comment and notifies observers if the comment
016 * has changed.
017 *
018 * @param comment the new upload comment. Empty string assumed if null.
019 */
020 public void setComment(String comment) {
021 String oldValue = this.comment;
022 this.comment = comment == null ? "" : comment;
023 if (!oldValue.equals(this.comment)) {
024 setChanged();
025 notifyObservers(this.comment);
026 }
027 }
028
029 /**
030 * Replies the current changeset comment in this model.
031 *
032 * @return the current changeset comment in this model.
033 */
034 public String getComment() {
035 return comment == null ? "": comment;
036 }
037 }