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.interaction;
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.interaction.sql.InteractionStep;
033:
034: public class Step extends DefaultGraphCell implements
035: InteractionElement {
036:
037: private InteractionStep data;
038: private Interaction owner;
039: private Collection inputs = new ArrayList();
040: private Collection outputs = new ArrayList();
041:
042: public Step(Interaction owner, InteractionStep data) {
043: super (data.getName());
044: this .data = data;
045: this .owner = owner;
046: }
047:
048: // public Step(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: "Step name shall not be blank");
057: return;
058: }
059:
060: if (!InteractionElementPropertiesDialog.compareStrings(newName,
061: data.getName())
062: && owner.checkDuplicateStepName(newName)) {
063:
064: JOptionPane.showMessageDialog(owner.getApplet(),
065: "Duplicate step 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 getGuard() {
085: return data.getGuardCode();
086: }
087:
088: public String getName() {
089: return data.getName();
090: }
091:
092: public Interaction getInteraction() {
093: return owner;
094: }
095:
096: public void setAction(String action) {
097: data.setActionCode(action);
098: }
099:
100: public void setDescription(String description) {
101: data.setDescription(description);
102: }
103:
104: public void setGuard(String guard) {
105: data.setGuardCode(guard);
106: }
107:
108: public void setName(String name) {
109: data.setName(name);
110: super .setUserObject(name);
111: }
112:
113: public Collection getInputs() {
114: return inputs;
115: }
116:
117: public Collection getOutputs() {
118: return outputs;
119: }
120:
121: private boolean isValid = true;
122:
123: void invalidate() {
124: isValid = false;
125: }
126:
127: public boolean isValid() {
128: return isValid;
129: }
130:
131: public InteractionStep getData() {
132: return data;
133: }
134:
135: }
|