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 java.util.ArrayList;
026: import java.util.Collection;
027:
028: import javax.swing.JOptionPane;
029:
030: import org.jgraph.graph.DefaultGraphCell;
031:
032: import biz.hammurapi.web.statemachine.sql.SmState;
033:
034: public class State extends DefaultGraphCell implements
035: StateMachineElement {
036:
037: private SmState data;
038: private StateMachine owner;
039: private Collection inputs = new ArrayList();
040: private Collection outputs = new ArrayList();
041:
042: public State(StateMachine owner, SmState data) {
043: super (data.getName());
044: this .data = data;
045: this .owner = owner;
046: }
047:
048: // public Task(Object userObject, AttributeMap storageMap) {
049: // super(userObject, storageMap);
050: // }
051:
052: public void setUserObject(Object userObject) {
053: String newName = userObject.toString();
054: if (newName == null || newName.trim().length() == 0) {
055: JOptionPane.showMessageDialog(owner.getApplet(),
056: "Task name shall not be blank");
057: return;
058: }
059:
060: if (!StatePropertiesDialog.compareStrings(newName, data
061: .getName())
062: && owner.checkDuplicateStateName(newName)) {
063:
064: JOptionPane.showMessageDialog(owner.getApplet(),
065: "Duplicate task name");
066: return;
067: }
068:
069: setName(newName);
070: }
071:
072: public Object getUserObject() {
073: return getName();
074: }
075:
076: public String getAction() {
077: return data.getActionCode();
078: }
079:
080: public String getDescription() {
081: return data.getDescription();
082: }
083:
084: public String getName() {
085: return data.getName();
086: }
087:
088: public StateMachine getStateMachine() {
089: return owner;
090: }
091:
092: public void setAction(String action) {
093: data.setActionCode(action);
094: }
095:
096: public void setDescription(String description) {
097: data.setDescription(description);
098: }
099:
100: public void setName(String name) {
101: data.setName(name);
102: super .setUserObject(name);
103: }
104:
105: public Collection getInputs() {
106: return inputs;
107: }
108:
109: public Collection getOutputs() {
110: return outputs;
111: }
112:
113: private boolean isValid = true;
114:
115: void invalidate() {
116: isValid = false;
117: }
118:
119: public boolean isValid() {
120: return isValid;
121: }
122:
123: public SmState getData() {
124: return data;
125: }
126:
127: }
|