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.process;
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.process.sql.ProcessTask;
033:
034: public class Task extends DefaultGraphCell implements ProcessElement {
035:
036: private ProcessTask data;
037: private Process owner;
038: private Collection inputs = new ArrayList();
039: private Collection outputs = new ArrayList();
040:
041: public Task(Process owner, ProcessTask data) {
042: super (data.getName());
043: this .data = data;
044: this .owner = owner;
045: }
046:
047: // public Task(Object userObject, AttributeMap storageMap) {
048: // super(userObject, storageMap);
049: // }
050:
051: public void setUserObject(Object userObject) {
052: String newName = userObject.toString();
053: if (newName == null || newName.trim().length() == 0) {
054: JOptionPane.showMessageDialog(owner.getApplet(),
055: "Task name shall not be blank");
056: return;
057: }
058:
059: if (!ProcessElementPropertiesDialog.compareStrings(newName,
060: data.getName())
061: && owner.checkDuplicateTaskName(newName)) {
062:
063: JOptionPane.showMessageDialog(owner.getApplet(),
064: "Duplicate task name");
065: return;
066: }
067:
068: setName(newName);
069: }
070:
071: public Object getUserObject() {
072: return getName();
073: }
074:
075: public String getAction() {
076: return data.getActionCode();
077: }
078:
079: public String getSummary() {
080: return data.getSummary();
081: }
082:
083: public String getGuard() {
084: return data.getGuardCode();
085: }
086:
087: public String getName() {
088: return data.getName();
089: }
090:
091: public Process getProcess() {
092: return owner;
093: }
094:
095: public void setAction(String action) {
096: data.setActionCode(action);
097: }
098:
099: public void setSummary(String summary) {
100: data.setSummary(summary);
101: }
102:
103: public void setGuard(String guard) {
104: data.setGuardCode(guard);
105: }
106:
107: public void setName(String name) {
108: data.setName(name);
109: super .setUserObject(name);
110: }
111:
112: public Collection getInputs() {
113: return inputs;
114: }
115:
116: public Collection getOutputs() {
117: return outputs;
118: }
119:
120: private boolean isValid = true;
121:
122: void invalidate() {
123: isValid = false;
124: }
125:
126: public boolean isValid() {
127: return isValid;
128: }
129:
130: public ProcessTask getData() {
131: return data;
132: }
133:
134: }
|