1 10 11 package org.enhydra.jawe.graph; 12 13 import org.enhydra.jawe.*; 14 import org.enhydra.jawe.xml.*; 15 import org.enhydra.jawe.xml.panels.*; 16 import org.enhydra.jawe.xml.elements.Participants; 17 18 import org.jgraph.graph.*; 19 20 import java.util.*; 21 import java.awt.*; 22 import javax.swing.*; 23 import org.enhydra.jawe.PackageEditor; 24 25 29 public class Activity extends DefaultGraphCell implements WorkflowElement, Linkable { 30 31 protected int activityVisualType=JaWEConstants.TYPE_OF_ELEMENT_NORMAL; 32 33 34 protected String connectionErrorMsg=null; 35 36 39 public Activity() { 40 this(null); 41 } 42 43 47 public Activity(Object userObject) { 48 super(userObject); 49 DefaultPort port = new DefaultPort("Center"); 52 add(port); 53 } 54 55 public ProcessEditor getImplementationEditor () { 56 return null; 57 } 58 59 public AbstractEditor getParentEditor () { 60 return null; 61 } 62 63 66 public DefaultPort getPort () { 67 for (Enumeration e=children();e.hasMoreElements();) { 68 Object child=e.nextElement(); 69 if (child instanceof DefaultPort) { 70 return (DefaultPort)child; 71 } 72 } 73 return null; 74 } 75 76 82 public String getConnectionErrorMessage() { 83 return connectionErrorMsg; 84 } 85 86 91 public boolean acceptsSource() { 92 if (activityVisualType==JaWEConstants.TYPE_OF_ELEMENT_NORMAL 93 || activityVisualType==JaWEConstants.TYPE_OF_ELEMENT_STARTING) { 94 return true; 95 } 96 else { 97 return false; 98 } 99 } 100 101 106 public boolean acceptsTarget() { 107 if (activityVisualType==JaWEConstants.TYPE_OF_ELEMENT_NORMAL 108 || activityVisualType==JaWEConstants.TYPE_OF_ELEMENT_ENDING) { 109 return true; 110 } 111 else { 112 return false; 113 } 114 } 115 116 119 public void showPropertyDialog(Window parentWindow,AbstractGraph graph){ 120 XMLElementDialog xmlED=((ProcessEditor)graph.getEditor()). 121 getElementEditingDialog(); 122 123 recreatePropertyObjectTransitions(); 124 XMLTabbedPanel tp=(XMLTabbedPanel)getPropertyObject().getPanel(); 125 if (xmlED.isShowing()) { 126 xmlED.switchPanel(tp, 127 ResourceManager.getLanguageDependentString("DialogActivityProperties")+ 128 " - "+userObject.toString(),true); 129 } else { 130 xmlED.setTitle(ResourceManager.getLanguageDependentString("DialogActivityProperties")+ 131 " - "+userObject.toString()); 132 xmlED.editXMLElement(tp,true,false); 133 } 134 try { 135 tp.setSelectedTab(org.enhydra.jawe.xml.elements.Activity.getSelectedTab()); 136 } catch (Exception ex) { 137 tp.setSelectedTab(org.enhydra.jawe.xml.elements.Activity.getSelectedTab()-1); 138 } 139 } 140 141 144 public XMLElement getPropertyObject () { 145 if (userObject instanceof XMLElement){ return (XMLElement)userObject; 147 } 148 else return null; } 151 152 155 public XMLElement get (String what) { 156 return ((XMLComplexElement)getPropertyObject()).get(what); 158 } 159 160 164 public void set (String what,Object value) { 165 ((XMLComplexElement)getPropertyObject()).set(what,value); 166 } 167 168 171 public String getTooltip () { 172 try { 173 return ((org.enhydra.jawe.xml.elements.Activity) 174 userObject).getTooltip(); 175 } catch (Exception e) { 176 return null; 177 } 178 } 179 180 183 public String toString () { 184 return userObject.toString(); 185 } 186 187 198 public Object clone() { 199 Activity c = (Activity)super.clone(); 200 c.setUserObject(c.userObject); 201 return c; 202 } 203 207 protected Object cloneUserObject() { 208 return ((org.enhydra.jawe.xml.elements.Activity) 209 userObject).clone(); 210 } 211 212 213 public boolean hasAnyPrecondition () { 214 Set inL=getIncomingTransitions(); 215 Iterator it=inL.iterator(); 216 while (it.hasNext()) { 217 if (((org.enhydra.jawe.xml.elements.Transition) 218 ((Transition)it.next()).getPropertyObject()).hasCondition()) { 219 return true; 220 } 221 } 222 return false; 223 } 224 225 public boolean hasAnyPostcondition () { 226 Set outL=getOutgoingTransitions(); 227 Iterator it=outL.iterator(); 228 while (it.hasNext()) { 229 if (((org.enhydra.jawe.xml.elements.Transition) 230 ((Transition)it.next()).getPropertyObject()).hasCondition()) { 231 return true; 232 } 233 } 234 return false; 235 } 236 237 241 public Set getIncomingTransitions () { 242 Set inputTransitions=new HashSet(); 243 for( Iterator i = getPort().edges(); i.hasNext();){ 244 Transition l = (Transition)i.next(); 245 Object target = ((DefaultPort)(l.getTarget())).getParent(); 246 if(this==target) { 247 inputTransitions.add(l); 248 } 249 } 250 return inputTransitions; 251 } 252 253 257 public Set getOutgoingTransitions () { 258 Set outputTransitions=new HashSet(); 259 for( Iterator i = getPort().edges(); i.hasNext();){ 260 Transition l = (Transition)i.next(); 261 Object source = ((DefaultPort)(l.getSource())).getParent(); 262 if(this==source) { 263 outputTransitions.add(l); 264 } 265 } 266 return outputTransitions; 267 } 268 269 public Set getNonExceptionalOutgoingTransitions () { 270 Set outputTransitions=new HashSet(); 271 for( Iterator i = getPort().edges(); i.hasNext();){ 272 Transition l = (Transition)i.next(); 273 Object source = ((DefaultPort)(l.getSource())).getParent(); 274 if(this==source) { 275 org.enhydra.jawe.xml.elements.Transition tuo= 276 (org.enhydra.jawe.xml.elements.Transition)l.getPropertyObject(); 277 org.enhydra.jawe.xml.elements.Condition condition = 278 (org.enhydra.jawe.xml.elements.Condition)tuo.get("Condition"); 279 String condType=condition.get("Type").toValue().toString(); 280 if (!(condType.equals(org.enhydra.jawe.xml.elements.Condition.CONDITION_TYPE_EXCEPTION) || 281 condType.equals(org.enhydra.jawe.xml.elements.Condition.CONDITION_TYPE_DEFAULTEXCEPTION))) { 282 outputTransitions.add(l); 283 } 284 } 285 } 286 return outputTransitions; 287 } 288 289 public void recreatePropertyObjectTransitions () { 290 try { 291 org.enhydra.jawe.xml.elements.Activity po= 292 (org.enhydra.jawe.xml.elements.Activity)userObject; 293 294 Iterator iter = getOutgoingTransitions().iterator(); 295 Set trans=new HashSet(); 296 while (iter.hasNext()) { 297 Transition tr = (Transition)iter.next(); 298 org.enhydra.jawe.xml.elements.Transition t= 299 (org.enhydra.jawe.xml.elements.Transition)tr.getUserObject(); 300 if (t!=null && t.getFrom()!=null && t.getTo()!=null) { 301 trans.add(t); 302 } 303 } 304 po.setOutgoingTransitions(trans); 305 } catch (Exception ex) {} } 307 } 308 | Popular Tags |