001: /*
002: * argun 1.0
003: * Web 2.0 delivery framework
004: * Copyright (C) 2007 Hammurapi Group
005: *
006: * This program is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * URL: http://www.hammurapi.biz
021: * e-Mail: support@hammurapi.biz
022: */
023: package biz.hammurapi.web.statemachine;
024:
025: import org.jgraph.graph.DefaultEdge;
026: import org.jgraph.graph.DefaultPort;
027:
028: import biz.hammurapi.web.statemachine.sql.SmTransition;
029:
030: public class Transition extends DefaultEdge implements
031: StateMachineElement {
032:
033: private SmTransition data;
034: private StateMachine owner;
035:
036: public Transition(StateMachine owner, SmTransition data) {
037: super (data.getName());
038: this .data = data;
039: this .owner = owner;
040: }
041:
042: private boolean isValid = true;
043:
044: void invalidate() {
045: isValid = false;
046: }
047:
048: public boolean isValid() {
049: return isValid;
050: }
051:
052: public void setUserObject(Object userObject) {
053: setName(userObject.toString());
054: }
055:
056: public Object getUserObject() {
057: return getName();
058: }
059:
060: public String getDescription() {
061: return data.getDescription();
062: }
063:
064: public String getGuard() {
065: return data.getConditionCode();
066: }
067:
068: public String getName() {
069: return data.getName();
070: }
071:
072: public StateMachine getStateMachine() {
073: return owner;
074: }
075:
076: public void setDescription(String description) {
077: data.setDescription(description);
078: }
079:
080: public void setGuard(String guard) {
081: data.setConditionCode(guard);
082: }
083:
084: public void setName(String name) {
085: data.setName(name);
086: super .setUserObject(name);
087: }
088:
089: public State getSourceState() {
090: return (State) (getSource() == null ? null
091: : ((DefaultPort) getSource()).getParent());
092: }
093:
094: public State getTargetState() {
095: return (State) (getTarget() == null ? null
096: : ((DefaultPort) getTarget()).getParent());
097: }
098:
099: public SmTransition getData() {
100: return data;
101: }
102: }
|