001: /*
002: * $Id: Interaction.java 520 2005-09-14 08:18:37Z hengels $
003: * (c) Copyright 2004 con:cern development team.
004: *
005: * This file is part of con:cern (http://concern.org).
006: *
007: * con:cern is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU Lesser General Public License
009: * as published by the Free Software Foundation; either version 2.1
010: * of the License, or (at your option) any later version.
011: *
012: * Please see COPYING for the complete licence.
013: */
014: package org.concern.model;
015:
016: import java.beans.PropertyChangeSupport;
017: import java.beans.PropertyChangeListener;
018:
019: /**
020: * @author hengels
021: * @version $Revision: 520 $
022: */
023: public class Interaction implements Cloneable {
024: public static final int IN = 1;
025: public static final int OUT = 2;
026: public static final int BOTH = 3;
027:
028: int direction = BOTH;
029: String message;
030: String collaborator;
031: PropertyChangeSupport changes = new PropertyChangeSupport(this );
032:
033: public Interaction() {
034: }
035:
036: public Interaction(int direction, String message,
037: String collaboration) {
038: this .direction = direction;
039: this .message = message;
040: this .collaborator = collaboration;
041: }
042:
043: public int getDirection() {
044: return direction;
045: }
046:
047: public void setDirection(int direction) {
048: int old = this .direction;
049: this .direction = direction;
050: changes.firePropertyChange("direction", old, direction);
051: }
052:
053: public String getMessage() {
054: return message;
055: }
056:
057: public void setMessage(String message) {
058: Object old = this .message;
059: this .message = message;
060: changes.firePropertyChange("message", old, message);
061: }
062:
063: public String getCollaborator() {
064: return collaborator;
065: }
066:
067: public void setCollaborator(String collaborator) {
068: Object old = this .collaborator;
069: this .collaborator = collaborator;
070: changes.firePropertyChange("collaborator", old, collaborator);
071: }
072:
073: public void removePropertyChangeListener(
074: PropertyChangeListener listener) {
075: changes.removePropertyChangeListener(listener);
076: }
077:
078: public void removePropertyChangeListener(String propertyName,
079: PropertyChangeListener listener) {
080: changes.removePropertyChangeListener(propertyName, listener);
081: }
082:
083: public void addPropertyChangeListener(
084: PropertyChangeListener listener) {
085: changes.addPropertyChangeListener(listener);
086: }
087:
088: public void addPropertyChangeListener(String propertyName,
089: PropertyChangeListener listener) {
090: changes.addPropertyChangeListener(propertyName, listener);
091: }
092:
093: public PropertyChangeListener[] getPropertyChangeListeners() {
094: return changes.getPropertyChangeListeners();
095: }
096:
097: public PropertyChangeListener[] getPropertyChangeListeners(
098: String propertyName) {
099: return changes.getPropertyChangeListeners(propertyName);
100: }
101:
102: public String toString() {
103: return message;
104: }
105:
106: public Object clone() {
107: try {
108: return super .clone();
109: } catch (CloneNotSupportedException e) {
110: throw new RuntimeException(e);
111: }
112: }
113: }
|