001: /*
002: * $Id: Event.java 521 2005-09-15 07:11:37Z hengels $
003: * (c) Copyright 2004 con:cern development team.
004: *
005: * This file is part of con:cern (http://concern.sf.net).
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 org.concern.model.parser.ParseException;
017:
018: /**
019: * @author hengels
020: */
021: public class Event extends Element implements Implementable,
022: Interactable {
023: String implementation;
024: String postcondition;
025: boolean user;
026:
027: private transient SimpleNegatedFormVisitor simpleNegatedFormVisitor = new SimpleNegatedFormVisitor();
028: private Interaction interaction;
029:
030: public Event(String name) {
031: super (name);
032: }
033:
034: public Event(String name, String implementation) {
035: super (name);
036: this .implementation = implementation;
037: }
038:
039: public Event() {
040: super (null);
041: }
042:
043: public String getImplementation() {
044: return implementation;
045: }
046:
047: public void setImplementation(String implementation) {
048: Object old = this .implementation;
049: this .implementation = implementation;
050: changes.firePropertyChange("implementation", old,
051: implementation);
052: }
053:
054: public String getPostcondition() {
055: return postcondition;
056: }
057:
058: public void setPostcondition(String postcondition) {
059: try {
060: postcondition = getSimpleNegatedFormVisitor()
061: .transformCondition(postcondition);
062: } catch (ParseException e) {
063: throw new RuntimeException(e);
064: }
065: Object old = this .postcondition;
066: this .postcondition = postcondition;
067: changes.firePropertyChange("postcondition", old, postcondition);
068: }
069:
070: public Interaction getInteraction() {
071: return interaction;
072: }
073:
074: public void setInteraction(Interaction interaction) {
075: Object old = this .interaction;
076: this .interaction = interaction;
077: changes.firePropertyChange("interaction", old, interaction);
078: }
079:
080: public boolean isUser() {
081: return user;
082: }
083:
084: public void setUser(boolean user) {
085: boolean old = this .user;
086: this .user = user;
087: changes.firePropertyChange("user", old, user);
088: }
089:
090: private SimpleNegatedFormVisitor getSimpleNegatedFormVisitor() {
091: if (simpleNegatedFormVisitor == null)
092: simpleNegatedFormVisitor = new SimpleNegatedFormVisitor();
093: return simpleNegatedFormVisitor;
094: }
095:
096: public Object clone() {
097: Interactable interactable = (Interactable) super .clone();
098: if (interaction != null)
099: interactable.setInteraction((Interaction) getInteraction()
100: .clone());
101: return interactable;
102: }
103: }
|