1 10 11 package org.enhydra.jawe.xml.elements; 12 13 import org.enhydra.jawe.xml.*; 14 import org.enhydra.jawe.xml.panels.*; 15 16 import java.util.*; 17 import javax.swing.*; 18 import org.w3c.dom.*; 19 20 23 public class Activity extends XMLCollectionElement { 24 private XMLAttribute attrName=new XMLAttribute("Name"); 25 26 private Description refDescription=new Description(); private Limit refLimit=new Limit(); private XMLComplexChoice refType; private Performer refPerformer=new Performer(); private StartMode refStartMode=new StartMode(); private FinishMode refFinishMode=new FinishMode(); private Priority refPriority=new Priority(); private Deadlines refDeadlines=new Deadlines(this); private SimulationInformation refSimulationInformation=new SimulationInformation(); private Icon refIcon=new Icon(); private Documentation refDocumentation=new Documentation(); private TransitionRestrictions refTransitionRestrictions=new TransitionRestrictions(this); private ExtendedAttributes refExtendedAttributes=new ExtendedAttributes(this); 41 42 private Tools clonedTools; 43 44 45 private ExtendedAttributes clonedEAs; 46 47 48 private Deadlines clonedDs; 49 50 51 private XMLCollection clonedHP; 52 53 57 private transient TransitionRestriction helperTR; 58 59 private transient Join helperJoin; 60 61 private transient Split helperSplit; 62 63 private transient TransitionRefs helperTRefs; 64 65 private transient XMLCollection helperPostcondition; 67 68 private transient XMLElement helperElement; 69 70 private transient WorkflowProcess myWorkflow=null; 71 72 78 private String visuallySortedParticipantIDs=""; 79 80 86 private Set startDescriptions=new HashSet(); 87 93 private Set endDescriptions=new HashSet(); 94 95 100 private transient int XOffset=-1; 101 106 private transient int YOffset=-1; 107 111 private transient String participantID=""; 112 113 114 private transient Set outgoingTransitions=new HashSet(); 115 116 private static int selectedTab=0; 117 118 136 public Activity (Activities acts,WorkflowProcess myWorkflow,int type) { 137 super(acts); 138 this.myWorkflow=myWorkflow; 139 setType(type); 140 setDefaultTransitionRestriction(null); 141 refTransitionRestrictions.add(helperTR); 142 143 fillStructure(); 144 recreatePostcondition(); 145 } 146 147 private void setDefaultTransitionRestriction (TransitionRestriction tr) { 148 if (tr!=null) { 149 helperTR=tr; 150 } else { 151 helperTR=new TransitionRestriction(); 152 } 153 helperJoin=(Join)helperTR.get("Join"); 154 helperSplit=(Split)helperTR.get("Split"); 155 helperTRefs=(TransitionRefs)helperSplit.get("TransitionRefs"); 156 } 157 158 163 public WorkflowProcess getOwnerProcess () { 164 return myWorkflow; 165 } 166 167 public void fromXML (Node node) { 169 refTransitionRestrictions.clear(); 170 super.fromXML(node); 172 restoreDeadlines(node); 173 } 174 175 private void restoreDeadlines (Node node) { 176 if (node!=null) { 177 if (node.hasChildNodes()) { 178 String nameSpacePrefix=node.getPrefix(); 179 if (nameSpacePrefix!=null) { 180 nameSpacePrefix+=":"; 181 } else { 182 nameSpacePrefix=""; 183 } 184 NodeList children = node.getChildNodes(); 186 for (int i = 0; i < children.getLength(); ++i) { 187 Node child = (Node) children.item(i); 188 if (child.getNodeName().equals(nameSpacePrefix+"Deadline")) { 189 XMLElement newOne = refDeadlines.generateNewElement(); 190 refDeadlines.decrementID(); 191 newOne.fromXML(child); 192 refDeadlines.add(newOne); 193 } 194 } 195 } 196 } 197 } 198 199 206 protected void afterImporting () { 207 if (refType.getChoosen() instanceof Route) { 209 helperElement=(XMLElement)refType.getChoices()[0]; 210 } else if (refType.getChoosen() instanceof BlockActivity) { 211 helperElement=(XMLElement)refType.getChoices()[2]; 212 } else { 213 Implementation i=(Implementation)refType.getChoices()[1]; 214 XMLComplexChoice t=(XMLComplexChoice)i.get("Type"); 215 XMLElement changeTo=(XMLElement)t.getChoosen(); 216 if (changeTo instanceof No) { 218 changeTo=(XMLElement)t.getChoices()[1]; 219 t.setValue(changeTo); 220 } 221 helperElement=changeTo; 222 } 223 Object newTR=refTransitionRestrictions.get(0); 225 226 setDefaultTransitionRestriction((TransitionRestriction)newTR); 227 int size=refTransitionRestrictions.size(); 233 if (size>1) { 234 for (int i=1; i<size; i++) { 235 TransitionRestriction tr=(TransitionRestriction) 236 refTransitionRestrictions.get(i); 237 Split s=(Split)tr.get("Split"); 238 TransitionRefs trfs=(TransitionRefs)s.get("TransitionRefs"); 239 if (trfs.size()>0 && helperSplit.get("Type").toValue().toString().length()==0) { 240 helperSplit.set("Type",s.get("Type").toString()); 241 } 242 helperTRefs.toCollection().addAll(trfs.toCollection()); 243 } 244 } 245 247 refTransitionRestrictions.clear(); 249 refTransitionRestrictions.add(helperTR); 250 251 Set easToRemove=new HashSet(); 254 if (myWorkflow.getPackage().isMadeByJaWE()) { 255 Iterator it=refExtendedAttributes.toCollection().iterator(); 256 String nm=""; 257 String val=""; 258 while (it.hasNext()) { 259 ExtendedAttribute ea=(ExtendedAttribute)it.next(); 260 nm=ea.get("Name").toValue().toString(); 261 val=ea.get("Value").toValue().toString(); 262 if (nm.equals("XOffset") && XOffset==-1) { 263 try { 264 XOffset=Integer.parseInt(val); 265 } catch (Exception ex) { 266 XOffset=0; 267 } 268 easToRemove.add(ea); 269 } 270 if (nm.equals("YOffset") && YOffset==-1) { 271 try { 272 YOffset=Integer.parseInt(val); 273 } catch (Exception ex) { 274 YOffset=0; 275 } 276 easToRemove.add(ea); 277 } 278 if (nm.equals("ParticipantID") && participantID.length()==0) { 279 participantID=val; 280 easToRemove.add(ea); 281 } 282 if (nm.equals("ParticipantVisualOrder") && visuallySortedParticipantIDs.length()==0) { 283 visuallySortedParticipantIDs=val; 284 easToRemove.add(ea); 285 } 286 if (nm.equals("StartOfBlock")) { 287 if (XMLUtil.howManyStringsWithinString(val,";")==4) { 288 startDescriptions.add(val); 289 easToRemove.add(ea); 290 } 291 } 292 if (nm.equals("EndOfBlock")) { 293 if (XMLUtil.howManyStringsWithinString(val,";")==4) { 294 endDescriptions.add(val); 295 easToRemove.add(ea); 296 } 297 } 298 } 299 } 300 refExtendedAttributes.toCollection().removeAll(easToRemove); 303 304 Participants ps=(Participants)myWorkflow.get("Participants"); 306 Participant perf=ps.getParticipant(refPerformer.toValue().toString()); 307 if (perf!=null) { 308 refPerformer.setValue(perf); 309 } 310 int type=getType(); 311 if (type==2) { 313 getTools().afterImporting(); 314 } 315 if (type==3) { 317 getSubflow().afterImporting(); 318 } 319 refStartMode.afterImporting(); 320 refFinishMode.afterImporting(); 321 322 helperPostcondition=null; 325 recreatePostcondition(); 326 } 327 328 335 public Set getStartDescriptions () { 336 return startDescriptions; 337 } 338 339 345 public void setStartDescriptions (Set sd) { 346 startDescriptions=sd; 347 } 348 349 356 public Set getEndDescriptions () { 357 return endDescriptions; 358 } 359 360 366 public void setEndDescriptions (Set eds) { 367 endDescriptions=eds; 368 } 369 370 381 public String getVisuallySortedParticipantIDs () { 382 return visuallySortedParticipantIDs; 383 } 384 385 391 public void setVisuallySortedParticipantIDs (String vsPID) { 392 visuallySortedParticipantIDs=vsPID; 393 } 394 395 401 public int getXOffset() { 402 return XOffset; 403 } 404 405 411 public void setXOffset(int xOffs) { 412 XOffset=xOffs; 413 } 414 415 421 public int getYOffset() { 422 return YOffset; 423 } 424 425 431 public void setYOffset(int yOffs) { 432 YOffset=yOffs; 433 } 434 435 439 public String getParticipantID () { 440 return participantID; 441 } 442 443 447 public void setParticipantID (String pID) { 448 participantID=pID; 449 } 450 451 public void setOutgoingTransitions (Set ts) { 452 outgoingTransitions=ts; 453 } 454 455 469 public int getType () { 470 return getType(helperElement); 471 } 472 473 480 public void setJoinType (String type) { 481 helperJoin.set("Type",type); 482 } 483 484 489 public Join getJoin () { 490 return helperJoin; 491 } 492 493 500 public void setSplitType (String type) { 501 helperSplit.set("Type",type); 502 } 503 504 509 public Split getSplit () { 510 return helperSplit; 511 } 512 513 public Tools getTools () { 514 if (getType()==2) { 515 return (Tools)helperElement; 516 } 517 return null; 518 } 519 520 public SubFlow getSubflow () { 521 if (getType()==3) { 522 return (SubFlow)helperElement; 523 } 524 return null; 525 } 526 527 public BlockActivity getBlockActivity () { 528 if (getType()==4) { 529 return (BlockActivity)helperElement; 530 } 531 return null; 532 } 533 534 535 private int getType (XMLElement helper) { 536 if (helper instanceof Route) return 0; 537 if (helper instanceof No) return 1; 538 if (helper instanceof Tools) return 2; 539 if (helper instanceof SubFlow) return 3; 540 return 4; 542 } 543 544 546 private void setType (int type) { 547 Implementation i=new Implementation(this); 548 Route r=new Route(); 549 BlockActivity ba=new BlockActivity(); 550 551 refType=new XMLComplexChoice("Type",new XMLElement[] { 552 r,i,ba},1,false,false,false,true,true); 553 554 if (type==0) { 555 helperElement=r; 556 refType.setValue(r); 557 } else if (type==4) { 558 helperElement=ba; 559 refType.setValue(ba); 560 } else { 561 XMLComplexChoice t=(XMLComplexChoice)i.get("Type"); 564 helperElement=(XMLElement)t.getChoices()[type-1]; 565 t.setValue(helperElement); 566 refType.setValue(i); 567 } 568 569 if (type<1 || type>2) { 570 refPerformer.setValue(""); 571 } 572 } 573 574 578 protected void fillStructure () { 579 super.fillStructure(); 580 complexStructure.add(attrName); 581 attributes.add(attrName); 582 complexStructure.add(refDescription); 583 complexStructure.add(refLimit); 584 refType.setRequired(true); 585 complexStructure.add(refType); 586 refPerformer.setReadOnly(true); 587 complexStructure.add(refPerformer); 588 complexStructure.add(refStartMode); 589 complexStructure.add(refFinishMode); 590 complexStructure.add(refPriority); 591 complexStructure.add(refDeadlines); 592 complexStructure.add(refSimulationInformation); 593 complexStructure.add(refIcon); 594 complexStructure.add(refDocumentation); 595 complexStructure.add(refTransitionRestrictions); 596 complexStructure.add(refExtendedAttributes); 597 } 598 599 606 public XMLPanel getPanel () { 607 recreatePostcondition (); 608 XMLAttribute tp=new XMLAttribute("Type"); 610 tp.setValue(helperElement.toLabel()); 611 tp.setReadOnly(true); 612 613 clonedDs=(Deadlines)refDeadlines.clone(); 614 Object perf=refPerformer.toValue(); 615 int type=getType(); 616 617 if (type==1 || type==2) { 618 if (perf instanceof Participant) { 619 refPerformer.setReadOnly(true); 620 } else { 621 refPerformer.setReadOnly(false); 622 } 623 } 624 XMLPanel p1=new XMLGroupPanel(this, 625 new XMLElement[] { 626 attrId, 627 attrName, 628 tp, 629 refPerformer, 630 refStartMode, 631 refFinishMode, 632 clonedDs, 633 refPriority, 634 refLimit, 635 refIcon, 636 refDocumentation, 637 refDescription 638 },XMLUtil.getLanguageDependentString("GeneralKey")); 639 640 641 XMLPanel p2; 642 if (type==2) { 643 clonedTools=(Tools)helperElement.clone(); 644 p2=clonedTools.getPanel(); 645 } else { 646 p2=helperElement.getPanel(); 647 } 648 649 Transitions ts=(Transitions)getCollection().getOwner().get("Transitions"); 650 XMLPanel p3; 651 boolean jChanged=false; 652 if (ts.getTransitions(getID(),1).size()>1) { 653 if (helperJoin.get("Type").toString().trim().length()==0) { 654 helperJoin.set("Type",XMLUtil.getLanguageDependentString("XORKey")); 655 jChanged=true; 656 } 657 XMLPanel hjp=helperJoin.getPanel(); 658 p3=new XMLGroupPanel(this,new Object [] {hjp}, 659 XMLUtil.getLanguageDependentString("PreconditionKey")); 660 if (hjp instanceof XMLComboPanel) { 661 ((XMLComboPanel)hjp).getComboBox().removeItemAt(0); 662 } 663 } else { 664 if (helperJoin.get("Type").toString().trim().length()>0) { 665 helperJoin.set("Type",""); 666 jChanged=true; 667 } 668 helperJoin.setReadOnly(true); 669 p3=new XMLGroupPanel(this,new Object [] {helperJoin.getPanel()}, 670 XMLUtil.getLanguageDependentString("PreconditionKey")); 671 if (!isReadOnly) { 672 helperJoin.setReadOnly(false); 673 } 674 } 675 676 clonedHP=createPostcondition(); 677 clonedHP.toCollection().addAll(helperPostcondition.toCollection()); 678 XMLPanel p4; 679 boolean sChanged=false; 680 if (helperPostcondition.size()>1) { 681 if (helperSplit.get("Type").toString().trim().length()==0) { 682 helperSplit.set("Type",XMLUtil.getLanguageDependentString("XORKey")); 683 sChanged=true; 684 } 685 XMLPanel hsp=helperSplit.getPanel(); 686 if (hsp instanceof XMLComboPanel) { 687 ((XMLComboPanel)hsp).getComboBox().removeItemAt(0); 688 } 689 p4=new XMLGroupPanel(this, 690 new XMLPanel[] { 691 hsp, 692 clonedHP.getPanel() 693 },XMLUtil.getLanguageDependentString("PostconditionKey")); 694 } else { 695 if (helperSplit.get("Type").toString().trim().length()>0) { 696 helperSplit.set("Type",""); 697 sChanged=true; 698 } 699 helperSplit.setReadOnly(true); 700 p4=new XMLGroupPanel(this, 701 new XMLPanel[] { 702 helperSplit.getPanel(), 703 clonedHP.getPanel() 704 },XMLUtil.getLanguageDependentString("PostconditionKey")); 705 if (!isReadOnly) { 706 helperSplit.setReadOnly(false); 707 } 708 } 709 if (jChanged) { 711 XMLElementDialog.notifyListeners(helperJoin); 712 } 713 if (sChanged) { 714 XMLElementDialog.notifyListeners(helperSplit); 715 } 716 717 XMLPanel p5=refSimulationInformation.getPanel(); 718 clonedEAs=(ExtendedAttributes)refExtendedAttributes.clone(); 719 XMLPanel p6=clonedEAs.getPanel(); 720 721 XMLTabbedPanel p; 722 if (type==0) { 723 p=new XMLTabbedPanel(this,new XMLPanel[] {p1,p3,p4,p5,p6}); 724 } else { 725 p=new XMLTabbedPanel(this,new XMLPanel[] {p1,p2,p3,p4,p5,p6}); 726 } 727 728 return p; 729 } 730 731 protected void fillOutgoingTransitions () { 732 Transitions ts=(Transitions)getCollection().getOwner().get("Transitions"); 733 Set ots=ts.getTransitions(getID(),-1); 734 if (ots!=null) { 735 outgoingTransitions.clear(); 736 outgoingTransitions.addAll(ots); 737 } 738 } 739 740 746 private void recreatePostcondition () { 747 if (helperPostcondition==null) { 748 helperPostcondition=createPostcondition(); 749 Transitions ts=(Transitions)getCollection().getOwner().get("Transitions"); 750 Iterator it=helperTRefs.toCollection().iterator(); 751 while (it.hasNext()) { 752 TransitionRef tr=(TransitionRef)it.next(); 753 String tId=tr.toValue().toString(); 754 Transition t=ts.getTransition(tId); 755 helperPostcondition.add(t); 756 } 757 } else { 758 Set otCopy=new HashSet(outgoingTransitions); 759 Set toRem=new HashSet(); 760 Iterator it=helperPostcondition.toCollection().iterator(); 761 while (it.hasNext()) { 762 Object t=it.next(); 763 if (!otCopy.remove(t)) { 764 toRem.add(t); 765 } 766 } 767 helperPostcondition.toCollection().removeAll(toRem); 768 it=otCopy.iterator(); 772 while (it.hasNext()) { 773 Transition t=(Transition)it.next(); 774 if (t.getTo()!=null) { 775 helperPostcondition.add(t); 776 } 777 } 778 } 779 } 780 781 788 public String toString () { 789 String disp=attrName.toString(); 790 if (disp.trim().length()==0) { 791 disp=attrId.toString(); 792 } 793 return disp; 794 } 795 796 803 public String getTooltip () { 804 XMLElement tp=new XMLElement("Type"); 805 tp.setValue(helperElement.toLabel()); 806 XMLElement tpSpecific=null; 807 int type=getType(); 808 if (type==2) { 809 Tools ts=getTools(); 810 if (ts.size()==0) { 811 tp.setValue(XMLUtil.getLanguageDependentString("NoKey")); 812 } else { 813 tpSpecific=new XMLElement("NoOfTools"); 814 tpSpecific.setValue(String.valueOf(ts.size())); 815 } 816 } 817 if (type==3) { 818 tpSpecific=new XMLElement("ReferencedProcess"); 819 try { 820 tpSpecific.setValue(((XMLComplexChoice)getSubflow(). 821 get("WorkflowProcess")).getChoosen().toString()); 822 } catch (Exception ex) { 823 tpSpecific.setValue(XMLUtil.getLanguageDependentString("NoneKey")); 824 } 825 } 826 if (type==4) { 827 } 830 831 if (tpSpecific!=null) { 832 return XMLUtil.makeTooltip(new XMLElement[] {attrId,attrName, 833 refPerformer,refStartMode, 834 refFinishMode,refPriority,refLimit,refDescription, 835 helperJoin.get("Type"),helperSplit.get("Type"), 836 tp,tpSpecific}); 837 } else { 838 return XMLUtil.makeTooltip(new XMLElement[] {attrId,attrName, 839 refPerformer,refStartMode, 840 refFinishMode,refPriority,refLimit,refDescription, 841 helperJoin.get("Type"),helperSplit.get("Type"), 842 tp}); 843 } 844 } 845 846 852 public void toXML (Node parent) throws DOMException { 853 helperTRefs.clear(); 856 Set otCopy=new HashSet(outgoingTransitions); 857 if (helperPostcondition!=null) { 858 Iterator it=helperPostcondition.toCollection().iterator(); 859 while (it.hasNext()) { 860 Transition t=(Transition)it.next(); 861 if (otCopy.remove(t)) { 862 if (t.getTo()!=null) { 863 String ID=t.getID(); 864 TransitionRef tr=new TransitionRef(); 865 tr.setValue(ID); 866 helperTRefs.add(tr); 867 } 868 } 869 } 870 } 871 Iterator it=otCopy.iterator(); 875 while (it.hasNext()) { 876 Transition t=(Transition)it.next(); 877 if (t.getTo()!=null) { 878 String ID=t.getID(); 879 TransitionRef tr=new TransitionRef(); 880 tr.setValue(ID); 881 helperTRefs.add(tr); 882 } 883 } 884 885 Set easToRemove=new HashSet(); 888 889 ExtendedAttribute ea; 890 891 ea=new ExtendedAttribute(refExtendedAttributes); 893 ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea); 894 ea.set("Name","YOffset"); 895 ea.set("Value",String.valueOf(YOffset)); 896 easToRemove.add(ea); 897 898 ea=new ExtendedAttribute(refExtendedAttributes); 899 ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea); 900 ea.set("Name","XOffset"); 901 ea.set("Value",String.valueOf(XOffset)); 902 easToRemove.add(ea); 903 904 ea=new ExtendedAttribute(refExtendedAttributes); 906 ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea); 907 ea.set("Name","ParticipantID"); 908 ea.set("Value",participantID); 909 easToRemove.add(ea); 910 911 if (getType()==4) { 913 if (visuallySortedParticipantIDs.length()>0) { 915 ea=new ExtendedAttribute(refExtendedAttributes); 916 ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea); 917 ea.set("Name","ParticipantVisualOrder"); 918 ea.set("Value",visuallySortedParticipantIDs); 919 easToRemove.add(ea); 920 } 921 if (endDescriptions.size()>0) { 923 it=endDescriptions.iterator(); 924 while (it.hasNext()) { 925 ea=new ExtendedAttribute(refExtendedAttributes); 926 ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea); 927 ea.set("Name","EndOfBlock"); 928 ea.set("Value",(String )it.next()); 929 easToRemove.add(ea); 930 } 931 } 932 if (startDescriptions.size()>0) { 934 it=startDescriptions.iterator(); 935 while (it.hasNext()) { 936 ea=new ExtendedAttribute(refExtendedAttributes); 937 ((ArrayList)refExtendedAttributes.toCollection()).add(0,ea); 938 ea.set("Name","StartOfBlock"); 939 ea.set("Value",(String )it.next()); 940 easToRemove.add(ea); 941 } 942 } 943 } 944 945 if (helperElement instanceof Tools && 948 ((Tools)helperElement).size()==0) { 949 Implementation i=(Implementation)refType.getChoices()[1]; 951 XMLComplexChoice t=(XMLComplexChoice)i.get("Type"); 952 XMLElement tmp=(XMLElement)t.getChoices()[0]; 953 t.setValue(tmp); 954 super.toXML(parent); 955 t.setValue(helperElement); 957 } 958 else { 959 super.toXML(parent); 960 } 961 962 964 refExtendedAttributes.toCollection().removeAll(easToRemove); 966 967 } 968 969 970 977 public Object clone () { 978 Activity a=(Activity)super.clone(); 979 a.attrId.setValue(myCollection.generateID()); 980 981 a.attrName=(XMLAttribute)this.attrName.clone(); 982 a.refDescription=(Description)this.refDescription.clone(); 983 a.refLimit=(Limit)this.refLimit.clone(); 984 a.refType=(XMLComplexChoice)this.refType.clone(); 985 a.refPerformer=(Performer)this.refPerformer.clone(); 986 a.refStartMode=(StartMode)this.refStartMode.clone(); 987 a.refFinishMode=(FinishMode)this.refFinishMode.clone(); 988 a.refPriority=(Priority)this.refPriority.clone(); 989 a.refDeadlines=(Deadlines)this.refDeadlines.clone(); 990 a.refSimulationInformation=(SimulationInformation)this.refSimulationInformation.clone(); 991 a.refIcon=(Icon)this.refIcon.clone(); 992 a.refDocumentation=(Documentation)this.refDocumentation.clone(); 993 a.refTransitionRestrictions=(TransitionRestrictions)this.refTransitionRestrictions.clone(); 994 a.refExtendedAttributes=(ExtendedAttributes)this.refExtendedAttributes.clone(); 995 996 a.myWorkflow=this.myWorkflow; 997 a.outgoingTransitions=new HashSet(); 998 999 a.refTransitionRestrictions.clear(); 1001 a.setDefaultTransitionRestriction(null); 1002 a.refTransitionRestrictions.add(a.helperTR); 1003 a.helperJoin.set("Type", 1004 ((XMLAttribute)helperJoin.get("Type")).getChoosen().toString()); 1005 a.helperSplit.set("Type", 1006 ((XMLAttribute)helperSplit.get("Type")).getChoosen().toString()); 1007 int type=getType(helperElement); 1009 if (type==0) { 1010 a.helperElement=(XMLElement)a.refType.getChoices()[0]; 1011 } else if (type==4) { 1012 a.helperElement=(XMLElement)a.refType.getChoices()[2]; 1013 } else { 1014 Implementation i=(Implementation)a.refType.getChoices()[1]; 1015 XMLComplexChoice t=(XMLComplexChoice)i.get("Type"); 1016 XMLElement changeTo=(XMLElement)t.getChoices()[type-1]; 1017 a.helperElement=changeTo; 1018 } 1019 a.helperPostcondition=a.createPostcondition(); 1020 a.clonedTools=null; 1021 a.clonedEAs=null; 1022 a.clonedDs=null; 1023 a.clonedHP=null; 1024 1025 a.fillStructure(); 1026 1027 return a; 1028 } 1029 1030 1033 public boolean isIDUniqueAndValid (XMLPanel tabbedPanel) { 1034 XMLGroupPanel groupPanel=(XMLGroupPanel)((XMLTabbedPanel)tabbedPanel).getTabbedPanel(0); 1035 XMLTextPanel tp=(XMLTextPanel)groupPanel.getPanel(0); 1036 String IDToCheck=tp.getText(); 1037 Activity act=getOwnerProcess().getActivity(IDToCheck); 1039 boolean isOK=true; 1040 String message=null; 1041 String dialogTitle=null; 1042 if (act!=null && act!=this) { 1043 message=XMLUtil.getLanguageDependentString("ErrorIDMustBeUnique"); 1044 dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotUnique"); 1045 isOK=false; 1046 } else if (!XMLCollection.isIdValid(IDToCheck)) { 1047 message=XMLUtil.getLanguageDependentString("ErrorIDMustBeValid"); 1048 dialogTitle=XMLUtil.getLanguageDependentString("DialogIDIsNotValid"); 1049 isOK=false; 1050 } 1051 if (!isOK) { 1052 XMLPanel.errorMessage(groupPanel.getDialog(),dialogTitle,"",message); 1053 ((JTextField)tp.getComponent(2)).requestFocus(); 1054 } 1055 return isOK; 1056 } 1057 1058 1071 public boolean isValidEnter (XMLPanel p) { 1072 selectedTab=((XMLTabbedPanel)p).getSelectedTab(); 1073 int type=getType(helperElement); 1074 if (type==3) { 1075 if (!getSubflow().isValidEnter(((XMLTabbedPanel)p).getTabbedPanel(1))) { 1076 return false; 1077 } 1078 } 1079 int gpi=3; 1080 if (type==0) { 1081 gpi=2; 1082 } 1083 XMLGroupPanel gppc=(XMLGroupPanel)((XMLTabbedPanel)p).getTabbedPanel(gpi); 1084 XMLListChoicePanel lcp=(XMLListChoicePanel)gppc.getPanel(1); 1085 XMLPanel tp=lcp.getDisplayedPanel(); 1086 if (tp!=null) { 1087 if (!tp.getOwner().isValidEnter(tp)) { 1088 return false; 1089 } 1090 if (!((XMLCollectionElement)tp.getOwner()).isIDUniqueAndValid(tp)) { 1091 return false; 1092 } 1093 } 1094 if (type==2 && clonedTools!=null) { 1095 helperElement=clonedTools; 1096 Implementation i=(Implementation)refType.getChoices()[1]; 1097 XMLComplexChoice t=(XMLComplexChoice)i.get("Type"); 1098 t.getChoices()[1]=helperElement; 1099 t.setValue(helperElement); 1100 } 1101 1102 if (clonedEAs!=null) { 1103 complexStructure.remove(refExtendedAttributes); 1104 refExtendedAttributes=clonedEAs; 1105 complexStructure.add(14,refExtendedAttributes); 1106 } 1107 1108 if (clonedDs!=null) { 1109 complexStructure.remove(refDeadlines); 1110 refDeadlines=clonedDs; 1111 complexStructure.add(9,refDeadlines); 1112 } 1113 1114 if (clonedHP!=null) { 1115 helperPostcondition=clonedHP; 1116 } 1117 1118 return true; 1119 } 1120 1121 private XMLCollection createPostcondition () { 1122 XMLCollection pConds=new XMLCollection(this) { 1123 public XMLPanel getPanel () { 1124 return new XMLListChoicePanel(this, 1125 XMLUtil.getLanguageDependentString("SelectTargetActivityKey"), 1126 XMLPanel.BOX_LAYOUT,true,false); 1127 } 1128 }; 1129 pConds.setReadOnly(isReadOnly); 1130 return pConds; 1131 } 1132 1133 1138 protected void setCollection (Activities newCollection) { 1139 this.myCollection=newCollection; 1140 } 1141 1142 public Set getNonExceptionalOutgoingTransitions () { 1143 Transitions ts=(Transitions)getCollection().getOwner().get("Transitions"); 1144 outgoingTransitions=ts.getTransitions(getID(),-1); 1145 Set nonExceptionalOutgoingTransitions=new HashSet(); 1146 Iterator it=outgoingTransitions.iterator(); 1147 while (it.hasNext()) { 1148 Transition t=(Transition)it.next(); 1149 Condition condition = (Condition)t.get("Condition"); 1150 String condType=condition.get("Type").toValue().toString(); 1151 if (!(condType.equals(Condition.CONDITION_TYPE_EXCEPTION) || 1152 condType.equals(Condition.CONDITION_TYPE_DEFAULTEXCEPTION))) { 1153 nonExceptionalOutgoingTransitions.add(t); 1154 } 1155 } 1156 return nonExceptionalOutgoingTransitions; 1157 } 1158 1159 public Set getIncomingTransitions () { 1160 Transitions ts=(Transitions)getCollection().getOwner().get("Transitions"); 1161 return ts.getTransitions(getID(),1); 1162 } 1163 1164 public static int getSelectedTab () { 1165 return selectedTab; 1166 } 1167 1168} 1169 1170 | Popular Tags |